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); }
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 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); }