Ejemplo n.º 1
0
        public static CheckInfo Check <T>(this SelectInfo <T> selectInfo, ref List <ErrorList> erolt)
        {
            List <ErrorList> erolts = new List <ErrorList>();
            Dictionary <string, IConfigIO> retDic = new Dictionary <string, IConfigIO>();
            CheckInfo checkInfo = new CheckInfo();

            Type[] configIOList = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.GetCustomAttribute <ConfigIOAttr>() != null).ToArray();
            foreach (Type type in configIOList)
            {
                Activator.CreateInstance(type.MakeGenericType(typeof(T)), selectInfo, erolts, checkInfo);
            }
            erolt = erolts;
            //检查错误
            return(checkInfo);
        }
Ejemplo n.º 2
0
        public Errorinfo Check03(SelectInfo <T> selectInfo, CheckInfo checkInfo)
        {
            Errorinfo errorinfo = new Errorinfo();

            if (string.IsNullOrEmpty(selectInfo.strWhere))
            {
                errorinfo.Warning  = "strWhere is null";
                checkInfo.strWhere = "";
            }
            else
            {
                checkInfo.strWhere = selectInfo.strWhere;
            }
            return(errorinfo);
        }
Ejemplo n.º 3
0
        public Errorinfo Check05(SelectInfo <T> selectInfo, CheckInfo checkInfo)
        {
            Errorinfo errorinfo = new Errorinfo();

            if (selectInfo.recordNum == -1)
            {
                errorinfo.Warning   = "recordNum is null,default is changed to 10";
                checkInfo.recordNum = 10;
            }
            if (errorinfo.Calibration && string.IsNullOrEmpty(errorinfo.Warning))
            {
                checkInfo.recordNum = selectInfo.recordNum;
            }
            return(errorinfo);
        }
Ejemplo n.º 4
0
        public Errorinfo Check02(SelectInfo <T> selectInfo, CheckInfo checkInfo)
        {
            Errorinfo errorinfo = new Errorinfo();

            if (selectInfo.tableType == -1)
            {
                errorinfo.Warning   = "tableType is null,default is changed to Table";
                checkInfo.tableType = TableType.Table;
            }
            if (errorinfo.Calibration && string.IsNullOrEmpty(errorinfo.Warning))
            {
                checkInfo.tableType = selectInfo.tableType;
            }
            return(errorinfo);
        }
Ejemplo n.º 5
0
        public Errorinfo Check01(SelectInfo <T> selectInfo, CheckInfo checkInfo)
        {
            Errorinfo errorinfo = new Errorinfo();

            if (selectInfo.tableName == null)
            {
                errorinfo.Calibration = false;
                errorinfo.Error       = "tableName is not null";
            }
            if (errorinfo.Calibration)
            {
                checkInfo.tableName = selectInfo.tableName;
            }
            return(errorinfo);
        }
Ejemplo n.º 6
0
        public Check(SelectInfo <T> selectInfo, List <ErrorList> erolt, CheckInfo checkInfo)
        {
            var methods = GetType().GetMethods().Where(t => t.GetCustomAttribute <ConfigMethodAttr>() != null);

            foreach (MethodInfo method in methods)
            {
                ErrorList errorList  = new ErrorList();
                string    configName = method.GetCustomAttribute <ConfigMethodAttr>().Name.ToUpper();
                Errorinfo errorinfo  = method.Invoke(this, new object[] { selectInfo, checkInfo }) as Errorinfo;
                errorList.Name      = configName;
                errorList.Errorinfo = errorinfo;
                if (!errorinfo.Calibration || !string.IsNullOrEmpty(errorinfo.Warning))
                {
                    erolt.Add(errorList);
                }
            }
        }
Ejemplo n.º 7
0
        public static List <T> Run <T>(this CheckInfo checkInfo, MSSqlDBContext db, List <ErrorList> erolt, ref int DataCount)
        {
            //select * from PaasOLT_OrderCarClean order by Id offset((2 - 1) * 20) rows fetch next 20 rows only;
            //查询
            string TsqlCountStr = "select COUNT(1) from " + checkInfo.tableName + " ";
            //条件
            string strWhere = checkInfo.strWhere == null ? null : " where " + checkInfo.strWhere;
            //查询总数
            DbContextSqlQueryCommand dbContextSqlQueryCommand = new DbContextSqlQueryCommand();

            dbContextSqlQueryCommand.QueryType = "text";
            dbContextSqlQueryCommand.Query     = TsqlCountStr + strWhere;
            int DbRequest = (int)DbContextExtensions.QueryObject(new MSSqlDBContext(), new DbContextSqlQueryCommands
            {
                Sql = dbContextSqlQueryCommand
            });

            DataCount = DbRequest;
            return(Run <T>(checkInfo, db, erolt));
        }
Ejemplo n.º 8
0
        public Errorinfo Check06(SelectInfo <T> selectInfo, CheckInfo checkInfo)
        {
            Errorinfo errorinfo  = new Errorinfo();
            string    orderByStr = string.Empty;

            if (selectInfo.orderByStr.ToList().Count == 0)
            {
                errorinfo.Warning    = "orderByStr is null,default is changed to order by 1";
                checkInfo.orderByStr = "order by 1";
            }
            else
            {
                foreach (var item in selectInfo.orderByStr.ToList())
                {
                    orderByStr += "," + item.Value;
                }
                checkInfo.orderByStr = orderByStr;
            }
            return(errorinfo);
        }
Ejemplo n.º 9
0
        public static List <T> Run <T>(this CheckInfo checkInfo, MSSqlDBContext db, List <ErrorList> erolt)
        {
            var dbContextSqlQueryCommand = TsqlFactory.Select(checkInfo);

            return(SelectDb <T>(dbContextSqlQueryCommand, db));
        }
Ejemplo n.º 10
0
        public Errorinfo Check07(SelectInfo <T> selectInfo, CheckInfo checkInfo)
        {
            Errorinfo errorinfo = new Errorinfo();

            return(errorinfo);
        }