private void populateKnockoutTables()
        {
            DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutTeams);
            int       count = 0;

            foreach (string eventName in m_selectedEventNames)
            {
                for (int i = 0; i < m_dataViews[eventName].Count; ++i)
                {
                    if (m_selectedTeams[m_currentTabNumber][eventName][i])
                    {
                        DataRow dRow = m_dataViews[eventName][i].Row;
                        int     originalTeamNumber = AccessDatabaseUtilities.getIntValue(dRow, "Team_Number");
                        string  teamName           = AccessDatabaseUtilities.getStringValue(dRow, "Team_Name");
                        string  memberNames        = AccessDatabaseUtilities.getStringValue(dRow, "Member_Names");
                        int     teamNumber         = count + 1;
                        DataRow newRow             = table.Rows[count];
                        newRow["Team_Number"]          = teamNumber;
                        newRow["Team_Name"]            = teamName;
                        newRow["Member_Names"]         = memberNames;
                        newRow["Original_Team_Number"] = originalTeamNumber;
                        newRow["Original_Event_Name"]  = eventName;
                        count++;
                    }
                }
            }
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutTeams);
        }
        private static void populateNamesTable()
        {
            DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.EventNames);
            DataTable computedScoresTable = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.EventComputedScores);
            DataTable existingTable       = m_dataSet.Tables["Names"];

            foreach (DataRow existingRow in existingTable.Rows)
            {
                DataRow dRow = table.NewRow();
                dRow["Team_Number"]  = AccessDatabaseUtilities.getIntValue(existingRow, "Number");
                dRow["Team_Name"]    = getStringValue(existingRow, "Team Name");
                dRow["Member_Names"] = getStringValue(existingRow, "Member 1 Name") + ", " +
                                       getStringValue(existingRow, "Member 2 Name") + ", " +
                                       getStringValue(existingRow, "Member 3 Name") + ", " +
                                       getStringValue(existingRow, "Member 4 Name") + ", " +
                                       getStringValue(existingRow, "Member 5 Name") + ", " +
                                       getStringValue(existingRow, "Member 6 Name");
                table.Rows.Add(dRow);
                dRow = computedScoresTable.NewRow();
                dRow["Team_Number"] = AccessDatabaseUtilities.getIntValue(existingRow, "Number");
                computedScoresTable.Rows.Add(dRow);
            }
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.EventNames);
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.EventComputedScores);
        }
Beispiel #3
0
        public String _commonPageHeader(DataRow dRow)
        {
            DateTime indianTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, Utilities.INDIAN_ZONE);
            String   result     = "Page Updated on " + indianTime.ToString() + " IST<br/>";

            result += "<a href='" + m_prefix + "leaderboard/index.html'>Round Robin Leaderboard</a>";
            result += " | <a href='" + m_prefix + "names/index.html'>Team Compositions</a><br/>";
            result += "Team Scores : ";
            DataTable table = getTable(Constants.TableName.EventNames);

            foreach (DataRow dTeamRow in table.Select("", "Team_Number ASC"))
            {
                int i = AccessDatabaseUtilities.getIntValue(dTeamRow, "Team_Number");

                //for (int i = 1; i <= m_numberOfTeams; ++i)
                //{

                result += (i == 1 ? "" : " | ") + "<a href='" + m_prefix + "teams" + "/team" + i + "score.html' title = '" + getTeamMemberNames(i) + "'>" + i + "</a>";
            }
            result += "<br/>";
            result += "Round Scores : ";
            for (int i = 1; i <= m_numberOfRounds; ++i)
            {
                result += (i == 1 ? "" : " | ") + "<a href='" + m_prefix + "rounds" + "/round" + i + "score.html'>" + i + "</a>";
            }
            return(result);
        }
Beispiel #4
0
        private void setUpMatches(int roundNumber)
        {
            DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber);
            // Overwrite existing team numbers to avoid unique value errors
            int count = -1;

            foreach (DataRow dRow in table.Rows)
            {
                dRow["Team_Number"] = count--;
            }
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber);
            DataTable previousTable = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + (roundNumber + 1));
            int       matchNumber   = 1;

            foreach (DataRow dRow in table.Rows)
            {
                DataRow[] dRows     = previousTable.Select("Match_Number = " + matchNumber);
                DataRow   winnerRow = findWinner(dRows);
                dRow["Team_Number"] = AccessDatabaseUtilities.getIntValue(winnerRow, "Team_Number");
                dRow["Team_Name"]   = AccessDatabaseUtilities.getStringValue(winnerRow, "Team_Name");
                matchNumber++;
            }
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + roundNumber);
            knockoutRoundsCombobox.SelectedIndex = roundNumber - 1;
        }
        private void getTeamsScoreWise()
        {
            string sort = "Rank_After_Round_" + m_scoreRoundNumber + " ASC, Tiebreaker_After_Round_" + m_scoreRoundNumber + " DESC";

            DataRow[] dRows = m_computedScoresTable.Select("", sort);
            int       count = 0;

            foreach (DataRow dRow in dRows)
            {
                int team = AccessDatabaseUtilities.getIntValue(dRow, "Team_Number");
                if (!LocalUtilities.hasWithdrawn(m_databaseFileName, team, m_drawRoundNumber))
                {
                    count++;
                }
            }
            m_teamNumber    = new int[count + 1];
            m_teamNumber[0] = 0;
            m_assigned      = new bool[count + 1];
            count           = 1;
            foreach (DataRow dRow in dRows)
            {
                int team = AccessDatabaseUtilities.getIntValue(dRow, "Team_Number");
                if (!LocalUtilities.hasWithdrawn(m_databaseFileName, team, m_drawRoundNumber))
                {
                    m_teamNumber[count] = team;
                    m_assigned[count]   = false;
                    count++;
                }
            }
        }
Beispiel #6
0
        private string getTeamLink(Object teamNumberObject, bool showNumber, bool showName)
        {
            string result = "";

            if (teamNumberObject == DBNull.Value)
            {
                return("-");
            }
            int       teamNumber = (int)teamNumberObject;
            DataTable table      = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutTeams);

            DataRow[] dRows = table.Select("Team_Number = " + teamNumber);
            Debug.Assert(dRows.Length == 1);
            DataRow dRow = dRows[0];
            string  originalEventName = AccessDatabaseUtilities.getStringValue(dRow, "Original_Event_Name");

            if (string.IsNullOrWhiteSpace(originalEventName))
            {
                result = "<span title='" + dRow["Member_Names"] + "' >" + (showNumber ? dRow["Team_Number"] + " " : "") + (showName ? dRow["Team_Name"] : "") + "</span>";
            }
            else
            {
                int originalTeamNumber = AccessDatabaseUtilities.getIntValue(dRow, "Original_Team_Number");
                //string webpagesRootDirectory = Path.Combine("..", "..", Constants.WebpagesFolderName, Utilities.makeIdentifier_(originalEventName));
                //string link = Path.Combine(webpagesRootDirectory, "teams", "team" + originalTeamNumber + "score.html");
                string webpagesRootDirectory = "../" + Utilities.makeIdentifier_(originalEventName);
                string link = webpagesRootDirectory + "/teams/team" + originalTeamNumber + "score.html";
                result = "<a href='" + link + "' title='" + dRow["Member_Names"] + "'>" + (showNumber ? dRow["Team_Number"] + " " : "") + (showName ? dRow["Team_Name"] : "") + "</a>";
            }
            return(result);
        }
        private void populateSwissLeagueTables(int numberOfRounds, int numberOfTeams)
        {
            DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.EventNames);
            int       count = 1;
            DataTable computedScoresTable = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.EventComputedScores);

            foreach (string eventName in m_selectedEventNames)
            {
                for (int i = 0; i < m_dataViews[eventName].Count; ++i)
                {
                    if (m_selectedTeams[m_currentTabNumber][eventName][i])
                    {
                        DataRow dRow = m_dataViews[eventName][i].Row;
                        int     originalTeamNumber = AccessDatabaseUtilities.getIntValue(dRow, "Team_Number");
                        string  teamName           = AccessDatabaseUtilities.getStringValue(dRow, "Team_Name");
                        string  memberNames        = AccessDatabaseUtilities.getStringValue(dRow, "Member_Names");
                        double  totalScore         = AccessDatabaseUtilities.getDoubleValue(dRow, "Total_Score");
                        int     teamNumber         = count;
                        DataRow newRow             = table.NewRow();
                        newRow["Team_Number"]          = keepOriginalTeamNumbersCheckbox.Checked?originalTeamNumber:teamNumber;
                        newRow["Team_Name"]            = teamName;
                        newRow["Member_Names"]         = memberNames;
                        newRow["Carryover"]            = carryoverTotalCheckbox.Checked ? totalScore : 0;
                        newRow["Original_Team_Number"] = originalTeamNumber;
                        newRow["Original_Event_Name"]  = eventName;
                        newRow["Total_Score"]          = 0;
                        newRow["Tiebreaker_Score"]     = 0;
                        newRow["Rank"] = 1;
                        table.Rows.Add(newRow);
                        newRow = computedScoresTable.NewRow();
                        newRow["Team_Number"] = keepOriginalTeamNumbersCheckbox.Checked ? originalTeamNumber : teamNumber;
                        computedScoresTable.Rows.Add(newRow);
                        count++;
                    }
                }
                DataTable scoresTable     = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.EventScores);
                int       numberOfMatches = (numberOfTeams / 2) + numberOfTeams % 2;
                for (int i = 1; i <= numberOfRounds; ++i)
                {
                    for (int j = 1; j <= numberOfMatches; ++j)
                    {
                        DataRow dRow = scoresTable.NewRow();
                        dRow["Table_Number"] = j;
                        dRow["Round_Number"] = i;
                        scoresTable.Rows.Add(dRow);
                    }
                }
            }
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.EventNames);
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.EventScores);
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.EventComputedScores);
        }
Beispiel #8
0
        private void createTeamPages()
        {
            printMessage("Creating Team Pages");
            String rootFolder = Path.Combine(m_webpagesRootDirectory, "teams");

            if (!Directory.Exists(rootFolder))
            {
                Directory.CreateDirectory(rootFolder);
            }
            DataTable table = getTable(Constants.TableName.EventNames);

            foreach (DataRow dTeamRow in table.Rows)
            {
                int i = AccessDatabaseUtilities.getIntValue(dTeamRow, "Team_Number");
                createTeamPage(i);
            }
        }
        private void getTeamsNumberWise()
        {
            string filterExpression = "Withdraw_Round is null OR WithDraw_Round > " + m_drawRoundNumber;
            string sort             = "Team_Number ASC";

            DataRow[] dRows = m_namesTable.Select(filterExpression, sort);
            m_teamNumber    = new int[dRows.Length + 1];
            m_teamNumber[0] = 0;
            m_assigned      = new bool[dRows.Length + 1];
            int count = 1;

            foreach (DataRow dRow in dRows)
            {
                m_teamNumber[count] = AccessDatabaseUtilities.getIntValue(dRow, "Team_Number");
                m_assigned[count]   = false;
                count++;
            }
        }
        private static void populateScoresTable()
        {
            DataTable table         = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.EventScores);
            DataTable existingTable = m_dataSet.Tables["Scores"];

            foreach (DataRow existingRow in existingTable.Rows)
            {
                DataRow dRow = table.NewRow();
                dRow["Round_Number"]         = AccessDatabaseUtilities.getIntValue(existingRow, "Round Number");
                dRow["Table_Number"]         = AccessDatabaseUtilities.getIntValue(existingRow, "Table Number");
                dRow["Team_1_Number"]        = AccessDatabaseUtilities.getIntValue(existingRow, "Team 1 Number");
                dRow["Team_2_Number"]        = AccessDatabaseUtilities.getIntValue(existingRow, "Team 2 Number");
                dRow["Team_1_VPs"]           = AccessDatabaseUtilities.getDoubleValue(existingRow, "Team 1 VPs");
                dRow["Team_2_VPs"]           = AccessDatabaseUtilities.getDoubleValue(existingRow, "Team 2 VPs");
                dRow["Team_1_VP_Adjustment"] = -1 * AccessDatabaseUtilities.getDoubleValue(existingRow, "Team 1 Adjustment");
                dRow["Team_2_VP_Adjustment"] = -1 * AccessDatabaseUtilities.getDoubleValue(existingRow, "Team 2 Adjustment");
                table.Rows.Add(dRow);
            }
            AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.EventScores);
        }
        public void initializeMatches()
        {
            DataTable teamsTable = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutTeams);

            for (int i = 1; i <= numberOfRounds; ++i)
            {
                DataTable table           = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + i);
                int       totalTeams      = Convert.ToInt32(Math.Pow(2, i));
                int       numberOfMatches = totalTeams / 2;
                for (int j = 1; j <= numberOfMatches; ++j)
                {
                    DataRow   team1Row = teamsTable.Rows[j - 1];
                    DataRow   team2Row = teamsTable.Rows[totalTeams - j];
                    DataRow[] dRows    = table.Select("Match_Number = " + j);
                    Debug.Assert(dRows.Length == 2);
                    dRows[0]["Team_Number"] = AccessDatabaseUtilities.getIntValue(team1Row, "Team_Number");
                    dRows[0]["Team_Name"]   = AccessDatabaseUtilities.getStringValue(team1Row, "Team_Name");
                    dRows[1]["Team_Number"] = AccessDatabaseUtilities.getIntValue(team2Row, "Team_Number");
                    dRows[1]["Team_Name"]   = AccessDatabaseUtilities.getStringValue(team2Row, "Team_Name");
                }
                AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + i);
            }
        }
 private int getIntValue(DataRow dRow, string columnName)
 {
     return(AccessDatabaseUtilities.getIntValue(dRow, columnName));
 }
Beispiel #13
0
        private void createTeamPage(int teamNumber)
        {
            printMessage("Creating Team Page for Team Number : " + teamNumber);
            m_prefix = "../";
            StreamWriter sw = new StreamWriter(Path.Combine(m_webpagesRootDirectory, "teams", "team" + teamNumber + "score.html"));

            sw.WriteLine("<html><head></head><body>");
            DataRow dRow           = getTable(Constants.TableName.EventNames).Rows.Find(teamNumber);
            string  headerTemplate = "<h2>Scores for " + teamNumber + " : {Team_Name} ({Member_Names})</h2>";

            headerTemplate += "<h3>Carryover : {Carryover}</h3>";
            sw.WriteLine(applyTemplate_(headerTemplate, dRow));
            string originalEventName = AccessDatabaseUtilities.getStringValue(dRow, "Original_Event_Name");

            if (!string.IsNullOrWhiteSpace(originalEventName))
            {
                int    originalTeamNumber    = AccessDatabaseUtilities.getIntValue(dRow, "Original_Team_Number");
                string webpagesRootDirectory = "../../" + Utilities.makeIdentifier_(originalEventName);
                string link = webpagesRootDirectory + "/teams" + "/team" + originalTeamNumber + "score.html";
                sw.WriteLine("<a href='" + link + "' title='" + dRow["Member_Names"] + "'>Previous Round Scores for this team</a>");
            }
            headerTemplate = "<br/>[_commonPageHeader]";
            sw.WriteLine(applyTemplate_(headerTemplate, dRow));

            sw.WriteLine(Utilities.makeTablePreamble_() + "<thead><tr>");
            ArrayList tableHeader = new ArrayList();

            tableHeader.Add("Round");
            tableHeader.Add("Opponent");
            tableHeader.Add("VPs");
            tableHeader.Add("Adjustment");
            tableHeader.Add("Cumulative Score After Round");
            tableHeader.Add("Rank After Round");
            sw.WriteLine(Utilities.makeTableHeader_(tableHeader) + "</tr></thead><tbody>");
            int withdrawnRound = getIntValue(dRow, "Withdraw_Round");

            if (withdrawnRound < 1)
            {
                withdrawnRound = m_roundsCompleted + 1;
            }
            for (int i = 1; i < withdrawnRound; ++i)
            {
                ArrayList tableRow = new ArrayList();
                tableRow.Add(getRoundNumberLink(i));
                DataRow[] foundRows = getTable(Constants.TableName.EventScores).Select("Round_Number = " + i + " AND Team_1_Number = " + teamNumber);
                if (foundRows.Length > 0)
                {
                    dRow = foundRows[0];
                    tableRow.Add("" + getTeamLink(dRow["Team_2_Number"], true, true));
                    tableRow.Add("" + getDoubleValue(dRow, "Team_1_VPs"));
                    tableRow.Add("" + getDoubleValue(dRow, "Team_1_VP_Adjustment"));
                }
                else
                {
                    foundRows = getTable(Constants.TableName.EventScores).Select("Round_Number = " + i + " AND Team_2_Number = " + teamNumber);
                    if (foundRows.Length < 1)
                    {
                        tableRow.Add("-");
                        tableRow.Add("-");
                        tableRow.Add("-");
                    }
                    else
                    {
                        dRow = foundRows[0];
                        tableRow.Add("" + getTeamLink(dRow["Team_1_Number"], true, true));
                        tableRow.Add("" + getDoubleValue(dRow, "Team_2_VPs"));
                        tableRow.Add("" + getDoubleValue(dRow, "Team_2_VP_Adjustment"));
                    }
                }
                foundRows = getTable(Constants.TableName.EventComputedScores).Select("Team_Number = " + teamNumber);
                Debug.Assert(foundRows.Length <= 1);
                if (foundRows.Length < 1)
                {
                    tableRow.Add("-");
                    tableRow.Add("-");
                }
                else
                {
                    dRow = foundRows[0];
                    string columnName = "Score_After_Round_" + i;
                    if (dRow.Table.Columns.Contains(columnName))
                    {
                        tableRow.Add("" + getDoubleValue(dRow, columnName));
                    }
                    else
                    {
                        tableRow.Add("-");
                    }
                    columnName = "Rank_After_Round_" + i;
                    if (dRow.Table.Columns.Contains(columnName))
                    {
                        tableRow.Add("" + getDoubleValue(dRow, columnName));
                    }
                    else
                    {
                        tableRow.Add("-");
                    }
                }
                sw.WriteLine("<tr>" + Utilities.makeTableCell_(tableRow, i) + "</tr>");
            }
            for (int i = withdrawnRound; i <= m_roundsCompleted; ++i)
            {
                ArrayList tableRow = new ArrayList();
                tableRow.Add("" + i);
                tableRow.Add("WITHDRAWN");
                tableRow.Add("-");
                tableRow.Add("-");
                tableRow.Add("-");
                tableRow.Add("-");
                sw.WriteLine("<tr>" + Utilities.makeTableCell_(tableRow, i) + "</tr>");
            }
            for (int i = m_roundsCompleted + 1; i <= m_numberOfRounds; ++i)
            {
                ArrayList tableRow = new ArrayList();
                tableRow.Add("" + i);
                tableRow.Add("-");
                tableRow.Add("-");
                tableRow.Add("-");
                tableRow.Add("-");
                tableRow.Add("-");
                sw.WriteLine("<tr>" + Utilities.makeTableCell_(tableRow, i) + "</tr>");
            }
            sw.WriteLine("</tbody></table>");
            sw.WriteLine("</body></html>");
            sw.Close();
            reportProgress("Created Team " + teamNumber + " Score Page");
        }