+ add the convert result page of the convert module.

This commit is contained in:
wangchunsheng
2010-02-20 03:28:28 +00:00
parent 02c11698a2
commit 2c2cea835a
8 changed files with 94 additions and 19 deletions

View File

@@ -50,6 +50,7 @@ class convert extends control
$setFunc = "set$sourceName";
$this->view->header->title = $this->lang->convert->setting;
$this->view->source = $sourceName;
$this->view->version = $version;
$this->view->setting = $this->fetch('convert', $setFunc, "version=$version");
$this->display();
}
@@ -112,6 +113,8 @@ class convert extends control
{
helper::import('./converter/bugfree.php');
$converter = new bugfreeConvertModel();
$converter->execute();
$this->view->result = $converter->execute();
$this->view->info = bugfreeConvertModel::$info;
$this->display();
}
}

View File

@@ -23,8 +23,9 @@
*/
class bugfreeConvertModel extends convertModel
{
public $map = array();
public $filePath = '';
public $map = array();
public $filePath = '';
static public $info = array();
public function __construct()
{
parent::__construct();
@@ -54,15 +55,17 @@ class bugfreeConvertModel extends convertModel
public function execute()
{
$this->clear();
$this->convertUser();
$this->convertProject();
$this->convertModule();
$result['users'] = $this->convertUser();
$result['projects'] = $this->convertProject();
$result['modules'] = $this->convertModule();
$result['bugs'] = $this->convertBug();
$result['actions'] = $this->convertAction();
$result['files'] = $this->convertFile();
$this->fixModulePath();
$this->convertBug();
$this->convertAction();
$this->convertFile();
return $result;
}
/* ת<><D7AA><EFBFBD>û<EFBFBD><C3BB><EFBFBD>*/
public function convertUser()
{
/* <20><>ѯ<EFBFBD><D1AF>ǰϵͳ<CFB5>д<EFBFBD><D0B4>ڵ<EFBFBD><DAB5>û<EFBFBD><C3BB><EFBFBD>*/
@@ -91,13 +94,20 @@ class bugfreeConvertModel extends convertModel
foreach($activeUsers as $account => $user) if(!isset($allUsers[$account])) $allUsers[$account] = $user;
/* <20><><EFBFBD>뵽zentao<61><6F><EFBFBD>ݿ<EFBFBD><DDBF>С<EFBFBD>*/
$convertCount = 0;
foreach($allUsers as $account => $user)
{
if(!$this->dao->dbh($this->dbh)->findByAccount($account)->from(TABLE_USER)->fetch('account'))
{
$this->dao->dbh($this->dbh)->insert(TABLE_USER)->data($user)->exec();
$convertCount ++;
}
else
{
self::$info['users'][] = sprintf($this->lang->convert->errorUserExists, $account);
}
}
return $convertCount;
}
/* ת<><D7AA><EFBFBD><EFBFBD>ĿΪ<C4BF><CEAA>Ʒ<EFBFBD><C6B7>*/
@@ -110,6 +120,7 @@ class bugfreeConvertModel extends convertModel
$this->dao->dbh($this->dbh)->insert(TABLE_PRODUCT)->data($project)->exec();
$this->map['product'][$projectID] = $this->dao->lastInsertID();
}
return count($projects);
}
/* ת<><D7AA>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>ΪBug<75><67>ͼģ<CDBC>顣*/
@@ -141,6 +152,7 @@ class bugfreeConvertModel extends convertModel
{
$this->dao->dbh($this->dbh)->update(TABLE_MODULE)->set('parent')->eq($newModuleID)->where('parent')->eq($oldModuleID)->exec();
}
return count($modules);
}
/* <20>޸<EFBFBD>ģ<EFBFBD><C4A3>·<EFBFBD><C2B7><EFBFBD><EFBFBD>*/
@@ -208,6 +220,7 @@ class bugfreeConvertModel extends convertModel
{
$this->dao->dbh($this->dbh)->update(TABLE_BUG)->set('duplicateBug')->eq($newBugID)->where('duplicateBug')->eq($oldBugID)->exec();
}
return count($bugs);
}
/* ת<><D7AA><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7>¼<EFBFBD><C2BC>*/
@@ -226,6 +239,7 @@ class bugfreeConvertModel extends convertModel
->from('BugHistory')
->orderBy('bugID, historyID')
->fetchGroup('objectID');
$convertCount = 0;
foreach($actions as $bugID => $bugActions)
{
/* <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>bugID<49><44>*/
@@ -243,8 +257,10 @@ class bugfreeConvertModel extends convertModel
$action->comment = '';
}
$this->dao->dbh($this->dbh)->insert(TABLE_ACTION)->data($action)->exec();
$convertCount ++;
}
}
return $convertCount;
}
/* ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
@@ -274,13 +290,21 @@ class bugfreeConvertModel extends convertModel
$this->dao->dbh($this->dbh)->insert(TABLE_FILE)->data($file)->exec();
/* <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>*/
$soureFile = $this->filePath . $file->pathname;
if(!file_exists($soureFile)) continue;
$soureFile = $this->filePath . $file->pathname;
if(!file_exists($soureFile))
{
self::$info['files'][] = sprintf($this->lang->convert->errorFileNotExits, $soureFile);
continue;
}
$targetFile = $this->app->getAppRoot() . "www/data/upload/{$this->app->company->id}/" . $file->pathname;
$targetPath = dirname($targetFile);
if(!is_dir($targetPath)) mkdir($targetPath, 0777, true);
copy($soureFile, $targetFile);
if(!copy($soureFile, $targetFile))
{
self::$info['files'][] = sprintf($this->lang->convert->errorCopyFailed, $targetFile);
}
}
return count($files);
}
/* <20><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>*/

View File

@@ -61,5 +61,18 @@ $lang->convert->checkTable = '表';
$lang->convert->checkPath = '安装路径';
$lang->convert->execute = '执行转换';
$lang->convert->item = '转换项';
$lang->convert->count = '转换数量';
$lang->convert->info = '转换信息';
$lang->convert->bugfree->users = '用户';
$lang->convert->bugfree->projects = '项目';
$lang->convert->bugfree->modules = '模块';
$lang->convert->bugfree->bugs = 'Bug';
$lang->convert->bugfree->actions = '历史记录';
$lang->convert->bugfree->files = '附件';
$lang->convert->errorConnectDB = '数据库连接失败 ';
$lang->convert->errorFileNotExits = '文件 %s 不存在';
$lang->convert->errorUserExists = '用户 %s 已存在';
$lang->convert->errorCopyFailed = '文件 %s 拷贝失败';

View File

@@ -0,0 +1,35 @@
<tr class='a-center'>
<th><?php echo $lang->convert->item?></th>
<th><?php echo $lang->convert->count?></th>
<th><?php echo $lang->convert->info?></th>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->convert->bugfree->users;?></th>
<td><?php echo $result['users'];?></td>
<td class='f-12px'><?php if(isset($info['users'])) echo join('<br />', $info['users']);?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->convert->bugfree->projects;?></th>
<td><?php echo $result['projects'];?></td>
<td class='f-12px'><?php if(isset($info['projects'])) echo join('<br />', $info['projects']);?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->convert->bugfree->modules;?></th>
<td><?php echo $result['modules'];?></td>
<td class='f-12px'><?php if(isset($info['modules'])) echo join('<br />', $info['modules']);?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->convert->bugfree->bugs;?></th>
<td><?php echo $result['bugs'];?></td>
<td class='f-12px'><?php if(isset($info['bugs'])) echo join('<br />', $info['bugs']);?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->convert->bugfree->actions;?></th>
<td><?php echo $result['actions'];?></td>
<td class='f-12px'><?php if(isset($info['actions'])) echo join('<br />', $info['actions']);?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->convert->bugfree->files;?></th>
<td><?php echo $result['files'];?></td>
<td class='f-12px'><?php if(isset($info['files'])) echo join('<br />', $info['files']);?></td>
</tr>

View File

@@ -23,7 +23,7 @@
?>
<?php include '../../common/header.html.php';?>
<div class='yui-d0'>
<table align='center' class='table-5 f-14px'>
<table align='center' class='f-14px'>
<caption><?php echo $lang->convert->execute . $lang->colon . strtoupper($source);?></caption>
<?php echo $executeResult;?>
</table>

View File

@@ -23,7 +23,7 @@
?>
<?php include '../../common/header.html.php';?>
<div class='yui-d0'>
<table align='center' class='table-6'>
<table align='center' class='table-5'>
<caption><?php echo $lang->convert->common;?></caption>
<tr><td><?php echo nl2br($lang->convert->desc);?></td></tr>
<tr><td><h3 class='a-center'><?php echo html::a($this->createLink('convert', 'selectsource'), $lang->convert->start);?></h3></td></tr>

View File

@@ -1,18 +1,18 @@
<tr>
<th class='rowhead w-200px'><?php echo $lang->convert->dbHost;?></th>
<td><?php echo html::input('dbHost', 'localhost');?></td>
<td><?php echo html::input('dbHost', $config->db->host);?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->convert->dbPort;?></th>
<td><?php echo html::input('dbPort', '3306');?></td>
<td><?php echo html::input('dbPort', $config->db->port);?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->convert->dbUser;?></th>
<td><?php echo html::input('dbUser', 'root');?></td>
<td><?php echo html::input('dbUser', $config->db->user);?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->convert->dbPassword;?></th>
<td><?php echo html::input('dbPassword');?></td>
<td><?php echo html::input('dbPassword', $config->db->password);?></td>
</tr>
<tr>
<th class='rowhead'><?php printf($lang->convert->dbName, $source);?></th>
@@ -28,4 +28,3 @@
<th class='rowhead'><?php printf($lang->convert->installPath, $source);?></th>
<td><?php echo html::input('installPath');?></td>
</tr>
<?php echo html::hidden('source', $source) . html::hidden('version', $version);?>

View File

@@ -31,6 +31,7 @@
<td colspan='2' class='a-center'><?php echo html::submitButton();?></td>
</tr>
</table>
<?php echo html::hidden('source', $source) . html::hidden('version', $version);?>
</form>
</div>
<?php include '../../common/footer.html.php';?>