public override IEnumerable <object> Run()
        {
            if (base.Operation.SearchKey == null || base.Operation.SearchKey.Length < 2 || base.Operation.SearchKey.Length > FeatureMatrix.GetInteger("GuildNamingRuleMaxBytes"))
            {
                Log <QueryGuildList> .Logger.InfoFormat("길드명 또는 길드 마스터 이름이 잘못되었습니다.{0}", base.Operation.SearchKey);

                base.Finished = true;
                yield return(new FailMessage("[QueryGuildListProcessor] GuildNamingRuleMaxBytes"));
            }
            else
            {
                int  total_page  = 1;
                bool queryResult = false;
                List <InGameGuildInfo> queryFuncResult = new List <InGameGuildInfo>();
                if (FeatureMatrix.IsEnable("GuildProcessorNotUseAsync"))
                {
                    queryResult = true;
                    int num;
                    ICollection <HeroesGuildInfo> list = GuildAPI.GetAPI().SearchGuild(base.Operation.QueryType, 0, base.Operation.Page, base.Operation.PageSize, base.Operation.SearchKey, out num);
                    total_page      = ((num == 0) ? 1 : ((num - 1) / (int)base.Operation.PageSize + 1));
                    queryFuncResult = list.ToGuildInfoList();
                }
                else
                {
                    AsyncFuncSync <List <InGameGuildInfo> > sync = new AsyncFuncSync <List <InGameGuildInfo> >(delegate
                    {
                        int num2;
                        ICollection <HeroesGuildInfo> list2 = GuildAPI.GetAPI().SearchGuild(this.Operation.QueryType, 0, this.Operation.Page, this.Operation.PageSize, this.Operation.SearchKey, out num2);
                        total_page = ((num2 == 0) ? 1 : ((num2 - 1) / (int)this.Operation.PageSize + 1));
                        return(list2.ToGuildInfoList());
                    });
                    yield return(sync);

                    queryResult     = sync.Result;
                    queryFuncResult = sync.FuncResult;
                }
                base.Finished = true;
                if (queryResult)
                {
                    yield return(queryFuncResult);

                    yield return(base.Operation.Page);

                    yield return(total_page);
                }
                else
                {
                    yield return(new FailMessage("[QueryGuildListProcessor] queryResult"));
                }
            }
            yield break;
        }
        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);
        }
示例#3
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;
        }
示例#4
0
        public override IEnumerable <object> Run()
        {
            try
            {
                GuildAPI.GetAPI().UserNameModify(base.Operation.Key, base.Operation.NewName);
            }
            catch (Exception ex)
            {
                Log <GuildService> .Logger.Error("UserNameModify Error", ex);
            }
            base.Finished = true;
            yield return(new OkMessage());

            yield break;
        }
示例#5
0
        public override IEnumerable <object> Run()
        {
            if (base.Entity.OnlineMembers.TryGetValue(base.Operation.Key.CharacterName) == null)
            {
                base.Finished = true;
                yield return(new FailMessage("[CloseGuildProcessor] member"));
            }
            else if (base.Entity.GetMemberCount() != 1)
            {
                base.Finished = true;
                yield return("HasMember");
            }
            else
            {
                bool closeResult = false;
                if (FeatureMatrix.IsEnable("GuildProcessorNotUseAsync"))
                {
                    closeResult = GuildAPI.GetAPI().CloseGuild(base.Entity, base.Operation.Key);
                }
                else
                {
                    AsyncFuncSync <bool> sync = new AsyncFuncSync <bool>(delegate
                    {
                        GuildAPI.GetAPI().CloseGuild(base.Entity, base.Operation.Key);
                        return(true);
                    });
                    yield return(sync);

                    closeResult = sync.Result;
                }
                base.Finished = true;
                if (closeResult)
                {
                    base.Entity.SyncCloseGuild();
                    yield return(new OkMessage());
                }
                else
                {
                    yield return(new FailMessage("[CloseGuildProcessor] closeResult"));
                }
            }
            yield break;
        }
示例#6
0
        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;
        }
示例#8
0
        public override IEnumerable <object> Run()
        {
            bool queryResult = false;
            HeroesUserGuildInfo queryFuncResult = null;

            if (FeatureMatrix.IsEnable("GuildProcessorNotUseAsync"))
            {
                queryResult = true;
                List <HeroesUserGuildInfo> guildInfo = GuildAPI.GetAPI().GetGuildInfo(base.Operation.GuildMemberKey);
                if (guildInfo.Count > 0)
                {
                    queryFuncResult = guildInfo.First <HeroesUserGuildInfo>();
                }
            }
            else
            {
                AsyncFuncSync <HeroesUserGuildInfo> sync = new AsyncFuncSync <HeroesUserGuildInfo>(delegate
                {
                    List <HeroesUserGuildInfo> guildInfo3 = GuildAPI.GetAPI().GetGuildInfo(base.Operation.GuildMemberKey);
                    if (guildInfo3.Count == 0)
                    {
                        return(null);
                    }
                    return(guildInfo3.First <HeroesUserGuildInfo>());
                });
                yield return(sync);

                queryResult     = sync.Result;
                queryFuncResult = sync.FuncResult;
            }
            base.Finished = true;
            if (queryResult)
            {
                if (queryFuncResult == null)
                {
                    Log <QueryGuildIDProcessor> .Logger.WarnFormat("[{0}] No Guild", base.Operation.GuildMemberKey.CharacterName);

                    yield return(0L);

                    yield return("");

                    yield return(0);

                    yield return(0);

                    int maxMember = FeatureMatrix.IsEnable("InGameGuild") ? FeatureMatrix.GetInteger("InGameGuild_MaxMember") : 0;
                    yield return(maxMember);
                }
                else
                {
                    Log <QueryGuildIDProcessor> .Logger.WarnFormat("[{0}] GuildSN[{1}] GuildName[{2}] Rank[{3}] ", new object[]
                    {
                        base.Operation.GuildMemberKey.CharacterName,
                        queryFuncResult.CharacterSN,
                        queryFuncResult.CharacterName,
                        queryFuncResult.GroupUserType
                    });

                    int maxMemberLimit = 0;
                    int level          = 0;
                    using (HeroesDataContext heroesDataContext = new HeroesDataContext())
                    {
                        GetInGameGuildInfo guildInfo2 = heroesDataContext.GetGuildInfo(queryFuncResult.GuildSN);
                        maxMemberLimit = guildInfo2.MaxMemberLimit;
                        level          = guildInfo2.Level;
                    }
                    yield return((long)queryFuncResult.GuildSN);

                    yield return(queryFuncResult.GuildName);

                    yield return(level);

                    yield return((int)queryFuncResult.GroupUserType.ToGuildMemberRank());

                    yield return(maxMemberLimit);
                }
            }
            else
            {
                yield return(new FailMessage("[QueryGuildIDProcessor] queryResult"));
            }
            yield break;
        }
示例#9
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);
            }
        }
示例#10
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;
        }
示例#11
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;
        }