Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int pageNr    = PageUtility.GetQueryInt(Request, "page", 1);
            int pageIndex = pageNr - 1;//Change range from 0 to * instead of 1 to *
            int count     = PageUtility.GetQueryInt(Request, "count", 50);

            if (count > 500)
            {
                count = 500;
            }

            var realm = RealmControl.Realm;

            if (realm == VF_RealmPlayersDatabase.WowRealm.Unknown || realm == VF_RealmPlayersDatabase.WowRealm.All)
            {
                InstanceControl.SetAllMode();
            }
            else if (StaticValues.GetWowVersion(realm, true) == VF_RealmPlayersDatabase.WowVersionEnum.TBC)
            {
                InstanceControl.SetTBCMode();
            }
            else
            {
                InstanceControl.SetVanillaMode();
            }
            string guildStr = PageUtility.GetQueryString(Request, "Guild", null);

            if (guildStr != null)
            {
                this.Title = "Raids for " + guildStr + " | RaidStats";

                m_BreadCrumbHTML = new MvcHtmlString(PageUtility.BreadCrumb_AddHome()
                                                     + PageUtility.BreadCrumb_AddRealm(realm)
                                                     + PageUtility.BreadCrumb_AddFinish(guildStr)
                                                     + PageUtility.BreadCrumb_AddFinish("Raids"));
                m_RaidListInfoHTML = new MvcHtmlString("<h1>Recorded raids for " + guildStr + "</h1><p>Sorted by the time the raid ended</p><p>"
                                                       + PageUtility.CreateLink("InstanceList.aspx?realm=" + RealmPlayersServer.StaticValues.ConvertRealmParam(realm) + "&Guild=" + guildStr, "Instances statistics by guild") + "</p><p>"
                                                       + PageUtility.CreateLink("BossList.aspx?realm=" + RealmPlayersServer.StaticValues.ConvertRealmParam(realm) + "&Guild=" + guildStr, "Bosses statistics by guild") + "</p><p>"
                                                       + (guildStr != "PUG" ? PageUtility.CreateLink(PageUtility.HOSTURL_Armory + "GuildViewer.aspx?realm=" + RealmPlayersServer.StaticValues.ConvertRealmParam(realm) + "&Guild=" + guildStr, "View guild on RealmPlayers(Armory)") : "") + "</p>");
            }
            else
            {
                this.Title = "Raids | RaidStats";

                m_BreadCrumbHTML = new MvcHtmlString(PageUtility.BreadCrumb_AddHome()
                                                     + PageUtility.BreadCrumb_AddRealm(realm) + PageUtility.BreadCrumb_AddFinish("Raids"));
                m_RaidListInfoHTML = new MvcHtmlString("<h1>All recorded raids</h1><p>Sorted by the time the raid ended</p>");
            }
            var raidCollection = ApplicationInstance.Instance.GetRaidCollection();
            var orderedRaids   = raidCollection.m_Raids.OrderByDescending((_Value) => { return(_Value.Value.RaidEndDate); });

            m_TableHeadHTML = new MvcHtmlString(
                PageUtility.CreateTableRow("",
                                           PageUtility.CreateTableColumnHead("#Nr") +
                                           PageUtility.CreateTableColumnHead("Guild") +
                                           PageUtility.CreateTableColumnHead("Raid Instance(ID)") +
                                           PageUtility.CreateTableColumnHead("Start Date") +
                                           PageUtility.CreateTableColumnHead("End Date") +
                                           PageUtility.CreateTableColumnHead("Realm")));

            VF_RaidDamageDatabase.RealmDB realmDB = null;
            var guildSummaryDB = ApplicationInstance.Instance.GetGuildSummaryDatabase();
            int nr             = 0;

            int    i         = orderedRaids.Count();
            string tableBody = "";

            foreach (var raid in orderedRaids)
            {
                if (raid.Value.Realm == VF_RealmPlayersDatabase.WowRealm.Test_Server)
                {
                    continue;//Skip Test_Server
                }
                if (raid.Value.RaidOwnerName == "")
                {
                    continue;//Skip RaidOwnerName == "" because something is obviously wrong!
                }
                if ((realm == VF_RealmPlayersDatabase.WowRealm.All || realm == raid.Value.Realm) &&
                    (guildStr == null || guildStr == raid.Value.RaidOwnerName) &&
                    InstanceControl.IsFiltered(raid.Value.RaidInstance) == true)
                {
                    nr++;
                    if (nr > pageIndex * count && nr <= (pageIndex + 1) * count)
                    {
                        string raidOwnerVisual = raid.Value.RaidOwnerName;
                        var    recordedBy      = raid.Value.GetRecordedByPlayers();
                        if (recordedBy.Count > 0)
                        {
                            VF_RealmPlayersDatabase.PlayerFaction faction = VF_RealmPlayersDatabase.PlayerFaction.Unknown;
                            if (raid.Value.RaidOwnerName != "PUG")
                            {
                                try
                                {
                                    faction = guildSummaryDB.GetGuildSummary(raid.Value.Realm, raid.Value.RaidOwnerName).Faction;
                                }
                                catch (Exception)
                                {}
                            }
                            else
                            {
                                if (realmDB == null || realmDB.Realm != raid.Value.Realm)
                                {
                                    realmDB = ApplicationInstance.Instance.GetRealmDB(raid.Value.Realm);
                                }
                                faction = RealmPlayersServer.StaticValues.GetFaction(realmDB.GetPlayer(recordedBy.First()).Character.Race);
                            }
                            if (faction == VF_RealmPlayersDatabase.PlayerFaction.Horde)
                            {
                                raidOwnerVisual = PageUtility.CreateImage("assets/img/Horde_32.png") + raidOwnerVisual;
                            }
                            else if (faction == VF_RealmPlayersDatabase.PlayerFaction.Alliance)
                            {
                                raidOwnerVisual = PageUtility.CreateImage("assets/img/Alliance_32.png") + raidOwnerVisual;
                            }
                        }
                        tableBody += PageUtility.CreateTableRow("", PageUtility.CreateTableColumn("#" + i) +
                                                                PageUtility.CreateTableColumn(PageUtility.CreateLink("RaidList.aspx?realm=" + RealmPlayersServer.StaticValues.ConvertRealmParam(raid.Value.Realm) + "&Guild=" + raid.Value.RaidOwnerName, raidOwnerVisual)) +
                                                                PageUtility.CreateTableColumn(PageUtility.CreateLink("RaidOverview.aspx?Raid=" + raid.Value.UniqueRaidID, PageUtility.CreateImage(StaticValues._RaidInstanceImages[raid.Value.RaidInstance]) + " " + raid.Value.RaidInstance + "(" + raid.Value.RaidID + ")")) +
                                                                PageUtility.CreateTableColumn(raid.Value.RaidStartDate.ToLocalTime().ToString("yyy-MM-dd HH:mm:ss")) +
                                                                PageUtility.CreateTableColumn(raid.Value.RaidEndDate.ToLocalTime().ToString("yyy-MM-dd HH:mm:ss")) +
                                                                PageUtility.CreateTableColumn(RealmPlayersServer.StaticValues.ConvertRealmViewing(raid.Value.Realm)));
                    }
                    if (nr >= (pageIndex + 1) * count)
                    {
                        break;
                    }
                }
                --i;
            }
            if (nr != 0 && nr <= pageIndex * count)
            {
                pageIndex = (nr - 1) / count;
                Response.Redirect(PageUtility.CreateUrlWithNewQueryValue(Request, "page", (pageIndex + 1).ToString()));
            }
            m_TableBodyHTML = new MvcHtmlString(tableBody);

            m_PaginationHTML = new MvcHtmlString(PageUtility.CreatePagination(Request, pageNr, ((orderedRaids.Count() - 1) / count) + 1));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string guildLimit  = PageUtility.GetQueryString(Request, "Guild", "null");
            string playerLimit = PageUtility.GetQueryString(Request, "player", "null");

            var realm = RealmControl.Realm;

            string breadCrumbCommon = "";

            if (guildLimit != "null")
            {
                playerLimit = "null";
                this.Title  = "Boss records for " + guildLimit + " | RaidStats";

                breadCrumbCommon = PageUtility.BreadCrumb_AddHome()
                                   + PageUtility.BreadCrumb_AddRealm(realm)
                                   + PageUtility.BreadCrumb_AddLink("RaidList.aspx?Guild=" + guildLimit, guildLimit);

                m_BossListInfoHTML = new MvcHtmlString("<h1>Raid Bosses for " + guildLimit + "</h1>"
                                                       + "<p>Top DPS, HPS and fastest kill times are listed below for the different bosses</p>"
                                                       + "<p>Note that this does only show data from the guild " + guildLimit + ".<br />If you want to see for all guilds click " + PageUtility.CreateLink("BossList.aspx?realm=" + RealmPlayersServer.StaticValues.ConvertRealmParam(realm), "here") + "</p>");
            }
            else if (playerLimit != "null")
            {
                this.Title = "Boss records for " + playerLimit + " | RaidStats";

                breadCrumbCommon = PageUtility.BreadCrumb_AddHome()
                                   + PageUtility.BreadCrumb_AddRealm(realm)
                                   + PageUtility.BreadCrumb_AddLink("PlayerOverview.aspx?realm=" + RealmPlayersServer.StaticValues.ConvertRealmParam(realm) + "&player=" + playerLimit, playerLimit);

                m_BossListInfoHTML = new MvcHtmlString("<h1>Raid Boss records for " + playerLimit + "</h1>"
                                                       + "<p>Top DPS, HPS and fastest kill times are listed below for the different bosses</p>"
                                                       + "<p>Note that this does only show data for player " + playerLimit + ".<br />If you want to see for all players on the realm click " + PageUtility.CreateLink("BossList.aspx?realm=" + RealmPlayersServer.StaticValues.ConvertRealmParam(realm), "here") + "</p>");
            }
            else
            {
                this.Title = "Boss records | RaidStats";

                breadCrumbCommon = PageUtility.BreadCrumb_AddHome()
                                   + PageUtility.BreadCrumb_AddRealm(realm);

                m_BossListInfoHTML = new MvcHtmlString("<h1>Raid Bosses</h1>"
                                                       + "<p>Top DPS, HPS and fastest kill times are listed below for the different bosses</p>");
            }

            if (ClassControl.HasClassLimits() == true)
            {
                string colorClasses = ClassControl.GetColorClassesStr();
                string breadCrumb   = breadCrumbCommon + PageUtility.BreadCrumb_AddThisPageWithout("Bosses", Request, "ClassLimit");

                if (ClassControl.HasFactionLimits() == true)
                {
                    breadCrumb += PageUtility.BreadCrumb_AddFinish("vs " + colorClasses);
                    breadCrumb += PageUtility.BreadCrumb_AddFinish("Only " + ClassControl.GetColorFactionStr());
                }
                else
                {
                    breadCrumb += PageUtility.BreadCrumb_AddFinish("vs " + colorClasses);
                }
                m_BreadCrumbHTML = new MvcHtmlString(breadCrumb);
            }
            else
            {
                if (ClassControl.HasFactionLimits() == true)
                {
                    m_BreadCrumbHTML = new MvcHtmlString(breadCrumbCommon
                                                         + PageUtility.BreadCrumb_AddThisPageWithout("Bosses", Request, "FactionLimit")
                                                         + PageUtility.BreadCrumb_AddFinish("Only " + ClassControl.GetColorFactionStr()));
                }
                else
                {
                    m_BreadCrumbHTML = new MvcHtmlString(breadCrumbCommon
                                                         + PageUtility.BreadCrumb_AddFinish("Bosses"));
                }
            }

            m_TableHeadHTML = new MvcHtmlString(
                PageUtility.CreateTableRow("",
                                           PageUtility.CreateTableColumnHead("Instance") +
                                           PageUtility.CreateTableColumnHead("Boss") +
                                           PageUtility.CreateTableColumnHead("Top DPS") +
                                           PageUtility.CreateTableColumnHead("Top HPS") +
                                           PageUtility.CreateTableColumnHead("Fastest Kill") +
                                           PageUtility.CreateTableColumnHead("Kill Count")));

            DateTime earliestCompatibleDate = new DateTime(2013, 10, 23, 0, 0, 0);
            var      realmDB = ApplicationInstance.Instance.GetRealmDB(VF_RealmPlayersDatabase.WowRealm.Emerald_Dream);
            //var raidCollection = ApplicationInstance.Instance.GetRaidCollection();

            var summaryDatabase = ApplicationInstance.Instance.GetSummaryDatabase();

            if (summaryDatabase == null)
            {
                return;
            }

            IEnumerable <VF_RaidDamageDatabase.Models.PurgedPlayer> purgePlayers = ApplicationInstance.Instance.GetPurgedPlayers(realm);

            var classLimits   = ClassControl.GetClassLimits();
            var factionLimits = ClassControl.GetFactionLimits();

            string tableBody = "";

            foreach (var boss in BossInformation.BossFights)
            {
                var bossFights = summaryDatabase.GetHSElligibleBossFights(boss.Key, realm, guildLimit == "null" ? null : guildLimit, playerLimit == "null" ? null : playerLimit, purgePlayers);
                if (bossFights.Count > 0)
                {
                    //averagePrecision /= bossFights.Count;
                    Tuple <string, int>    fastestKill = new Tuple <string, int>("", int.MaxValue);
                    Tuple <string, double> topDPS      = new Tuple <string, double>("", 0.0);
                    Tuple <string, double> topHPS      = new Tuple <string, double>("", 0.0);
                    foreach (var fight in bossFights)
                    {
                        if (realmDB.Realm != fight.CacheRaid.CacheGroup.Realm)
                        {
                            realmDB = ApplicationInstance.Instance.GetRealmDB(fight.CacheRaid.CacheGroup.Realm);
                        }
                        //if (fight.DataDetails.FightPrecision < averagePrecision - 0.05)
                        //    continue;
                        if (fight.FightDuration < fastestKill.Item2)
                        {
                            fastestKill = new Tuple <string, int>(
                                PageUtility.CreateLink("FightOverview.aspx?Raid=" + fight.CacheRaid.UniqueRaidID
                                                       + "&Fight=" + fight.StartDateTime.ToString("ddHHmmss"), fight.FightDuration.ToString() + " seconds")
                                , fight.FightDuration);
                        }

                        var unitsData = fight.PlayerFightData;//.GetFilteredPlayerUnitsData(true, realmDB.RD_GetPlayerIdentifier);
                        Tuple <string, int> topDmg  = new Tuple <string, int>("", 0);
                        Tuple <string, int> topHeal = new Tuple <string, int>("", 0);
                        foreach (var unit in unitsData)
                        {
                            if (unit.Item2.Damage > topDmg.Item2)
                            {
                                var playerName = unit.Item1;
                                if (playerName == "Unknown")
                                {
                                    continue;
                                }
                                if (playerLimit != "null" && playerLimit != playerName)
                                {
                                    continue;
                                }
                                if (BossInformation.BossFights.ContainsKey(playerName) == true)
                                {
                                    continue;
                                }

                                var playerData = realmDB.RD_FindPlayer(playerName, fight);
                                if (playerData != null && (classLimits == null || classLimits.Contains(playerData.Character.Class)) &&
                                    (factionLimits == null || factionLimits.Contains(StaticValues.GetFaction(playerData.Character.Race))))
                                {
                                    topDmg = new Tuple <string, int>(unit.Item1, unit.Item2.Damage);
                                }
                            }
                            if (unit.Item2.EffectiveHeal > topHeal.Item2)
                            {
                                var playerName = unit.Item1;
                                if (playerName == "Unknown")
                                {
                                    continue;
                                }
                                if (playerLimit != "null" && playerLimit != playerName)
                                {
                                    continue;
                                }
                                if (BossInformation.BossFights.ContainsKey(playerName) == true)
                                {
                                    continue;
                                }

                                var playerData = realmDB.RD_FindPlayer(playerName, fight);
                                if (playerData != null && (classLimits == null || classLimits.Contains(playerData.Character.Class)) &&
                                    (factionLimits == null || factionLimits.Contains(StaticValues.GetFaction(playerData.Character.Race))))
                                {
                                    topHeal = new Tuple <string, int>(unit.Item1, unit.Item2.EffectiveHeal);
                                }
                            }
                        }
                        double topThisDPS = (double)topDmg.Item2 / (double)fight.FightDuration;
                        double topThisHPS = (double)topHeal.Item2 / (double)fight.FightDuration;
                        if (topThisDPS > topDPS.Item2)
                        {
                            topDPS = new Tuple <string, double>(PageUtility.CreateLink_RaidStats_Player(topDmg.Item1, realmDB.Realm
                                                                                                        , PageUtility.CreateColorCodedName(topDmg.Item1, realmDB.GetPlayer(topDmg.Item1).Character.Class))
                                                                + "(" + PageUtility.CreateLink("FightOverview.aspx?Raid=" + fight.CacheRaid.UniqueRaidID
                                                                                               + "&Fight=" + fight.StartDateTime.ToString("ddHHmmss")
                                                                                               , topThisDPS.ToStringDot("0.0")) + ")", topThisDPS);
                        }
                        if (topThisHPS > topHPS.Item2)
                        {
                            topHPS = new Tuple <string, double>(PageUtility.CreateLink_RaidStats_Player(topHeal.Item1, realmDB.Realm
                                                                                                        , PageUtility.CreateColorCodedName(topHeal.Item1, realmDB.GetPlayer(topHeal.Item1).Character.Class))
                                                                + "(" + PageUtility.CreateLink("FightOverview.aspx?Raid=" + fight.CacheRaid.UniqueRaidID
                                                                                               + "&Fight=" + fight.StartDateTime.ToString("ddHHmmss")
                                                                                               , topThisHPS.ToStringDot("0.0")) + ")", topThisHPS);
                        }
                    }
                    int killCount = bossFights.Count((_Value) => { return(_Value.AttemptType == VF_RDDatabase.AttemptType.KillAttempt); });

                    tableBody += PageUtility.CreateTableRow("", PageUtility.CreateTableColumn(PageUtility.CreateImage(StaticValues._RaidInstanceImages[boss.Value]) + boss.Value) +
                                                            PageUtility.CreateTableColumn(PageUtility.CreateLink("FightOverallOverview.aspx?FightName=" + boss.Key + (guildLimit != "null" ? "&Guild=" + guildLimit : "") + (playerLimit != "null" ? "&realm=" + StaticValues.ConvertRealmParam(realm) + "&PlayerLimit=" + playerLimit : ""), boss.Key)) +
                                                            PageUtility.CreateTableColumn(topDPS.Item1) +
                                                            PageUtility.CreateTableColumn(topHPS.Item1) +
                                                            PageUtility.CreateTableColumn(fastestKill.Item1) +
                                                            PageUtility.CreateTableColumn(killCount.ToString()));
                }
            }
            m_TableBodyHTML = new MvcHtmlString(tableBody);
        }