コード例 #1
0
        public static List <Tuple <DateTime, string, string> > GetDonations()
        {
            string donatorsText  = DynamicFileData.GetTextFile(Constants.RPPDbDir + "RPPWebsitePages\\Donators.txt");
            var    donatorsArray = donatorsText.SplitVF("\r\n");

            List <Tuple <DateTime, string, string> > donations = new List <Tuple <DateTime, string, string> >();

            foreach (var donator in donatorsArray)
            {
                try
                {
                    var donatorArgs = donator.Split(',');
                    if (donatorArgs.Length == 3)
                    {
                        var      player = donatorArgs[0].Replace("\t", "");
                        DateTime date   = DateTime.Parse(donatorArgs[2].Replace("\t", ""));
                        string   amount = donatorArgs[1].Replace("\t", "");
                        //if(donatorArgs[1].Replace("\t", "").TryParseFloat(out amount) == false)
                        //    throw new Exception("TryParseFloat failed!");

                        donations.Add(Tuple.Create(date, amount, player));
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                }
            }
            return(donations);
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Redirect("http://forum.realmplayers.com");
            TimeSpan outDateTimeSpan = new TimeSpan(1, 0, 0);

            if (PageUtility.GetQueryString(Request, "ForceReload", "false") != "false")
            {
                outDateTimeSpan = new TimeSpan(0, 0, 0);
            }
            string[] changelogFiles = System.IO.Directory.GetFiles(Constants.RPPDbDir + "RPPWebsitePages\\Changelogs\\");
            List <Tuple <string, DateTime> > changelogs = new List <Tuple <string, DateTime> >();

            foreach (var changelogFile in changelogFiles)
            {
                string   dateTimeStr        = changelogFile.Split(new char[] { '/', '\\' }).Last().Split('.').First();
                string[] dateTimeComponents = dateTimeStr.Split('_');
                if (dateTimeComponents.Count() == 5)
                {
                    DateTime dateTime = new DateTime(int.Parse(dateTimeComponents[0])
                                                     , int.Parse(dateTimeComponents[1])
                                                     , int.Parse(dateTimeComponents[2])
                                                     , int.Parse(dateTimeComponents[3])
                                                     , int.Parse(dateTimeComponents[4])
                                                     , 0, DateTimeKind.Local);

                    string changelogEntry = DynamicFileData.GetTextFile(changelogFile, outDateTimeSpan);
                    if (changelogEntry != "")
                    {//<div class='row'><div class='span12'></div></div>
                        changelogEntry = "<div class='changelogentry'><h3>" + dateTime.ToString("yyyy-MM-dd") + "</h3>" + changelogEntry + "</div>";
                        changelogs.Add(new Tuple <string, DateTime>(changelogEntry, dateTime));
                    }
                }
            }
            var orderedChangelogs = changelogs.OrderByDescending((_Value) => { return(_Value.Item2); });

            string changelogText = "";

            foreach (var changelog in orderedChangelogs)
            {
                changelogText += changelog.Item1;
            }
            m_ChangelogTextHTML = new MvcHtmlString(changelogText);
        }