/// <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(); } }