Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "Error | RealmPlayers";
            string reasonStr = Request.QueryString.Get("reason");

            if (reasonStr == "loading")
            {
                Response.AppendHeader("Refresh", "10");

                string returnStr = Request.QueryString.Get("return");
                if (returnStr != null)
                {
                    returnStr = System.Web.HttpUtility.UrlDecode(returnStr);
                }
                else
                {
                    returnStr = "";
                }

                var rppDatabase      = Hidden.ApplicationInstance.Instance.GetRPPDatabase(false);
                var itemInfoCache    = Hidden.ApplicationInstance.Instance.GetItemInfoCache(VF_RealmPlayersDatabase.WowVersionEnum.Vanilla, false);
                var itemInfoCacheTBC = Hidden.ApplicationInstance.Instance.GetItemInfoCache(VF_RealmPlayersDatabase.WowVersionEnum.TBC, false);

                m_ErrorTextData = new MvcHtmlString("<h1>Website Database Loading</h1>" +
                                                    "<p>The website is currently loading the database which means you will unfortunately have to wait a bit before it is done."
                                                    + "<br />Depending on what section you are trying to visit this may take anywhere between 10 seconds and 5 minutes."
                                                    + "<br />You can have a look around other parts of the website while the database is loading" + (rppDatabase != null ? ", may i suggest <a class='nav' href='PVPList.aspx?section=lifetime_kills'>Lifetime Kills</a>?" : "")
                                                    + "<br /><br />The website auto refreshes every 10 seconds and when loading is done will redirect you automatically to"
                                                    + "<br /><a class='nav' href='" + returnStr + "'>" + returnStr + "</a></p>");

                if (rppDatabase != null && itemInfoCache != null && itemInfoCacheTBC != null)
                {
                    string waitStr = Request.QueryString.Get("wait");
                    if (waitStr != null)
                    {
                        if (waitStr.Contains('-'))
                        {
                            string[] waitParts = waitStr.Split('-');
                            var      realm     = StaticValues.ConvertRealm(waitParts[0]);
                            if (realm != VF_RealmPlayersDatabase.WowRealm.Unknown)
                            {
                                var realmDatabase = rppDatabase.GetRealm(realm);
                                if (realmDatabase.IsPlayersLoadComplete() == false)
                                {
                                    return;
                                }
                                if (waitParts.Length > 1)
                                {
                                    if (waitParts[1] == "history")
                                    {
                                        if (realmDatabase.IsPlayersHistoryLoadComplete() == false)
                                        {
                                            return;
                                        }
                                    }
                                    //else if (waitParts[1] == "itemsused")
                                    //{
                                    //    if (realmDatabase.IsLoadComplete() == false)
                                    //        return;
                                    //    var cacheDB = realmDatabase.GetCacheDatabase(false, true);
                                    //    if (cacheDB == null || cacheDB.IsItemsUsedLoaded() == false)
                                    //        return;
                                    //}
                                    else if (waitParts[1] == "guilds")
                                    {
                                        if (realmDatabase.IsLoadComplete() == false)
                                        {
                                            return;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (waitParts[0] == "itemdropdatabase")
                                {
                                    if (DatabaseAccess.GetItemDropDatabase(this, VF_RealmPlayersDatabase.WowVersionEnum.Vanilla, NotLoadedDecision.ReturnNull) == null)
                                    {
                                        return;
                                    }
                                }
                            }
                        }
                        else if (waitStr == "contributors")
                        {
                            if (DatabaseAccess.GetContributorStatistics() == null)
                            {
                                return;
                            }
                        }
                    }
                    Response.Redirect(returnStr);
                }
            }
            else if (reasonStr == "website_error")
            {
                string returnStr = Request.QueryString.Get("return");
                if (returnStr != null)
                {
                    returnStr = System.Web.HttpUtility.UrlDecode(returnStr);
                }
                else
                {
                    returnStr = "";
                }

                Response.AppendHeader("Refresh", "20;URL=" + returnStr);

                m_ErrorTextData = new MvcHtmlString("<h1>Website Error</h1>" +
                                                    "<p>There was some error that caused you to be redirect to this site."
                                                    + "<br />The error you encountered has been logged. Please report this error at the forum <a href='http://forum.realmplayers.com'>http://forum.realmplayers.com</a> so i can investigate it and solve it as soon as possible."
                                                    + "<br />You will get redirected to another section of the website to avoid further errors."
                                                    + "<br /><br />The website will refresh after 20 seconds and will redirect you automatically to"
                                                    + "<br /><a class='nav' href='" + returnStr + "'>" + returnStr + "</a></p>");
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "Contributors | RealmPlayers";
            var statisticsData = DatabaseAccess.GetContributorStatistics();

            if (statisticsData == null)
            {
                PageUtility.RedirectErrorLoading(this, "contributors");
                return;
            }
            m_BreadCrumbHTML = new MvcHtmlString(PageUtility.BreadCrumb_AddHome() + PageUtility.BreadCrumb_AddFinish("Contributors"));

            var statsRealms = new WowRealm[] { WowRealm.Emerald_Dream, WowRealm.Warsong, WowRealm.Al_Akir, WowRealm.Rebirth, WowRealm.Nostalrius, WowRealm.Kronos, WowRealm.Archangel };

            Dictionary <WowRealm, int> totalRealmInspects = new Dictionary <WowRealm, int>();

            string realmInspectsHeaderColumns = "";

            foreach (var statsRealm in statsRealms)
            {
                realmInspectsHeaderColumns += PageUtility.CreateTableColumnHead(StaticValues.ConvertRealmViewing(statsRealm));
                totalRealmInspects.Add(statsRealm, 0);
            }

            m_TableHeadHTML = new MvcHtmlString(PageUtility.CreateTableRow("", PageUtility.CreateTableColumnHead("#Nr")
                                                                           + PageUtility.CreateTableColumnHead("Name")
                                                                           + PageUtility.CreateTableColumnHead("Total inspects")
                                                                           + realmInspectsHeaderColumns
                                                                           + PageUtility.CreateTableColumnHead("Active since")
                                                                           + PageUtility.CreateTableColumnHead("Last active")));

            SortedList <int, string> tableRows = new SortedList <int, string>();
            string tableBody = "";

            var contributors = ContributorDB.GetAllTrustWorthyContributors();

            foreach (var data in contributors)
            {
                DateTime earliestActive       = DateTime.MaxValue;
                DateTime latestActive         = DateTime.MinValue;
                int      totalInspects        = 0;
                string   realmInspectsColumns = "";
                foreach (var statRealm in statsRealms)
                {
                    int inspects = 0;
                    Code.ContributorStatisticItem stats = null;
                    if (statisticsData[statRealm].TryGetValue(data.ContributorID, out stats) == false)
                    {
                        stats = new Code.ContributorStatisticItem(-1);
                    }
                    earliestActive = (stats.m_EarliestActiveUTC < earliestActive ? stats.m_EarliestActiveUTC : earliestActive);
                    latestActive   = (stats.m_LatestActiveUTC > latestActive ? stats.m_LatestActiveUTC : latestActive);

                    foreach (var inspection in stats.m_PlayerInspects)
                    {
                        inspects += inspection.Value;
                    }
                    totalInspects += inspects;
                    totalRealmInspects[statRealm] += inspects;
                    realmInspectsColumns          += PageUtility.CreateTableColumn(inspects.ToString());
                }

                if (totalInspects > 0 && data.Name != "Unknown" &&
                    ((DateTime.UtcNow - latestActive).TotalDays < 15 ||
                     (totalInspects > 5000 && (DateTime.UtcNow - latestActive).TotalDays < 60)))
                {
                    int keyToUse = int.MaxValue - totalInspects * 100;
                    while (tableRows.ContainsKey(keyToUse) == true)
                    {
                        keyToUse += 1;
                    }


                    tableRows.Add(keyToUse, PageUtility.CreateTableColumn(data.Name)
                                  + PageUtility.CreateTableColumn(totalInspects.ToString())
                                  + realmInspectsColumns
                                  + PageUtility.CreateTableColumn(earliestActive.ToString("yyy-MM-dd"))
                                  + PageUtility.CreateTableColumn(StaticValues.GetTimeSinceLastSeenUTC(latestActive)));
                }
            }
            int    totalALLInspects         = 0;
            string totalRealmInspectsColumn = "";

            foreach (var statRealm in statsRealms)
            {
                totalRealmInspectsColumn += PageUtility.CreateTableColumn(totalRealmInspects[statRealm].ToString());
                totalALLInspects         += totalRealmInspects[statRealm];
            }
            tableBody += PageUtility.CreateTableRow("", PageUtility.CreateTableColumn("#ALL") + PageUtility.CreateTableColumn("TOTAL")
                                                    + PageUtility.CreateTableColumn(totalALLInspects.ToString())
                                                    + totalRealmInspectsColumn
                                                    + PageUtility.CreateTableColumn("-")
                                                    + PageUtility.CreateTableColumn("-"));
            int i = 1;

            foreach (var tableRow in tableRows)
            {
                tableBody += PageUtility.CreateTableRow("", PageUtility.CreateTableColumn("#" + i++) + tableRow.Value);
            }
            m_TableBodyHTML = new MvcHtmlString(tableBody);

            m_ContributorsInfoHTML = new MvcHtmlString(
                "<h1>Contributors<span class='badge badge-inverse'>" + tableRows.Count() + " Players</span></h1>"
                + "<p>List displays the persons that contribute data to this project. Sorted by the amount of inspects they have contributed with.</p>"
                + "<br/><p>The more contributors the better! If you are interested in being a contributor to help out the project please do not hesitate contacting <a href='http://forum.realmplayers.com/memberlist.php?mode=viewprofile&u=51'>Sethzer</a> on RealmPlayers forums. Make sure you also read the thread: <a href='http://realmplayers.com:5555/viewtopic.php?f=14&t=15'>About Data Contribution</a>.</p><br/>");
        }