Esempio n. 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", 100);

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

            var realm = RealmControl.Realm;

            if (realm == VF_RealmPlayersDatabase.WowRealm.Unknown)
            {
                return;
            }
            var wowVersion = StaticValues.GetWowVersion(realm);
            int itemID     = PageUtility.GetQueryInt(Request, "item", 19364);
            int suffixID   = PageUtility.GetQueryInt(Request, "suffix", 0);

            this.Title = "\"" + itemID + "\" ItemUsage @ " + StaticValues.ConvertRealmParam(realm) + " | RealmPlayers";

            m_BreadCrumbHTML = new MvcHtmlString(PageUtility.BreadCrumb_AddHome()
                                                 + PageUtility.BreadCrumb_AddFinish("ItemUsage"));

            var itemSummaryDB = Hidden.ApplicationInstance.Instance.GetItemSummaryDatabase();

            using (VF.SQLComm comm = new VF.SQLComm())
            {
                List <Tuple <DateTime, string> > players = null;
                players = itemSummaryDB.GetItemUsage(realm, itemID, suffixID);//, out players) == true)
                {
                    string currentItemDatabase = DatabaseAccess.GetCurrentItemDatabaseAddress();

                    var itemInfo = DatabaseAccess.GetItemInfo(itemID, wowVersion);
                    m_ItemUsageInfoHTML = new MvcHtmlString("<div style='overflow: hidden; display: table;'><div style='display: table-cell;'><h1>Players with&nbsp;<h1></div>"
                                                            + "<div class='inventory' style='background: none; width: 58px; height: 58px; display: table-cell;'><div>"
                                                            + "<img class='itempic' src='" + "http://realmplayers.com/" + itemInfo.GetIconImageAddress() + "'/>"
                                                            + "<div class='quality' id='" + CharacterViewer.ItemQualityConversion[itemInfo.ItemQuality] + "'></div>"
                                                            + "<img class='itemframe' src='assets/img/icons/ItemNormalFrame.png'/>"
                                                            + CharacterViewer.GenerateItemLink(currentItemDatabase, itemID, suffixID, wowVersion)
                                                            + "</div></div>"
                                                            + "<span class='badge badge-inverse'>" + players.Count + " Players</span></div>" + "<p>Sorted by date \"aquired\"</p>");

                    Dictionary <PlayerColumn, string[]> extraColumns = new Dictionary <PlayerColumn, string[]>();
                    PlayerColumn ItemAndAquiredDateAfterColumn       = PlayerColumn.Number;
                    extraColumns.Add(ItemAndAquiredDateAfterColumn, new string[] { "Item", "Date Aquired" });
                    m_TableHeadHTML = new MvcHtmlString(PageUtility.CreatePlayerTableHeaderRow(Table_Columns, extraColumns));

                    string tableBody = "";
                    int    nr        = 0;
                    Func <Tuple <DateTime, string>, DateTime> lambdaComparison = (_Tuple) => { return(_Tuple.Item1); };
                    players = players.OrderBy(lambdaComparison).ToList();
                    foreach (var playerDateAndName in players)
                    {
                        Player player = DatabaseAccess.FindRealmPlayer(this, realm, playerDateAndName.Item2);
                        if (player != null)
                        {
                            ++nr;
                            // style='position: absolute; margin: auto; width:58px; height:58px;'
                            if (nr > pageIndex * count && nr <= (pageIndex + 1) * count)
                            {
                                //string itemLink = "";
                                VF_RealmPlayersDatabase.PlayerData.ItemInfo playerItemData = null;
                                try
                                {
                                    playerItemData = player.Gear.Items.First((_Item) => { return(_Item.Value.ItemID == itemID); }).Value;
                                }
                                catch (Exception)
                                {
                                    playerItemData = null;
                                }
                                if (playerItemData != null)
                                {
                                    //Data fanns i gearen som playern använder för tillfället!
                                    //itemLink = currentItemDatabase + "?item=" + playerItemData.ItemID + "' rel='rand=" + playerItemData.SuffixID + ";ench=" + playerItemData.EnchantID;
                                }
                                else
                                {
                                    //Måste titta igenom history!
#if NO_SQL
                                    PlayerHistory playerHistory = DatabaseAccess.FindRealmPlayerHistory(this, realm, playerDateAndName.Item2);
                                    if (playerHistory != null)
                                    {
                                        for (int i = playerHistory.GearHistory.Count - 1; i >= 0; --i)
                                        {
                                            try
                                            {
                                                playerItemData = playerHistory.GearHistory[i].Data.Items.First((_Item) => { return(_Item.Value.ItemID == itemID); }).Value;
                                            }
                                            catch (Exception)
                                            {
                                                playerItemData = null;
                                            }
                                            if (playerItemData != null)
                                            {
                                                //Data fanns i gearen som playern använder för tillfället!
                                                //itemLink = currentItemDatabase + "?item=" + playerItemData.ItemID + "' rel='rand=" + playerItemData.SuffixID + ";ench=" + playerItemData.EnchantID;
                                                break;
                                            }
                                        }
                                    }
#else
                                    /*Disable this for now. it is too slow...*/
                                    //playerItemData = comm.GetLatestItemInfoForPlayer(playerDateAndName.Item2, realm, itemID);
#endif
                                }
                                if (playerItemData == null)
                                {
                                    playerItemData = new VF_RealmPlayersDatabase.PlayerData.ItemInfo {
                                        Slot = VF_RealmPlayersDatabase.ItemSlot.Unknown, ItemID = itemID, SuffixID = 0, EnchantID = 0, UniqueID = 0, GemIDs = null
                                    };
                                }
                                extraColumns[ItemAndAquiredDateAfterColumn] = new string[] {
                                    "<div class='inventory' style='background: none; width: 58px; height: 58px;'><div>"
                                    + "<img class='itempic' src='" + "http://realmplayers.com/" + itemInfo.GetIconImageAddress() + "'/>"
                                    + "<div class='quality' id='" + CharacterViewer.ItemQualityConversion[itemInfo.ItemQuality] + "'></div>"
                                    + "<img class='itemframe' src='assets/img/icons/ItemNormalFrame.png'/>"
                                    + CharacterViewer.GenerateItemLink(currentItemDatabase, playerItemData, wowVersion)
                                    + "</div></div>"
                                    , playerDateAndName.Item1.ToString("yyyy-MM-dd")
                                };
                                tableBody += PageUtility.CreatePlayerRow(nr, realm, player, Table_Columns, null, extraColumns);
                            }
                            if (nr >= (pageIndex + 1) * count)
                            {
                                break;
                            }
                        }
                    }
                    if (nr != 0 && nr <= pageIndex * count)
                    {
                        pageIndex = (nr - 1) / count;
                        Response.Redirect(PageUtility.CreateUrlWithNewQueryValue(Request, "page", (pageIndex + 1).ToString()));
                    }
                    m_TableBodyHTML = new MvcHtmlString(tableBody);

                    int maxPageNr = 1000000 / count;
                    m_PaginationHTML = new MvcHtmlString(PageUtility.CreatePagination(Request, pageNr, ((players.Count - 1) / count) + 1));
                }
            }
        }
Esempio n. 2
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));
        }
Esempio n. 3
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", 100);

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

            string searchStr   = PageUtility.GetQueryString(Request, "search", "null");
            string searchRealm = PageUtility.GetQueryString(Request, "realm", "All");
            string searchRace  = PageUtility.GetQueryString(Request, "race", "All");
            string searchClass = PageUtility.GetQueryString(Request, "class", "All");
            string searchLevel = PageUtility.GetQueryString(Request, "level", "All");
            string searchSort  = PageUtility.GetQueryString(Request, "sort", "NameSearch");

            if (searchStr != "")
            {
                this.Title = "Search \"" + searchStr + "\" | RealmPlayers";
            }
            else
            {
                this.Title = "Search | RealmPlayers";
            }
            //List<Tuple<WowRealm, Player>>

            WowRealm realm = StaticValues.ConvertRealm(searchRealm);

            if (realm == WowRealm.Unknown)
            {
                realm = WowRealm.All;
            }

            int nr = 0;

            if (searchStr.Length >= 4 || searchStr.Contains(' '))
            {
                var guildSummaryDB = Hidden.ApplicationInstance.Instance.GetGuildSummaryDatabase();

                var searchStrLower = searchStr.ToLower();
                var guildArray     = guildSummaryDB.GetGuilds(realm).Where((_Value) => _Value.Value.GuildName.ToLower().Contains(searchStrLower));

                if (guildArray.Count() > pageIndex * count)
                {
                    Dictionary <string, Player> realmDB = null;
                    if (realm != WowRealm.All)
                    {
                        realmDB = DatabaseAccess.GetRealmPlayers(this, realm);
                    }
                    var realmDBRealm = realm;

                    System.Text.StringBuilder guildResultTable = new System.Text.StringBuilder(10000);
                    guildResultTable.Append("<h3>Guilds matching &quot;" + searchStr + "&quot;</h3>");
                    guildResultTable.Append("<table id=\"guild-table\" class=\"table\"><thead>");
                    guildResultTable.Append(PageUtility.CreateGuildTableHeaderRow(Table_GuildColumns));
                    guildResultTable.Append("</thead><tbody>");
                    var orderedGuildArray = guildArray.OrderBy((_Value) => _Value.Key);
                    foreach (var guild in orderedGuildArray)
                    {
                        if (realmDBRealm != guild.Value.Realm)
                        {
                            realmDB      = DatabaseAccess.GetRealmPlayers(this, guild.Value.Realm);
                            realmDBRealm = guild.Value.Realm;
                        }
                        guild.Value.GenerateCache(realmDB);
                    }
                    orderedGuildArray = orderedGuildArray.OrderByDescending((_Value) => _Value.Value.GetMembers().Count);
                    foreach (var guild in orderedGuildArray)
                    {
                        if (guild.Value.GetMembers().Count < 2)
                        {
                            continue;
                        }
                        nr++;
                        if (nr > pageIndex * count && nr <= (pageIndex + 1) * count)
                        {
                            guildResultTable.Append(PageUtility.CreateGuildRow(0, guild.Value, Table_GuildColumns));
                        }
                        if (nr >= (pageIndex + 1) * count)
                        {
                            break;
                        }
                    }
                    guildResultTable.Append("</tbody></table>");
                    guildResultTable.Append("<h3>Players matching &quot;" + searchStr + "&quot;</h3>");
                    if (nr > 0)
                    {
                        m_GuildResultTableHTML = new MvcHtmlString(guildResultTable.ToString());
                    }
                }
                else
                {
                    m_GuildResultTableHTML = null;
                    nr += guildArray.Count();
                }
            }

            var playersList = FindPlayersMatching(searchStr, searchRealm, searchRace, searchClass, searchLevel, searchSort);//.OrderBy((_Value) => { return ((int)_Value.Item1).ToString() + _Value.Item2.Name; });

            System.Text.StringBuilder page = new System.Text.StringBuilder(10000);

            IEnumerable <Player> orderedPlayersList = playersList;
            //if (playersList.Count() > 500 || searchStr.Length < 2)
            //    orderedPlayersList = playersList;//.OrderBy(_Player => _Player.Item2.Name);
            //else
            //if (searchStr.Length >= 1)
            //{
            //    string nameFormattedSearchStr = char.ToUpper(searchStr[0]) + searchStr.Substring(1).ToLower();
            //    orderedPlayersList = playersList.OrderByDescending(_Player => _Player.LastSeen.AddYears(_Player.Name.StartsWith(nameFormattedSearchStr) ? 2 : 0));
            //}
            //else
            //{
            //    orderedPlayersList = playersList.OrderBy(_Player => _Player.Name);
            //}
            var playerListCount = playersList.Count();

            foreach (Player player in orderedPlayersList)
            {
                if (playerListCount < count && player.Character.Level < 10 && searchStr.Length <= (double)player.Name.Length * 0.7)
                {
                    continue;
                }

                nr++;
                if (nr > pageIndex * count && nr <= (pageIndex + 1) * count)
                {
                    page.Append(PageUtility.CreatePlayerRow(0, player.Realm, player, Table_Columns));
                }
                if (nr >= (pageIndex + 1) * count)
                {
                    break;
                }
            }
            if (nr != 0 && nr <= pageIndex * count)
            {
                pageIndex = (nr - 1) / count;
                Response.Redirect(PageUtility.CreateUrlWithNewQueryValue(Request, "page", (pageIndex + 1).ToString()));
            }

            m_BreadCrumbHTML   = new MvcHtmlString(PageUtility.BreadCrumb_AddHome() + PageUtility.BreadCrumb_AddFinish("Characters"));
            m_CharListInfoHTML = new MvcHtmlString(CreateCharListInfo(searchStr, playersList.Count()));
            m_TableHeadHTML    = new MvcHtmlString(PageUtility.CreatePlayerTableHeaderRow(Table_Columns, null, Request));
            m_TableBodyHTML    = new MvcHtmlString(page.ToString());

            m_PaginationHTML = new MvcHtmlString(PageUtility.CreatePagination(Request, pageNr, ((playersList.Count() - 1) / count) + 1));
        }
Esempio n. 4
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 == WowRealm.Unknown)
            {
                return;
            }

            this.Title = "Guilds @ " + StaticValues.ConvertRealmParam(realm) + " | RealmPlayers";

            var realmDB = DatabaseAccess.GetRealmPlayers(this, realm, NotLoadedDecision.RedirectAndWait);

            var guildSummaryDB = Hidden.ApplicationInstance.Instance.GetGuildSummaryDatabase();
            //;// DatabaseAccess.GetRealmGuilds(this, realm, NotLoadedDecision.RedirectAndWait).Where((guild) => { return guild.Value.GetTotalPlayers() > 0; })
            var    guildArray = guildSummaryDB.GetGuilds(realm);//.OrderByDescending((guild) => { return guild.Value.Players.Count; });
            string page       = "";
            int    nr         = 0;

            string guildProgressData = "";

            List <Tuple <int, Tuple <VF_RPDatabase.GuildSummary, string> > > progressGuilds = new List <Tuple <int, Tuple <VF_RPDatabase.GuildSummary, string> > >();

            foreach (var guild in guildArray)
            {
                guild.Value.GenerateCache(realmDB);
                if (guild.Value.GetMembers().Count > 0)
                {
                    string thisGuildProgressData   = guild.Value.m_GuildProgressData.Item1;
                    int    progressComparisonValue = guild.Value.m_GuildProgressData.Item2;
                    if (thisGuildProgressData == "" && guild.Value.Stats_GetTotalMaxLevels() >= 25)
                    {
                        try
                        {
                            thisGuildProgressData           = CreateProgressStr(this, guild.Value, realm, out progressComparisonValue);
                            guild.Value.m_GuildProgressData = Tuple.Create(thisGuildProgressData, progressComparisonValue);
                        }
                        catch (Exception ex)
                        {
                            Logger.LogException(ex);
                        }
                    }
                    progressGuilds.Add(Tuple.Create(progressComparisonValue, Tuple.Create(guild.Value, thisGuildProgressData)));
                }
            }
            var orderedProgressGuilds = progressGuilds.OrderByDescending(_Value =>
            {
                UInt64 sortValue = (((UInt64)_Value.Item1) << 32);
                if (sortValue != 0)
                {
                    //sortValue |= (((UInt64)(UInt32)_Value.Item2.Item1.Stats_GetAveragePVPRank()) << 16) | ((UInt64)(UInt32)_Value.Item2.Item1.GetMembers().Count);
                    sortValue |= (((UInt64)(UInt32)_Value.Item2.Item1.Stats_GetAverageMemberHKs()) << 16) | ((UInt64)(UInt32)_Value.Item2.Item1.GetMembers().Count);
                }
                else
                {
                    sortValue |= (UInt64)(UInt32)_Value.Item2.Item1.Stats_GetTotalMaxLevels();
                }
                return(sortValue);
            });

            if (orderedProgressGuilds.Count() > 0)
            {
                if (GuildProgress.GetProgressAQ40(orderedProgressGuilds.First().Item1) == 0) //AQ Content not released
                {
                    guildProgressData += "g_AQReleased = false;";
                }
                else
                {
                    guildProgressData += "g_AQReleased = true;";
                }
                if (GuildProgress.GetProgressNaxx(orderedProgressGuilds.First().Item1) == 0) //Naxx Content not released
                {
                    guildProgressData += "g_NaxxReleased = false;";
                }
                else
                {
                    guildProgressData += "g_NaxxReleased = true;";
                }
            }
            foreach (var guild in orderedProgressGuilds)
            {
                nr++;
                if (nr > pageIndex * count && nr <= (pageIndex + 1) * count)
                {
                    page += PageUtility.CreateGuildRow(nr, guild.Item2.Item1, Table_Columns);
                    guildProgressData += guild.Item2.Item2;
                }
                if (nr >= (pageIndex + 1) * count)
                {
                    break;
                }
            }
            if (nr != 0 && nr <= pageIndex * count)
            {
                pageIndex = (nr - 1) / count;
                Response.Redirect(PageUtility.CreateUrlWithNewQueryValue(Request, "page", (pageIndex + 1).ToString()));
            }
            m_BreadCrumbHTML = new MvcHtmlString(PageUtility.BreadCrumb_AddHome()
                                                 + PageUtility.BreadCrumb_AddRealm(RealmControl.Realm)
                                                 + PageUtility.BreadCrumb_AddFinish("Guilds"));
            m_GuildListInfoHTML = new MvcHtmlString(CreateGuildListInfo(StaticValues.GetWowVersion(RealmControl.Realm), progressGuilds.Count));
            m_TableHeadHTML     = new MvcHtmlString(PageUtility.CreateGuildTableHeaderRow(Table_Columns));
            m_TableBodyHTML     = new MvcHtmlString(page);

            m_PaginationHTML  = new MvcHtmlString(PageUtility.CreatePagination(Request, pageNr, ((guildArray.Count() - 1) / count) + 1));
            m_GuildScriptData = new MvcHtmlString("<script>var guildProgress = new Array();"
                                                  + guildProgressData
                                                  + "</script>");
        }
Esempio n. 5
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;

            this.Title = "Raids | RaidStats";

            m_BreadCrumbHTML = new MvcHtmlString(PageUtility.BreadCrumb_AddHome()
                                                 + PageUtility.BreadCrumb_AddRealm(realm) + PageUtility.BreadCrumb_AddFinish("Dungeons"));
            m_DungeonListInfoHTML = new MvcHtmlString("<h1>All recorded dungeons</h1><p>Sorted by the time the dungeon ended</p>");

            var raidCollection  = ApplicationInstance.Instance.GetRaidCollection();
            var orderedDungeons = raidCollection.m_Dungeons.OrderByDescending((_Value) => { return(_Value.Value.m_DungeonEndDate); });

            m_TableHeadHTML = new MvcHtmlString(
                PageUtility.CreateTableRow("",
                                           PageUtility.CreateTableColumnHead("#Nr") +
                                           PageUtility.CreateTableColumnHead("Players") +
                                           PageUtility.CreateTableColumnHead("Dungeon") +
                                           PageUtility.CreateTableColumnHead("Start Date") +
                                           PageUtility.CreateTableColumnHead("End Date") +
                                           PageUtility.CreateTableColumnHead("Realm")));


            int nr = 0;

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

            foreach (var dungeon in orderedDungeons)
            {
                if (dungeon.Value.Realm == VF_RealmPlayersDatabase.WowRealm.Test_Server)
                {
                    continue;//Skip Test_Server
                }
                if ((realm == VF_RealmPlayersDatabase.WowRealm.All || realm == dungeon.Value.Realm))
                {
                    nr++;
                    if (nr > pageIndex * count && nr <= (pageIndex + 1) * count)
                    {
                        string dungeonOwnerVisual = "\"" + dungeon.Value.m_GroupMembers.MergeToStringVF("\", \"") + "\"";

                        tableBody += PageUtility.CreateTableRow("", PageUtility.CreateTableColumn("#" + i) +
                                                                PageUtility.CreateTableColumn(dungeonOwnerVisual) +
                                                                PageUtility.CreateTableColumn(PageUtility.CreateLink("DungeonOverview.aspx?Dungeon=" + dungeon.Value.m_UniqueDungeonID, dungeon.Value.m_Dungeon)) +
                                                                PageUtility.CreateTableColumn(dungeon.Value.m_DungeonStartDate.ToLocalTime().ToString("yyy-MM-dd HH:mm:ss")) +
                                                                PageUtility.CreateTableColumn(dungeon.Value.m_DungeonEndDate.ToLocalTime().ToString("yyy-MM-dd HH:mm:ss")) +
                                                                PageUtility.CreateTableColumn(RealmPlayersServer.StaticValues.ConvertRealmViewing(dungeon.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, ((orderedDungeons.Count() - 1) / count) + 1));
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sectionStr = PageUtility.GetQueryString(Request, "section", "ranks");
            int    count      = PageUtility.GetQueryInt(Request, "count", 100);

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

            var realm = RealmControl.Realm;

            if (realm == WowRealm.Unknown)
            {
                return;
            }
            var wowVersion = StaticValues.GetWowVersion(realm);

            PlayerColumn[] lifetimeKillsColumns = Table_Lifetime_Kills_Columns;
            PlayerColumn[] rankColumns          = Table_Ranks_Columns;
            Func <KeyValuePair <string, Player>, double> rankSorterLambda = (KeyValuePair <string, Player> _Player) => { return(_Player.Value.GetRankTotal()); };
            Func <Player, bool> rankShowLambda = (Player _Player) => { return(_Player.ReceivedStandingLastWeek() == true && ((DateTime.UtcNow - _Player.LastSeen).TotalDays <= 7.0)); };

            if (wowVersion == VF_RealmPlayersDatabase.WowVersionEnum.TBC)
            {
                lifetimeKillsColumns = Table_Lifetime_Kills_Columns_TBC;
                rankColumns          = Table_Ranks_Columns_TBC;
                rankSorterLambda     = (KeyValuePair <string, Player> _Player) => {
                    return(_Player.Value.GetArenaRatingTotal());
                };
                rankShowLambda = (Player _Player) => {
                    return(_Player.Arena != null);
                };
            }
            if (sectionStr == "standings")
            {
                this.Title = "Standings @ " + StaticValues.ConvertRealmParam(realm) + " | RealmPlayers";

                m_PageHTML = new MvcHtmlString(CreateStandingsTable(realm, count, (player) => { return(player.ReceivedStandingLastWeek()); }));

                if (wowVersion == VF_RealmPlayersDatabase.WowVersionEnum.TBC)
                {
                    GeneratePageDetails("Standings", count * 2, "TBC works with a different PVP system so there are no standings.");
                }
                else
                {
                    var rankUpdateDay = StaticValues.GetRankUpdadeDayType(realm);
                    switch (rankUpdateDay)
                    {
                    case VF_RealmPlayersDatabase.StaticValues.RankUpdateDayType.Wednesday_Morning:
                        GeneratePageDetails("Standings", count * 2, "Last weeks standings for players. Only shows players who received a standing last week. This list resets when the realm calculates new standings for players every wednesday morning.");
                        break;

                    case VF_RealmPlayersDatabase.StaticValues.RankUpdateDayType.Wednesday_Midday:
                        GeneratePageDetails("Standings", count * 2, "Last weeks standings for players. Only shows players who received a standing last week. This list resets when the realm calculates new standings for players every wednesday.");
                        break;

                    case VF_RealmPlayersDatabase.StaticValues.RankUpdateDayType.Sunday_Midnight:
                        GeneratePageDetails("Standings", count * 2, "Last weeks standings for players. Only shows players who received a standing last week. This list resets when the realm calculates new standings for players every sunday midnight.");
                        break;

                    default:
                        break;
                    }
                }
            }
            else if (sectionStr == "twink_ranks")
            {
                this.Title = "Twinks @ " + StaticValues.ConvertRealmParam(realm) + " | RealmPlayers";

                m_PageHTML = new MvcHtmlString(CreatePVPTable(realm, count, Table_Twink_Ranks_Columns
                                                              , (KeyValuePair <string, Player> _Player) => { return(_Player.Value.GetRankTotal()); }
                                                              , (Player _Player) => { return(_Player.Character.Level > 10 && _Player.Character.Level < 60 && _Player.Honor.CurrentRank > 0 && (DateTime.UtcNow - _Player.LastSeen).TotalDays <= 30); }));
                GeneratePageDetails("Twinks", count, "PVP Ranks for players that are below lvl 60. This is meant to show active twinks on the realm. Only shows players that was seen less than 30 days ago");
            }
            else if (sectionStr == "lifetime_kills")
            {
                this.Title = "Lifetime Kills @ " + StaticValues.ConvertRealmParam(realm) + " | RealmPlayers";

                m_PageHTML = new MvcHtmlString(CreatePVPTable(realm, count, lifetimeKillsColumns
                                                              , (KeyValuePair <string, Player> _Player) => { return(_Player.Value.Honor.LifetimeHK); }
                                                              , (Player _Player) => { return(true); }));

                GeneratePageDetails("Lifetime Kills", count, "List sorted by the amount of total honorable kills received. This is to show the players who have pvped the most overall.");
            }
            else if (sectionStr == "highest_ranks")
            {
                this.Title = "Highest Ranks @ " + StaticValues.ConvertRealmParam(realm) + " | RealmPlayers";

                if (wowVersion == VF_RealmPlayersDatabase.WowVersionEnum.TBC)
                {
                    m_PageHTML = new MvcHtmlString("");
                    GeneratePageDetails("Highest Ranks", count, "TBC works with a different PVP system so there are no lifetime highest ranks.");
                }
                else
                {
                    var      playerSummaryDB     = Hidden.ApplicationInstance.Instance.GetPlayerSummaryDatabase();
                    var      pvpSummaries        = playerSummaryDB.GetPVPSummaries(realm);
                    DateTime referenceDateTime   = new DateTime(2010, 1, 1);
                    var      orderedPVPSummaries = pvpSummaries.OrderByDescending((_Value) => ((int)_Value.Value.m_HighestRank.Key) * 100000 - (_Value.Value.m_HighestRank.Value != DateTime.MinValue ? (int)((_Value.Value.m_HighestRank.Value - referenceDateTime).TotalDays) : 0));
                    //////////////////////////////////
                    int pageIndex = PageUtility.GetQueryInt(Request, "page", 1) - 1;//Change range from 0 to * instead of 1 to *

                    PlayerColumn[] playerColumns = new PlayerColumn[] {
                        PlayerColumn.Number,
                        PlayerColumn.Character_And_Guild,
                        PlayerColumn.Race_And_Class,
                        PlayerColumn.Total_HKs,
                        PlayerColumn.LastSeen,
                    };
                    Dictionary <PlayerColumn, string[]> extraColumns = new Dictionary <PlayerColumn, string[]>();

                    extraColumns[PlayerColumn.Number] = new string[] { "Rank", "Date Achieved" };
                    //extraColumns[PlayerColumn.Total_HKs] = new string[] { "Weeks with standing" };

                    string table = "<table class='table'>";
                    table += "<thead>" + PageUtility.CreatePlayerTableHeaderRow(playerColumns, extraColumns) + "</thead>";
                    table += "<tbody>";
                    var playerArray = DatabaseAccess.GetRealmPlayers(this, realm, NotLoadedDecision.RedirectAndWait);
                    int nr          = 0;
                    foreach (var pvpSummary in orderedPVPSummaries)
                    {
                        nr++;
                        if (nr > pageIndex * count && nr <= (pageIndex + 1) * count)
                        {
                            Player playerData = null;
                            if (playerArray.TryGetValue(playerSummaryDB.GetPlayer(pvpSummary), out playerData) == true)
                            {
                                VF_RealmPlayersDatabase.PlayerFaction playerFaction = StaticValues.GetFaction(playerData.Character.Race);
                                int   rank         = (int)pvpSummary.Value.m_HighestRank.Key;
                                float rankProgress = pvpSummary.Value.m_HighestRank.Key - (float)rank;
                                extraColumns[PlayerColumn.Number] = new string[] { PageUtility.CreatePlayerRankDiv(rank, rankProgress, playerFaction), pvpSummary.Value.m_HighestRank.Value.ToString("yyyy-MM-dd") };
                                //extraColumns[PlayerColumn.Total_HKs] = new string[] { pvpSummary.Value.m_ActivePVPWeeks.ToString() };
                                table += PageUtility.CreatePlayerRow(nr, realm, playerData, playerColumns, null, extraColumns);
                            }
                        }
                        if (nr >= (pageIndex + 1) * count)
                        {
                            break;
                        }
                    }
                    table += "</tbody></table>";

                    if (nr != 0 && nr <= pageIndex * count)
                    {
                        pageIndex = (nr - 1) / count;
                        Response.Redirect(PageUtility.CreateUrlWithNewQueryValue(Request, "page", (pageIndex + 1).ToString()));
                    }
                    m_PageHTML = new MvcHtmlString(table);
                    //////////////////////////////////

                    GeneratePageDetails("Highest Ranks", count, "Highest lifetime achieved PVP Ranks for players, sorted by date of achievment");
                }
            }
            else// if (sectionStr == "ranks")
            {
                this.Title = "Ranks @ " + StaticValues.ConvertRealmParam(realm) + " | RealmPlayers";

                if (realm == WowRealm.Nostalrius || realm == WowRealm.NostalriusPVE)
                {
                    rankShowLambda = (Player _Player) =>
                    {
                        return((DateTime.UtcNow - _Player.LastSeen).TotalDays < 14);
                    };
                    GeneratePageDetails("Ranks", count, "Highest PVP Ranks for active players.");
                }
                else if (wowVersion == VF_RealmPlayersDatabase.WowVersionEnum.TBC)
                {
                    GeneratePageDetails("Arena Ranking", count, "Shows the highest rated arena teams, sorted by a sum of the total rating for 5v5, 3v3 and 2v2.");
                }
                else
                {
                    GeneratePageDetails("Ranks", count, "Highest PVP Ranks for players. Only lists players who received standing last week. This is because no rank decay would make the list extremely boring(filled with players that dont even pvp).");
                }
                m_PageHTML = new MvcHtmlString(CreatePVPTable(realm, count, rankColumns
                                                              , rankSorterLambda, rankShowLambda));
            }
            //href='javascript:navigateWithNewQuery(\"page\",\"1\")'
            int pageNr    = PageUtility.GetQueryInt(Request, "page", 1);
            int maxPageNr = 1000000 / count;

            m_PaginationHTML = new MvcHtmlString(PageUtility.CreatePagination(Request, pageNr, maxPageNr));
        }