public String _makeOpponentLink(DataRow dRow)
        {
            String sectionName = PairsGeneral.findOtherSectionName("" + dRow["Section_Name"]);
            int    pairNumber  = Convert.ToInt16(dRow["Opponent"]);

            return("<a href='" + m_prefix + Utilities.makeIdentifier_(sectionName) + "/pair" + pairNumber + "score.html'>" + pairNumber + ". " + findPairNames_(sectionName, pairNumber) + "</a>");
        }
 private void addBoardWiseScoresRow(int boardNumber, String dealer, String vul,
                                    String sectionName, int pairNumber, String direction, int opponent,
                                    String result, String score, String datum, bool update = false)
 {
     if (!update)
     {
         Object[] keys = new Object[3];
         keys[0] = boardNumber;
         keys[1] = sectionName;
         keys[2] = pairNumber;
         DataRow dRow    = m_databaseParameters.m_ds.Tables["Board_Wise_Scores"].Rows.Find(keys);
         bool    addFlag = false;
         if (dRow == null)
         {
             addFlag = true;
             dRow    = m_databaseParameters.m_ds.Tables["Board_Wise_Scores"].NewRow();
         }
         dRow["Section_Name"]  = sectionName;
         dRow["Pair_Number"]   = pairNumber;
         dRow["Direction"]     = direction;
         dRow["Board_Number"]  = boardNumber;
         dRow["Opponent"]      = opponent;
         dRow["Result"]        = result;
         dRow["Score"]         = score;
         dRow["Datum"]         = datum;
         dRow["Dealer"]        = dealer;
         dRow["Vulnerability"] = vul;
         if (addFlag)
         {
             m_databaseParameters.m_ds.Tables["Board_Wise_Scores"].Rows.Add(dRow);
         }
     }
     else
     {
         Object[] keys = new Object[3];
         keys[0] = boardNumber;
         keys[1] = PairsGeneral.findOtherSectionName(sectionName);
         keys[2] = opponent;
         DataRow dRow = m_databaseParameters.m_ds.Tables["Board_Wise_Scores"].Rows.Find(keys);
         if (dRow == null)
         {
             return;
         }
         dRow["Opponent_Score"]  = score;
         dRow["Opponent_Result"] = result;
     }
 }
Beispiel #3
0
        public static PairsEventInformation getEventInformation_(string text)
        {
            m_eventInformation         = PairsGeneral.createDefaultEventInformation();
            m_eventInformation.rawText = text;
            String patternString = "Summary\\s*for\\s*Pair";

            if (!Utilities.containsPattern_(text, patternString))
            {
                m_eventInformation.isACBLSummary = false;
                return(m_eventInformation);
            }
            else
            {
                m_eventInformation.isACBLSummary = true;
            }
            patternString = "BRD\\s*DLR\\s*VUL\\s*DIR\\s*VS\\s*RESULT\\s*SCORE\\s*DATUM";
            if (Utilities.containsPattern_(text, patternString))
            {
                setSummaryInfo_(isIMP: true, hasDirectionField: true); return(m_eventInformation);
            }
            patternString = "BRD\\s*DLR\\s*VUL\\s*VS\\s*RESULT\\s*SCORE\\s*DATUM";
            if (Utilities.containsPattern_(text, patternString))
            {
                setSummaryInfo_(isIMP: true, hasDirectionField: false); return(m_eventInformation);
            }
            patternString = "BRD\\s*DLR\\s*VUL\\s*DIR\\s*VS\\s*RESULT\\s*SCORE";
            if (Utilities.containsPattern_(text, patternString))
            {
                setSummaryInfo_(isIMP: false, hasDirectionField: true); return(m_eventInformation);
            }
            patternString = "BRD\\s*DLR\\s*VUL\\s*VS\\s*RESULT\\s*SCORE";
            if (Utilities.containsPattern_(text, patternString))
            {
                setSummaryInfo_(isIMP: false, hasDirectionField: false); return(m_eventInformation);
            }
            return(m_eventInformation);
        }
        private void loadSummaryIntoDatabaseInternal()
        {
            m_databaseParameters = PairsGeneral.createDefaultDatabaseParameters();
            System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(m_eventInformation.databaseFileName));
            System.IO.File.Delete(m_eventInformation.databaseFileName);
            String sourceFileName = System.IO.Path.Combine(Globals.m_rootDirectory, "Databases", "PairsScoreDatabaseTemplate.mdb");

            System.IO.File.Copy(sourceFileName, m_eventInformation.databaseFileName);
            PairsGeneral.loadPairsDatabaseInformation(m_eventInformation.databaseFileName, out m_databaseParameters);
            printMessage("Updating Event Information...");
            reportProgress(0, "Reading Event Information");
            DataTable eventInfoTable = m_databaseParameters.m_ds.Tables["Event_Information"];

            eventInfoTable.Clear();
            DataRow dRow = eventInfoTable.NewRow();

            dRow["ID"]                  = 1;
            dRow["ACBL_Summary"]        = m_eventInformation.isACBLSummary;
            dRow["Has_Direction_Field"] = m_eventInformation.hasDirectionField;
            dRow["Scoring_Type"]        = m_eventInformation.isIMP ? "IMP" : "MP";
            dRow["Event_Name"]          = m_eventInformation.eventName;
            dRow["Event_Date"]          = m_eventInformation.eventDate.ToString();
            eventInfoTable.Rows.Add(dRow);
            printMessage("Uploading Event Information Table to Database...");
            m_databaseParameters.m_daEventInformation.Update(m_databaseParameters.m_ds, "Event_Information");
            reportProgress(10, "Processing Summaries");
            printMessage("Processing Summaries...");
            String[] lines = m_eventInformation.rawText.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            if (lines.Length < 2)
            {
                lines = m_eventInformation.rawText.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
            }
            int lineNumber = getNextSummaryLine_(lines, 0);

            while (lineNumber < lines.Length && lineNumber != -1)
            {
                lineNumber = processOneSummary_(lines, lineNumber, false);
                lineNumber = getNextSummaryLine_(lines, lineNumber);
            }
            lineNumber = getNextSummaryLine_(lines, 0);
            while (lineNumber < lines.Length && lineNumber != -1)
            {
                lineNumber = processOneSummary_(lines, lineNumber, true);
                lineNumber = getNextSummaryLine_(lines, lineNumber);
            }

            reportProgress(50, "Calculating Scores");
            printMessage("Calculating Ranks...");
            // Combined Ranking
            doRanking_();
            // Section Ranking
            if (m_eventInformation.hasDirectionField)
            {
                doRanking_(PairsGeneral.SINGLE_SECTION_NAME, "Session_Rank");
            }
            else
            {
                doRanking_(PairsGeneral.NORTH_SOUTH_SECTION_NAME, "Session_Rank");
                doRanking_(PairsGeneral.EAST_WEST_SECTION_NAME, "Session_Rank");
            }
            reportProgress(75, "Saving to database");
            printMessage("Uploading Pair Information Table to Database...");
            m_databaseParameters.m_daPairInformation.Update(m_databaseParameters.m_ds, "Pair_Information");
            printMessage("Uploading Pair Wise Scores Table to Database...");
            m_databaseParameters.m_daPairWiseScores.Update(m_databaseParameters.m_ds, "Pair_Wise_Scores");
            printMessage("Uploading Board Wise Scores Table to Database...");
            m_databaseParameters.m_daBoardWiseScores.Update(m_databaseParameters.m_ds, "Board_Wise_Scores");
            printMessage("Finished Creating Database.");
        }