/// <summary> /// 收集相关信息 /// </summary> /// <param name="guid"></param> /// <param name="allowNew">是否需要创建项目</param> /// <returns></returns> public override object[] GetGenerateInfo(string guid, bool allowNew) { //找到项目源 string pid = CdeCmdId.BelongId(guid); Project prjt = TemplateContainer.Resove <Project>(pid); if (prjt == null && allowNew) { string pname = PrjCmdId.FindProjectName(pid); if (pid != "06D57C23-4D51-430D-A8E6-9A19F38390E3") { prjt = CommonContainer.CommonServer.AddClassLibrary(pname); } else { prjt = CommonContainer.CommonServer.AddWebService(pname); } TemplateContainer.Regist(pid, prjt); } string templatePath = Path.Combine(CommonContainer.RootPath, TemplateContainer.Resove <string>(guid)); return(new object[] { guid, pid, prjt, templatePath }); }
void context_HandledOne(object sender, EventHandledArg arg) { int currentCount = _currentTotalCount - arg.CurrentCount; int percent = (int)(_totalPercent * (_processCurrentCount / _processTotalCount) * (currentCount / _currentTotalCount) * 100); _work.ReportProgress(percent, string.Format(Properties.Resources.BeginReference, PrjCmdId.FindProjectName(arg.HandledId))); }
void context_GeneratedOne(object sender, EventGeneratedArg arg) { int currentCount = _currentTotalCount - arg.CurrentCount; int percent = (int)(_totalPercent * (_processCurrentCount / _processTotalCount) * (currentCount / _currentTotalCount) * 100); _work.ReportProgress(percent, string.Format(Properties.Resources.EndGenerate, PrjCmdId.FindProjectName(arg.GeneratedId), arg.CurrentEntity)); }
/// <summary> /// 执行上下文 /// </summary> public void Commit() { while (_rEntityQueue.Count() > 0) { ReferenceEntity queue = _rEntityQueue.Dequeue(); try { Project proj = TemplateContainer.Resove <Project>(queue.ProjectId); List <string> refers = queue.ReferenceCollection; if (refers != null && refers.Count > 0) { refers.ForEach(t => { proj.AddReferByKey(t); }); } } catch (Exception ex) { MsgBoxHelp.ShowError(string.Format(Properties.Resource.ReferError, PrjCmdId.FindProjectName(queue.ProjectId)), ex); } finally { if (HandledOne != null) { HandledOne(this, new EventHandledArg(queue.ProjectId, Count)); } } } }
/// <summary> /// 开始执行上下文中所有的内容 /// </summary> public void Commit() { while (_gEntityQueue.Count() > 0) { GenerateEntity queue = _gEntityQueue.Dequeue(); try { queue.GenerateEngin.Generate(queue.GenerateId, queue.GenerateArgment, queue.GenerateContainer); } catch (Exception ex) { MsgBoxHelp.ShowError(string.Format(Properties.Resource.GenerateError, PrjCmdId.FindProjectName(queue.GenerateId)), ex); } finally { if (GeneratedOne != null) { GeneratedOne(this, new EventGeneratedArg(queue.GenerateId, Count, KeywordContainer.Resove("$Entity$"))); } } } }