public override void OnClick() { Hy.Check.Task.Task task = Hy.Check.Command.CheckApplication.CurrentTask; if (task == null) return; if (task.State != Hy.Check.Task.enumTaskState.Created) { if (DevExpress.XtraEditors.XtraMessageBox.Show("��ǰ�����Ѿ�ִ�й���飬��ȷ��Ҫ����֮ǰ�ļ������", "��ʾ", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) return; } task.ReadyForCheck(true); TemplateRules templateRules = new TemplateRules(task.SchemaID); CheckApplication.TaskChanged(null); Hy.Check.UI.Forms.FrmTaskCheck frmCheck = new Hy.Check.UI.Forms.FrmTaskCheck(task,templateRules.CurrentSchemaRules); frmCheck.CheckTask(); //if (frmCheck.DialogResult == System.Windows.Forms.DialogResult.Abort) // return; CheckApplication.TaskChanged(task); }
/// <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; }
/// <summary> /// Loads the rules tree. /// </summary> public void LoadRulesTree() { this.treeListRule.BeginUnboundLoad(); this.treeListRule.BeginUpdate(); this.treeListRule.ClearNodes(); try { if (m_CurrTemplateRules == null) { m_CurrTemplateRules = new TemplateRules(CurrentSchemaId); } RulesDt = m_CurrTemplateRules.CurrentSchemaRulesDt; m_TempScheamRules = m_CurrTemplateRules.CurrentSchemaRules; bool NodeChecked = false; //����һ������ if (TreeShowType == RuleTreeShowType.ViewRulesAndSelection) { //����һ������ if (RulesSelection == null) { SchemaRuleEx[] ex = new SchemaRuleEx[m_TempScheamRules.Count]; m_CurrTemplateRules.CurrentSchemaRules.CopyTo(ex, 0); RulesSelection = new List<SchemaRuleEx>(); RulesSelection.AddRange(ex); } } //���Ӹ��ڵ� int count = m_CurrTemplateRules.CalculateRulesCount(m_CurrTemplateRules.ClassifyRules); TreeListNode rootNode = treeListRule.AppendNode(new object[] { string.Format("{0} ({1})", CurrentTaskName, count), 0, "0", count }, null); //rootNode.StateImageIndex = 0; if (RulesSelection != null) { SetRulesHistoryState(Convert.ToInt32(rootNode["ruleBM"]), RulesSelection); } //GetRulesHistoryState(rootNode["RuleName"].ToString(), ref NodeChecked); rootNode.Checked = RulesSelection == null ? treeListRule.OptionsView.ShowCheckBoxes : NodeChecked; //SetRulesHistoryState(rootNode["RuleName"].ToString(), rootNode.Checked); //����һ���������ڵ� AppendTreeNodes(m_CurrTemplateRules.ClassifyRules, rootNode); } catch { } finally { treeListRule.Columns[0].Width = 280; //treeListRule.BestFitColumns(); this.treeListRule.EndUpdate(); this.treeListRule.EndUnboundLoad(); this.treeListRule.ExpandAll(); } }
/// <summary> /// Loads the results tree. /// </summary> public void LoadResultsTree() { this.treeListRule.BeginUnboundLoad(); this.treeListRule.BeginUpdate(); this.treeListRule.ClearNodes(); try { if (m_CurrTemplateRules == null) { m_CurrTemplateRules = new TemplateRules(CurrentSchemaId); RulesDt = m_CurrTemplateRules.CurrentSchemaRulesDt; } //���Ӹ��ڵ� TreeListNode rootNode = treeListRule.AppendNode(new object[] { string.Format("{0} ({1})", CurrentTaskName, this.CheckResultsCount), 0, "0", this.CheckResultsCount }, null); //rootNode.StateImageIndex = 0; rootNode.Checked =treeListRule.OptionsView.ShowCheckBoxes; if (m_RuleType == RuleShowType.DefualtType) { //����һ���������ڵ� AppendResultsNodes(m_CurrTemplateRules.ClassifyRules, rootNode); } else { AppendLayersResultNodes(rootNode); } } catch { } finally { this.treeListRule.EndUpdate(); this.treeListRule.EndUnboundLoad(); this.treeListRule.ExpandAll(); treeListRule.BestFitColumns(); } }
/// <summary> /// ���ݷ���id��ʼ����ǰ��������Ĺ����� /// </summary> /// <returns></returns> public static TemplateRules InitCurrentTemplateRules() { if (m_CurrentTemplateRules == null) { if (CurrentTask == null) return null; if (string.IsNullOrEmpty(CurrentTask.SchemaID)) return null; m_CurrentTemplateRules = new TemplateRules(CurrentTask.SchemaID); } return m_CurrentTemplateRules; }
/// <summary> /// 使用统一入口进行质检 /// </summary> /// <param name="dsTarget">可以是IWorkspace,IFeatureClass或ITable</param> /// <returns></returns> public DataTable Check(IDataset dsTarget) { // 数据导入 string strBaseName = "Base.gdb"; string strQueryDB = "Base.mdb"; bool ready = false; enumDataType baseDataType = enumDataType.FileGDB; SendCheckingMessage("正在进行数据导入…"); try { Clear(); if (dsTarget is IWorkspace) { ready = PrepareForWorkspace(dsTarget as IWorkspace, out strBaseName, out strQueryDB, out baseDataType); } else if (dsTarget is IFeatureClass) { ready = PrepareForFeatureClass(dsTarget, out strBaseName, out strQueryDB); baseDataType = enumDataType.PGDB; } else if (dsTarget is ITable) { ready = PrepareForTable(dsTarget, out strBaseName, out strQueryDB); baseDataType = enumDataType.PGDB; } if (!ready) { } // 开始准备检查 string strBaseFullName = string.Format("{0}\\{1}", TempPath, strBaseName); string strQueryFullName = string.Format("{0}\\{1}", TempPath, strQueryDB); IWorkspace wsBase = AEAccessFactory.OpenWorkspace(baseDataType, strBaseFullName); IWorkspace wsQuery = AEAccessFactory.OpenWorkspace(enumDataType.PGDB, strQueryFullName); IDbConnection queryConnection = AdoDbHelper.GetDbConnection(strQueryFullName); // 开始执行检查 Checker curChecker = new Checker(); curChecker.VerifyingRuleChanged += new DealingRuleChangedHandler(VerifyingRuleChanged); curChecker.VerifyedComplete += new VerifyedCompleteHandler(VerifyedComplete); curChecker.PretreatingRuleChanged += new DealingRuleChangedHandler(PretreatingRuleChanged); curChecker.PretreatComplete += new CheckEventHandler(PretreatComplete); curChecker.CheckingRuleChanged += new DealingRuleChangedHandler(CheckingRuleChanged); curChecker.CheckComplete += new CheckEventHandler(CheckComplete); curChecker.RuleChecked += new RuleCheckedHandler(RuleChecked); curChecker.TopoRuleCheckBegin += new CheckEventHandler(TopoRuleCheckBegin); curChecker.BaseWorkspace = wsBase; curChecker.QueryWorkspace = wsQuery; curChecker.QueryConnection = queryConnection; curChecker.ResultPath = TempPath; // 如果没有设置SchemaID,获取第一个 // 如果没有设置RuleInfo列表,获取所有 if (string.IsNullOrEmpty(this.SchemaID)) { Dictionary<int, string> dictStandard = SysDbHelper.GetStandardInfo(); if (dictStandard == null || dictStandard.Count == 0) return null; Dictionary<string, string> dictSchema = SysDbHelper.GetSchemasInfo(dictStandard.ElementAt(0).Value); if (dictSchema == null || dictSchema.Count == 0) return null; this.SchemaID = dictSchema.ElementAt(0).Key; } if (this.RuleInfos == null) { TemplateRules templateRule = new TemplateRules(this.SchemaID); this.RuleInfos = templateRule.CurrentSchemaRules; } curChecker.RuleInfos = this.RuleInfos; curChecker.SchemaID = this.SchemaID; curChecker.TopoDBPath = TempPath; curChecker.TopoTolerance = this.TopoTolerence; COMMONCONST.TOPOTOLORANCE = this.TopoTolerence; COMMONCONST.dAreaThread = this.MapScale * 0.04; COMMONCONST.dLengthThread = this.MapScale * 0.2 / 10000; //SendCheckBeginEvent(curChecker); curChecker.Check(); // 检查 // 获取结果 string strResultFullName = string.Format("{0}\\{1}", TempPath, "Result.mdb"); IDbConnection resultConnection = AdoDbHelper.GetDbConnection(strResultFullName); return GetErrors(resultConnection); } catch { return null; } finally { GC.Collect(); //Clear(); } }