diff --git a/trunk/module/convert/control.php b/trunk/module/convert/control.php index 8bcf58fb60..9644f2be09 100644 --- a/trunk/module/convert/control.php +++ b/trunk/module/convert/control.php @@ -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(); } } diff --git a/trunk/module/convert/converter/bugfree.php b/trunk/module/convert/converter/bugfree.php index 36672346ec..e536dafd3c 100644 --- a/trunk/module/convert/converter/bugfree.php +++ b/trunk/module/convert/converter/bugfree.php @@ -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; } + /* 转换用户。*/ public function convertUser() { /* 查询当前系统中存在的用户。*/ @@ -91,13 +94,20 @@ class bugfreeConvertModel extends convertModel foreach($activeUsers as $account => $user) if(!isset($allUsers[$account])) $allUsers[$account] = $user; /* 导入到zentao数据库中。*/ + $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; } /* 转换项目为产品。*/ @@ -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); } /* 转换原来的模块为Bug视图模块。*/ @@ -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); } /* 修复模块路径。*/ @@ -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); } /* 转换历史记录。*/ @@ -226,6 +239,7 @@ class bugfreeConvertModel extends convertModel ->from('BugHistory') ->orderBy('bugID, historyID') ->fetchGroup('objectID'); + $convertCount = 0; foreach($actions as $bugID => $bugActions) { /* 获得转换之后的bugID。*/ @@ -243,8 +257,10 @@ class bugfreeConvertModel extends convertModel $action->comment = ''; } $this->dao->dbh($this->dbh)->insert(TABLE_ACTION)->data($action)->exec(); + $convertCount ++; } } + return $convertCount; } /* 转换附件。*/ @@ -274,13 +290,21 @@ class bugfreeConvertModel extends convertModel $this->dao->dbh($this->dbh)->insert(TABLE_FILE)->data($file)->exec(); /* 拷贝文件。*/ - $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); } /* 清空导入之后的数据。*/ diff --git a/trunk/module/convert/lang/zh-cn.php b/trunk/module/convert/lang/zh-cn.php index 1efd3da1fc..b146890ad5 100644 --- a/trunk/module/convert/lang/zh-cn.php +++ b/trunk/module/convert/lang/zh-cn.php @@ -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 鎷疯礉澶辫触'; diff --git a/trunk/module/convert/view/convertbugfree.html.php b/trunk/module/convert/view/convertbugfree.html.php new file mode 100644 index 0000000000..5d4c0524ac --- /dev/null +++ b/trunk/module/convert/view/convertbugfree.html.php @@ -0,0 +1,35 @@ + + convert->item?> + convert->count?> + convert->info?> + + + convert->bugfree->users;?> + + ', $info['users']);?> + + + convert->bugfree->projects;?> + + ', $info['projects']);?> + + + convert->bugfree->modules;?> + + ', $info['modules']);?> + + + convert->bugfree->bugs;?> + + ', $info['bugs']);?> + + + convert->bugfree->actions;?> + + ', $info['actions']);?> + + + convert->bugfree->files;?> + + ', $info['files']);?> + diff --git a/trunk/module/convert/view/execute.html.php b/trunk/module/convert/view/execute.html.php index b628466876..3cf9d624b8 100644 --- a/trunk/module/convert/view/execute.html.php +++ b/trunk/module/convert/view/execute.html.php @@ -23,7 +23,7 @@ ?>
- +
convert->execute . $lang->colon . strtoupper($source);?>
diff --git a/trunk/module/convert/view/index.html.php b/trunk/module/convert/view/index.html.php index eba5bb52cc..c76063176c 100644 --- a/trunk/module/convert/view/index.html.php +++ b/trunk/module/convert/view/index.html.php @@ -23,7 +23,7 @@ ?>
- +
diff --git a/trunk/module/convert/view/setbugfree.html.php b/trunk/module/convert/view/setbugfree.html.php index 1326bc3951..267f4bbdf0 100644 --- a/trunk/module/convert/view/setbugfree.html.php +++ b/trunk/module/convert/view/setbugfree.html.php @@ -1,18 +1,18 @@ - + - + - + - + @@ -28,4 +28,3 @@ - diff --git a/trunk/module/convert/view/setconfig.html.php b/trunk/module/convert/view/setconfig.html.php index 3111bb0da1..c538239d00 100644 --- a/trunk/module/convert/view/setconfig.html.php +++ b/trunk/module/convert/view/setconfig.html.php @@ -31,6 +31,7 @@
convert->common;?>
convert->desc);?>

createLink('convert', 'selectsource'), $lang->convert->start);?>

convert->dbHost;?>db->host);?>
convert->dbPort;?>db->port);?>
convert->dbUser;?>db->user);?>
convert->dbPassword;?>db->password);?>
convert->dbName, $source);?>convert->installPath, $source);?>
+