public void SetXiakeLevel (long[] xiakeIds, XiakeLevel xiakeLevel) { lock (LockObject) { Init(); mClient.Service.SetXiakeLevel(xiakeIds,xiakeLevel); } }
public void AddXiake (long id, string name, string tokenPass, XiakeType xiakeType, XiakeLevel xiakeLevel) { lock(LockObject) { var newXiake = new LoginXiake() { Id = id, Name = name, Token = tokenPass, XiakeType = xiakeType, XiakeLevel = xiakeLevel }; var oldXiake = mLoginXiakes.FirstOrDefault(a => a.Id == id); if(oldXiake != null) { mLoginXiakes.Remove(oldXiake); } mLoginXiakes.Add(newXiake); } }
public string[] XiakeJoin (long id, string name, string token, XiakeType xiakeType, XiakeLevel level) { return mService.Service.XiakeJoin(id, name, token, xiakeType, level); }
public string[] XiakeJoin (long id, string name, string token, XiakeType xiakeType, XiakeLevel level) { try { string[] servers = null; using (var db = DbContextFactory.CreateDbContext()) { servers = db.Fuwuqis.Select(a => a.Url).ToArray(); } var urls = new List<string>(); var firstUrl = servers[RandomObject.Next(0, servers.Length)]; if (xiakeType == XiakeType.Mengzhu || xiakeType == XiakeType.Xiaoer || xiakeType == XiakeType.Tangzhu) { firstUrl = MasterBaseUrl; } urls.Add(firstUrl); urls.AddRange(servers.Where(a => a != firstUrl)); mOnlineXiakeManager.AddXiake(new LoginXiake() { Id = id, Name = name, Token = token, XiakeLevel = level, XiakeType = xiakeType }); return urls.ToArray(); } catch(Exception) { return new string[] { MasterBaseUrl }; } }
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 void SetXiakeLevel( long[] xiakeIds, XiakeLevel xiakeLevel ) { using (WebDbContext db = DbContextFactory.CreateDbContext()) { IQueryable<Xiake> xikes = db.Xiakes.Where(a => xiakeIds.Contains(a.Id)); foreach (Xiake xk in xikes) { xk.Level = xiakeLevel; xk.Token = ""; } db.SaveChanges(); } }
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); } }