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);
        }
        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);
        }
Esempio n. 3
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);
        }