protected override bool DoSuccess(int userId) { //原因:重登录时,数据会回档问题 var cacheSet = new GameDataCacheSet<GameUser>(); GameUser userInfo = cacheSet.FindKey(Uid); if (userInfo != null) { //原因:还在加载中时,返回 if (userInfo.IsRefreshing) { Uid = string.Empty; ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().ServerLoading; return false; } } if (userInfo == null || string.IsNullOrEmpty(userInfo.SessionID) || !userInfo.IsOnline) { UserCacheGlobal.Load(Uid); //重新刷缓存 userInfo = cacheSet.FindKey(Uid); } if (userInfo != null) { if (userInfo.UserStatus == UserStatus.FengJin) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1004_IDDisable; return false; } //todo //NoticeHelper.RankNotice(userInfo); //公告 CombatHelper.LoadProperty(userInfo); //todo //NoviceHelper.OldFriendPack(Uid, userInfo.LoginTime); //好友礼包 UserLoginLog userLoginLog = new UserLoginLog(); userLoginLog.UserId = userInfo.UserID; userLoginLog.SessionID = Sid; userLoginLog.MobileType = MobileType; userLoginLog.ScreenX = ScreenX; userLoginLog.ScreenY = ScreenY; userLoginLog.RetailId = RetailID; userLoginLog.AddTime = DateTime.Now; userLoginLog.State = LoginStatus.Logined; userLoginLog.DeviceID = DeviceID; userLoginLog.Ip = this.GetRealIP(); userLoginLog.Pid = userInfo.Pid; userLoginLog.UserLv = userInfo.UserLv; //原因:报表统计 userLoginLog.PlotID = userInfo.PlotProgress; PlotInfo plotInfo = new ConfigCacheSet<PlotInfo>().FindKey(userInfo.PlotProgress); if (plotInfo != null) { userLoginLog.PlotName = plotInfo.PlotName; } var sender = DataSyncManager.GetDataSender(); sender.Send(userLoginLog); //int vipLv; //var vipLvArray = new ConfigCacheSet<VipLvInfo>().FindAll(u => u.PayGold <= userInfo.PayGold); //vipLv = vipLvArray.Count > 0 ? vipLvArray[vipLvArray.Count - 1].VipLv : (short)0; userInfo.LoginTime = DateTime.Now; userInfo.SessionID = Sid; userInfo.IsOnline = true; //userInfo.VipLv = vipLv; userInfo.GameId = GameType; userInfo.ServerId = ServerID; userInfo.ChatVesion = 0; userInfo.ChatDate = DateTime.MinValue; userInfo.BroadcastVesion = 0; if (userInfo.DailyLoginTime == MathUtils.SqlMinDate || userInfo.DailyLoginTime.Date != DateTime.Now.Date) { userInfo.DailyLoginTime = DateTime.Now; } //todo RankingHelper.DailySportsRankPrize(userInfo); } else { ErrorCode = 1005; ErrorInfo = LanguageManager.GetLang().St1005_RoleCheck; } return true; }
//protected override bool ValidateElement() //{ // return UserHelper.GetKeyWordSubstitution(UserName); //} protected override bool CreateUserRole(out IUser user) { user = null; int MaxLength = ConfigEnvSet.GetInt("User.MaxLength"); int length = System.Text.Encoding.Default.GetByteCount(UserName); if (UserHelper.GetKeyWordSubstitution(UserName)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1005_RegistNameKeyWord; return false; } if (GameUser.IsNickName(UserName)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1005_Rename; return false; } if (length <= 0 || length > MaxLength) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = string.Format(LanguageManager.GetLang().St1005_KingNameTooLong, MaxLength); return false; } Regex re = new Regex(@"^[\u4e00-\u9fa5\w]+$"); if (!re.IsMatch(UserName)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1005_RegistNameExceptional; return false; } if (!Pid.ToLower().StartsWith("z")) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1005_PassportError; return false; } GeneralInfo general = new ShareCacheStruct<GeneralInfo>().FindKey(generalID); if (general == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; return false; } CareerInfo careerInfo = new ShareCacheStruct<CareerInfo>().FindKey(general.CareerID); if (careerInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1005_Professional; return false; } GameUser userEntity = new PersonalCacheStruct<GameUser>().FindKey(UserId.ToString()); if (userEntity != null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1005_RoleExist; return false; } bool userSex = Sex == 0 ? false : true; if (new PersonalCacheStruct<GameUser>().FindKey(UserId.ToString()) == null) { userEntity = CreateGameUser(userSex); user = new SessionUser(userEntity); NoviceHelper.RetailLoginDaysReceive(userEntity); //渠道登录奖励 CreateGeneral(careerInfo); CreateMagic(userEntity); //每日限制次数 CreateDailyRestrain(); //开启默认功能 EnableFunction(); //SendGifItem(); UserPrayHelper.AddUserPray(UserId, PrayType.SanTianQiDao); UserPackHelper.AddUserPack(UserId.ToString()); UserLoginLog userLoginLog = new UserLoginLog(); userLoginLog.UserId = UserId.ToString(); userLoginLog.SessionID = Sid; userLoginLog.MobileType = MobileType; userLoginLog.ScreenX = ScreenX; userLoginLog.ScreenY = ScreenY; userLoginLog.RetailId = RetailID; userLoginLog.AddTime = DateTime.Now; userLoginLog.State = LoginStatus.Logined; userLoginLog.DeviceID = DeviceID; userLoginLog.Ip = this.GetRealIP(); userLoginLog.Pid = userEntity.Pid; userLoginLog.UserLv = userEntity.UserLv; var sender = DataSyncManager.GetDataSender(); sender.Send(userLoginLog); BackPackHelper.AddBack(userEntity); UserHelper.OpenMagic(UserId.ToString(), 1); //封测注册发放礼包 UserItemHelper.AddUserItem(UserId.ToString(), 1704, 1, ItemStatus.BeiBao); } else { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1005_RoleExist; return false; } PlotHelper.EnablePlot(UserId.ToString(), ConfigEnvSet.GetInt("UserPlot.OpenLockPlotID")); return true; }