public string RenderData(ArrayList playerList, string sHead, [Optional] string sortOrder, IRatePlayers scorer) { // Output the list Utility.Announce("PlayerListing " + sHead); var r = new SimpleTableReport { ReportHeader = sHead, DoRowNumbers = true }; if (!string.IsNullOrEmpty(SubHeader)) { r.SubHeader = SubHeader; } //////////////////////////////////////////// var ds = LoadData(playerList, scorer); // <--action //////////////////////////////////////////// r.AddColumn(new ReportColumn("Name", "NAME", "{0,-15}")); r.AddColumn(new ReportColumn("Pos", "POS", "{0,9}")); r.AddColumn(new ReportColumn("Role", "ROLE", "{0,9}")); r.AddColumn(new ReportColumn("RookieYr", "ROOKIEYR", "{0,4}")); r.AddColumn(new ReportColumn("Team", "CURRTEAM", "{0,2}")); r.AddColumn(new ReportColumn("Age", "AGE", "{0,2}")); r.AddColumn(new ReportColumn("Owner", "FT", "{0,2}")); if (LongStats) { r.AddColumn(new ReportColumn("Curr", "CURSCORES", "{0,5}")); r.AddColumn(new ReportColumn("Tot", "SCORES", "{0,5}")); r.AddColumn(new ReportColumn("Avg", "AVG", "{0:0.0}")); r.AddColumn(new ReportColumn("Inj", "INJURY", "{0,5}")); r.AddColumn(new ReportColumn("YDp", "YDP", "{0,5}")); r.AddColumn(new ReportColumn("Tdp", "TDP", "{0,5}")); r.AddColumn(new ReportColumn("YDr", "YDR", "{0,5}")); r.AddColumn(new ReportColumn("Tdr", "TDR", "{0,5}")); r.AddColumn(new ReportColumn("YDc", "YDC", "{0,5}")); r.AddColumn(new ReportColumn("TDc", "TDC", "{0,5}")); r.AddColumn(new ReportColumn("Fg", "Fg", "{0,5}")); } r.AddColumn(new ReportColumn("Points", "POINTS", "{0,5}")); var dt = ds.Tables[0]; dt.DefaultView.Sort = LongStats ? (string.IsNullOrEmpty(sortOrder) ? "Points DESC" : sortOrder) : "Points DESC"; r.LoadBody(dt); // just assigns the data table if (string.IsNullOrEmpty(FileOut)) { FileOut = string.Format("{0}{2}//{1}.htm", Utility.OutputDirectory(), sHead, Utility.CurrentSeason()); } r.RenderAsHtml(FileOut, true); if (RenderToCsv) { r.RenderAsCsv("Starters-" + sHead, Logger); } return(FileOut); }
public string RenderProjectedData( ArrayList playerList, string sHead, [Optional] string sortOrder, IRatePlayers scorer, IWeekMaster weekMaster, IAdpMaster adpMaster = null) { // Output the list Utility.Announce("PlayerListing " + sHead); SimpleTableReport r = SetUpProjectionReport( sHead); var ds = LoadProjectedData( plyrList: playerList, scorer: scorer, weekMaster: weekMaster, adpMaster: adpMaster); var dt = ds.Tables[0]; dt.DefaultView.Sort = LongStats ? (string.IsNullOrEmpty(sortOrder) ? "Points DESC" : sortOrder) : "Points DESC"; r.LoadBody(dt); // just assigns the data table FileOut = $@"{ Utility.OutputDirectory() }//{ Season }//Projections//{ sHead }.htm" ; r.RenderAsHtml( fileName: FileOut, persist: true); if (RenderToCsv) { r.RenderAsCsv( "Starters-" + sHead, Logger); } return(FileOut); }
/// <summary> /// Make a big report then write it as CSV /// </summary> public void DumpPlayersToCsv() { // Define the simple report var when = string.Format("Week{0}-{1:0#}", Utility.CurrentSeason(), Int32.Parse(Utility.CurrentWeek()) + 1); var str = new SimpleTableReport(string.Format("Player Stats : {0}", when)); str.AddColumn(new ReportColumn("Jersey", "JERSEY", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Name", "NAME", "{0,-15}", typeof (String))); str.AddColumn(new ReportColumn("Team", "CURRTEAM", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Unit", "UNIT", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Rookie", "ROOKIEYR", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Drafted", "DRAFTED", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Category", "CATEGORY", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Pos", "POSDESC", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Role", "ROLE", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Owner", "OWNER", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Age", "AGE", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Stars", "STARS", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Value", "VALUE", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Scores", "SCORES", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Rushes", "RUSHES", "{0}", typeof (String))); str.AddColumn(new ReportColumn("YDr", "YDR", "{0}", typeof (String))); str.AddColumn(new ReportColumn("AvgYDr", "AVGYDR", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Tdr", "TDR", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Catches", "CATCHES", "{0}", typeof (String))); str.AddColumn(new ReportColumn("YDc", "YDC", "{0}", typeof (String))); str.AddColumn(new ReportColumn("AvgYDc", "AVGYDC", "{0}", typeof (String))); str.AddColumn(new ReportColumn("TDc", "TDC", "{0}", typeof (String))); str.AddColumn(new ReportColumn("COM", "COM", "{0}", typeof (String))); str.AddColumn(new ReportColumn("ATTEMPTS", "ATTEMPTS", "{0}", typeof (String))); str.AddColumn(new ReportColumn("YDp", "YDp", "{0}", typeof (String))); str.AddColumn(new ReportColumn("AVGYDp", "AVGYDp", "{0}", typeof (String))); str.AddColumn(new ReportColumn("Tdp", "Tdp", "{0}", typeof (String))); str.AddColumn(new ReportColumn("INT", "INT", "{0}", typeof (String))); var dt = new DataTable(); var cols = dt.Columns; cols.Add("JERSEY", typeof (String)); cols.Add("NAME", typeof (String)); cols.Add("TEAM", typeof (String)); cols.Add("UNIT", typeof (String)); cols.Add("ROOKIEYR", typeof (String)); cols.Add("DRAFTED", typeof (String)); cols.Add("CATEGORY", typeof (String)); cols.Add("POSDESC", typeof (String)); cols.Add("ROLE", typeof (String)); cols.Add("OWNER", typeof (String)); cols.Add("AGE", typeof (String)); cols.Add("STARS", typeof (String)); cols.Add("VALUE", typeof (String)); cols.Add("SCORES", typeof (String)); cols.Add("RUSHES", typeof (String)); cols.Add("YDR", typeof (String)); cols.Add("AVGYDR", typeof (String)); cols.Add("TDR", typeof (String)); cols.Add("CATCHES", typeof (String)); cols.Add("YDC", typeof (String)); cols.Add("AVGYDC", typeof (String)); cols.Add("TDC", typeof (String)); cols.Add("COM", typeof (String)); cols.Add("ATTEMPTS", typeof (String)); cols.Add("YDp", typeof (String)); cols.Add("AVGYDp", typeof (String)); cols.Add("Tdp", typeof (String)); cols.Add("INT", typeof (String)); // Load the body foreach (NflConference c in _confList) foreach (NFLDivision d in c.DivList) foreach (NflTeam t in d.TeamList) { if (t.PlayerList == null) t.LoadPlayerUnits(); foreach (NFLPlayer p in t.PlayerList) { p.LoadPerformances(false, false, Utility.SeasonInFocus()); if (!string.IsNullOrEmpty(p.PlayerName)) { var dr = dt.NewRow(); dr["JERSEY"] = p.JerseyNo; dr["NAME"] = p.PlayerName; dr["TEAM"] = p.CurrTeam.TeamCode; dr["UNIT"] = p.Unit(); dr["ROOKIEYR"] = p.RookieYear; dr["DRAFTED"] = p.Drafted.Trim(); dr["CATEGORY"] = p.PlayerCat; dr["POSDESC"] = p.PlayerPos.Replace(",", "-"); dr["ROLE"] = p.PlayerRole; dr["OWNER"] = p.Owner; dr["AGE"] = p.PlayerAge(); dr["STARS"] = p.StarRating; dr["VALUE"] = p.Value().ToString(); dr["SCORES"] = p.Scores.ToString(); if (p.TotStats == null) { dr["RUSHES"] = "0"; dr["YDR"] = "0"; dr["AVGYDR"] = "0.0"; dr["TDR"] = "0"; dr["CATCHES"] = "0"; dr["YDC"] = "0.0"; dr["AVGYDC"] = "0"; dr["TDC"] = "0"; dr["COM"] = "0"; dr["ATTEMPTS"] = "0"; dr["YDp"] = "0"; dr["AVGYDp"] = "0.0"; dr["Tdp"] = "0"; dr["INT"] = "0"; } else { dr["RUSHES"] = p.TotStats.Rushes.ToString(); dr["YDR"] = p.TotStats.YDr.ToString(); dr["AVGYDR"] = string.Format("{0:0.0}", Utility.Average(p.TotStats.YDr, p.TotStats.Rushes)); dr["TDR"] = p.TotStats.Tdr.ToString(); dr["CATCHES"] = p.TotStats.Catches.ToString(); dr["YDC"] = p.TotStats.YDc.ToString(); dr["AVGYDC"] = string.Format("{0:0.0}", Utility.Average(p.TotStats.YDc, p.TotStats.Catches)); dr["TDC"] = p.TotStats.Tdc.ToString(); dr["COM"] = p.TotStats.Completions.ToString(); dr["ATTEMPTS"] = p.TotStats.PassAtts.ToString(); dr["YDp"] = p.TotStats.YDp.ToString(); dr["AVGYDp"] = string.Format("{0:0.0}", Utility.Average(p.TotStats.YDp, p.TotStats.Completions)); dr["Tdp"] = p.TotStats.Tdp.ToString(); dr["INT"] = p.TotStats.PassInt.ToString(); } dt.Rows.Add(dr); } } } str.LoadBody(dt); str.RenderAsCsv( "Players" ); }
/// <summary> /// Make a big report then write it as CSV /// </summary> public void DumpPlayersToCsv() { // Define the simple report var when = string.Format("Week{0}-{1:0#}", Utility.CurrentSeason(), Int32.Parse(Utility.CurrentWeek()) + 1); var str = new SimpleTableReport(string.Format("Player Stats : {0}", when)); str.AddColumn(new ReportColumn("Jersey", "JERSEY", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Name", "NAME", "{0,-15}", typeof(String))); str.AddColumn(new ReportColumn("Team", "CURRTEAM", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Unit", "UNIT", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Rookie", "ROOKIEYR", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Drafted", "DRAFTED", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Category", "CATEGORY", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Pos", "POSDESC", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Role", "ROLE", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Owner", "OWNER", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Age", "AGE", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Stars", "STARS", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Value", "VALUE", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Scores", "SCORES", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Rushes", "RUSHES", "{0}", typeof(String))); str.AddColumn(new ReportColumn("YDr", "YDR", "{0}", typeof(String))); str.AddColumn(new ReportColumn("AvgYDr", "AVGYDR", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Tdr", "TDR", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Catches", "CATCHES", "{0}", typeof(String))); str.AddColumn(new ReportColumn("YDc", "YDC", "{0}", typeof(String))); str.AddColumn(new ReportColumn("AvgYDc", "AVGYDC", "{0}", typeof(String))); str.AddColumn(new ReportColumn("TDc", "TDC", "{0}", typeof(String))); str.AddColumn(new ReportColumn("COM", "COM", "{0}", typeof(String))); str.AddColumn(new ReportColumn("ATTEMPTS", "ATTEMPTS", "{0}", typeof(String))); str.AddColumn(new ReportColumn("YDp", "YDp", "{0}", typeof(String))); str.AddColumn(new ReportColumn("AVGYDp", "AVGYDp", "{0}", typeof(String))); str.AddColumn(new ReportColumn("Tdp", "Tdp", "{0}", typeof(String))); str.AddColumn(new ReportColumn("INT", "INT", "{0}", typeof(String))); var dt = new DataTable(); var cols = dt.Columns; cols.Add("JERSEY", typeof(String)); cols.Add("NAME", typeof(String)); cols.Add("TEAM", typeof(String)); cols.Add("UNIT", typeof(String)); cols.Add("ROOKIEYR", typeof(String)); cols.Add("DRAFTED", typeof(String)); cols.Add("CATEGORY", typeof(String)); cols.Add("POSDESC", typeof(String)); cols.Add("ROLE", typeof(String)); cols.Add("OWNER", typeof(String)); cols.Add("AGE", typeof(String)); cols.Add("STARS", typeof(String)); cols.Add("VALUE", typeof(String)); cols.Add("SCORES", typeof(String)); cols.Add("RUSHES", typeof(String)); cols.Add("YDR", typeof(String)); cols.Add("AVGYDR", typeof(String)); cols.Add("TDR", typeof(String)); cols.Add("CATCHES", typeof(String)); cols.Add("YDC", typeof(String)); cols.Add("AVGYDC", typeof(String)); cols.Add("TDC", typeof(String)); cols.Add("COM", typeof(String)); cols.Add("ATTEMPTS", typeof(String)); cols.Add("YDp", typeof(String)); cols.Add("AVGYDp", typeof(String)); cols.Add("Tdp", typeof(String)); cols.Add("INT", typeof(String)); // Load the body foreach (NflConference c in _confList) { foreach (NFLDivision d in c.DivList) { foreach (NflTeam t in d.TeamList) { if (t.PlayerList == null) { t.LoadPlayerUnits(); } foreach (NFLPlayer p in t.PlayerList) { p.LoadPerformances(false, false, Utility.SeasonInFocus()); if (!string.IsNullOrEmpty(p.PlayerName)) { var dr = dt.NewRow(); dr["JERSEY"] = p.JerseyNo; dr["NAME"] = p.PlayerName; dr["TEAM"] = p.CurrTeam.TeamCode; dr["UNIT"] = p.Unit(); dr["ROOKIEYR"] = p.RookieYear; dr["DRAFTED"] = p.Drafted.Trim(); dr["CATEGORY"] = p.PlayerCat; dr["POSDESC"] = p.PlayerPos.Replace(",", "-"); dr["ROLE"] = p.PlayerRole; dr["OWNER"] = p.Owner; dr["AGE"] = p.PlayerAge(); dr["STARS"] = p.StarRating; dr["VALUE"] = p.Value().ToString(); dr["SCORES"] = p.Scores.ToString(); if (p.TotStats == null) { dr["RUSHES"] = "0"; dr["YDR"] = "0"; dr["AVGYDR"] = "0.0"; dr["TDR"] = "0"; dr["CATCHES"] = "0"; dr["YDC"] = "0.0"; dr["AVGYDC"] = "0"; dr["TDC"] = "0"; dr["COM"] = "0"; dr["ATTEMPTS"] = "0"; dr["YDp"] = "0"; dr["AVGYDp"] = "0.0"; dr["Tdp"] = "0"; dr["INT"] = "0"; } else { dr["RUSHES"] = p.TotStats.Rushes.ToString(); dr["YDR"] = p.TotStats.YDr.ToString(); dr["AVGYDR"] = string.Format("{0:0.0}", Utility.Average(p.TotStats.YDr, p.TotStats.Rushes)); dr["TDR"] = p.TotStats.Tdr.ToString(); dr["CATCHES"] = p.TotStats.Catches.ToString(); dr["YDC"] = p.TotStats.YDc.ToString(); dr["AVGYDC"] = string.Format("{0:0.0}", Utility.Average(p.TotStats.YDc, p.TotStats.Catches)); dr["TDC"] = p.TotStats.Tdc.ToString(); dr["COM"] = p.TotStats.Completions.ToString(); dr["ATTEMPTS"] = p.TotStats.PassAtts.ToString(); dr["YDp"] = p.TotStats.YDp.ToString(); dr["AVGYDp"] = string.Format("{0:0.0}", Utility.Average(p.TotStats.YDp, p.TotStats.Completions)); dr["Tdp"] = p.TotStats.Tdp.ToString(); dr["INT"] = p.TotStats.PassInt.ToString(); } dt.Rows.Add(dr); } } } } } str.LoadBody(dt); str.RenderAsCsv("Players", Logger); }
public string RenderProjectedData(ArrayList playerList, string sHead, [Optional] string sortOrder, IRatePlayers scorer, IWeekMaster weekMaster ) { // Output the list Utility.Announce("PlayerListing " + sHead); var r = new SimpleTableReport { ReportHeader = sHead, ReportFooter = Season, DoRowNumbers = true}; if (!string.IsNullOrEmpty(SubHeader)) r.SubHeader = SubHeader; /////////////////////////////////////////////////////////////// var ds = LoadProjectedData(playerList, scorer, weekMaster ); // <-- projection action here /////////////////////////////////////////////////////////////// r.AddColumn(new ReportColumn("Name", "NAME", "{0,-15}")); r.AddColumn(new ReportColumn("Pos", "POS", "{0,9}")); r.AddColumn(new ReportColumn("Role", "ROLE", "{0,9}")); r.AddColumn(new ReportColumn("RookieYr", "ROOKIEYR", "{0,4}")); r.AddColumn(new ReportColumn("Team", "CURRTEAM", "{0,2}")); if (ShowOpponent) { r.AddColumn(new ReportColumn("Opp", "OPPONENT", "{0,2}")); r.AddColumn(new ReportColumn("Opp", "OPPRATE", "{0,2}")); r.AddColumn(new ReportColumn("Spread", "SPREAD", "{0,5}")); } r.AddColumn(new ReportColumn("Age", "AGE", "{0,2}")); r.AddColumn(new ReportColumn("Owner", "FT", "{0,2}")); if (LongStats) { r.AddColumn(new ReportColumn("Curr", "CURSCORES", "{0,5}")); r.AddColumn(new ReportColumn("Tot", "SCORES", "{0,5}")); r.AddColumn(new ReportColumn("Avg", "AVG", "{0:0.0}")); r.AddColumn(new ReportColumn("Inj", "INJURY", "{0,5}")); r.AddColumn(new ReportColumn("YDp", "YDP", "{0,5}")); r.AddColumn(new ReportColumn("Tdp", "TDP", "{0,5}")); r.AddColumn(new ReportColumn("YDr", "YDR", "{0,5}")); r.AddColumn(new ReportColumn("Tdr", "TDR", "{0,5}")); r.AddColumn(new ReportColumn("YDc", "YDC", "{0,5}")); r.AddColumn(new ReportColumn("TDc", "TDC", "{0,5}")); r.AddColumn(new ReportColumn("Fg", "Fg", "{0,5}")); } r.AddColumn(new ReportColumn("Points", "POINTS", "{0,5}")); var dt = ds.Tables[0]; dt.DefaultView.Sort = LongStats ? (string.IsNullOrEmpty(sortOrder) ? "Points DESC" : sortOrder) : "Points DESC"; r.LoadBody(dt); // just assigns the data table FileOut = string.Format("{0}{1}.htm", Utility.OutputDirectory(), sHead); r.RenderAsHtml( FileOut, true); if (RenderToCsv) r.RenderAsCsv("Starters-" + sHead); return FileOut; }