private void writeAdjustmentDaily(AdjustmentsDailyDO oAdjustmentsDaily, DateTime GameDate, string LeagueName, int RotNum, string Team, double AdjustmentAmount) { AdjustmentsDailyDTO oAdjustmentsDailyDTO = new AdjustmentsDailyDTO() { LeagueName = LeagueName , GameDate = GameDate , RotNum = RotNum , Team = Team , AdjustmentAmount = AdjustmentAmount }; oAdjustmentsDaily.InsertRow(oAdjustmentsDailyDTO); }
//string QueryAdjustmentsSql = "" // + "SELECT * FROM Adjustments " // + $" WHERE LeagueName = '{LeagueName}' " // + $" AND ((Type = 'L' AND StartDate <= #{GameDate}# AND (EndDate IS NULL or EndDate >= #{GameDate}#) ) " // + $" Or (StartDate <= #{GameDate}# AND (EndDate IS NULL or EndDate >= #{GameDate}#) ) AND AdjAmt <> 0 ) " // + " ORDER BY Type DESC ;" // ; //string QueryString = "SqlCommand=Select&SQL=" + VBFunctions.URLEncode(QueryAdjustmentsSql); //String url = "http://bball.com.violet.arvixe.com/ExecSql2.aspx"; //WebPageGet oWebPageGet = new WebPageGet(); //oWebPageGet.NewWebPagePost(url, QueryString); //string xmlString = oWebPageGet.Html; //// Simple deserialization of XML to C# object - http://www.janholinka.net/Blog/Article/11 //StringReader stringReader = new StringReader(xmlString); //XmlSerializer serializer = new XmlSerializer(typeof(List<Row>), new XmlRootAttribute("SQLrows")); //List<Row> adjList = (List<Row>)serializer.Deserialize(stringReader); //List<Row> SortedAdjList = adjList.OrderBy(o => o.Team).ToList(); public void ProcessDailyAdjustments(DateTime GameDate, string LeagueName) { DateTime LoadDateTime = DateTime.Now; string _strLoadDateTime = LoadDateTime.ToString(); SortedList <string, CoversDTO> ocRotation = new SortedList <string, CoversDTO>(); populateRotation(ocRotation, GameDate, _ConnectionString, _strLoadDateTime); if (ocRotation.Count == 0) { return; // No Games for GameDate } List <string> Teams = new List <string>(); foreach (var matchup in ocRotation) { CoversDTO oCoversDTO = matchup.Value; Teams.Add(oCoversDTO.TeamAway); Teams.Add(oCoversDTO.TeamHome); } DeleteAdjustments(GameDate, LeagueName); List <Row> SortedAdjList = getAdjustmentsFromWeb(GameDate, LeagueName); double ctrLgAdj = 0; foreach (Row adjRow in SortedAdjList) { if (adjRow.Type == "L") { ctrLgAdj += adjRow.AdjAmt; } else if (Teams.SingleOrDefault(s => s == adjRow.Team) == null) // If Team not in list, they don't play today, so bypass { continue; } writeAdjustment(adjRow); } AdjustmentsDailyDO oAdjustmentsDaily = new AdjustmentsDailyDO(_ConnectionString); oAdjustmentsDaily.DeleteDailyAdjustments(GameDate, LeagueName); foreach (var matchup in ocRotation) { CoversDTO oCoversDTO = matchup.Value; string[] teams = new string[] { oCoversDTO.TeamAway, oCoversDTO.TeamHome }; int RotNum = oCoversDTO.RotNum; for (int ixVenue = 0; ixVenue < 2; ixVenue++) { double ctrTeamAdj = ctrLgAdj; foreach (Row r in SortedAdjList) { if (r.Team == teams[ixVenue]) { ctrTeamAdj += r.AdjAmt; } } // loop adj rows writeAdjustmentDaily(oAdjustmentsDaily, GameDate, LeagueName, RotNum, teams[ixVenue], ctrTeamAdj); RotNum++; } // foreach Venue } // foreach matchup } // ProcessDailyAdjustments