public override bool Verify() { //根据别名取featureclass的名字 int standardID = SysDbHelper.GetStandardIDBySchemaID(this.m_SchemaID); strSrcLayer = LayerReader.GetNameByAliasName(m_pPara.strTargetLayer, standardID); strRelLayer = LayerReader.GetNameByAliasName(m_pPara.strRelLayer, standardID); if (this.m_BaseWorkspace != null) { if (!(this.m_BaseWorkspace as IWorkspace2).get_NameExists(esriDatasetType.esriDTFeatureClass, strSrcLayer)) { string strLog = "当前工作数据库的关系图层" + strSrcLayer + "不存在,无法执行检查!"; SendMessage(enumMessageType.RuleError, strLog); return(false); } if (!(this.m_BaseWorkspace as IWorkspace2).get_NameExists(esriDatasetType.esriDTFeatureClass, strSrcLayer)) { string strLog = "当前工作数据库的目标图层" + strRelLayer + "不存在,无法执行检查!"; SendMessage(enumMessageType.RuleError, strLog); return(false); } return(true); } else { return(false); } }
protected void RenameClassObjects(IWorkspace wsTarget) { int standardID = SysDbHelper.GetStandardIDBySchemaID(this.m_SchemaID); IEnumDataset enDataset = wsTarget.get_Datasets(esriDatasetType.esriDTAny); IDataset dsCurrent = enDataset.Next(); while (dsCurrent != null) { switch (dsCurrent.Type) { case esriDatasetType.esriDTTable: case esriDatasetType.esriDTFeatureClass: RenameClassObject(dsCurrent, standardID); break; case esriDatasetType.esriDTFeatureDataset: //RenameClassObject(dsCurrent, standardID); // FeatureDataset需要改吗 IEnumDataset enSubDataset = dsCurrent.Subsets; IDataset subDataset = enSubDataset.Next(); while (subDataset != null) { RenameClassObject(subDataset, standardID); subDataset = enSubDataset.Next(); } break; } System.Runtime.InteropServices.Marshal.ReleaseComObject(dsCurrent); dsCurrent = enDataset.Next(); } }
/// <summary> /// /// </summary> /// <param name="nLayerID">图层的ID</param> /// <param name="strStdName">建库标准名称</param> /// <param name="strAttrTableName">图层别名</param> /// <returns></returns> public bool GetLayerIDByTableName(ref int nLayerID, string schemaID, string strAttrTableName) { try { int nStdID = SysDbHelper.GetStandardIDBySchemaID(schemaID); string strSql = "Select LayerID From LR_DicLayer Where StandardID = " + nStdID + "and AttrTableName = '" + strAttrTableName + "'"; DataTable dt = new DataTable(); // 打开表LR_DicStandard dt = AdoDbHelper.GetDataTable(this.m_DBConnection, strSql); if (dt.Rows.Count == 0) { return(false); } DataRow dr = dt.Rows[0]; nLayerID = Convert.ToInt32(dr["LayerID"]); } catch (Exception ex) { //Hy.Check.Rule.Helper.LogAPI.CheckLog.AppendErrLogs(ex.ToString()); //显示错误信息; //XtraMessageBox.Show("XStandardHelper::GetLayerIDByAlias()" + ex.Message); return(false); } return(true); }
/// <summary> ///通过图层别名获取图层名称 /// </summary> /// <param name="strAliasName">Name of the STR alias.</param> /// <returns></returns> protected string GetLayerName(string strAliasName) { if (string.IsNullOrEmpty(strAliasName)) { return(null); } int standardID = SysDbHelper.GetStandardIDBySchemaID(this.m_SchemaID); return(LayerReader.GetNameByAliasName(strAliasName, standardID)); }
private string ConstructErrorInfo() { int layerid = -1; StandardHelper pStand = new StandardHelper(SysDbHelper.GetSysDbConnection()); pStand.GetLayerIDByTableName(ref layerid, this.m_SchemaID, m_structPara.strFtName); string strSql1 = "Select FieldCode,FieldName From LR_DicField Where LayerID = " + layerid; List <FIELDMAP> arrFieldMap = new List <FIELDMAP>(); DataTable dt = new DataTable(); AdoDbHelper.GetDataTable(SysDbHelper.GetSysDbConnection(), strSql1); if (dt.Rows.Count == 0) { return(null); } foreach (DataRow dr in dt.Rows) { string FName = dr["FieldCode"].ToString(); //字段名 string FAlias = dr["FieldName"].ToString(); //字段别名 FIELDMAP fMap = new FIELDMAP(); fMap.strAlias = FAlias; fMap.strName = FName; arrFieldMap.Add(fMap); } /*string Alias = "", Alias2 = ""; * pStand.GetAliasByLayerName(ref Alias, m_structPara.strFtName, m_strStdName); * pStand.GetAliasByLayerName(ref Alias2, m_structPara.strFtName2, m_strStdName);*/ int standardID = SysDbHelper.GetStandardIDBySchemaID(this.m_SchemaID); if (!string.IsNullOrEmpty(FtName1)) { FtName1 = LayerReader.GetNameByAliasName(m_structPara.strFtName, standardID); } if (!string.IsNullOrEmpty(FtName2)) { FtName2 = LayerReader.GetNameByAliasName(m_structPara.strFtName, standardID); } string strErrInfo = m_structPara.strClause; for (int i = 0; i < arrFieldMap.Count; i++) { string strR = arrFieldMap[i].strAlias; string strS = arrFieldMap[i].strName; strErrInfo.Replace(strS, strR); } strErrInfo.Replace(m_structPara.strFtName, FtName1); strErrInfo.Replace(m_structPara.strFtName2, FtName2); strErrInfo = "字段值符合表达式 (" + strErrInfo + ")"; return(strErrInfo); }
public override bool Verify() { //根据别名取图层名 int standardID = SysDbHelper.GetStandardIDBySchemaID(this.m_SchemaID); layerName = LayerReader.GetNameByAliasName(m_structPara.strFtName, standardID); if (string.IsNullOrEmpty(layerName)) { SendMessage(enumMessageType.VerifyError, string.Format("当前标准中不存在图层“{0}”", m_structPara.strFtName)); return(false); } return(true); }
public override bool Verify() { int standardID = SysDbHelper.GetStandardIDBySchemaID(this.m_SchemaID); lyr = LayerReader.GetLayerByAliasName(m_structFrePara.strFtName, standardID); if (lyr == null) { SendMessage(enumMessageType.VerifyError, "当前方案所在的标准中找不到名为“" + m_structFrePara.strFtName + "”的图层"); return(false); } return(true); }
public override bool Verify() { //根据别名取featureclass的名字 int standardID = SysDbHelper.GetStandardIDBySchemaID(this.m_SchemaID); layerName = LayerReader.GetNameByAliasName(m_structPara.strFtName, standardID); //清除以前结果 if (this.m_QueryConnection == null) { return(false); } return(true); }
public override bool Verify() { m_StandarID = SysDbHelper.GetStandardIDBySchemaID(this.m_SchemaID); //根据别名取图层名 m_layerName = LayerReader.GetNameByAliasName(m_structInvalidPara.strFtName, m_StandarID); if (m_QueryWorkspace == null) { return(false); } if (!(m_QueryWorkspace as IWorkspace2).get_NameExists(esriDatasetType.esriDTTable, m_layerName)) { string strLog = "当前工作数据库中不存在图层" + m_layerName + ",无法执行非法字符检查!"; SendMessage(enumMessageType.RuleError, strLog); return(false); } return(true); }
public override bool Verify() { standarID = SysDbHelper.GetStandardIDBySchemaID(this.m_SchemaID); StandardLayer lyr = LayerReader.GetLayerByAliasName(m_psPara.strTargetLayer, standarID); if (lyr == null) { SendMessage(enumMessageType.VerifyError, "当前方案所在的标准中找不到名为“" + m_psPara.strTargetLayer + "”的图层"); return(false); } strLayerName = lyr.Name; strCodeField = FieldReader.GetNameByAliasName(m_psPara.strCodeField, lyr.ID); if (string.IsNullOrEmpty(strCodeField)) { SendMessage(enumMessageType.VerifyError, string.Format("当前方案所在的标准中找不到名为“{0}”的图层", m_psPara.strCodeField)); return(false); } return(true); }
private string ConstructErrorInfo() { string strInfo; strInfo = "线长度小于域值" + COMMONCONST.dLengthThread + " "; string strFields = ""; StandardLayer distLayer = LayerReader.GetLayerByName(m_structLengthPara.strFtName, SysDbHelper.GetStandardIDBySchemaID(this.m_SchemaID)); if (m_structLengthPara.fieldArray != null) { for (int i = 0; i < m_structLengthPara.fieldArray.Count; i++) { strFields = strFields + "|" + FieldReader.GetAliasName(m_structLengthPara.fieldArray[i], distLayer.ID); } strFields = strFields.Remove(0, 1); strFields = strFields + " 字段都为空"; strInfo = strInfo + ",并且 " + strFields; } return(strInfo); }
private string ConstructErrorInfo() { string strInfo = ""; string strFields = ""; StandardLayer distLayer = LayerReader.GetLayerByName(m_structBlankPara.strFtName, SysDbHelper.GetStandardIDBySchemaID(this.m_SchemaID)); if (m_structBlankPara.fieldArray.Count > 0) { for (int i = 1; i < m_structBlankPara.fieldArray.Count; i++) { strFields = strFields + "|" + FieldReader.GetAliasName(m_structBlankPara.fieldArray[i], distLayer.ID); } strFields = strFields.Remove(0, 1); } if (m_structBlankPara.iType == 0) { strInfo = "字段 " + strFields + " 都为空"; } else if (m_structBlankPara.iType == 1) { strInfo = "字段 " + strFields + " 中有一个或多个为空"; } return(strInfo); }
public override bool Verify() { //先取得要进行空间关系查询的ILayer IFeatureWorkspace ipFtWS = (IFeatureWorkspace)m_BaseWorkspace; int standarID = SysDbHelper.GetStandardIDBySchemaID(this.m_SchemaID); StandardLayer lyrSource = LayerReader.GetLayerByAliasName(m_pPara.strGeographyObject, standarID); if (lyrSource == null) { SendMessage(enumMessageType.VerifyError, string.Format("当前方案所在的标准中批不到名为“{0}”的图层", m_pPara.strGeographyObject)); return(false); } strSrcLayer = lyrSource.Name; if (m_pPara.arrayGraphSpeckleField.Count > 0) { strSrcFiled = FieldReader.GetNameByAliasName(m_pPara.arrayGraphSpeckleField[0], lyrSource.ID); if (string.IsNullOrEmpty(strSrcFiled)) { SendMessage(enumMessageType.VerifyError, string.Format("当前方案所在的标准中批不到名为“{0}”的图层", m_pPara.arrayGraphSpeckleField[0])); return(false); } } StandardLayer lyrRel = LayerReader.GetLayerByAliasName(m_pPara.strGraphSpeckle, standarID); strRelLayer = lyrRel.Name; if (m_pPara.arrayGeographyObjectField.Count > 0) { strRelField = FieldReader.GetNameByAliasName(m_pPara.arrayGeographyObjectField[0], lyrRel.ID); if (string.IsNullOrEmpty(strRelField)) { SendMessage(enumMessageType.VerifyError, string.Format("当前方案所在的标准中批不到名为“{0}”的图层", m_pPara.arrayGeographyObjectField[0])); return(false); } } //得到目标图层和关系图层的featureclass IFeatureClass pSrcFeatClass = null; IFeatureClass pRelFeatClass = null; IWorkspace TempWorkspace = null; IWorkspace2 wsTest = ipFtWS as IWorkspace2; // 原始数据准备 // 打开“源” try { pSrcFeatClass = ipFtWS.OpenFeatureClass(strSrcLayer); } catch { SendMessage(enumMessageType.VerifyError, "当前工作数据库的关系图层" + strSrcLayer + "不存在,无法执行检查!"); return(false); } m_srcfcname = strSrcLayer; if (pSrcFeatClass.FeatureCount(null) == 0) { Marshal.ReleaseComObject(pSrcFeatClass); SendMessage(enumMessageType.VerifyError, "当前工作数据库的关系图层" + strSrcLayer + "为空,无法执行检查!"); return(false); } if (pSrcFeatClass != null) { Marshal.ReleaseComObject(pSrcFeatClass); pSrcFeatClass = null; } // 打开“目标” try { pRelFeatClass = ipFtWS.OpenFeatureClass(strRelLayer); } catch { SendMessage(enumMessageType.VerifyError, "当前工作数据库的目标图层" + strRelLayer + "不存在,无法执行检查!"); return(false); } if (pRelFeatClass.FeatureCount(null) == 0) { Marshal.ReleaseComObject(pRelFeatClass); SendMessage(enumMessageType.VerifyError, "当前工作数据库的关系图层" + strSrcLayer + "为空,无法执行检查!"); return(false); } if (pRelFeatClass != null) { Marshal.ReleaseComObject(pRelFeatClass); pRelFeatClass = null; } return(true); }