Example #1
0
        public static InGameGuildInfo ToGuildInfo(this HeroesGuildInfo groupInfo)
        {
            InGameGuildInfo result = null;

            try
            {
                HeroesDataContext heroesDataContext = new HeroesDataContext();
                int maxMemberLimit = heroesDataContext.GetMaxMemberLimit(groupInfo.GuildSN);
                if (FeatureMatrix.IsEnable("NewbieGuildRecommend"))
                {
                    GetInGameGuildInfo guildInfo   = heroesDataContext.GetGuildInfo(groupInfo.GuildSN);
                    int      guildLevel            = 1;
                    long     guildPoint            = 0L;
                    DateTime guildLastDailyGPReset = heroesDataContext.GetGuildLastDailyGPReset(groupInfo.GuildSN);
                    Dictionary <byte, int> dailyGainGP;
                    if (FeatureMatrix.IsEnable("GuildLevel"))
                    {
                        guildLevel = guildInfo.Level;
                        guildPoint = guildInfo.Exp;
                        DateTime prevDailyGPResetTime = GuildContents.GetPrevDailyGPResetTime();
                        if (guildLastDailyGPReset >= prevDailyGPResetTime)
                        {
                            dailyGainGP = heroesDataContext.GetGuildDailyGainGP(groupInfo.GuildSN);
                        }
                        else
                        {
                            dailyGainGP = new Dictionary <byte, int>();
                            heroesDataContext.ResetInGameGuildDailyGainGP(groupInfo.GuildSN);
                        }
                    }
                    else
                    {
                        dailyGainGP = new Dictionary <byte, int>();
                    }
                    result = new InGameGuildInfo(groupInfo.GuildSN, groupInfo.GuildName, guildLevel, groupInfo.RealUserCount, groupInfo.NameInGroup_Master, maxMemberLimit, guildInfo.NewbieRecommend, guildPoint, guildInfo.Notice, dailyGainGP);
                }
                else
                {
                    result = new InGameGuildInfo(groupInfo.GuildSN, groupInfo.GuildName, 1, groupInfo.RealUserCount, groupInfo.NameInGroup_Master, maxMemberLimit);
                }
            }
            catch (Exception ex)
            {
                Log <GuildAPI> .Logger.ErrorFormat("Exception occured in GuildAPI_Extension::ToGuildInfo( GroupInfo ) : {0}", ex.ToString());

                return(null);
            }
            return(result);
        }
Example #2
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;
        }