Пример #1
0
        private static List <string> GetDicValues(List <AttValueInfo> attValList)
        {
            List <string> valueList = new List <string>();

            try
            {
                for (int i = 0; i < attValList.Count; i++)
                {
                    AttValueInfo attVal = attValList[i];
                    if (string.IsNullOrEmpty(attVal.Memo))
                    {
                        string[] temp = attVal.Value.Split('、');
                        valueList.AddRange(temp);
                    }
                    else if (attVal.Memo == "$")
                    {
                        string[] temp = attVal.Value.Split('$');
                        valueList.AddRange(temp);
                    }
                }
                return(valueList);
            }
            catch (Exception ex)
            {
                return(valueList);
            }
        }
Пример #2
0
        private void GetData()
        {
            InfoEarthFrame.Data.IDatabase DBAccess = InfoEarthFrame.Data.Factory.GetDBAccess(ConfigurationManager.ConnectionStrings["Default"].ConnectionString, InfoEarthFrame.Data.AccessDBType.Oracle);

            _txLyrList.Clear();
            _lyrAttList.Clear();
            _attValueList.Clear();

            //图系图层信息
            //string sqlStr = "select trim(GUID) as GUID,trim(TXNAME) AS TXNAME,trim(TJNAME) AS TJNAME ,trim(LAYERNAME) AS LAYERNAME,trim(JHTZ) AS JHTZ from DIC_TX_LAYER order by SERIALNUM";
            string  sqlStr  = "select  Max(\"Id\") as GUID,\"TXName\",\"TJName\" ,\"LayerName\", \"DataLayer\" from DIC_TX_LAYERPROPERTY  group by \"TXName\",\"TJName\" ,\"LayerName\", \"DataLayer\"";
            DataSet dataset = DBAccess.GetDataSetFromExcuteCommand(sqlStr, null);

            if (dataset != null && dataset.Tables.Count > 0)
            {
                DataTable tbl = dataset.Tables[0];
                for (int i = 0; i < tbl.Rows.Count; i++)
                {
                    TxLayerInfo info = new TxLayerInfo()
                    {
                        Guid      = tbl.Rows[i]["GUID"] as string,
                        TxName    = tbl.Rows[i]["TXNAME"] as string,
                        TjName    = tbl.Rows[i]["TJNAME"] as string,
                        LayerName = tbl.Rows[i]["LAYERNAME"] as string,
                        DataLayer = tbl.Rows[i]["DataLayer"] as string,
                        GeoType   = "",//tbl.Rows[i]["JHTZ"] as string,
                    };
                    _txLyrList.Add(info);
                }
            }
            //图层属性信息
            //sqlStr = "select trim(GUID) as GUID,trim(LAYERID) AS LAYERID,trim(DATANAME) AS DATANAME ,trim(DATACODE) AS DATACODE,trim(DES) AS DES,trim(DATATYPE) AS DATATYPE,trim(CONSTRAINT) AS CONSTRAINT,trim(VALUETYPE) AS VALUETYPE,trim(UNIT) AS UNIT,trim(MEMO) AS MEMO from DIC_TX_LAYERPROPERTY order by LAYERID";
            sqlStr  = "select  \"Id\" as GUID,\"TXName\",\"TJName\" ,\"LayerName\",trim(\"FieldName\") AS DATANAME, trim(\"InputControl\") AS INPUTCONTROL, trim(\"DataLayer\") as DATALAYER ,trim(\"FieldCode\") AS DATACODE ,\"FieldType\", \"FieldLen\",\"FieldDec\",trim(\"InputControl\") AS CONSTRAINT from DIC_TX_LAYERPROPERTY";
            dataset = DBAccess.GetDataSetFromExcuteCommand(sqlStr, null);
            if (dataset != null && dataset.Tables.Count > 0)
            {
                DataTable tbl = dataset.Tables[0];
                for (int i = 0; i < tbl.Rows.Count; i++)
                {
                    LayerAttInfo info = new LayerAttInfo()
                    {
                        Guid         = tbl.Rows[i]["GUID"] as string,
                        TxName       = tbl.Rows[i]["TXName"] as string,
                        TjName       = tbl.Rows[i]["TJName"] as string,
                        LayerName    = tbl.Rows[i]["LayerName"] as string,
                        DataName     = tbl.Rows[i]["DATANAME"] as string,
                        DataCode     = tbl.Rows[i]["DATACODE"] as string,
                        Des          = "",                           //tbl.Rows[i]["DES"] as string,
                        DataLayer    = tbl.Rows[i]["DATALAYER"] as string,
                        DataType     = ConvertDataType(tbl.Rows[i]), //tbl.Rows[i]["DATATYPE"] as string,
                        Constraint   = tbl.Rows[i]["CONSTRAINT"] as string,
                        ValueType    = "自由文本",                       //tbl.Rows[i]["VALUETYPE"] as string,
                        Unit         = "/",                          //tbl.Rows[i]["U_NAME"] as string,
                        Memo         = "/",                          //tbl.Rows[i]["MEMO"] as string,
                        InputControl = tbl.Rows[i]["INPUTCONTROL"] as string,
                    };
                    _lyrAttList.Add(info);
                }
            }
            //字典项字段信息
            //sqlStr = "select trim(GUID) as GUID,trim(PROPERTYID) AS PROPERTYID,trim(VALUE) AS VALUE ,trim(MEMO) AS MEMO,trim(PARENTPROPERTYID) AS PARENTPROPERTYID from DIC_TX_PROPERTYVALUE";
            sqlStr  = "select trim(\"Id\") as GUID, trim(\"FieldValue\") AS VALUE from DIC_TX_PROPERTYVALUE";
            dataset = DBAccess.GetDataSetFromExcuteCommand(sqlStr, null);
            if (dataset != null && dataset.Tables.Count > 0)
            {
                DataTable tbl = dataset.Tables[0];
                for (int i = 0; i < tbl.Rows.Count; i++)
                {
                    AttValueInfo info = new AttValueInfo()
                    {
                        Guid     = tbl.Rows[i]["GUID"] as string,
                        AttId    = "", //tbl.Rows[i]["PROPERTYID"] as string,
                        Value    = tbl.Rows[i]["VALUE"] as string,
                        Memo     = "", //tbl.Rows[i]["MEMO"] as string,
                        ParentId = "", //tbl.Rows[i]["PARENTPROPERTYID"] as string
                    };
                    _attValueList.Add(info);
                }
            }
        }
Пример #3
0
        //检查字段字典项
        private static List <string> CheckDicAtt(DataTable tbl, LayerAttInfo attInfo, DicInfoReader dicInfo)
        {
            List <string>       rlts       = new List <string>();
            List <AttValueInfo> attValList = dicInfo.AttValueList.Where(t => t.AttId == attInfo.Guid).ToList();

            if (attValList == null || attValList.Count < 1)
            {
                return(rlts);
            }
            List <string> cols = new List <string>();

            for (int i = 0; i < tbl.Columns.Count; i++)
            {
                cols.Add(tbl.Columns[i].ColumnName);
            }
            if (attValList.Count == 1 && string.IsNullOrEmpty(attValList[0].ParentId) == false)
            {
                AttValueInfo attVal = attValList[0];
                //检查大类是符合字典项
                AttValueInfo  pAttVal  = dicInfo.AttValueList.First(t => t.Guid == attVal.ParentId);
                LayerAttInfo  pAttInfo = dicInfo.LyrAttList.First(t => t.Guid == pAttVal.AttId);
                List <string> infoList = CheckDicAtt(tbl, pAttInfo, dicInfo);
                if (infoList != null && infoList.Count > 0)
                {
                    rlts.AddRange(infoList.ToArray());
                }
            }
            //检查是否符合字典项
            List <string> valueList = GetDicValues(attValList);

            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                object obj = null;
                if (cols.Contains(attInfo.DataName))
                {
                    obj = tbl.Rows[i][attInfo.DataName];
                }
                if (obj == null)
                {
                    continue;
                }
                string valStr = obj.ToString();
                if (attInfo.Constraint.Equals("M", StringComparison.CurrentCultureIgnoreCase) && valueList.Contains(valStr) == false)
                {
                    string info = string.Format("数据检查:第{0}行“{1}”字段值不在字典项({2})里", i, attInfo.DataName, JoinStr(valueList));
                    rlts.Add(info);
                }
                else if (attInfo.Constraint.Equals("O", StringComparison.CurrentCultureIgnoreCase))
                {
                    //有待完善
                    bool ok = false;
                    for (int j = 0; j < valueList.Count; j++)
                    {
                        if (valStr.Contains(valueList[j]))
                        {
                            ok = true;
                        }
                    }
                    if (ok == false)
                    {
                        string info = string.Format("数据检查:第{0}行{1}字段值不在字典项({2})里", i, attInfo.DataName, JoinStr(valueList));
                        rlts.Add(info);
                    }
                }
            }
            return(rlts);
        }