public Team(int iTeamID) { SQLDatabaseAccess SQLDBA = new SQLDatabaseAccess(); SqlParameter[] sqlParam = new SqlParameter[1]; SqlDataReader sqlDR; SQLDBA.Open(); sqlParam[0] = SQLDBA.CreateParameter("@FranchiseID", SqlDbType.Int, 64, ParameterDirection.Input, iTeamID); SQLDBA.ExecuteSqlSP("Select_Team", sqlParam, out sqlDR); if (sqlDR.HasRows) { sqlDR.Read(); franchiseID = int.Parse(SQLDBA.sqlGet(sqlDR, "FranchiseID")); city = SQLDBA.sqlGet(sqlDR, "City"); mascot = SQLDBA.sqlGet(sqlDR, "Mascot"); abbreviation = SQLDBA.sqlGet(sqlDR, "Abbreviation"); ScoreList = new ArrayList(); score = "0"; } SQLDBA.Close(); sqlDR.Close(); SQLDBA.Dispose(); sqlDR.Dispose(); }
public ArrayList ScoreList; // The amount of wins/points this team has over every other team in the league /*************************************************************************************** * Team::Team * * PARAMETERS * * int iTeamID * The team's Franchise ID. * * string cbLeague * The league this team is a member of * * PURPOSE * * This Constructor requires a franchise ID and a league marker that will allow us to * look up data about the team from the database. * * ************************************************************************************/ public Team(int iTeamID, string cbLeague) { SQLDatabaseAccess SQLDBA = new SQLDatabaseAccess(); SqlParameter[] sqlParam = new SqlParameter[1]; SqlDataReader sqlDR; SQLDBA.Open(); sqlParam[0] = SQLDBA.CreateParameter("@FranchiseID", SqlDbType.Int, 64, ParameterDirection.Input, iTeamID); if (cbLeague == "NCAAF") { SQLDBA.ExecuteSqlSP("Select_CFTeam", sqlParam, out sqlDR); } else if (cbLeague == "BBTC") { SQLDBA.ExecuteSqlSP("Select_BBTeam", sqlParam, out sqlDR); } else { SQLDBA.ExecuteSqlSP("Select_Team", sqlParam, out sqlDR); } // Select the team's data from the database if (sqlDR.HasRows) { // Populate retrieved data into the member variables sqlDR.Read(); franchiseID = int.Parse(SQLDBA.sqlGet(sqlDR, "FranchiseID")); city = SQLDBA.sqlGet(sqlDR, "City"); mascot = SQLDBA.sqlGet(sqlDR, "Mascot"); abbreviation = SQLDBA.sqlGet(sqlDR, "Abbreviation"); conference = SQLDBA.sqlGet(sqlDR, "Conference"); division = SQLDBA.sqlGet(sqlDR, "Division"); shortabbrev = SQLDBA.sqlGet(sqlDR, "RefAbbr"); ScoreList = new ArrayList(); } SQLDBA.Close(); sqlDR.Close(); SQLDBA.Dispose(); sqlDR.Dispose(); }
static void appendYear(string sLeague, string sYear) { //Add in cancelled 2004 NHL season before the 2005 season if (sLeague == "NHL" && sYear == "2005") { sbFileList.Append("$filearray[\"" + sLeague + "\"][\"2004\"] = array(\"Season Cancelled\");\n"); } SQLDatabaseAccess SQLDBA = new SQLDatabaseAccess(); SqlParameter[] sqlParam = new SqlParameter[2]; SqlDataReader sqlDR; ArrayList alWeeks = new ArrayList(); int iCount = 0; SQLDBA.Open(); sqlParam[0] = SQLDBA.CreateParameter("@Year", SqlDbType.NVarChar, 50, ParameterDirection.Input, sYear); sqlParam[1] = SQLDBA.CreateParameter("@League", SqlDbType.NVarChar, 50, ParameterDirection.Input, sLeague); SQLDBA.ExecuteSqlSP("Select_Weeks", sqlParam, out sqlDR); sbFileList.Append("$filearray[\"" + sLeague + "\"][\"" + sYear + "\"] = array("); if (sqlDR.HasRows) { while (sqlDR.Read()) { alWeeks.Add(SQLDBA.sqlGet(sqlDR, "RangeID")); } alWeeks.Reverse(); } foreach (string sWeek in alWeeks) { if (iCount == 0) { sbFileList.Append(sWeek); } else { sbFileList.Append(", " + sWeek); } iCount++; } sbFileList.Append(");\n"); sqlDR.Close(); sqlDR.Dispose(); SQLDBA.Close(); SQLDBA.Dispose(); }
static void appendSeason(string sLeague) { SQLDatabaseAccess SQLDBA = new SQLDatabaseAccess(); SqlParameter[] sqlParam = new SqlParameter[1]; SqlDataReader sqlDR; int iCount = 0; SQLDBA.Open(); sqlParam[0] = SQLDBA.CreateParameter("@League", SqlDbType.NVarChar, 50, ParameterDirection.Input, sLeague); SQLDBA.ExecuteSqlSP("Select_Seasons", sqlParam, out sqlDR); sbFileList.Append("\n"); sbFileList.Append("$filearray[\"" + sLeague + "\"] = array("); if (sqlDR.HasRows) { while (sqlDR.Read()) { if (alLeagues.IndexOf(sLeague) != -1) { ((ArrayList)alSeasons[alLeagues.IndexOf(sLeague)]).Add(SQLDBA.sqlGet(sqlDR, "Year")); if (iCount == 0) { sbFileList.Append("\"" + SQLDBA.sqlGet(sqlDR, "Year") + "\" => array()"); } else { sbFileList.Append(",\n\"" + SQLDBA.sqlGet(sqlDR, "Year") + "\" => array()"); } iCount++; //Add in cancelled 2004 NHL season if (sLeague == "NHL" && SQLDBA.sqlGet(sqlDR, "Year") == "2003") { sbFileList.Append(",\n\"2004\" => array()"); } } } } sbFileList.Append(");\n\n"); sqlDR.Close(); sqlDR.Dispose(); SQLDBA.Close(); SQLDBA.Dispose(); }
static void listLeagues() { SQLDatabaseAccess SQLDBA = new SQLDatabaseAccess(); SqlDataReader sqlDR; int iCount = 0; SQLDBA.Open(); SQLDBA.ExecuteSqlSP("Select_Leagues", out sqlDR); sbFileList.Append("<?\n\n"); sbFileList.Append("$filearray = array("); if (sqlDR.HasRows) { while (sqlDR.Read()) { alLeagues.Add(SQLDBA.sqlGet(sqlDR, "League")); alSeasons.Add(new ArrayList()); if (iCount == 0) { sbFileList.Append("\"" + SQLDBA.sqlGet(sqlDR, "League") + "\" => array()"); } else { sbFileList.Append(",\n\"" + SQLDBA.sqlGet(sqlDR, "League") + "\" => array()"); } iCount++; } } sbFileList.Append(");\n"); sqlDR.Close(); sqlDR.Dispose(); SQLDBA.Close(); SQLDBA.Dispose(); foreach (string sLeague in alLeagues) { appendSeason(sLeague); } iCount = 0; foreach (string sLeague in alLeagues) { sbFileList.Append("\n"); foreach (string sYear in ((ArrayList)alSeasons[iCount])) { appendYear(sLeague, sYear); } iCount++; } sbFileList.Append("\n?>"); TextWriter twOut = new StreamWriter(sFilePath + "/filelist.php", false); twOut.Write(sbFileList.ToString()); twOut.Close(); Console.WriteLine("Uploading Filelist"); FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://ftp.hawkflightstudios.com/beatgraphs.com/filelist.php"); request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential("thoraxcs", "Ih8ppl"); byte[] fileContents = File.ReadAllBytes(sFilePath + "/filelist.php"); Stream requestStream = request.GetRequestStream(); requestStream.Write(fileContents, 0, fileContents.Length); requestStream.Close(); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); Console.WriteLine("Upload Filelist Complete, status {0}" + response.StatusDescription); response.Close(); }
static void Main(string[] args) { SQLDatabaseAccess SQLDBA = new SQLDatabaseAccess(); SqlDataReader sqlDR; int maxrange; //sFilePath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); sFilePath = @"C:\WebSites\www.beatgraphs.com\"; /* EVENT LOGGING */ string sSource = "BGraphs"; string sLog = "BGraphsLog"; EventSourceCreationData escdSource = new EventSourceCreationData(sSource, sLog); escdSource.MachineName = "."; eLog = new EventLog(); if (!EventLog.SourceExists(sSource, escdSource.MachineName)) { EventLog.CreateEventSource(escdSource); } eLog.Source = sSource; eLog.WriteEntry("Runner job started.", EventLogEntryType.Information, 0, (short)0); SQLDBA.Open(); SQLDBA.ExecuteSqlSP("Select_RegSeason_Graphs", out sqlDR); if (sqlDR.HasRows) { while (sqlDR.Read()) { league = SQLDBA.sqlGet(sqlDR, "League"); year = SQLDBA.sqlGet(sqlDR, "Year"); maxrange = int.Parse(SQLDBA.sqlGet(sqlDR, "LastWeek")); if (league == "MLB") { if (strSeasonMLB == "") { strSeasonMLB = year; } else if (strSeasonMLB != year) { continue; } } if (league == "NBA") { if (strSeasonNBA == "") { strSeasonNBA = year; } else if (strSeasonNBA != year) { continue; } } if (league == "NFL") { if (strSeasonNFL == "") { strSeasonNFL = year; } else if (strSeasonNFL != year) { continue; } } if (league == "NHL") { if (strSeasonNHL == "") { strSeasonNHL = year; } else if (strSeasonNHL != year) { continue; } } if (league == "NCAAF") { if (strSeasonNCAAF == "") { strSeasonNCAAF = year; } else if (strSeasonNCAAF != year) { continue; } } //if (league == "NCAAF") //Use this to exclude a league or run a specific league from the run // continue; //for (int i = 1; i <= maxrange; i++) //Use this to run the entire season for (int i = maxrange; i <= maxrange; i++) //Use this to run just the latest week, this is for everyday runs. { Process pBuilder = new Process(); pBuilder.StartInfo.FileName = @"C:\WebSites\www.beatgraphs.com\Code\BGBuilder\BGBuilder\bin\Debug\BGBuilder.exe"; pBuilder.StartInfo.Arguments = "-l " + league + " -s " + year + " -r " + i + " -m S"; Console.WriteLine(@"C:\WebSites\www.beatgraphs.com\Code\BGBuilder\BGBuilder\bin\Debug\BGBuilder.exe -l " + league + " -s " + year + " -r " + i + " -m S"); try { pBuilder.StartInfo.RedirectStandardOutput = true; pBuilder.StartInfo.UseShellExecute = false; pBuilder.StartInfo.CreateNoWindow = true; pBuilder.Start(); pBuilder.WaitForExit(); } catch (Exception ex) { Console.WriteLine("Failed: " + ex.Message); eLog.WriteEntry("Builder job failed (Standard): " + ex.Message, EventLogEntryType.Error, 0, (short)0); } pBuilder.StartInfo.Arguments = "-l " + league + " -s " + year + " -r " + i + " -m I"; Console.WriteLine(@"C:\WebSites\www.beatgraphs.com\Code\BGBuilder\BGBuilder\bin\Debug\BGBuilder.exe -l " + league + " -s " + year + " -r " + i + " -m I"); try { pBuilder.Start(); pBuilder.WaitForExit(); } catch (Exception ex) { Console.WriteLine("Failed: " + ex.Message); eLog.WriteEntry("Builder job failed (Iterative): " + ex.Message, EventLogEntryType.Error, 0, (short)0); } pBuilder.StartInfo.Arguments = "-l " + league + " -s " + year + " -r " + i + " -m W"; Console.WriteLine(@"C:\WebSites\www.beatgraphs.com\Code\BGBuilder\BGBuilder\bin\Debug\BGBuilder.exe -l " + league + " -s " + year + " -r " + i + " -m W"); try { pBuilder.Start(); pBuilder.WaitForExit(); } catch (Exception ex) { Console.WriteLine("Failed: " + ex.Message); eLog.WriteEntry("Builder job failed (Weighted): " + ex.Message, EventLogEntryType.Error, 0, (short)0); } } } } SQLDBA.Close(); sqlDR.Close(); SQLDBA.Dispose(); sqlDR.Dispose(); runPlayoffs(); listLeagues(); printFooter(); uploadTop5s(); eLog.WriteEntry("RUNNER COMPLETED.", EventLogEntryType.Information, 0, (short)0); }
static void runPlayoffs() { SQLDatabaseAccess SQLDBA = new SQLDatabaseAccess(); SqlDataReader sqlDR; int minrange, maxrange; SQLDBA.Open(); SQLDBA.ExecuteSqlSP("Select_Playoff_Graphs", out sqlDR); if (sqlDR.HasRows) { while (sqlDR.Read()) { league = SQLDBA.sqlGet(sqlDR, "League"); year = SQLDBA.sqlGet(sqlDR, "Year"); minrange = int.Parse(SQLDBA.sqlGet(sqlDR, "FirstWeek")); maxrange = int.Parse(SQLDBA.sqlGet(sqlDR, "LastWeek")); if (league == "MLB") { if (strSeasonMLB != year) { continue; } } if (league == "NBA") { if (strSeasonNBA != year) { continue; } } if (league == "NFL") { if (strSeasonNFL != year) { continue; } } if (league == "NHL") { if (strSeasonNHL != year) { continue; } } if (league == "NCAAF") { continue; // Bowl games are not marked as playoff games. They use a regular week count for the entire season. } //for (int i = 501; i <= maxrange; i++) // Use this to generate all weeks. for (int i = maxrange; i <= maxrange; i++) // Use this to run just the last week, used for every day runs { Process pBuilder = new Process(); pBuilder.StartInfo.FileName = @"C:\WebSites\www.beatgraphs.com\Code\BGBuilder\BGBuilder\bin\Debug\BGBuilder.exe"; pBuilder.StartInfo.Arguments = "-l " + league + " -s " + year + " -r " + i + " -m S"; Console.WriteLine(@"C:\WebSites\www.beatgraphs.com\Code\BGBuilder\BGBuilder\bin\Debug\BGBuilder.exe -l " + league + " -s " + year + " -r " + i + " -m S"); try { pBuilder.StartInfo.RedirectStandardOutput = true; pBuilder.StartInfo.UseShellExecute = false; pBuilder.StartInfo.CreateNoWindow = true; pBuilder.Start(); pBuilder.WaitForExit(); } catch (Exception ex) { Console.WriteLine("Failed: " + ex.Message); eLog.WriteEntry("Builder job failed (Standard Playoffs): " + ex.Message, EventLogEntryType.Error, 0, (short)0); } pBuilder.StartInfo.Arguments = "-l " + league + " -s " + year + " -r " + i + " -m I"; Console.WriteLine(@"C:\WebSites\www.beatgraphs.com\Code\BGBuilder\BGBuilder\bin\Debug\BGBuilder.exe -l " + league + " -s " + year + " -r " + i + " -m I"); try { pBuilder.Start(); pBuilder.WaitForExit(); } catch (Exception ex) { Console.WriteLine("Failed: " + ex.Message); eLog.WriteEntry("Builder job failed (Iterative Playoffs): " + ex.Message, EventLogEntryType.Error, 0, (short)0); } pBuilder.StartInfo.Arguments = "-l " + league + " -s " + year + " -r " + i + " -m W"; Console.WriteLine(@"C:\WebSites\www.beatgraphs.com\Code\BGBuilder\BGBuilder\bin\Debug\BGBuilder.exe -l " + league + " -s " + year + " -r " + i + " -m W"); try { pBuilder.Start(); pBuilder.WaitForExit(); } catch (Exception ex) { Console.WriteLine("Failed: " + ex.Message); eLog.WriteEntry("Builder job failed (Weighted Playoffs): " + ex.Message, EventLogEntryType.Error, 0, (short)0); } } } } SQLDBA.Close(); sqlDR.Close(); SQLDBA.Dispose(); sqlDR.Dispose(); }