public HeroesGuildMemberInfo GetMemberInfo(GuildEntity guild, GuildMemberKey key) { HeroesGuildMemberInfo result; try { Log <GuildAPI> .Logger.InfoFormat("GroupMemberGetInfo: ServerCode[{0}], GuildSN[{1}], MemberNexonSN[{2}]", GuildAPI.ServerCode, guild.GuildSN, key.NexonSN); GroupMemberInfo groupMemberInfo = HeroesGuild.GroupMemberGetInfo(GuildAPI.ServerCode, guild.GuildSN, key.CharacterSN, key.CharacterName); HeroesGuildUserType value = this.ConvertToHeroesGuildUserType(groupMemberInfo.emGroupUserType); if (value.ToGuildMemberRank().IsInvalid()) { result = null; } else { result = new HeroesGuildMemberInfo(groupMemberInfo); } } catch (GroupException ex) { if (ex.ErrorCode != 15) { Log <GuildService> .Logger.Error("GroupMemberGetInfo Error", ex); } result = null; } catch (Exception ex2) { Log <GuildService> .Logger.Error("GroupMemberGetInfo Error", ex2); result = null; } return(result); }
public override IEnumerable <object> Run() { bool leaveResult = false; HeroesGuildMemberInfo leaveFuncResult = null; if (FeatureMatrix.IsEnable("GuildProcessorNotUseAsync")) { leaveResult = true; GuildAPI.GetAPI().LeaveGuild(base.Entity, base.Operation.Key); leaveFuncResult = GuildAPI.GetAPI().GetMemberInfo(base.Entity, base.Operation.Key); } else { AsyncFuncSync <HeroesGuildMemberInfo> sync = new AsyncFuncSync <HeroesGuildMemberInfo>(delegate { GuildAPI.GetAPI().LeaveGuild(base.Entity, base.Operation.Key); return(GuildAPI.GetAPI().GetMemberInfo(base.Entity, base.Operation.Key)); }); yield return(sync); leaveResult = sync.Result; leaveFuncResult = sync.FuncResult; } base.Finished = true; if (leaveResult) { if (leaveFuncResult != null) { base.Entity.UpdateGroupMemberInfo(base.Operation.Key, leaveFuncResult); base.Entity.Sync(); yield return(new FailMessage("[LeaveGuildProcessor] leaveFuncResult")); } else { using (HeroesDataContext heroesDataContext = new HeroesDataContext()) { heroesDataContext.UpdateGuildCharacterInfo(new long?(base.Operation.Key.CID), new long?(0L)); GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, base.Operation.Key.CID, OperationType.GainGuildPoint, GuildLedgerEventType.UpdateGuildUserPoint, "0", "LeaveGuild")); } base.Entity.UpdateGroupMemberInfo(base.Operation.Key, leaveFuncResult); base.Entity.Sync(); yield return(new OkMessage()); } } else { yield return(new FailMessage("[LeaveGuildProcessor] leaveResult")); } yield break; }
public void SetGroupMemberInfo(HeroesGuildMemberInfo groupMemberInfo, HeroesDataContext context) { this.HeroesGuildMemberInfo = groupMemberInfo; string text = groupMemberInfo.CharacterName.RemoveServerHeader(); GetCharacterInfoByName getCharacterInfoByName = context.GetCharacterInfoByName(text).FirstOrDefault <GetCharacterInfoByName>(); int level = (getCharacterInfoByName == null) ? 0 : getCharacterInfoByName.Level; long cid = (getCharacterInfoByName == null) ? -1L : getCharacterInfoByName.ID; long guildCharacterPoint = context.GetGuildCharacterPoint(cid); DateTime?dateTime = null; context.GetLatestConnectedDateByName(text, ref dateTime); DateTime lastLoginTime = (dateTime == null || dateTime == null) ? DateTime.UtcNow : dateTime.Value; this.Key = new GuildMemberKey(cid, (int)groupMemberInfo.CharacterSN, groupMemberInfo.NexonSN, text); this.GuildMemberInfo = new GuildMemberInfo(text, level, groupMemberInfo.emGroupUserType.ToGuildMemberRank(), guildCharacterPoint, lastLoginTime, this.Parent.OnlineMembers.ContainsKey(text)); }
public override IEnumerable <object> Run() { if (!this.Entity.IsInitialized) { Log <ConnectGuildProcessor> .Logger.WarnFormat("ConnectGuildProcessor Set TriggerSync"); TriggerSync triggerSync = new TriggerSync(20000); this.Entity.InitializCompleted += new Action(triggerSync.Trigger); this.Entity.QueryGuildInfo(); yield return((object)triggerSync); if (!triggerSync.Result) { this.Finished = true; bool isInitGroupInfo = this.Entity.GuildInfo != null; bool isInitGroupMemberInfo = this.Entity.GuildMemberDict != null; Log <ConnectGuildProcessor> .Logger.ErrorFormat("Failed to connect to guild. Guild initialization failed. Queried = {0}, value = {1} GuildSN : {2}, IsInitialized: {3}, GuildInfo: {4}, MemberInfo: {5}", (object)this.Entity.IsQueriedGuildInfo, (object)this.Operation.Key.ToString(), (object)this.Entity.GuildSN, (object)this.Entity.IsInitialized, (object)isInitGroupInfo, (object)isInitGroupMemberInfo); yield return((object)new FailMessage("[ConnectGuildProcessor] triggerSync.Result")); yield break; } } this.Entity.Connect(this.Operation.Key, this.Connection.RemoteID); if (FeatureMatrix.IsEnable("GuildProcessorNotUseAsync")) { HeroesGuildMemberInfo info = (HeroesGuildMemberInfo)null; try { info = GuildAPI.GetAPI().GetMemberInfo(this.Entity, this.Operation.Key); } catch (Exception ex) { Log <ConnectGuildProcessor> .Logger.Warn((object)ex); } if (info != null) { this.Entity.UpdateGroupMemberInfo(this.Operation.Key, info); this.Entity.Sync(); } } else { AsyncFuncSync <HeroesGuildMemberInfo> sync = new AsyncFuncSync <HeroesGuildMemberInfo>((Func <HeroesGuildMemberInfo>)(() => { try { return(GuildAPI.GetAPI().GetMemberInfo(this.Entity, this.Operation.Key)); } catch (Exception ex) { Log <ConnectGuildProcessor> .Logger.Warn((object)ex); return((HeroesGuildMemberInfo)null); } })); yield return((object)sync); if (sync.Result && sync.FuncResult != null) { this.Entity.UpdateGroupMemberInfo(this.Operation.Key, sync.FuncResult); this.Entity.Sync(); } } this.Finished = true; yield return((object)new OkMessage()); }
public override IEnumerable <object> Run() { if (base.Entity == null) { base.Finished = true; yield return(ChangeGuildMaster.ResultCodeEnum.ChangeMaster_NotExistGuild); } else { GuildMember oldMaster = base.Entity.GetGuildMember(base.Operation.OldMasterName); if (oldMaster == null) { GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, -1L, OperationType.ChangeMaster, GuildLedgerEventType.ChangeMaster_NotMatchOldMaster)); base.Finished = true; yield return(ChangeGuildMaster.ResultCodeEnum.ChangeMaster_NotMatchOldMaster); } else { GuildMember newMaster = base.Entity.GetGuildMember(base.Operation.NewMasterName); if (newMaster == null) { GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, oldMaster.Key.CID, OperationType.ChangeMaster, GuildLedgerEventType.ChangeMaster_NotFoundNewMaster, base.Operation.NewMasterName)); base.Finished = true; yield return(ChangeGuildMaster.ResultCodeEnum.ChangeMaster_NotFoundNewMaster); } else if (oldMaster.Key.CID == newMaster.Key.CID) { Log <ChangeGuildMasterProcessor> .Logger.InfoFormat("EqualNew&OldID [ op.old: {0}, op.new: {1} ]", base.Operation.OldMasterName, base.Operation.NewMasterName); Log <ChangeGuildMasterProcessor> .Logger.InfoFormat("EqualNew&OldID [ old: {0}, new: {1} ]", oldMaster.Key.ToString(), newMaster.Key.ToString()); GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, oldMaster.Key.CID, OperationType.ChangeMaster, GuildLedgerEventType.ChangeMaster_EqualNewAndOldID)); base.Finished = true; yield return(ChangeGuildMaster.ResultCodeEnum.ChangeMaster_EqualNewAndOldID); } else if (!newMaster.Rank.IsOperator()) { GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, oldMaster.Key.CID, OperationType.ChangeMaster, GuildLedgerEventType.ChangeMaster_LowRankOldMaster)); base.Finished = true; yield return(ChangeGuildMaster.ResultCodeEnum.ChangeMaster_LowRankOldMaster); } else if (!base.Entity.ChangeGuildMaster(newMaster, oldMaster)) { GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, oldMaster.Key.CID, OperationType.ChangeMaster, GuildLedgerEventType.ChangeMaster_SystemError, base.Operation.NewMasterName)); base.Finished = true; yield return(ChangeGuildMaster.ResultCodeEnum.ChangeMaster_SystemError); } else { Func <bool> func = delegate { bool result; try { this.Entity.GuildInfo = null; this.Entity.GuildInfo = GuildAPI.GetAPI().GetGuildInfo(this.Entity.GuildSN).ToGuildInfo(); this.Entity.ReportGuildInfoChanged(); HeroesGuildMemberInfo memberInfo = GuildAPI.GetAPI().GetMemberInfo(this.Entity, oldMaster.Key); if (memberInfo == null) { result = false; } else { this.Entity.UpdateGroupMemberInfo(oldMaster.Key, memberInfo); HeroesGuildMemberInfo memberInfo2 = GuildAPI.GetAPI().GetMemberInfo(this.Entity, newMaster.Key); if (memberInfo2 == null) { result = false; } else { this.Entity.UpdateGroupMemberInfo(newMaster.Key, memberInfo2); result = true; } } } catch (Exception ex) { Log <ConnectGuildProcessor> .Logger.Warn(ex); result = false; } return(result); }; if (FeatureMatrix.IsEnable("GuildProcessorNotUseAsync")) { bool funcResult = func(); if (funcResult) { base.Entity.Sync(); GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, oldMaster.Key.CID, OperationType.ChangeMaster, GuildLedgerEventType.ChangeMaster_Success, base.Operation.NewMasterName)); base.Finished = true; yield return(ChangeGuildMaster.ResultCodeEnum.ChangeMaster_Success); } else { GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, oldMaster.Key.CID, OperationType.ChangeMaster, GuildLedgerEventType.ChangeMaster_SyncFailed, base.Operation.NewMasterName)); base.Finished = true; yield return(ChangeGuildMaster.ResultCodeEnum.ChangeMaster_SyncFailed); } } else { AsyncFuncSync <bool> sync = new AsyncFuncSync <bool>(func); yield return(sync); if (sync.Result && sync.FuncResult) { base.Entity.Sync(); GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, oldMaster.Key.CID, OperationType.ChangeMaster, GuildLedgerEventType.ChangeMaster_Success, base.Operation.NewMasterName)); base.Finished = true; yield return(ChangeGuildMaster.ResultCodeEnum.ChangeMaster_Success); } else { GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, oldMaster.Key.CID, OperationType.ChangeMaster, GuildLedgerEventType.ChangeMaster_SyncFailed, base.Operation.NewMasterName)); base.Finished = true; yield return(ChangeGuildMaster.ResultCodeEnum.ChangeMaster_SyncFailed); } } } } } yield break; }
public GuildOperationResult(bool result, GuildMemberKey key, HeroesGuildMemberInfo info) { this.Result = result; this.Key = key; this.HeroesGuildMemberInfo = info; }
public override IEnumerable <object> Run() { if (!this.Entity.IsInitialized) { Log <JoinGuildProcessor> .Logger.WarnFormat("JoinGuildProcessor Set TriggerSync"); TriggerSync triggerSync = new TriggerSync(20000); this.Entity.InitializCompleted += new Action(triggerSync.Trigger); this.Entity.QueryGuildInfo(); yield return(triggerSync); } bool checkResult = false; bool checkFuncResult = false; if (FeatureMatrix.IsEnable("GuildProcessorNotUseAsync")) { checkResult = true; checkFuncResult = FeatureMatrix.IsEnable("koKR") ? GuildAPI.GetAPI().CheckGuild((long)this.Operation.Key.CharacterSN, this.Operation.Key.NexonSN, this.Operation.Key.CharacterName) : GuildAPI.GetAPI().GetGuildInfo(this.Operation.Key).Count == 0; if (!checkResult) { Log <JoinGuildProcessor> .Logger.ErrorFormat("Failed to join the guild. Cannot see my guild.{0}", (object)this.Operation.Key.ToString()); this.Finished = true; yield return("GuildCheckFail"); } if (!checkFuncResult) { Log <JoinGuildProcessor> .Logger.InfoFormat("Failed to join the guild. Already belong to another guild.. {0}", (object)this.Operation.Key.ToString()); this.Finished = true; yield return("HasGuild"); if (this.Entity.GetRegularMemberCount() >= this.Entity.GetMaxMemberCount()) { Log <JoinGuildProcessor> .Logger.InfoFormat("Failed to join the guild. Guild members are full.{0} >= {1}", (object)this.Entity.GetRegularMemberCount(), (object)this.Entity.GetMaxMemberCount()); this.Finished = true; yield return("GuildFull"); } bool joinResult = false; HeroesGuildMemberInfo joinFuncResult = (HeroesGuildMemberInfo)null; if (FeatureMatrix.IsEnable("GuildProcessorNotUseAsync")) { joinResult = true; try { GuildAPI.GetAPI().Join(this.Entity, this.Operation.Key); joinFuncResult = GuildAPI.GetAPI().GetMemberInfo(this.Entity, this.Operation.Key); } catch (Exception ex) { Log <JoinGuildProcessor> .Logger.Warn((object)ex); } this.Finished = true; if (joinResult && joinFuncResult != null && joinFuncResult.emGroupUserType.ToGuildMemberRank() == GuildMemberRank.Wait) { using (HeroesDataContext heroesDataContext = new HeroesDataContext()) { heroesDataContext.UpdateGuildCharacterInfo(new long?(this.Operation.Key.CID), new long?(0L)); GuildLog.AddGuildLedger(new LogData((long)this.Entity.GuildSN, this.Operation.Key.CID, OperationType.GainGuildPoint, GuildLedgerEventType.UpdateGuildUserPoint, "0", "JoinGuild")); } this.Entity.UpdateGroupMemberInfo(this.Operation.Key, joinFuncResult); this.Entity.Sync(); yield return(base.Entity.GuildID); } yield return(new FailMessage("[JoinGuildProcessor] ToGuildMemberRank") { Reason = FailMessage.ReasonCode.LogicalFail }); } AsyncFuncSync <HeroesGuildMemberInfo> sync = new AsyncFuncSync <HeroesGuildMemberInfo>((Func <HeroesGuildMemberInfo>)(() => { try { GuildAPI.GetAPI().Join(this.Entity, this.Operation.Key); return(GuildAPI.GetAPI().GetMemberInfo(this.Entity, this.Operation.Key)); } catch (Exception ex) { Log <JoinGuildProcessor> .Logger.Warn((object)ex); return((HeroesGuildMemberInfo)null); } })); yield return(sync); } AsyncFuncSync <bool> checkSync = new AsyncFuncSync <bool>((Func <bool>)(() => { if (!FeatureMatrix.IsEnable("koKR")) { return(GuildAPI.GetAPI().GetGuildInfo(this.Operation.Key).Count == 0); } return(GuildAPI.GetAPI().CheckGuild((long)this.Operation.Key.CharacterSN, this.Operation.Key.NexonSN, this.Operation.Key.CharacterName)); })); yield return(checkSync); } }
public GuildMember(GuildEntity parent, HeroesGuildMemberInfo groupMemberInfo, HeroesDataContext context) { this.Parent = parent; this.SetGroupMemberInfo(groupMemberInfo, context); }
public GuildMember(GuildEntity parent, HeroesGuildMemberInfo groupMemberInfo) : this(parent, groupMemberInfo, new HeroesDataContext()) { }