Ejemplo n.º 1
0
        public BetWhiteListInfo_Collection QueryBetWhiteListCollection(string userId, string userDisplayName, string isHm, DateTime startTime, DateTime endTime, int pageIndex, int pageSize)
        {
            Session.Clear();
            BetWhiteListInfo_Collection collection = new BetWhiteListInfo_Collection();

            collection.TotalCount = 0;
            startTime             = startTime.Date;
            endTime = endTime.AddDays(1).Date;
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select WhiteLlistId,UserId,UserDisplayName,isnull(IsEnable,0),RegisterTime,isnull(ExpansionOne,'')as ExpansionOne,isnull(ExpansionTwo,0) as ExpansionTwo,CreateTime,isnull(IsOpenHeMai,0)as IsOpenHeMai,Isnull(IsOpenBDFX,0)IsOpenBDFX,isnull(IsSingleScheme,0) IsSingleScheme from E_Bet_WhiteList where 1=1");
            if (!string.IsNullOrEmpty(userId) || !string.IsNullOrEmpty(userDisplayName))
            {
                if (!string.IsNullOrEmpty(userId) && !BusinessHelper.CheckSQLCondition(userId))
                {
                    strSql.Append(" and UserId='" + userId + "' ");
                }
                if (!string.IsNullOrEmpty(userDisplayName) && !BusinessHelper.CheckSQLCondition(userDisplayName))
                {
                    strSql.Append(" and UserDisplayName='" + userDisplayName + "' ");
                }
            }
            if (!string.IsNullOrEmpty(isHm) && !BusinessHelper.CheckSQLCondition(isHm))
            {
                strSql.Append(" and IsOpenHeMai=" + isHm + " ");
            }
            if (string.IsNullOrEmpty(userId) && string.IsNullOrEmpty(userDisplayName))
            {
                strSql.Append(" and CreateTime>='" + startTime + "' and CreateTime<'" + endTime + "'");
            }
            var result = Session.CreateSQLQuery(strSql.ToString()).List();

            if (result != null)
            {
                collection.TotalCount = result.Count;
                foreach (var item in result)
                {
                    var array             = item as object[];
                    BetWhiteListInfo info = new BetWhiteListInfo();
                    info.WhiteLlistId    = Convert.ToInt32(array[0]);
                    info.UserId          = array[1].ToString();
                    info.UserDisplayName = array[2].ToString();
                    info.IsEnable        = Convert.ToBoolean(array[3]);
                    info.RegisterTime    = Convert.ToDateTime(array[4]);
                    info.ExpansionOne    = array[5].ToString();
                    info.ExpansionTwo    = Convert.ToDecimal(array[6]);
                    info.CreateTime      = Convert.ToDateTime(array[7]);
                    info.IsOpenHeMai     = Convert.ToBoolean(array[8]);
                    info.IsOpenBDFX      = Convert.ToBoolean(array[9]);
                    info.IsSingleScheme  = Convert.ToBoolean(array[10]);
                    collection.BetInfoList.Add(info);
                }
            }

            #region 暂时屏蔽
            //if (string.IsNullOrEmpty(isHm))
            //{
            //    var query = from b in Session.Query<BetWhiteList>()
            //                where (userId == string.Empty || b.UserId == userId) && (userDisplayName == string.Empty || b.UserDisplayName == userDisplayName) && (b.CreateTime >= startTime && b.CreateTime < endTime) && (b.IsOpenHeMai == false || b.IsOpenHeMai == true)
            //                select new BetWhiteListInfo
            //                {
            //                    WhiteLlistId = b.WhiteLlistId,
            //                    UserId = b.UserId,
            //                    UserDisplayName = b.UserDisplayName,
            //                    IsEnable = b.IsEnable,
            //                    RegisterTime = b.RegisterTime,
            //                    ExpansionOne = b.ExpansionOne,
            //                    ExpansionTwo = b.ExpansionTwo,
            //                    CreateTime = b.CreateTime,
            //                    IsOpenHeMai = b.IsOpenHeMai == null ? false : b.IsOpenHeMai,
            //                };
            //    if (query != null && query.ToList().Count > 0)
            //    {
            //        collection.TotalCount = query.Count();
            //        collection.BetInfoList = query.Skip(pageIndex * pageSize).Take(pageSize).ToList();
            //    }
            //}
            //else if (isHm == "1")
            //{
            //    var query = from b in Session.Query<BetWhiteList>()
            //                where (userId == string.Empty || b.UserId == userId) && (userDisplayName == string.Empty || b.UserDisplayName == userDisplayName) && (b.CreateTime >= startTime && b.CreateTime < endTime) && (b.IsOpenHeMai == true)
            //                select new BetWhiteListInfo
            //                {
            //                    WhiteLlistId = b.WhiteLlistId,
            //                    UserId = b.UserId,
            //                    UserDisplayName = b.UserDisplayName,
            //                    IsEnable = b.IsEnable,
            //                    RegisterTime = b.RegisterTime,
            //                    ExpansionOne = b.ExpansionOne,
            //                    ExpansionTwo = b.ExpansionTwo,
            //                    CreateTime = b.CreateTime,
            //                    IsOpenHeMai = b.IsOpenHeMai == null ? false : b.IsOpenHeMai,
            //                };
            //    if (query != null && query.ToList().Count > 0)
            //    {
            //        collection.TotalCount = query.Count();
            //        collection.BetInfoList = query.Skip(pageIndex * pageSize).Take(pageSize).ToList();
            //    }
            //}
            //else
            //{
            //    var query = from b in Session.Query<BetWhiteList>()
            //                where (userId == string.Empty || b.UserId == userId) && (userDisplayName == string.Empty || b.UserDisplayName == userDisplayName) && (b.CreateTime >= startTime && b.CreateTime < endTime) && b.IsOpenHeMai == false
            //                select new BetWhiteListInfo
            //                {
            //                    WhiteLlistId = b.WhiteLlistId,
            //                    UserId = b.UserId,
            //                    UserDisplayName = b.UserDisplayName,
            //                    IsEnable = b.IsEnable,
            //                    RegisterTime = b.RegisterTime,
            //                    ExpansionOne = b.ExpansionOne,
            //                    ExpansionTwo = b.ExpansionTwo,
            //                    CreateTime = b.CreateTime,
            //                    IsOpenHeMai = b.IsOpenHeMai == null ? false : b.IsOpenHeMai,
            //                };
            //    if (query != null && query.ToList().Count > 0)
            //    {
            //        collection.TotalCount = query.Count();
            //        collection.BetInfoList = query.Skip(pageIndex * pageSize).Take(pageSize).ToList();
            //    }
            //}
            #endregion

            collection.BetInfoList = collection.BetInfoList.Skip(pageIndex * pageSize).Take(pageSize).ToList();
            return(collection);
        }