Exemplo n.º 1
0
        public override object GetData(JsonParameter[] paramList)
        {
            var dbProvider = DbConnectionProvider.CreateDbProvider(DbConfig.Data);
            var filter     = dbProvider.CreateCommandFilter();
            //command.Columns = "count(ID)";
            //command.Filter = dbProvider.CreateCommandFilter();
            //command.Filter.Condition = condition;
            //command.Filter.AddParam("NickName", name);
            //command.Parser();

            int pageIndex = 0;
            int pageSize  = 0;
            //string condition = "Where 1=1";
            List <SqlParameter> paramValues = new List <SqlParameter>();

            foreach (JsonParameter param in paramList)
            {
                if (param.Key == "pageIndex")
                {
                    pageIndex = Convert.ToInt32(param.Value);
                    pageIndex = pageIndex < 1 ? 1 : pageIndex;
                }
                else if (param.Key == "pageSize")
                {
                    pageSize = Convert.ToInt32(param.Value);
                    pageSize = pageSize <= 0 ? 20 : pageSize;
                }
                else if (param.Key == "fromDate")
                {
                    filter.Condition += " AND " + filter.FormatExpression("CreateDate", ">=", param.Key);
                    filter.AddParam(param.Key, Convert.ToDateTime(param.Value));
                }
                else if (param.Key == "toDate")
                {
                    filter.Condition += " AND " + filter.FormatExpression("CreateDate", "<=", param.Key);
                    if (param.Value.Length <= 10)
                    {
                        param.Value += " 23:59:59";
                    }
                    filter.AddParam(param.Key, Convert.ToDateTime(param.Value));
                }
                else if (param.Key == "IsTasked")
                {
                    filter.Condition += " AND " + filter.FormatExpression("IsTasked");
                    filter.AddParam("IsTasked", param.Value.ToBool());
                }
                else if (param.Key == "UserID" && !string.IsNullOrEmpty(param.Value))
                {
                    filter.Condition += " AND " + filter.FormatExpression("UserID");
                    filter.AddParam("UserID", Convert.ToString(param.Value));
                }
            }

            pageSize  = pageSize <= 0 ? 20 : pageSize;
            pageIndex = pageIndex < 1 ? 1 : pageIndex;
            int statIndex = (pageIndex - 1) * pageSize;
            int endIndex  = pageIndex * pageSize;

            var command = dbProvider.CreateCommandStruct("UserTakePrize", CommandMode.Inquiry);

            command.Columns = "COUNT(ID)";
            command.Filter  = filter;
            command.Parser();
            int pageCount = dbProvider.ExecuteScalar(CommandType.Text, command.Sql, command.Parameters).ToInt();

            JsonGrid jsonGrid = new JsonGrid();

            jsonGrid.rows  = GetUserPrizeList(dbProvider, filter, statIndex, endIndex);
            jsonGrid.total = pageCount;
            return(jsonGrid);
        }
Exemplo n.º 2
0
        public override object GetData(JsonParameter[] paramList)
        {
            var dbProvider = DbConnectionProvider.CreateDbProvider(DbConfig.Data);
            var filter = dbProvider.CreateCommandFilter();
            //command.Columns = "count(ID)";
            //command.Filter = dbProvider.CreateCommandFilter();
            //command.Filter.Condition = condition;
            //command.Filter.AddParam("NickName", name);
            //command.Parser();

            int pageIndex = 0;
            int pageSize = 0;
            //string condition = "Where 1=1";
            List<SqlParameter> paramValues = new List<SqlParameter>();
            foreach (JsonParameter param in paramList)
            {
                if (param.Key == "pageIndex")
                {
                    pageIndex = Convert.ToInt32(param.Value);
                    pageIndex = pageIndex < 1 ? 1 : pageIndex;
                }
                else if (param.Key == "pageSize")
                {
                    pageSize = Convert.ToInt32(param.Value);
                    pageSize = pageSize <= 0 ? 20 : pageSize;
                }
                else if (param.Key == "fromDate")
                {
                    filter.Condition += " AND " + filter.FormatExpression("CreateDate", ">=", param.Key);
                    filter.AddParam(param.Key, Convert.ToDateTime(param.Value));
                }
                else if (param.Key == "toDate")
                {
                    filter.Condition += " AND " + filter.FormatExpression("CreateDate", "<=", param.Key);
                    if (param.Value.Length <= 10)
                    {
                        param.Value += " 23:59:59";
                    }
                    filter.AddParam(param.Key, Convert.ToDateTime(param.Value));
                }
                else if (param.Key == "IsTasked")
                {
                    filter.Condition += " AND " + filter.FormatExpression("IsTasked");
                    filter.AddParam("IsTasked", param.Value.ToBool());
                }
                else if (param.Key == "UserID" && !string.IsNullOrEmpty(param.Value))
                {
                    filter.Condition += " AND " + filter.FormatExpression("UserID");
                    filter.AddParam("UserID", Convert.ToString(param.Value));
                }
            }

            pageSize = pageSize <= 0 ? 20 : pageSize;
            pageIndex = pageIndex < 1 ? 1 : pageIndex;
            int statIndex = (pageIndex - 1) * pageSize;
            int endIndex = pageIndex * pageSize;

            var command = dbProvider.CreateCommandStruct("UserTakePrize", CommandMode.Inquiry);
            command.Columns = "COUNT(ID)";
            command.Filter = filter;
            command.Parser();
            int pageCount = dbProvider.ExecuteScalar(CommandType.Text,command.Sql, command.Parameters).ToInt();

            JsonGrid jsonGrid = new JsonGrid();
            jsonGrid.rows = GetUserPrizeList(dbProvider, filter, statIndex, endIndex);
            jsonGrid.total = pageCount;
            return jsonGrid;
        }
Exemplo n.º 3
0
        public override object GetData(JsonParameter[] paramList)
        {
            int pageIndex = 0;
            int pageSize = 0;
            string condition = "Where 1=1";
            List<SqlParameter> paramValues = new List<SqlParameter>();
            foreach (JsonParameter param in paramList)
            {
                if (param.Key == "pageIndex")
                {
                    pageIndex = Convert.ToInt32(param.Value);
                    pageIndex = pageIndex < 1 ? 1 : pageIndex;
                }
                else if (param.Key == "pageSize")
                {
                    pageSize = Convert.ToInt32(param.Value);
                    pageSize = pageSize <= 0 ? 20 : pageSize;
                }
                else if (param.Key == "fromDate")
                {
                    condition += string.Format(" and CreateDate >= @{0}", param.Key);
                    paramValues.Add(SqlParamHelper.MakeInParam("@" + param.Key, SqlDbType.DateTime, 0, Convert.ToDateTime(param.Value)));
                }
                else if (param.Key == "toDate")
                {
                    condition += string.Format(" and CreateDate <= @{0}", param.Key);
                    if (param.Value.Length <= 10)
                    {
                        param.Value += " 23:59:59";
                    }
                    paramValues.Add(SqlParamHelper.MakeInParam("@" + param.Key, SqlDbType.DateTime, 0, Convert.ToDateTime(param.Value)));
                }
                else if (param.Key == "IsTasked")
                {
                    condition += string.Format(" and IsTasked = @{0}", param.Key);
                    paramValues.Add(SqlParamHelper.MakeInParam("@" + param.Key, SqlDbType.Bit, 0, param.Value.ToBool()));
                }
                else if (param.Key == "UserID" && !string.IsNullOrEmpty(param.Value))
                {
                    condition += string.Format(" and UserID = @{0}", param.Key);
                    paramValues.Add(SqlParamHelper.MakeInParam("@" + param.Key, SqlDbType.VarChar, 0, Convert.ToString(param.Value)));
                }
            }

            pageSize = pageSize <= 0 ? 20 : pageSize;
            pageIndex = pageIndex < 1 ? 1 : pageIndex;
            int statIndex = (pageIndex - 1) * pageSize;
            int endIndex = pageIndex * pageSize;
            paramValues.Add(SqlParamHelper.MakeInParam("@statIndex", SqlDbType.Int, 0, statIndex));
            paramValues.Add(SqlParamHelper.MakeInParam("@endIndex", SqlDbType.Int, 0, endIndex));

            int pageCount = 0;

            JsonGrid jsonGrid = new JsonGrid();
            jsonGrid.rows = GetUserPrizeList(condition, out pageCount, paramValues.ToArray());
            jsonGrid.total = pageCount;
            return jsonGrid;
        }