Beispiel #1
0
        public CombinationSearchXiakeData SearchXiakesByMengzhu(XiakeType[] xiakeTypes, XiakeLevel[] xiakeLevels, XiakeStatus[] xiakeStatus, string xiakeName, long lastID, bool isTimeRangeRequired, SearchTimeType timeType, DateTime startTime, DateTime endTime, bool isOnline)
        {
            var result = new CombinationSearchXiakeData();
            using (WebDbContext db = DbContextFactory.CreateDbContext())
            {  
                IQueryable<Xiake> xiakes = db.Xiakes.OrderByDescending(a => a.Id);

                if (!string.IsNullOrEmpty(xiakeName))
                {
                    xiakes = xiakes.Where(a => a.XiakeName == xiakeName);
                }
                else
                {
                    if (lastID != 0)
                    {
                        xiakes = xiakes.Where(a => a.Id <lastID);
                    }

                    xiakes = xiakes.Where(a => xiakeTypes.Contains(a.UserType))
                        .Where(a => xiakeLevels.Contains(a.Level))
                        .Where(a => xiakeStatus.Contains(a.Status));
                    if (isTimeRangeRequired)
                    {
                        if (timeType == SearchTimeType.JoinTime)
                        {
                            xiakes = xiakes.Where(a => a.CreateTime >= startTime && a.CreateTime <= endTime);
                        }
                        else
                        {
                            xiakes = xiakes.Where(a => a.LastLoginTime >= startTime && a.LastLoginTime <= endTime);
                        }
                    }
                    if(isOnline)
                    {
                        var ids = this.OnlineXiakeManager.GetOnlineXiakes().Select(a => a.Id);
                        xiakes = xiakes.Where(a => ids.Contains(a.Id));
                    }
                }

                if (lastID == 0)
                {
                    result.TotalCount = xiakes.Count();
                }

                xiakes = xiakes.Take(DomainDefinition.PAGE_SIZE);
                xiakes = xiakes.Include(a => a.Credits);

                foreach (Xiake xk in xiakes)
                {
                    var x = new SearchXiakeData()
                    {
                        ID = xk.Id,
                        Name = xk.XiakeName,
                        QQ = xk.QQ,
                        Mail = xk.Mail,
                        Type = xk.UserType,
                        Level = xk.Level,
                        Status = xk.Status,
                        JoinTime = xk.CreateTime,
                        LastLoginTime = xk.LastLoginTime,
                        LoginCount = xk.LoginCount,
                        Credits = xk.Credits.FreeCredits,
                        IsOnline = OnlineXiakeManager.IsXiakeOnline(xk.Id)
                    };
                    result.Items.Add(x);
                }
                if (result.Items.Count < DomainDefinition.PAGE_SIZE)
                {
                    result.IsLoadedAllData = true;
                }
            }
            return result;
        }
 public CombinationSearchXiakeData SearchXiakesByMengzhu (XiakeType[] xiakeTypes,
     XiakeLevel[] xiakeLevels,
     XiakeStatus[] xiakeStatus,
     string xiakeName,
     long lastID,
     bool isTimeRangeRequired,
     SearchTimeType timeType,
     DateTime startTime,
     DateTime endTime,
     bool isOnline)
 {
     lock (LockObject)
     {
         Init();
         return mClient.Service.SearchXiakesByMengzhu(xiakeTypes,xiakeLevels,xiakeStatus,xiakeName,lastID,isTimeRangeRequired,timeType,startTime,endTime,isOnline);
     }
 }