Ejemplo n.º 1
0
        public bool CloseGuild(GuildEntity guild, GuildMemberKey key)
        {
            if (guild == null || key == null)
            {
                Log <HeroesGuildAPI> .Logger.ErrorFormat("parameter is null in CloseGuild()", new object[0]);

                return(false);
            }
            int num = -1;

            try
            {
                Log <HeroesGuildAPI> .Logger.InfoFormat("Remove: GuildMemberKey[{0}]", key);

                HeroesGuildDBDataContext heroesGuildDBDataContext = new HeroesGuildDBDataContext();
                num = heroesGuildDBDataContext.GuildRemove(new int?(GuildAPI.ServerCode), new int?(key.NexonSN), new int?(guild.GuildSN));
            }
            catch (Exception ex)
            {
                Log <HeroesGuildAPI> .Logger.Error("Remove(CloseGuild) Error: ", ex);
            }
            if (num == 0)
            {
                GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, key.CID, OperationType.HeroesCore_CloseGuild, GuildLedgerEventType.Success, string.Format("GuildSn: {0}, GuildToString: {1}", guild.GuildSN, guild.ToString())));
            }
            else
            {
                GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, key.CID, OperationType.HeroesCore_CloseGuild, GuildLedgerEventType.DatabaseFail, string.Format("GuildSn: {0}, GuildToString: {1}", guild.GuildSN, guild.ToString())));
            }
            return(num == 0);
        }
Ejemplo n.º 2
0
        public int OpenGuild(GuildMemberKey key, string guildName, string guildID, string guildIntro)
        {
            int num = 0;

            Log <HeroesGuildAPI> .Logger.InfoFormat("Create: GuildMemberKey[{0}], guildName[{1}], guildID[{2}], guildIntro[{3}]", new object[]
            {
                key,
                guildName,
                guildID,
                guildIntro
            });

            try
            {
                Log <HeroesGuildAPI> .Logger.Warn("Sending OpenGuild");

                HeroesGuildDBDataContext heroesGuildDBDataContext = new HeroesGuildDBDataContext();
                num = heroesGuildDBDataContext.GuildCreate(new int?(GuildAPI.ServerCode), new int?(key.NexonSN), new long?((long)key.CharacterSN), key.CharacterName, guildName, guildID, guildIntro);
                Log <HeroesGuildAPI> .Logger.Warn("Done OpenGuild");
            }
            catch (Exception ex)
            {
                Log <HeroesGuildAPI> .Logger.Error("Error in Create", ex);
            }
            if (num >= 0)
            {
                GuildLog.AddGuildLedger(new LogData((long)num, key.CID, OperationType.HeroesCore_OpenGuild, GuildLedgerEventType.Success, string.Format("GuildName: {0}, GuildID: {1}", guildName, guildID)));
            }
            else
            {
                GuildLog.AddGuildLedger(new LogData((long)num, key.CID, OperationType.HeroesCore_OpenGuild, GuildLedgerEventType.DatabaseFail, string.Format("GuildName: {0}, GuildID: {1}", guildName, guildID)));
            }
            return(num);
        }
Ejemplo n.º 3
0
        public bool ChangeRank(GuildEntity guild, GuildMemberRank operatorRank, GuildMember targetMember, GuildMemberRank toRank)
        {
            Log <GuildAPI> .Logger.InfoFormat("ChangeRank: MemberRank[{0}], MemberSN[{1}], ToRank[{2}]", operatorRank, targetMember.Key.NexonSN, toRank);

            if (toRank == GuildMemberRank.Unknown)
            {
                if (operatorRank.HasSecedePermission(targetMember.Rank, toRank))
                {
                    Log <GuildAPI> .Logger.InfoFormat("UserSecede: ServiceCode[{0}], GuildSN[{1}], MemberNexonSN[{2}]", GuildAPI.ServerCode, guild.GuildSN, targetMember.Key.NexonSN);

                    HeroesGuild.UserSecede(GuildAPI.ServerCode, guild.GuildSN, targetMember.Key.NexonSN, targetMember.Key.CharacterSN, targetMember.Key.CharacterName);
                    using (HeroesDataContext heroesDataContext = new HeroesDataContext())
                    {
                        heroesDataContext.UpdateGuildCharacterInfo(new long?(targetMember.Key.CID), new long?(0L));
                        GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, targetMember.Key.CID, OperationType.GainGuildPoint, GuildLedgerEventType.UpdateGuildUserPoint, "0", "Secede"));
                    }
                    return(true);
                }
            }
            else if (operatorRank.HasRankChangePermission(targetMember.Rank, toRank))
            {
                Log <GuildAPI> .Logger.InfoFormat("UserTypeModify: ServiceCode[{0}], GuildSN[{1}], MemberNexonSN[{2}]", GuildAPI.ServerCode, guild.GuildSN, targetMember.Key.NexonSN);

                HeroesGuild.UserTypeModify(GuildAPI.ServerCode, guild.GuildSN, targetMember.Key.NexonSN, targetMember.Key.CharacterSN, targetMember.Key.CharacterName, this.ConvertToGroupUserType(toRank.ToGroupUserType()));
                return(true);
            }
            return(false);
        }
        public override IEnumerable <object> Run()
        {
            this.Finished = true;
            string guildName = this.Operation.GuildName;
            string guildID   = this.Operation.GuildID;
            string guildLog  = string.Format("GuildSN={0}, GuildID={1}, GuildName={2}", (object)this.Operation.GuildSN, (object)guildID, (object)guildName);

            if (guildName != null)
            {
                GroupNameCheckResult namingResult = GuildAPI.GetAPI().CheckGroupName(this.Operation.GuildName);
                if (namingResult != GroupNameCheckResult.Succeed)
                {
                    GuildLog.AddGuildLedger(new LogData((long)this.Operation.GuildSN, this.Operation.MemberKey.CID, OperationType.HeroesCore_GuildIDAndNameModify, GuildLedgerEventType.ChangeIDAndName_InvalidName, guildLog));
                    yield return((object)ChangeGuildIDAndName.ResultCodeEnum.Fail_InvalidGuildName);

                    yield break;
                }
            }
            if (guildID != null)
            {
                GroupIDCheckResult checkResult = GuildAPI.GetAPI().CheckGroupID(guildID);
                if (checkResult != GroupIDCheckResult.Succeed)
                {
                    GuildLog.AddGuildLedger(new LogData((long)this.Operation.GuildSN, this.Operation.MemberKey.CID, OperationType.HeroesCore_GuildIDAndNameModify, GuildLedgerEventType.ChangeIDAndName_InvalidID, guildLog));
                    yield return((object)ChangeGuildIDAndName.ResultCodeEnum.Fail_InvalidGuildID);

                    yield break;
                }
            }
            using (HeroesDataContext heroesDataContext = new HeroesDataContext())
            {
                if (heroesDataContext.GuildInfoUpdate(new int?(this.Operation.GuildSN), guildID, guildName) != 0)
                {
                    GuildLog.AddGuildLedger(new LogData((long)this.Operation.GuildSN, this.Operation.MemberKey.CID, OperationType.HeroesCore_GuildIDAndNameModify, GuildLedgerEventType.ChangeIDAndName_UpdateFailed, guildLog));
                    yield return((object)ChangeGuildIDAndName.ResultCodeEnum.Fail_GuildInfoUpdateFailed);

                    yield break;
                }
                else
                {
                    GuildLog.AddGuildLedger(new LogData((long)this.Operation.GuildSN, this.Operation.MemberKey.CID, OperationType.HeroesCore_GuildIDAndNameModify, GuildLedgerEventType.ChangeIDAndName_Success, guildLog));
                }
            }
            if (this.Entity != null)
            {
                this.Entity.ReportGuildInfoChanged();
                this.Entity.Sync();
            }
            yield return((object)ChangeGuildIDAndName.ResultCodeEnum.Success);
        }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
        public void LeaveGuild(GuildEntity guild, GuildMemberKey key)
        {
            int num = -1;

            try
            {
                HeroesGuildDBDataContext heroesGuildDBDataContext = new HeroesGuildDBDataContext();
                num = heroesGuildDBDataContext.GuildUserSecede(new int?(GuildAPI.ServerCode), new int?(guild.GuildSN), new int?(key.NexonSN), new long?((long)key.CharacterSN), key.CharacterName);
            }
            catch (Exception ex)
            {
                Log <HeroesGuildAPI> .Logger.Error("Error in LeaveGuild(GuildEntity guild, GuildMemberKey key)", ex);
            }
            if (num == 0)
            {
                GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, key.CID, OperationType.HeroesCore_LeaveGuild, GuildLedgerEventType.Success, string.Format("GuildSn: {0}, GuildToString: {1}", guild.GuildSN, guild.ToString(), key.ToString())));
                return;
            }
            GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, key.CID, OperationType.HeroesCore_LeaveGuild, GuildLedgerEventType.DatabaseFail, string.Format("GuildSn: {0}, GuildToString: {1}", guild.GuildSN, guild.ToString(), key.ToString())));
        }
Ejemplo n.º 7
0
        public bool ChangeMaster(GuildEntity guild, GuildMember newMaster, GuildMember oldMaster)
        {
            GuildMemberKey      key   = newMaster.Key;
            HeroesGuildUserType value = GuildMemberRank.Operator.ToGroupUserType();
            int num = -1;

            try
            {
                HeroesGuildDBDataContext heroesGuildDBDataContext = new HeroesGuildDBDataContext();
                num = heroesGuildDBDataContext.GuildGroupChangeMaster(new int?(GuildAPI.ServerCode), new int?(guild.GuildSN), new int?(key.NexonSN), new long?((long)key.CharacterSN), key.CharacterName, new int?((int)value));
            }
            catch (Exception ex)
            {
                Log <HeroesGuildAPI> .Logger.Error("Error in ChangeMaster", ex);
            }
            if (num == 0)
            {
                GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, newMaster.Key.CID, OperationType.HeroesCore_ChangeMaster, GuildLedgerEventType.Success, guild.GuildInfo.MasterName, newMaster.Key.CharacterName));
                return(true);
            }
            GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, newMaster.Key.CID, OperationType.HeroesCore_ChangeMaster, GuildLedgerEventType.DatabaseFail, guild.GuildInfo.MasterName, newMaster.Key.CharacterName));
            return(false);
        }
Ejemplo n.º 8
0
        public void UserNameModify(GuildMemberKey key, string newName)
        {
            int num = -1;

            try
            {
                HeroesGuildDBDataContext heroesGuildDBDataContext = new HeroesGuildDBDataContext();
                num = heroesGuildDBDataContext.GuildUserNameModify(new int?(GuildAPI.ServerCode), new int?(key.NexonSN), new long?((long)key.CharacterSN), newName);
            }
            catch (Exception ex)
            {
                Log <HeroesGuildAPI> .Logger.Error("Error in UserNameModify(GuildMemberKey key, string newName)", ex);
            }
            if (num == 0)
            {
                GuildLog.AddGuildLedger(new LogData(0L, key.CID, OperationType.HeroesCore_UserNameModify, GuildLedgerEventType.Success, string.Format("Prev: {0}", key.ToString()), string.Format("New: {0}", newName)));
            }
            else
            {
                Log <HeroesGuildAPI> .Logger.ErrorFormat("ErrorCode return in UserNameModify(GuildMemberKey key, string newName): {0}", num);

                GuildLog.AddGuildLedger(new LogData(0L, key.CID, OperationType.HeroesCore_UserNameModify, GuildLedgerEventType.DatabaseFail, string.Format("Prev: {0}", key.ToString()), string.Format("New: {0}", newName)));
            }
        }
Ejemplo n.º 9
0
        public bool AcceptJoin(GuildEntity guild, GuildMemberRank operatorRank, GuildMember targetMember, bool accept)
        {
            int num = -1;

            try
            {
                if (operatorRank.HasAcceptJoinPermission(targetMember.Rank))
                {
                    HeroesGuildDBDataContext heroesGuildDBDataContext = new HeroesGuildDBDataContext();
                    if (accept)
                    {
                        num = heroesGuildDBDataContext.GuildUserJoinApply(new int?(GuildAPI.ServerCode), new int?(guild.GuildSN), new int?(targetMember.Key.NexonSN), new long?((long)targetMember.Key.CharacterSN), targetMember.Key.CharacterName);
                    }
                    else
                    {
                        num = heroesGuildDBDataContext.GuildUserJoinReject(new int?(GuildAPI.ServerCode), new int?(guild.GuildSN), new int?(targetMember.Key.NexonSN), new long?((long)targetMember.Key.CharacterSN), targetMember.Key.CharacterName);
                    }
                }
            }
            catch (Exception ex)
            {
                Log <HeroesGuildAPI> .Logger.Error("Error in AcceptJoin(GuildEntity guild, GuildMemberRank operatorRank, GuildMember targetMember, bool accept)", ex);
            }
            GuildLedgerEventType eventType;

            if (num == 0)
            {
                eventType = GuildLedgerEventType.Success;
            }
            else
            {
                eventType = GuildLedgerEventType.DatabaseFail;
            }
            GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, targetMember.Key.CID, OperationType.HeroesCore_ResponseJoin, eventType, string.Format("GuildSn: {0}, isAccept: {1}", guild.GuildSN, accept.ToString()), targetMember.Key.ToString()));
            return(num == 0);
        }
Ejemplo n.º 10
0
        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;
        }
Ejemplo n.º 11
0
        public bool ChangeRank(GuildEntity guild, GuildMemberRank operatorRank, GuildMember targetMember, GuildMemberRank toRank)
        {
            int num = -1;
            HeroesGuildDBDataContext heroesGuildDBDataContext = new HeroesGuildDBDataContext();

            if (toRank == GuildMemberRank.Unknown)
            {
                if (operatorRank.HasSecedePermission(targetMember.Rank, toRank))
                {
                    try
                    {
                        num = heroesGuildDBDataContext.GuildUserSecede(new int?(GuildAPI.ServerCode), new int?(guild.GuildSN), new int?(targetMember.Key.NexonSN), new long?((long)targetMember.Key.CharacterSN), targetMember.Key.CharacterName);
                    }
                    catch
                    {
                        Log <GuildAPI> .Logger.ErrorFormat("GuildUserSecede fail in ChangeRank : ServiceCode[{0}], GuildSN[{1}], MemberNexonSN[{2}]", GuildAPI.ServerCode, guild.GuildSN, targetMember.Key.NexonSN);
                    }
                    if (num == 0)
                    {
                        GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, targetMember.Key.CID, OperationType.GainGuildPoint, GuildLedgerEventType.UpdateGuildUserPoint, "0", "Secede"));
                        int num2 = -1;
                        try
                        {
                            using (HeroesDataContext heroesDataContext = new HeroesDataContext())
                            {
                                num2 = heroesDataContext.UpdateGuildCharacterInfo(new long?(targetMember.Key.CID), new long?(0L));
                            }
                        }
                        catch
                        {
                            Log <GuildAPI> .Logger.ErrorFormat("UpdateGuildCharacterInfo fail in ChangeRank : ServiceCode[{0}], GuildSN[{1}], MemberNexonSN[{2}], toRank[{3}]", new object[]
                            {
                                GuildAPI.ServerCode,
                                guild.GuildSN,
                                targetMember.Key.NexonSN,
                                toRank
                            });
                        }
                        if (num2 == 0)
                        {
                            GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, targetMember.Key.CID, OperationType.HeroesCore_LeaveGuild, GuildLedgerEventType.Success, string.Format("GuildSn: {0}, GuildToString: {1}", guild.GuildSN, guild.ToString(), targetMember.Key.ToString())));
                        }
                    }
                    else
                    {
                        GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, targetMember.Key.CID, OperationType.HeroesCore_LeaveGuild, GuildLedgerEventType.DatabaseFail, string.Format("GuildSn: {0}, GuildToString: {1}", guild.GuildSN, guild.ToString(), targetMember.Key.ToString())));
                    }
                }
            }
            else if (operatorRank.HasRankChangePermission(targetMember.Rank, toRank))
            {
                Log <GuildAPI> .Logger.InfoFormat("UserTypeModify: ServiceCode[{0}], GuildSN[{1}], MemberNexonSN[{2}]", GuildAPI.ServerCode, guild.GuildSN, targetMember.Key.NexonSN);

                try
                {
                    num = heroesGuildDBDataContext.GuildUserTypeModify(new int?(GuildAPI.ServerCode), new int?(guild.GuildSN), new int?(targetMember.Key.NexonSN), new int?(targetMember.Key.CharacterSN), targetMember.Key.CharacterName, new int?((int)toRank.ToGroupUserType()));
                }
                catch (Exception ex)
                {
                    Log <HeroesGuildAPI> .Logger.Error("Error in ChangeRank(GuildEntity guild, GuildMemberRank operatorRank, GuildMember targetMember, GuildMemberRank toRank)", ex);
                }
                if (num == 0)
                {
                    GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, targetMember.Key.CID, OperationType.HeroesCore_ChangeRank, GuildLedgerEventType.Success, string.Format("GuildSn: {0}, GuildToString: {1}", guild.GuildSN, guild.ToString(), targetMember.Key.ToString())));
                }
                else
                {
                    GuildLog.AddGuildLedger(new LogData((long)guild.GuildSN, targetMember.Key.CID, OperationType.HeroesCore_ChangeRank, GuildLedgerEventType.DatabaseFail, string.Format("GuildSn: {0}, GuildToString: {1}", guild.GuildSN, guild.ToString(), targetMember.Key.ToString())));
                }
            }
            return(num == 0);
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 13
0
        public override IEnumerable <object> Run()
        {
            Log <OpenGuildProcessor> .Logger.Warn("Starting OpenGuild...");

            Func <int> func = delegate
            {
                GroupIDCheckResult groupIDCheckResult = GuildAPI.GetAPI().CheckGroupID(base.Operation.GuildNameID);
                if (groupIDCheckResult != GroupIDCheckResult.Succeed)
                {
                    int result;
                    switch (groupIDCheckResult)
                    {
                    case GroupIDCheckResult.IDNotSupplied:
                        result = -8;
                        break;

                    case GroupIDCheckResult.DuplicatedID:
                        result = -9;
                        break;

                    case GroupIDCheckResult.InvalidCharacter:
                        result = -1;
                        break;

                    default:
                        Log <OpenGuildProcessor> .Logger.ErrorFormat("CheckGroupID result is {0}, but it's not processed by OpenGuildProcessor.Run().", groupIDCheckResult.ToString());

                        result = -7;
                        break;
                    }
                    return(result);
                }
                GroupNameCheckResult groupNameCheckResult = GuildAPI.GetAPI().CheckGroupName(base.Operation.GuildName);
                if (groupNameCheckResult != GroupNameCheckResult.Succeed)
                {
                    int result2;
                    switch (groupNameCheckResult)
                    {
                    case GroupNameCheckResult.NotMatchedNamingRule:
                        result2 = -2;
                        break;

                    case GroupNameCheckResult.NotMatchedNamingRuleMaxBytes:
                        result2 = -5;
                        break;

                    case GroupNameCheckResult.RepeatedCharacters:
                        result2 = -6;
                        break;

                    case GroupNameCheckResult.DuplicatedName:
                        result2 = -4;
                        break;

                    default:
                        result2 = -7;
                        break;
                    }
                    return(result2);
                }
                return(GuildAPI.GetAPI().OpenGuild(base.Operation.GuildMemberKey, base.Operation.GuildName, base.Operation.GuildNameID, base.Operation.GuildIntro));
            };
            bool openResult     = false;
            int  openFuncResult = -99;

            if (FeatureMatrix.IsEnable("GuildProcessorNotUseAsync"))
            {
                openResult     = true;
                openFuncResult = func();
            }
            else
            {
                AsyncFuncSync <int> sync = new AsyncFuncSync <int>(func);
                yield return(sync);

                openResult     = sync.Result;
                openFuncResult = sync.FuncResult;
            }
            Log <OpenGuildProcessor> .Logger.Warn("OpenGuild Finished");

            base.Finished = true;
            if (openResult)
            {
                Log <OpenGuildProcessor> .Logger.WarnFormat("OpenGuild Result : {0}", openResult);

                if (openFuncResult > 0)
                {
                    using (HeroesDataContext heroesDataContext = new HeroesDataContext())
                    {
                        heroesDataContext.UpdateGuildCharacterInfo(new long?(base.Operation.GuildMemberKey.CID), new long?(0L));
                        GuildLog.AddGuildLedger(new LogData((long)openFuncResult, base.Operation.GuildMemberKey.CID, OperationType.GainGuildPoint, GuildLedgerEventType.UpdateGuildUserPoint, "0", "OpenGuild"));
                    }
                    yield return((long)openFuncResult);
                }
                else if (openFuncResult == -1)
                {
                    yield return("GuildID");
                }
                else if (openFuncResult == -2)
                {
                    yield return("GuildNamingRule");
                }
                else if (openFuncResult == -3)
                {
                    yield return("GuildInvalidName");
                }
                else if (openFuncResult == -4)
                {
                    yield return("GuildDuplicatedName");
                }
                else if (openFuncResult == -5)
                {
                    yield return("GuildNamingRuleMaxBytes");
                }
                else if (openFuncResult == -6)
                {
                    yield return("GuildRepeatedCharacters");
                }
                else if (openFuncResult == -7)
                {
                    yield return("GuildEtc");
                }
                else if (openFuncResult == -8)
                {
                    yield return("GuildEmptyID");
                }
                else if (openFuncResult == -9)
                {
                    yield return("GuildDuplicatedID");
                }
                else
                {
                    yield return(new FailMessage("[OpenGuildProcessor] openFuncResult"));
                }
            }
            else
            {
                yield return(new FailMessage("[OpenGuildProcessor] openResult"));
            }
            yield break;
        }
Ejemplo n.º 14
0
        public override IEnumerable <object> Run()
        {
            base.Operation.Result = DirectPurchaseGuildItemResultCode.Success;
            GuildLedgerEventType result    = GuildLedgerEventType.Success;
            GuildMember          myInfo    = base.Entity.GetGuildMember(base.Operation.Key.CharacterName);
            OnlineGuildMember    member    = base.Entity.GetOnlineMember(myInfo.Key.CID);
            string maxIncreaseCountParsing = base.Operation.ItemClass.Replace("guild_extension_member_", "");
            int    maxIncreaseCount        = 0;

            if (!base.Entity.IsInitialized || base.Entity.GuildInfo == null)
            {
                base.Operation.Result = DirectPurchaseGuildItemResultCode.GuildNotInitialize;
                result = GuildLedgerEventType.GuildNotInitialize;
            }
            else if (myInfo == null || !myInfo.Rank.IsMaster() || member == null)
            {
                base.Operation.Result = DirectPurchaseGuildItemResultCode.IsNotMaster;
                result = GuildLedgerEventType.IsNotMaster;
            }
            else if (!int.TryParse(maxIncreaseCountParsing, out maxIncreaseCount))
            {
                base.Operation.Result = DirectPurchaseGuildItemResultCode.CannotParseItem;
                result = GuildLedgerEventType.CannotParseItem;
            }
            else if (FeatureMatrix.GetInteger("InGameGuild_MaxMemberLimit") < base.Entity.GuildInfo.MaxMemberCount + maxIncreaseCount)
            {
                base.Operation.Result = DirectPurchaseGuildItemResultCode.OverMaxMemberLimit;
                result = GuildLedgerEventType.OverMaxMemberLimit;
            }
            if (base.Operation.Result != DirectPurchaseGuildItemResultCode.Success)
            {
                GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, base.Operation.Key.CID, OperationType.DirectPurchaseGuildItem, result));
                base.Finished = true;
                yield return(base.Operation.Result);
            }
            else
            {
                DirectPickUpByProductNo directPickupOp = new DirectPickUpByProductNo(new List <int>
                {
                    base.Operation.ProductNo
                }, base.Operation.IsCredit);
                OperationSync directPickupSync = new OperationSync
                {
                    Connection = member.CashShopConn,
                    Operation  = directPickupOp
                };
                yield return(directPickupSync);

                if (!directPickupSync.Result)
                {
                    if (directPickupOp.FailReasonString.StartsWith("BeginDirectPurchaseItem"))
                    {
                        base.Operation.Result = DirectPurchaseGuildItemResultCode.BeginDirectPurchaseItem;
                        result = GuildLedgerEventType.BeginDirectPurchaseItem;
                    }
                    else if (directPickupOp.FailReasonString.StartsWith("EndDirectPurchaseItem"))
                    {
                        base.Operation.Result = DirectPurchaseGuildItemResultCode.EndDirectPurchaseItem;
                        result = GuildLedgerEventType.EndDirectPurchaseItem;
                    }
                    else
                    {
                        base.Operation.Result = DirectPurchaseGuildItemResultCode.Unknown;
                        result = GuildLedgerEventType.Unknown;
                    }
                    GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, base.Operation.Key.CID, OperationType.DirectPurchaseGuildItem, result));
                    base.Finished = true;
                    yield return(new FailMessage("[DirectPurchaseGuildItemProcessor] directPickupSync.Result"));
                }
                else
                {
                    bool updateResult = false;
                    try
                    {
                        HeroesDataContext heroesDataContext = new HeroesDataContext();
                        updateResult = heroesDataContext.UpdateMaxMemberLimit(base.Entity.GuildInfo.GuildSN, base.Entity.GuildInfo.MaxMemberCount + maxIncreaseCount);
                        if (!updateResult)
                        {
                            base.Operation.Result = DirectPurchaseGuildItemResultCode.DatabaseFail;
                            result = GuildLedgerEventType.DatabaseFail;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log <DirectPurchaseGuildItemProcessor> .Logger.Error("UpdateGuildInfoProcessor DataBase Exception ", ex);

                        base.Operation.Result = DirectPurchaseGuildItemResultCode.DatabaseException;
                        result = GuildLedgerEventType.DatabaseException;
                    }
                    HeroesGuildInfo guildInfo = GuildAPI.GetAPI().GetGuildInfo(base.Entity.GuildSN);
                    if (guildInfo != null)
                    {
                        base.Entity.GuildInfo = guildInfo.ToGuildInfo();
                        base.Entity.UpdateGroupInfo();
                        base.Entity.Sync();
                    }
                    else
                    {
                        base.Operation.Result = DirectPurchaseGuildItemResultCode.ReloadFail;
                        result = GuildLedgerEventType.ReloadFail;
                    }
                    if (!updateResult || base.Operation.Result != DirectPurchaseGuildItemResultCode.Success)
                    {
                        RollbackDirectPickUp rollbackPickupOp = new RollbackDirectPickUp
                        {
                            OrderNo       = directPickupOp.OrderNo,
                            ProductNoList = directPickupOp.ProductNoList
                        };
                        OperationSync rollbackPickupSync = new OperationSync
                        {
                            Connection = member.CashShopConn,
                            Operation  = rollbackPickupOp
                        };
                        yield return(rollbackPickupSync);

                        Log <DirectPurchaseGuildItemProcessor> .Logger.ErrorFormat("UpdateGuildInfoProcessor DataBase Fail {0}", base.Entity.GuildSN);

                        GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, base.Operation.Key.CID, OperationType.DirectPurchaseGuildItem, result));
                        base.Finished = true;
                        yield return(base.Operation.Result);
                    }
                    else
                    {
                        base.Operation.Result = DirectPurchaseGuildItemResultCode.Success;
                        result = GuildLedgerEventType.Success;
                        GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, base.Operation.Key.CID, OperationType.DirectPurchaseGuildItem, result));
                        base.Finished = true;
                        yield return(base.Operation.Result);
                    }
                }
            }
            yield break;
        }
Ejemplo n.º 15
0
		public override IEnumerable<object> Run()
		{
			base.Finished = true;
			if (!FeatureMatrix.IsEnable("GuildLevel"))
			{
				yield return new FailMessage("[GiveGuildGPProcessor] GuildLevel")
				{
					Reason = FailMessage.ReasonCode.NotSupportedOperation
				};
			}
			else
			{
				using (HeroesDataContext context = new HeroesDataContext())
				{
					bool gpAdded = false;
					foreach (KeyValuePair<long, int> keyValuePair in base.Operation.GiveDict)
					{
						long key = keyValuePair.Key;
						int value = keyValuePair.Value;
						OnlineGuildMember onlineGuildMember = null;
						foreach (KeyValuePair<string, OnlineGuildMember> keyValuePair2 in base.Entity.OnlineMembers)
						{
							if (keyValuePair2.Value.CID == key)
							{
								onlineGuildMember = keyValuePair2.Value;
								break;
							}
						}
						if (onlineGuildMember != null && onlineGuildMember.GuildMember.Rank.IsRegularMember())
						{
							int num = base.Entity.GiveGP(value, base.Operation.GainType, key);
							gpAdded |= (num != 0);
							try
							{
								onlineGuildMember.GuildMember.AddPoint(num);
								long point = onlineGuildMember.GuildMember.GetPoint();
								base.Entity.ReportGuildMemberChanged(onlineGuildMember.GuildMember.Key);
								context.UpdateGuildCharacterInfo(new long?(key), new long?(point));
								GuildLog.AddGuildLedger(new LogData((long)base.Entity.GuildSN, key, OperationType.GainGuildPoint, GuildLedgerEventType.UpdateGuildUserPoint, point.ToString()));
							}
							catch (Exception ex)
							{
								Log<GiveGuildGP>.Logger.ErrorFormat("Error while GiveGuildGPProcessor, Step UpdateGuildCharacterInfo : {0}", ex.ToString());
							}
						}
					}
					if (!gpAdded)
					{
						yield return new FailMessage("[GiveGuildGPProcessor] gpAdded");
						yield break;
					}
					try
					{
						context.UpdateGuildInfo(new int?(FeatureMatrix.GameCode), new int?(GuildAPI.ServerCode), new int?(base.Entity.GuildSN), null, null, new int?(base.Entity.GuildInfo.GuildLevel), new long?(base.Entity.GuildInfo.GuildPoint), null, new int?(FeatureMatrix.GetInteger("InGameGuild_MaxMember")), null);
					}
					catch (Exception ex2)
					{
						Log<GiveGuildGP>.Logger.ErrorFormat("Error while GiveGuildGPProcessor, Step UpdateGuildInfo : {0}", ex2.ToString());
					}
				}
				base.Entity.ReportGuildInfoChanged();
				base.Entity.Sync();
				yield return new OkMessage();
			}
			yield break;
		}