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);
        }
Example #2
0
        public GroupIDCheckResult CheckGroupID(string guildID)
        {
            if (guildID == null || guildID.Length == 0)
            {
                return(GroupIDCheckResult.IDNotSupplied);
            }
            if (GuildContents.HasForbiddenWords(guildID))
            {
                return(GroupIDCheckResult.InvalidCharacter);
            }
            GroupIDCheckResult result = GroupIDCheckResult.Succeed;

            try
            {
                Log <GuildAPI> .Logger.InfoFormat("CheckGroupID: ServerCode[{0}], GuildName[{1}]", GuildAPI.ServerCode, guildID);

                HeroesGuildDBDataContext heroesGuildDBDataContext = new HeroesGuildDBDataContext();
                if (heroesGuildDBDataContext.GuildCheckGroupID(new int?(GuildAPI.ServerCode), guildID) == 0)
                {
                    return(GroupIDCheckResult.Succeed);
                }
                return(GroupIDCheckResult.DuplicatedID);
            }
            catch (ArgumentException ex)
            {
                if (ex.Message == "Exists Guid ID.")
                {
                    result = GroupIDCheckResult.DuplicatedID;
                }
                else
                {
                    if (ex.Message != "Guild ID has special character")
                    {
                        Log <GuildAPI> .Logger.ErrorFormat("Unknown CheckGroupID exception message: {0}", ex.Message);
                    }
                    result = GroupIDCheckResult.InvalidCharacter;
                }
            }
            catch (Exception ex2)
            {
                Log <GuildService> .Logger.Error("CheckGroupID failed [" + guildID + "]", ex2);

                result = GroupIDCheckResult.InvalidCharacter;
            }
            return(result);
        }
Example #3
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;
        }