private void Init() { this.m_ErrorCount = 0; this.m_SucceedCount = 0; // 验证 if (this.m_BaseWorkspace == null) { SendMessage(enumMessageType.Exception, "检查驱动的Base库没有设置,无法继续检查"); return; } if (this.m_QueryWorkspace == null || this.m_QueryConnection == null) { SendMessage(enumMessageType.Exception, "检查驱动的Query库没有设置,无法继续检查"); return; } // 结果库 try { string strResultDBFile = this.m_ResultPath + "\\" + COMMONCONST.DB_Name_Result; System.IO.File.Copy(System.Windows.Forms.Application.StartupPath + "\\template\\report\\result_AutoTmpl.mdb", strResultDBFile, true); this.m_ResultConnection = Hy.Common.Utility.Data.AdoDbHelper.GetDbConnection(strResultDBFile); } catch (Exception exp) { SendMessage(enumMessageType.Exception, string.Format("创建结果库出错,信息:{0}", exp.Message)); return; } // 创建规则实例,赋值,分类 if (RuleInfos == null || RuleInfos.Count == 0) { return; } int count = RuleInfos.Count; m_NormalRuleList = new List <ICheckRule>(); m_TopoRuleList = new List <ICheckRule>(); m_DictRuleAndInfo = new Dictionary <ICheckRule, SchemaRule>(); for (int i = 0; i < count; i++) { if (this.RuleInfos[i] == null || this.RuleInfos[i].ruleDllInfo == null) { continue; } RuleInfo ruleInfo = new RuleInfo();// this.RuleInfos[i].ruleDllInfo; ruleInfo.ID = this.RuleInfos[i].arrayRuleParas[0].strInstID; ruleInfo.Name = this.RuleInfos[i].arrayRuleParas[0].strName; ruleInfo.Paramters = this.RuleInfos[i].arrayRuleParas[0].pParas; ruleInfo.RuleClassInfo = this.RuleInfos[i].ruleDllInfo; ruleInfo.Description = this.RuleInfos[i].strRemark; //if (ruleClassInfo == null) // continue; if (ruleInfo.RuleClassInfo == null) { SendMessage(enumMessageType.OperationalLog, string.Format("规则“{0}”无类信息,跳过检查", ruleInfo.Name)); continue; } ICheckRule checkRule = RuleFactory.CreateRuleInstance(ruleInfo.RuleClassInfo.DllName, ruleInfo.RuleClassInfo.ClassName); if (checkRule == null) { SendMessage(enumMessageType.OperationalLog, string.Format("规则“{0}”反射未成功,跳过检查", ruleInfo.Name)); continue; } try { // 参数设置 checkRule.BaseWorkspace = this.m_BaseWorkspace; checkRule.InstanceName = ruleInfo.Name; checkRule.InstanceID = ruleInfo.ID; checkRule.DefectLevel = DefectHelper.GetRuleDefectLevel(ruleInfo.ID); checkRule.MessageHandler = this.m_Messager; checkRule.QueryConnection = this.m_QueryConnection; checkRule.QueryWorkspace = this.m_QueryWorkspace; checkRule.TopoWorkspace = this.m_TopoWorkspace; checkRule.ResultConnection = this.m_ResultConnection; checkRule.SchemaID = this.m_SchemaID; checkRule.SetParamters(ruleInfo.Paramters); if (checkRule.ErrorType == enumErrorType.Topology) { if (m_Topology == null) { try { // 先创建Topo库(空库)和结果库 if (System.IO.Directory.Exists(this.m_TopoDBPath + "\\" + COMMONCONST.DB_Name_Topo)) { System.IO.Directory.Delete(this.m_TopoDBPath + "\\" + COMMONCONST.DB_Name_Topo, true); } Hy.Common.Utility.Esri.AEAccessFactory.CreateFGDB(this.m_TopoDBPath, COMMONCONST.DB_Name_Topo, ref this.m_TopoWorkspace); if (this.m_TopoWorkspace == null) { SendMessage(enumMessageType.Exception, "创建拓扑库失败"); } // 根据Base库找第一个Geodataset的空间参考,用来创建拓扑库 ISpatialReference topoSptatialRef = null; IEnumDataset enDataset = this.m_BaseWorkspace.get_Datasets(esriDatasetType.esriDTAny); IDataset ds = enDataset.Next(); while (ds != null) { if (ds is IGeoDataset) { topoSptatialRef = (ds as IGeoDataset).SpatialReference; break; } ds = enDataset.Next(); } IFeatureDataset fDataset = (this.m_TopoWorkspace as IFeatureWorkspace).CreateFeatureDataset(COMMONCONST.Dataset_Name, topoSptatialRef); if (fDataset == null) { SendMessage(enumMessageType.Exception, "创建拓扑库Dataset失败"); } ITopologyContainer topoContainer = fDataset as ITopologyContainer; //m_Topology = topoContainer.get_TopologyByName(COMMONCONST.Topology_Name); // 若已有Topology,则不再创建 //if (m_Topology == null) m_Topology = topoContainer.CreateTopology(COMMONCONST.Topology_Name, this.m_TopoTolerance, COMMONCONST.TopoError_MaxCount, "esriConfigurationKeywordTopology"); } catch (Exception exp) { SendMessage(enumMessageType.Exception, "创建Topology出错,信息:" + exp.ToString()); } } (checkRule as ITopologicalRule).Topology = m_Topology; m_TopoRuleList.Add(checkRule); } else { m_NormalRuleList.Add(checkRule); } //m_RuleList.Add(checkRule); m_DictRuleAndInfo.Add(checkRule, this.RuleInfos[i]); } catch (Exception ex) { SendMessage(enumMessageType.Exception, "初始化规则失败,信息:" + ex.ToString()); continue; } } }