public MultiTask CreateMultiTask() { List <string> m_DatasourceList = null; List <enumDataType> m_DatasourceTypes = null; List <string> m_TaskNameList = null; TestDatasourceFolder(ref m_DatasourceList, ref m_DatasourceTypes, ref m_TaskNameList); MultiTask multiTask = new MultiTask(); int count = m_DatasourceList.Count; for (int i = 0; i < count; i++) { ExtendTask task = new ExtendTask(); task.SourcePath = m_DatasourceList[i]; string strTaskName = TaskHelper.GetValidateTaskName(this.DatasourceFolder, m_TaskNameList[i]); task.Path = this.DatasourceFolder; task.Name = strTaskName; task.TopoTolerance = this.TopoTolerance; task.MapScale = this.MapScale; task.DatasourceType = m_DatasourceTypes[i]; task.UseSourceDirectly = false; task.SchemaID = this.SchemaID; task.CheckMode = enumCheckMode.CreateOnly; multiTask.AddTask(task); } return(multiTask); }
public MultiTask CreateMultiTask() { List<string> m_DatasourceList = null; List<enumDataType> m_DatasourceTypes = null; List<string> m_TaskNameList = null; TestDatasourceFolder(ref m_DatasourceList, ref m_DatasourceTypes, ref m_TaskNameList); MultiTask multiTask = new MultiTask(); int count = m_DatasourceList.Count; for (int i = 0; i < count; i++) { ExtendTask task = new ExtendTask(); task.SourcePath = m_DatasourceList[i]; string strTaskName = TaskHelper.GetValidateTaskName(this.DatasourceFolder, m_TaskNameList[i]); task.Path= this.DatasourceFolder; task.Name = strTaskName; task.TopoTolerance= this.TopoTolerance; task.MapScale= this.MapScale; task.DatasourceType= m_DatasourceTypes[i]; task.UseSourceDirectly= false; task.SchemaID = this.SchemaID; task.CheckMode = enumCheckMode.CreateOnly; multiTask.AddTask(task); } return multiTask; }
/// <summary> /// 执行 /// 指创建任务[并执行检查] /// </summary> /// <returns>返回【至少创建成功了的】任务列表</returns> public bool Excute(ref List <Task> availableTasks) { try { availableTasks = new List <Task>(); this.m_SucceedCount = 0; this.m_PromptMsg = ""; if (this.m_TaskList == null || this.m_TaskList.Count == 0) { m_PromptMsg = "任务列表为空!无法创建质检任务!"; return(false); } int count = this.m_TaskList.Count; int succeedCount = 0; int excuteCount = 0; for (int i = 0; i < count; i++) { ExtendTask curTask = this.m_TaskList[i] as ExtendTask; if (curTask == null) { continue; } // 创建 if (this.CreatingTaskChanged != null) { this.CreatingTaskChanged.Invoke(curTask); } bool isSucceed = curTask.Create(); isSucceed = curTask.CreateMXD(); if (this.TaskCreated != null) { this.TaskCreated.Invoke(curTask); } if (!isSucceed) { SendMessage(enumMessageType.Exception, string.Format("任务:{0}创建失败", curTask.Name)); continue; } availableTasks.Add(curTask); ////执行质检 if (curTask.CheckMode != enumCheckMode.CreateOnly) { Checker m_TaskChecker = new Checker(); if (this.CheckingTaskChanged != null) { this.CheckingTaskChanged.Invoke(m_TaskChecker, curTask); } curTask.ReadyForCheck(); m_TaskChecker.BaseWorkspace = curTask.BaseWorkspace; m_TaskChecker.QueryConnection = curTask.QueryConnection; m_TaskChecker.QueryWorkspace = curTask.QueryWorkspace; m_TaskChecker.ResultPath = curTask.GetResultDBPath(); if (curTask.CheckMode == enumCheckMode.CheckAll) { TemplateRules tempRules = new TemplateRules(curTask.SchemaID); m_TaskChecker.RuleInfos = tempRules.CurrentSchemaRules; } else { m_TaskChecker.RuleInfos = curTask.RuleInfos; } m_TaskChecker.SchemaID = curTask.SchemaID; m_TaskChecker.TopoDBPath = curTask.GetResultDBPath(); m_TaskChecker.TopoTolerance = curTask.TopoTolerance; COMMONCONST.TOPOTOLORANCE = curTask.TopoTolerance; COMMONCONST.dAreaThread = curTask.MapScale * 0.04; COMMONCONST.dLengthThread = curTask.MapScale * 0.2 / 10000; m_TaskChecker.Check(); if (this.TaskChecked != null) { this.TaskChecked.Invoke(m_TaskChecker, curTask); } excuteCount++; } succeedCount++; } if (succeedCount == count) { if (excuteCount == 0) { m_PromptMsg = string.Format("{0}个任务全部创建完成!", count); } else { m_PromptMsg = string.Format("{0}个任务全部创建完成,{1}个任务检查完成!", count, excuteCount); } } else { if (excuteCount == 0) { m_PromptMsg = string.Format("{0}质检任务创建完成,其余质检任务执行失败", succeedCount); } else { m_PromptMsg = string.Format("{0}质检任务创建完成({1}个任务检查完成),其余质检任务执行失败", succeedCount, excuteCount); } } } catch (Exception ex) { SendMessage(enumMessageType.Exception, "创建任务过程中出现错误,错误原因:" + ex.ToString()); return(false); } finally { } return(true); }
private ExtendTask GetTaskFromDataRow(DataRow rowTask) { if (rowTask == null) return null; // Task本身 ExtendTask task = new ExtendTask(); task.DatasourceType = (enumDataType)rowTask["DataType"]; task.MapScale = (int)rowTask["MapScale"]; task.Name = rowTask["TaskName"] as string; task.Path = rowTask["TaskPath"] as string; task.SourcePath = rowTask["Datasource"] as string; task.StandardName = cmbStandard.SelectedItem as string; task.SchemaID = ((KeyValuePair<string, string>)cmbSchema.SelectedItem).Key; task.TopoTolerance = Convert.ToDouble( rowTask["TopoTolerance"]); task.UseSourceDirectly = (bool)rowTask["UseSourceDirectly"]; task.Messager = this.MessageHandler; // DataImport IDataImport dataImporter = null; if (task.DatasourceType == enumDataType.VCT) { dataImporter = new VCTDataImport(); } else { NoReferenceDataImport noRefDataImport = new NoReferenceDataImport(); noRefDataImport.ReferenceLayer = ((KeyValuePair<string, string>)cmbSpatialRefLayer.SelectedItem).Key; dataImporter = noRefDataImport; } dataImporter.ImportingObjectChanged+=new ImportingObjectChangedHandler(dataImporter_ImportingObjectChanged); task.DataImporter = dataImporter; string strCheckMode = rowTask["CheckMode"] as string; enumCheckMode checkMode = enumCheckMode.CreateOnly; if (strCheckMode == Text_CheckMode_CheckPartly) { checkMode = enumCheckMode.CheckPartly; } if (strCheckMode == Text_CheckMode_CheckAll) { checkMode = enumCheckMode.CheckAll; task.ReadyForCheck(true); } task.CheckMode = checkMode; task.RuleInfos = rowTask["Hy.Check.Rules"] as List<SchemaRuleEx>; return task; }