Beispiel #1
0
        public void Program()
        {
            var _connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}", _mdbFilePath);

            using (var connection = new OleDbConnection(_connectionString))
            {
                connection.Open();
                try
                {
                    var reader = ADOSQLHelper.ExecuteReader(connection, "Select XZCDM,XZCMC from XZQ_XZC");
                    if (reader != null)
                    {
                        var xzcdm = string.Empty;
                        var xzcmc = string.Empty;
                        while (reader.Read())
                        {
                            xzcdm = reader[0].ToString().Trim();
                            xzcmc = reader[1].ToString().Trim();
                            if (!_List.Any(e => e.XZCDM == xzcdm && e.XZCMC == xzcmc))
                            {
                                _List.Add(new XZC
                                {
                                    XZCDM = xzcdm,
                                    XZCMC = xzcmc
                                });
                            }
                        }
                    }
                }
                catch
                {
                    _questions.Add(new Question {
                        Code = "", Name = "", Project = CheckProject.汇总表与数据库图层逻辑一致性, TableName = "XZQ_XZC", Description = ""
                    });
                }
                _tools.Add(new ExcelOne {
                    Connection = connection, List = _List, District = District, Code = Code, Folder = Folder
                });
                _tools.Add(new ExcelTwo {
                    Connection = connection, List = _List, District = District, Code = Code, Folder = Folder
                });
                _tools.Add(new ExcelThree {
                    Connection = connection, List = _List, District = District, Code = Code, Folder = Folder
                });
                _tools.Add(new ExcelFour {
                    Connection = connection, List = _List, District = District, Code = Code, Folder = Folder
                });

                Parallel.ForEach(_tools, item =>
                {
                    item.Check();
                });
                foreach (var tool in _tools)
                {
                    _questions.AddRange(tool.ParalleQuestions.AsEnumerable());
                }

                connection.Close();
            }
        }
Beispiel #2
0
        private bool CheckNoWhere(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, string.Format("select {0},{1} from {2}", CheckFieldName, Key, TableName));

            if (reader != null)
            {
                var str   = string.Empty;
                var error = string.Empty;
                Messages = new List <string>();
                while (reader.Read())
                {
                    str = reader[0].ToString();
                    if (Values.Contains(str))
                    {
                        continue;
                    }
                    else
                    {
                        error = string.Format("{0}对应的‘{1}’值不正确", reader[1].ToString(), str);
                        Messages.Add(error);
                        _questions.Add(new Question()
                        {
                            Code = "3201", Name = Name, Project = CheckProject.值符合性, TableName = TableName, BSM = reader[1].ToString(), Description = error
                        });
                    }
                }
                QuestionManager.AddRange(_questions);
                return(true);
            }
            return(false);
        }
Beispiel #3
0
        private bool CheckWhere(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, string.Format("Select {0},{1},{2} from {3}", CheckFieldName, Key, string.Join(",", WhereFields), TableName));

            if (reader != null)
            {
                var str   = string.Empty;
                var error = string.Empty;
                var array = new string[WhereFields.Length];
                while (reader.Read())
                {
                    str = reader[0].ToString();
                    for (var i = 0; i < WhereFields.Length; i++)
                    {
                        array[i] = reader[i + 2].ToString();
                    }
                    var key = string.Join(Split, array);
                    if (WhereList.Contains(key))
                    {
                        if (!Values.Contains(str))
                        {
                            error = string.Format("{0}对应的‘{1}’不正确", reader[1].ToString(), str);
                            _questions.Add(new Question {
                                Code = "3201", Name = Name, Project = CheckProject.值符合性, TableName = TableName, BSM = reader[1].ToString(), Description = error
                            });
                        }
                    }
                }
                return(true);
            }
            return(false);
        }
        public bool Check(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, _SQL);

            if (reader == null)
            {
                return(false);
            }

            while (reader.Read())
            {
                var keyValue   = reader[0].ToString().Trim();
                var checkValue = reader[0].ToString().Trim();
                if (string.IsNullOrEmpty(keyValue) == false)
                {
                    if (Values.Contains(checkValue) == false)
                    {
                        Messages2.Add(new Models.VillageMessage
                        {
                            Value       = keyValue,
                            Description = string.Format("【{0}={1}】不符合【{2}】", Key, keyValue, Name),
                            WhereClause = string.Format("[{0}] = '{1}'", Key, keyValue)
                        });
                        //Messages.Add(keyValue);
                    }
                }
            }
            return(true);
        }
        public bool Check(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, string.Format("Select {0} from {1}", string.Join(",", Fields), TableName));

            if (reader != null)
            {
                var array = new string[Fields.Length];
                var info  = string.Empty;
                while (reader.Read())
                {
                    array = new string[Fields.Length];
                    for (var i = 0; i < Fields.Length; i++)
                    {
                        array[i] = Fields[i].ToString();
                    }
                    var val = string.Join(Split, array);
                    if (!Values.Contains(val))
                    {
                        info = string.Format("不存在:{0}", val);
                        Messages.Add(info);
                        _questions.Add(new Question {
                            Code = Code, Name = Name, Project = CheckProject.属性正确性, TableName = TableName, Description = info
                        });
                    }
                }
                QuestionManager.AddRange(_questions);
                return(true);
            }

            return(false);
        }
        public bool Check(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, string.IsNullOrEmpty(WhereFieldName) ? string.Format("Select {0} from {1}", CheckFieldName, TableName) : string.Format("Select {0},{1} from {1}", CheckFieldName, WhereFieldName, TableName));

            if (reader != null)
            {
                var temp = new List <string>();
                var str  = string.Empty;
                var info = string.Empty;
                while (reader.Read())
                {
                    str = string.IsNullOrEmpty(WhereFieldName) ? string.Format("{0}:{1}", CheckFieldName, reader[0].ToString()) : string.Format("{0}:{1}并且{2}:{3}", WhereFieldName, reader[1], CheckFieldName, reader[0]);
                    if (temp.Contains(str))
                    {
                        info = string.Format("{0}  存在重复", str);
                        Messages.Add(info);
                        _questions.Add(new Question {
                            Code = Code, Name = Name, Project = CheckProject.属性正确性, TableName = TableName, BSM = CheckFieldName, Description = info
                        });
                    }
                    else
                    {
                        temp.Add(str);
                    }
                }
                QuestionManager.AddRange(_questions);
                return(true);
            }
            return(false);
        }
Beispiel #7
0
        public void Gain(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, string.Format("select XZCDM,XZCMC,TBBH,{0} from {1}", string.Join(",", AreaFields), TableName));

            if (reader != null)
            {
                List = new List <TB>();
                while (reader.Read())
                {
                    var val = new TB
                    {
                        XZCDM = reader[0].ToString(),
                        XZCMC = reader[1].ToString(),
                        TBBH  = reader[2].ToString()
                    };
                    var sum = .0;
                    for (var i = 3; i < AreaFields.Length + 3; i++)
                    {
                        var a = .0;
                        if (double.TryParse(reader[i].ToString(), out a))
                        {
                            sum += a;
                        }
                    }
                    val.MJ = sum;
                    List.Add(val);
                }
                if (List.Count > 0)
                {
                    DCDYTBManager.AddTB(TableName, List);
                }
            }
        }
Beispiel #8
0
        public bool Check(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, _SQL);

            if (reader == null)
            {
                return(false);
            }

            while (reader.Read())
            {
                var keyValue = reader[0].ToString().Trim();
                if (string.IsNullOrEmpty(keyValue) == false)
                {
                    var leftValue  = GetValue(reader, 1, 1 + CheckLeftFieldNames.Length);
                    var rightValue = GetValue(reader, 1 + CheckLeftFieldNames.Length, 1 + CheckLeftFieldNames.Length + CheckRightFieldNames.Length);
                    var abs        = Math.Abs(leftValue - rightValue);
                    var flag       = false;
                    if (Relative.HasValue)
                    {
                        var pp = abs / leftValue;
                        flag = pp < Relative.Value;
                    }
                    if (Absolute.HasValue)
                    {
                        flag = abs < Absolute.Value;
                    }
                }
            }
            return(true);
        }
        public bool Check(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, string.Format("Select {0},{1} from {2}", CheckFieldName, Key, TableName));

            if (reader != null)
            {
                var str  = string.Empty;
                var info = string.Empty;
                while (reader.Read())
                {
                    str = reader[0].ToString();
                    if (Regex.IsMatch(str, RegexString))
                    {
                        continue;
                    }
                    else
                    {
                        info = string.Format("{0}对应的值不正确,请核对", reader[1].ToString());
                        Messages.Add(info);
                        _questions.Add(new Question()
                        {
                            Code = "3201", Name = Name, Project = CheckProject.值符合性, TableName = TableName, BSM = reader[1].ToString(), Description = info
                        });
                    }
                }
                QuestionManager.AddRange(_questions);
                return(true);
            }
            return(false);
        }
        public bool Check(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, _SQL);

            if (reader == null)
            {
                return(false);
            }
            var list = new List <string>();

            while (reader.Read())
            {
                var keyValue = reader[0].ToString().Trim();

                if (string.IsNullOrEmpty(keyValue) == false)
                {
                    var str = string.Format("{0}:{1}", reader[2].ToString().Trim(), reader[1].ToString().Trim());
                    if (list.Contains(str))
                    {
                        Messages2.Add(new Models.VillageMessage
                        {
                            Value       = keyValue,
                            CheckValue  = str,
                            Description = string.Format("【{0} ={1}】对应的数据不符合【{2}】", Key, keyValue, Name),
                            WhereClause = string.Format("[{0}] = '{1}'", Key, keyValue)
                        });
                    }
                    else
                    {
                        list.Add(str);
                    }
                }
            }
            return(true);
        }
        private bool CheckNoWhereFields(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection,
                                                    string.IsNullOrEmpty(WhereCaluse) ?
                                                    (
                                                        LocationFields == null ?
                                                        string.Format("Select {0},{1} from {2}", string.Join(",", CheckFields), Key, TableName)
                 : string.Format("Select {0},{1},{2} from {3}", string.Join(",", CheckFields), Key, string.Join(",", LocationFields), TableName)
                                                    )
                : (
                                                        LocationFields == null ?
                                                        string.Format("Select {0},{1} from {2} where {3}", string.Join(",", CheckFields), Key, TableName, WhereCaluse)
                : string.Format("Select {0},{1},{2} from {3} where {4}", string.Join(",", CheckFields), Key, string.Join(",", LocationFields), TableName, WhereCaluse)
                                                        )

                                                    );

            if (reader != null)
            {
                var str  = string.Empty;
                var info = string.Empty;
                while (reader.Read())
                {
                    str = string.Empty;
                    for (var i = 0; i < CheckFields.Count(); i++)
                    {
                        var a = reader[i].ToString().Trim();
                        if (Is_Nullable ^ string.IsNullOrEmpty(a))//异或  Is_NULLable  ture 为空  字段不为空或者 Is_NULLable false 必填 字段为空 矛盾
                        {
                            str += CheckFields[i] + ",";
                        }
                    }
                    if (!string.IsNullOrEmpty(str))
                    {
                        info = string.Format("{0}对应的字段:{1}与要求的{2}不符", reader[CheckFields.Count()], str, Is_Nullable ? "为空" : "必填");
                        _questions.Add(
                            new Question
                        {
                            Code              = "5101",
                            Name              = Name,
                            Project           = CheckProject.图层内属性一致性,
                            TableName         = TableName,
                            BSM               = reader[CheckFields.Count()].ToString(),
                            Description       = info,
                            RelationClassName = RelationName,
                            ShowType          = ShowType.Space,
                            WhereClause       =
                                LocationFields == null ?
                                string.Format("[{0}] ='{1}'", Key, reader[CheckFields.Count()].ToString())
                                : ADOSQLHelper.GetWhereClause(LocationFields, ADOSQLHelper.GetValues(reader, 1 + CheckFields.Length, LocationFields.Length))
                        });
                        Messages.Add(info);
                    }
                }
                QuestionManager.AddRange(_questions);
                return(true);
            }
            return(false);
        }
Beispiel #12
0
        private bool CheckWhere(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection,
                                                    LocationFields == null ?
                                                    string.Format("Select {0},{1},{2} from {3}", CheckFieldName, Key, string.Join(",", WhereFields), TableName)
                : string.Format("Select {0},{1},{2},{3} from {4}", CheckFieldName, Key, string.Join(",", WhereFields), string.Join(",", LocationFields), TableName)
                                                    );

            if (reader != null)
            {
                var str   = string.Empty;
                var error = string.Empty;
                var array = new string[WhereFields.Length];
                while (reader.Read())
                {
                    str = reader[0].ToString().Trim();
                    for (var i = 0; i < WhereFields.Length; i++)
                    {
                        array[i] = reader[i + 2].ToString();
                    }
                    var key = string.Join(Split, array);
                    if (WhereList.Contains(key))
                    {
                        if (!Values.Contains(str))
                        {
                            error = string.Format("{0}对应的‘{1}’不正确", reader[1].ToString(), str);
                            _questions.Add(
                                new Question
                            {
                                Code              = "3201",
                                Name              = Name,
                                Project           = CheckProject.值符合性,
                                TableName         = TableName,
                                BSM               = reader[1].ToString(),
                                Description       = error,
                                ShowType          = ShowType.Space,
                                RelationClassName = RelationName,
                                WhereClause       =
                                    LocationFields == null?
                                    string.Format("[{0}] = '{1}'", Key, reader[1].ToString())
                                    :ADOSQLHelper.GetWhereClause(LocationFields, ADOSQLHelper.GetValues(reader, WhereFields.Length + 2, LocationFields.Length))
                            });
                        }
                    }
                }
                return(true);
            }
            return(false);
        }
        private bool CheckNoWhereField(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection,
                                                    LocationFields == null?
                                                    string.Format("Select {0} from {1}", CheckFieldName, TableName)
                :string.Format("Select {0},{1} from {2}", CheckFieldName, string.Join(",", LocationFields), TableName)
                                                    );

            if (reader != null)
            {
                var temp = new List <string>();
                var str  = string.Empty;
                var info = string.Empty;
                while (reader.Read())
                {
                    str = string.Format("{0}:{1}", CheckFieldName, reader[0].ToString());
                    if (temp.Contains(str))
                    {
                        info = string.Format("{0}  存在重复", str);
                        Messages.Add(info);
                        _questions.Add(
                            new Question
                        {
                            Code              = Code,
                            Name              = Name,
                            Project           = CheckProject.属性正确性,
                            TableName         = TableName,
                            BSM               = CheckFieldName,
                            Description       = info,
                            RelationClassName = RelationName,
                            ShowType          = ShowType.Space,
                            WhereClause       =
                                LocationFields == null ?
                                string.Empty
                                : ADOSQLHelper.GetWhereClause(LocationFields, ADOSQLHelper.GetValues(reader, 1, LocationFields.Length))
                        });
                    }
                    else
                    {
                        temp.Add(str);
                    }
                }
                QuestionManager.AddRange(_questions);
                return(true);
            }

            return(false);
        }
Beispiel #14
0
        private bool CheckNoWhere(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection,
                                                    LocationFields == null ?
                                                    string.Format("select {0},{1} from {2}", CheckFieldName, Key, TableName)
                : string.Format("select {0},{1},{2} from {3}", CheckFieldName, Key, string.Join(",", LocationFields), TableName)
                                                    );

            if (reader != null)
            {
                var str   = string.Empty;
                var error = string.Empty;
                Messages = new List <string>();
                while (reader.Read())
                {
                    str = reader[0].ToString().Trim();
                    if (Values.Contains(str))
                    {
                        continue;
                    }
                    else
                    {
                        error = string.Format("{0}对应的‘{1}’值不正确", reader[1].ToString(), str);
                        Messages.Add(error);
                        _questions.Add(
                            new Question()
                        {
                            Code              = "3201",
                            Name              = Name,
                            Project           = CheckProject.值符合性,
                            TableName         = TableName,
                            BSM               = reader[1].ToString(),
                            Description       = error,
                            ShowType          = ShowType.Space,
                            RelationClassName = RelationName,
                            WhereClause       =
                                LocationFields == null ?
                                string.Format("[{0}] ='{1}'", Key, reader[1].ToString())
                                : ADOSQLHelper.GetWhereClause(LocationFields, ADOSQLHelper.GetValues(reader, 2, LocationFields.Length))
                        });
                    }
                }
                QuestionManager.AddRange(_questions);
                return(true);
            }
            return(false);
        }
        public bool Check(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, _SQL);

            if (reader == null)
            {
                return(false);
            }

            while (reader.Read())
            {
                var keyValue = reader[0].ToString().Trim();
                if (string.IsNullOrEmpty(keyValue) == false)
                {
                    var temp = new List <string>();
                    for (var i = 0; i < CheckFields.Count(); i++)
                    {
                        var a = reader[i + 1].ToString().Trim();
                        if (string.IsNullOrEmpty(RegexString) == false && Is_Nullable == false)
                        {
                            if (Regex.IsMatch(a, RegexString) == false)
                            {
                                temp.Add(CheckFields[i]);
                            }
                        }
                        else
                        {
                            if (Is_Nullable ^ string.IsNullOrEmpty(a))
                            {
                                temp.Add(CheckFields[i]);
                            }
                        }
                    }
                    if (temp.Count > 0)
                    {
                        Messages2.Add(new Models.VillageMessage
                        {
                            Value       = keyValue,
                            Description = string.Format("【{0} = {1}】对应的字段【{2}】值不符合【{3}】", Key, keyValue, string.Join(",", temp.ToArray()), Name),
                            WhereClause = string.Format("[{0}] = '{1}'", Key, keyValue)
                        });
                    }
                }
            }
            return(true);
        }
Beispiel #16
0
        public void Gain(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, string.Format("select XZCDM,XZCMC,TBBH,{0} from {1}", string.Join(",", AreaFields), TableName));

            if (reader != null)
            {
                List = new List <TB>();
                while (reader.Read())
                {
                    var val = new TB
                    {
                        XZCDM = reader[0].ToString(),
                        XZCMC = reader[1].ToString(),
                        TBBH  = reader[2].ToString()
                    };
                    var sum = .0;
                    for (var i = 3; i < AreaFields.Length + 3; i++)
                    {
                        var a = .0;
                        if (double.TryParse(reader[i].ToString(), out a))
                        {
                            sum += a / Denominator;
                        }
                    }
                    val.MJ = sum;
                    List.Add(val);
                }
                if (List.Count == 0)
                {
                    //var info = string.Format("获取表【{0}】中的图斑面积时,图斑面积数据量为空", TableName);
                    //LogManager.Log(info);
                    //QuestionManager.Add(new Question { Code = "3201", Name = "检验图斑面积", TableName = TableName, Description = info });
                }
                else
                {
                    DCDYTBManager.AddTB(List);
                }
            }
        }
Beispiel #17
0
        public bool Check(OleDbConnection connection)
        {
            var sb = new StringBuilder(CheckFields[0]);

            for (var i = 1; i < CheckFields.Count(); i++)
            {
                sb.AppendFormat(",{0}", CheckFields[i]);
            }
            var reader = ADOSQLHelper.ExecuteReader(connection, string.Format("Select {0},{1} from {2} where {3}", sb.ToString(), Key, TableName, WhereCaluse));

            if (reader != null)
            {
                var str  = string.Empty;
                var info = string.Empty;
                while (reader.Read())
                {
                    str = string.Empty;
                    for (var i = 0; i < CheckFields.Count(); i++)
                    {
                        if (Is_Nullable ^ string.IsNullOrEmpty(reader[i].ToString()))//异或  Is_NULLable  ture 为空  字段不为空或者 Is_NULLable false 必填 字段为空 矛盾
                        {
                            str += CheckFields[i] + ",";
                        }
                    }
                    if (!string.IsNullOrEmpty(str))
                    {
                        info = string.Format("{0}对应的字段:{1}与要求的{2}不符", reader[CheckFields.Count()], str, Is_Nullable ? "为空" : "必填");
                        _questions.Add(new Question {
                            Code = "5101", Name = Name, Project = CheckProject.图层内属性一致性, TableName = TableName, BSM = reader[CheckFields.Count()].ToString(), Description = info
                        });
                        Messages.Add(info);
                    }
                }
                QuestionManager.AddRange(_questions);
                return(true);
            }
            return(false);
        }
        public bool Check(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, _SQL);

            if (reader == null)
            {
                return(false);
            }
            while (reader.Read())
            {
                var keyValue = reader[0].ToString().Trim();
                if (string.IsNullOrEmpty(keyValue) == false)
                {
                    var value = reader[1].ToString().Trim();
                    var flag  = false;
                    foreach (var item in RegexStrings)
                    {
                        if (Regex.IsMatch(value, item))
                        {
                            flag = true;
                            break;
                        }
                    }

                    if (flag == false)
                    {
                        Messages2.Add(new Models.VillageMessage
                        {
                            Value       = keyValue,
                            CheckValue  = value,
                            Description = string.Format("【{0}={1}】对应的数据不符合【{2}】", Key, keyValue, Name),
                            WhereClause = string.Format("[{0}] = '{1}'", Key, keyValue)
                        });
                    }
                }
            }
            return(true);
        }
Beispiel #19
0
        public bool Check(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, _SQL);

            if (reader == null)
            {
                return(false);
            }
            while (reader.Read())
            {
                var keyValue = reader[0].ToString().Trim();
                if (string.IsNullOrEmpty(keyValue) == false)
                {
                    var value1 = reader[1].ToString().Trim();
                    var value2 = reader[2].ToString().Trim();
                    if (string.IsNullOrEmpty(value1) == false && string.IsNullOrEmpty(value2) == false)
                    {
                        if (CurrentDict.ContainsKey(value1))
                        {
                            if (CurrentDict[value1].ToLower() != value2.ToLower())
                            {
                                Messages2.Add(new Models.VillageMessage
                                {
                                    Value       = keyValue,
                                    CheckValue  = value1 + ";" + value2,
                                    Description = string.Format("【{0}={1}】对应的数据不符合【{2}】", Key, keyValue, Name),
                                    WhereClause = string.Format("[{0}] = '{1}'", Key, keyValue)
                                });
                            }
                        }
                    }
                }
            }

            return(true);
        }
        public bool Check(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, _SQL);

            if (reader == null)
            {
                return(false);
            }
            var a      = .0;
            var tbmj   = .0;
            var tbdlmj = .0;
            var tkxs   = .0;
            var kksm   = .0;

            while (reader.Read())
            {
                var keyValue = reader[0].ToString().Trim();
                if (string.IsNullOrEmpty(keyValue) == false)
                {
                    if (double.TryParse(reader[4].ToString().Trim(), out a))//应扣田坎计算面积
                    {
                        kksm = Math.Round(a, 0);
                    }
                    else
                    {
                        Messages.Add(new VillageMessage
                        {
                            Value       = keyValue,
                            CheckValue  = reader[4].ToString().Trim(),
                            Description = string.Format("未获取应扣田坎计算面积,无法核对【{0}】", Name),
                            WhereClause = string.Format("[BSM] = '{0}'", keyValue)
                        });
                        continue;
                    }
                    if (double.TryParse(reader[1].ToString().Trim(), out a))//图斑面积
                    {
                        tbmj = Math.Round(a, 0);
                    }
                    else
                    {
                        Messages.Add(new VillageMessage
                        {
                            Value       = keyValue,
                            CheckValue  = reader[1].ToString().Trim(),
                            Description = string.Format("未获取图斑面积,无法核对【{0}】", Name),
                            WhereClause = string.Format("[BSM] = '{0}'", keyValue)
                        });
                        continue;
                    }

                    #region 核对 规则1
                    if (double.TryParse(reader[2].ToString().Trim(), out a))//图斑地类面积
                    {
                        tbdlmj = Math.Round(a, 0);
                        var abs = Math.Abs(tbdlmj - tbmj + kksm);

                        var sb = new StringBuilder();

                        if (Relative.HasValue)
                        {
                            var va = abs / tbdlmj;
                            if (va > Relative.Value)
                            {
                                sb.AppendFormat("相对值为【{0}】;", va);
                            }
                        }

                        if (Absolute.HasValue)
                        {
                            if (abs > Absolute.Value)
                            {
                                sb.AppendFormat("绝对值为【{0};", abs);
                            }
                        }
                        if (sb.Length > 0)
                        {
                            Messages.Add(new VillageMessage
                            {
                                Value       = keyValue,
                                CheckValue  = sb.ToString(),
                                Description = string.Format("【BSM = '{0}'】对应的数据不符合【{1}】", keyValue, Rule1),
                                WhereClause = string.Format("[BSM] = '{0}'", keyValue)
                            });
                        }
                    }
                    else
                    {
                        Messages.Add(new VillageMessage
                        {
                            Value       = keyValue,
                            CheckValue  = reader[2].ToString().Trim(),
                            Description = string.Format("未获取图斑地类面积,无法核对【{0}】", Rule1),
                            WhereClause = string.Format("[BSM] = '{0}'", keyValue)
                        });
                    }

                    #endregion


                    #region 核对  规则2
                    if (double.TryParse(reader[3].ToString().Trim(), out a))//田坎系数
                    {
                        tkxs = Math.Round(a, 4);
                        var calSum = tbmj * tkxs;
                        var abs    = Math.Abs(calSum - kksm);
                        var sb     = new StringBuilder();

                        if (Relative.HasValue)
                        {
                            var va = abs / kksm;
                            if (va > Relative.Value)
                            {
                                sb.AppendFormat("相对值为【{0}】;", va);
                            }
                        }

                        if (Absolute.HasValue)
                        {
                            if (abs > Absolute.Value)
                            {
                                sb.AppendFormat("绝对值为【{0};", abs);
                            }
                        }
                        if (sb.Length > 0)
                        {
                            Messages.Add(new VillageMessage
                            {
                                Value       = keyValue,
                                CheckValue  = sb.ToString(),
                                Description = string.Format("【BSM = '{0}'】对应的数据不符合【{1}】", keyValue, Rule2),
                                WhereClause = string.Format("[BSM] = '{0}'", keyValue)
                            });
                        }
                    }
                    else
                    {
                        Messages.Add(new VillageMessage
                        {
                            Value       = keyValue,
                            CheckValue  = reader[3].ToString().Trim(),
                            Description = string.Format("未获取田坎系数,无法核对【{0}】", Rule2),
                            WhereClause = string.Format("[BSM] = '{0}'", keyValue)
                        });
                    }

                    #endregion
                }
            }


            return(true);
        }
        public bool Check(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection, string.Format("Select {0},{1},{2} from {3}", Key, string.Join(",", FieldArray1), string.Join(",", FieldArray2), TableName));

            if (reader != null)
            {
                var val1 = .0;
                var val2 = .0;
                var a    = .0;
                var info = string.Empty;
                while (reader.Read())
                {
                    var str = reader[0].ToString().Trim();
                    for (var i = 0; i < FieldArray1.Length; i++)
                    {
                        if (double.TryParse(reader[i + 1].ToString(), out a))
                        {
                            val1 += a;
                        }
                    }
                    for (var i = 0; i < FieldArray2.Length; i++)
                    {
                        if (double.TryParse(reader[i + 1 + FieldArray1.Length].ToString(), out a))
                        {
                            val2 += a;
                        }
                    }
                    var flag = false;
                    switch (Compare)
                    {
                    case Compare.Above:
                        flag = val1 > val2;
                        break;

                    case Compare.MoreEqual:
                        flag = val1 >= val2;
                        break;

                    case Compare.Equal:
                        flag = Math.Abs(val1 - val2) < 0.001;
                        break;

                    case Compare.Less:
                        flag = val1 < val2;
                        break;

                    case Compare.SmarllerEqual:
                        flag = val1 <= val2;
                        break;
                    }
                    if (flag)
                    {
                        info = string.Format("{0}对应的不符合{1}", str, Name);
                        Messages.Add(info);
                        _questions.Add(new Models.Question {
                            Code = "3201", Name = Name, TableName = TableName, BSM = str, Description = info
                        });
                    }
                }
                QuestionManager.AddRange(_questions);
                return(true);
            }
            return(false);
        }
        private bool CheckWhereFields(OleDbConnection connection)
        {
            var reader = ADOSQLHelper.ExecuteReader(connection,
                                                    string.IsNullOrEmpty(WhereCaluse) ?
                                                    (
                                                        LocationFields == null ?
                                                        string.Format("Select {0},{1},{2} from {3}", Key, string.Join(",", CheckFields), string.Join(",", WhereFields), TableName)
                 : string.Format("Select {0},{1},{2},{3} from {4}", Key, string.Join(",", CheckFields), string.Join(",", WhereFields), string.Join(",", LocationFields), TableName)
                                                    )
                : (
                                                        LocationFields == null ?
                                                        string.Format("Select {0},{1},{2} from {3} where {4}", Key, string.Join(",", CheckFields), string.Join(",", WhereFields), TableName, WhereCaluse)
                 : string.Format("Select {0},{1},{2},{3} from {4} where {5}", Key, string.Join(",", CheckFields), string.Join(",", WhereFields), string.Join(",", LocationFields), TableName, WhereCaluse)
                                                        )

                                                    );

            if (reader != null)
            {
                var array = new string[WhereFields.Length];
                var str   = string.Empty;
                var info  = string.Empty;
                while (reader.Read())
                {
                    for (var i = 0; i < WhereFields.Length; i++)
                    {
                        array[i] = reader[i + 1 + CheckFields.Length].ToString();
                    }
                    var key = string.Join(Split, array);
                    if (WhereList.Contains(key))
                    {
                        str = string.Empty;
                        for (var i = 0; i < CheckFields.Length; i++)
                        {
                            var a = reader[i + 1].ToString().Trim();
                            if (Is_Nullable ^ string.IsNullOrEmpty(a))
                            {
                                str += CheckFields[i] + ",";
                            }
                        }
                        if (!string.IsNullOrEmpty(str))
                        {
                            info = string.Format("{0}对应的字段:{1}与要求的{2}不符,图斑信息:行政村代码:【{3}】图斑编号:【{4}】", reader[0].ToString().Trim(), str, Is_Nullable ? "为空" : "必填", array[0], array[1]);
                            _questions.Add(
                                new Question
                            {
                                Code              = "5101",
                                Name              = Name,
                                Project           = CheckProject.图层内属性一致性,
                                TableName         = TableName,
                                BSM               = reader[0].ToString(),
                                Description       = info,
                                RelationClassName = RelationName,
                                ShowType          = ShowType.Space,
                                WhereClause       =
                                    LocationFields == null ?
                                    string.Format("[{0}] ='{1}'", Key, reader[0].ToString())
                                    : ADOSQLHelper.GetWhereClause(LocationFields, ADOSQLHelper.GetValues(reader, 1 + CheckFields.Length + WhereFields.Length, LocationFields.Length))
                            });
                            Messages.Add(info);
                        }
                    }
                }
                QuestionManager.AddRange(_questions);

                return(true);
            }
            return(false);
        }