public override bool Verify() { // 获取标准ID int nStdID = SysDbHelper.GetStandardID(this.m_strStdName); lyr = LayerReader.GetLayerByAliasName(m_psPara.strFtName, nStdID); if (lyr == null) { SendMessage(enumMessageType.VerifyError, string.Format("标准中不存在图层“{0}”", m_psPara.strFtName)); return(false); } // 获取实际字值名 Helper.StandardHelper helper = new Hy.Check.Rule.Helper.StandardHelper(this.m_QueryConnection); strFieldCode = FieldReader.GetNameByAliasName(m_psPara.strCodeField, lyr.ID); if (string.IsNullOrEmpty(strFieldCode)) { SendMessage(enumMessageType.VerifyError, string.Format("标准图层中不存在字段“{0}”", m_psPara.strCodeField)); return(false); } strFieldCodeType = helper.GetLayerFieldType(strFieldCode, lyr.AttributeTableName); if (string.IsNullOrEmpty(strFieldCodeType)) { SendMessage(enumMessageType.VerifyError, string.Format("数据图层中不存在字段“{0}”", m_psPara.strCodeField)); return(false); } if (m_psPara.strNameField != "") { strFieldName = FieldReader.GetNameByAliasName(m_psPara.strNameField, lyr.ID); } else { SendMessage(enumMessageType.VerifyError, "没有配置字段"); return(false); } return(true); }
public override bool Check(ref List <Error> checkResult) { try { List <Error> m_pRuleResult = new List <Error>(); List <string> aryFtCode = new List <string>(); Helper.StandardHelper StdHelp = new Hy.Check.Rule.Helper.StandardHelper(SysDbHelper.GetSysDbConnection()); StdHelp.GetLayerCodes(ref aryFtCode, m_psPara.strTargetLayer, standarID); if (aryFtCode == null) //如果编码类型为空 { string strSql = "select OBJECTID,BSM from " + strLayerName; DataTable ipRecordset = new DataTable(); ipRecordset = Hy.Common.Utility.Data.AdoDbHelper.GetDataTable(this.m_QueryConnection, strSql); if (ipRecordset == null) { return(false); } // 从DataTable中获取名称 foreach (DataRow dr in ipRecordset.Rows) // 遍历结果集 { if (dr != null) { int nOID = Convert.ToInt32(dr["ObjectID"]); // 添家结果记录 Error pResInfo = new Error(); pResInfo.DefectLevel = this.m_DefectLevel; pResInfo.RuleID = this.InstanceID; pResInfo.OID = nOID; pResInfo.BSM = dr["BSM"].ToString(); pResInfo.LayerName = m_psPara.strTargetLayer; // 目标图层 // 错误信息 string strMsg; strMsg = string.Format("'{0}'层标识码为'{1}'的'{2}'字段对应的要素类型代码为空", pResInfo.LayerName, pResInfo.BSM, strCodeField); if (m_psPara.strRemark != null && m_psPara.strRemark.Trim() != "") { pResInfo.Description = m_psPara.strRemark; } else { pResInfo.Description = strMsg; } m_pRuleResult.Add(pResInfo); break; } } checkResult = m_pRuleResult; // 关闭记录集 ipRecordset.Dispose(); } else { try { string strSql; string strFtCode = ""; for (int i = 0; i < aryFtCode.Count; i++) { string strTmp; strTmp = aryFtCode[i]; strFtCode += strTmp; } strSql = "select OBJECTID,BSM,YSDM from " + strLayerName + " where (" + strCodeField + " not in ('" + strFtCode.Substring(0, strFtCode.Length) + "')) or (" + strCodeField + " is null )"; DataTable ipRecordset = new DataTable(); ipRecordset = Hy.Common.Utility.Data.AdoDbHelper.GetDataTable(this.m_QueryConnection, strSql); if (ipRecordset == null) { return(false); } // 从DataTable中获取名称 foreach (DataRow dr in ipRecordset.Rows) // 遍历结果集 { if (dr != null) { int nOID = Convert.ToInt32(dr["ObjectID"]); // 添家结果记录 Error pResInfo = new Error(); pResInfo.DefectLevel = this.m_DefectLevel; pResInfo.RuleID = this.InstanceID; pResInfo.OID = nOID; pResInfo.BSM = dr["BSM"].ToString(); pResInfo.LayerName = m_psPara.strTargetLayer; // 目标图层 // 错误信息 string strMsg; strMsg = string.Format("'{0}'层标识码为'{1}'的'{2}({3})'字段的值'{4}'不正确。应为:{5}", pResInfo.LayerName, pResInfo.BSM, m_psPara.strCodeField, strCodeField, dr["YSDM"], strFtCode); if (m_psPara.strRemark != null && !string.IsNullOrEmpty(m_psPara.strRemark.Trim())) { pResInfo.Description = m_psPara.strRemark; } else { pResInfo.Description = strMsg; } m_pRuleResult.Add(pResInfo); } } checkResult = m_pRuleResult; // 关闭记录集 ipRecordset.Dispose(); } catch (Exception ex) { SendMessage(enumMessageType.Exception, ex.ToString()); return(false); } } } catch (Exception ex) { SendMessage(enumMessageType.Exception, ex.ToString()); return(false); } return(true); }
public override bool Check(ref List<Error> checkResult) { try { List<Error> m_pRuleResult = new List<Error>(); List<string> aryFtCode = new List<string>(); Helper.StandardHelper StdHelp = new Hy.Check.Rule.Helper.StandardHelper(SysDbHelper.GetSysDbConnection()); StdHelp.GetLayerCodes(ref aryFtCode, m_psPara.strTargetLayer, standarID); if (aryFtCode == null) //�����������Ϊ�� { string strSql = "select OBJECTID,BSM from " + strLayerName; DataTable ipRecordset = new DataTable(); ipRecordset = Hy.Common.Utility.Data.AdoDbHelper.GetDataTable(this.m_QueryConnection, strSql); if (ipRecordset == null) { return false; } // ��DataTable�л�ȡ���� foreach (DataRow dr in ipRecordset.Rows) // ��������� { if (dr != null) { int nOID = Convert.ToInt32(dr["ObjectID"]); // ��ҽ����¼ Error pResInfo = new Error(); pResInfo.DefectLevel = this.m_DefectLevel; pResInfo.RuleID = this.InstanceID; pResInfo.OID = nOID; pResInfo.BSM = dr["BSM"].ToString(); pResInfo.LayerName = m_psPara.strTargetLayer; // Ŀ��ͼ�� // ������Ϣ string strMsg; strMsg = string.Format("'{0}'���ʶ��Ϊ'{1}'��'{2}'�ֶζ�Ӧ��Ҫ�����ʹ���Ϊ��", pResInfo.LayerName, pResInfo.BSM, strCodeField); if (m_psPara.strRemark != null && m_psPara.strRemark.Trim() != "") { pResInfo.Description = m_psPara.strRemark; } else { pResInfo.Description = strMsg; } m_pRuleResult.Add(pResInfo); break; } } checkResult = m_pRuleResult; // �رռ�¼�� ipRecordset.Dispose(); } else { try { string strSql; string strFtCode = ""; for (int i = 0; i < aryFtCode.Count; i++) { string strTmp; strTmp = aryFtCode[i]; strFtCode += strTmp; } strSql = "select OBJECTID,BSM,YSDM from " + strLayerName + " where (" + strCodeField + " not in ('" + strFtCode.Substring(0, strFtCode.Length) + "')) or (" + strCodeField + " is null )"; DataTable ipRecordset = new DataTable(); ipRecordset = Hy.Common.Utility.Data.AdoDbHelper.GetDataTable(this.m_QueryConnection, strSql); if (ipRecordset == null) { return false; } // ��DataTable�л�ȡ���� foreach (DataRow dr in ipRecordset.Rows) // ��������� { if (dr != null) { int nOID = Convert.ToInt32(dr["ObjectID"]); // ��ҽ����¼ Error pResInfo = new Error(); pResInfo.DefectLevel = this.m_DefectLevel; pResInfo.RuleID = this.InstanceID; pResInfo.OID = nOID; pResInfo.BSM = dr["BSM"].ToString(); pResInfo.LayerName = m_psPara.strTargetLayer; // Ŀ��ͼ�� // ������Ϣ string strMsg; strMsg = string.Format("'{0}'���ʶ��Ϊ'{1}'��'{2}({3})'�ֶε�ֵ'{4}'����ȷ��ӦΪ��{5}", pResInfo.LayerName, pResInfo.BSM, m_psPara.strCodeField, strCodeField, dr["YSDM"], strFtCode); if (m_psPara.strRemark != null && !string.IsNullOrEmpty(m_psPara.strRemark.Trim())) { pResInfo.Description = m_psPara.strRemark; } else { pResInfo.Description = strMsg; } m_pRuleResult.Add(pResInfo); } } checkResult = m_pRuleResult; // �رռ�¼�� ipRecordset.Dispose(); } catch (Exception ex) { SendMessage(enumMessageType.Exception, ex.ToString()); return false; } } } catch (Exception ex) { SendMessage(enumMessageType.Exception, ex.ToString()); return false; } return true; }
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() { // ��ȡ��ID int nStdID = SysDbHelper.GetStandardID(this.m_strStdName); lyr = LayerReader.GetLayerByAliasName(m_psPara.strFtName, nStdID); if (lyr == null) { SendMessage(enumMessageType.VerifyError, string.Format("���в�����ͼ�㡰{0}��", m_psPara.strFtName)); return false; } // ��ȡʵ����ֵ�� Helper.StandardHelper helper = new Hy.Check.Rule.Helper.StandardHelper(this.m_QueryConnection); strFieldCode = FieldReader.GetNameByAliasName(m_psPara.strCodeField, lyr.ID); if (string.IsNullOrEmpty(strFieldCode)) { SendMessage(enumMessageType.VerifyError, string.Format("��ͼ���в������ֶΡ�{0}��", m_psPara.strCodeField)); return false; } strFieldCodeType = helper.GetLayerFieldType(strFieldCode, lyr.AttributeTableName); if (string.IsNullOrEmpty(strFieldCodeType)) { SendMessage(enumMessageType.VerifyError, string.Format("����ͼ���в������ֶΡ�{0}��", m_psPara.strCodeField)); return false; } if (m_psPara.strNameField != "") { strFieldName = FieldReader.GetNameByAliasName(m_psPara.strNameField, lyr.ID); } else { SendMessage(enumMessageType.VerifyError,"û�������ֶ�"); return false; } return true; }