public SiteSetup(SiteDetails details)
        {
            InitializeComponent();
            foreach (SiteName.Values s in Enum.GetValues(typeof(SiteName.Values)))
            {
                if (HandHistoryParserFactory.HasHandHistoryParserFactory(s))
                {
                    PokerSites.Items.Add(new SiteName(s));
                }
            }

            HandHistoryLocation.Text       = details.HandsLocation;
            TournamentSummaryLocation.Text = details.TournamentsLocation;
        }
 List<IHandHistoryParser> GetAllParsers()
 {
     return new List<IHandHistoryParser>()
     {
         HandHistoryParserFactory.GetHandHistoryParserFactory(SiteName.Values.Entraction).HandHistoryParser,
         HandHistoryParserFactory.GetHandHistoryParserFactory(SiteName.Values.FullTilt).HandHistoryParser,
         HandHistoryParserFactory.GetHandHistoryParserFactory(SiteName.Values.Pacific).HandHistoryParser,
         HandHistoryParserFactory.GetHandHistoryParserFactory(SiteName.Values.PartyPoker).HandHistoryParser,
         HandHistoryParserFactory.GetHandHistoryParserFactory(SiteName.Values.PokerStars).HandHistoryParser,
         HandHistoryParserFactory.GetHandHistoryParserFactory(SiteName.Values.OnGame).HandHistoryParser,
         HandHistoryParserFactory.GetHandHistoryParserFactory(SiteName.Values.Merge).HandHistoryParser,
         HandHistoryParserFactory.GetHandHistoryParserFactory(SiteName.Values.MicroGaming).HandHistoryParser,
         HandHistoryParserFactory.GetHandHistoryParserFactory(SiteName.Values.IPoker).HandHistoryParser,
         HandHistoryParserFactory.GetHandHistoryParserFactory(SiteName.Values.Winamax).HandHistoryParser,
         HandHistoryParserFactory.GetHandHistoryParserFactory(SiteName.Values.WinningPoker).HandHistoryParser,
     };
 }
        private void parsingWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            Dictionary <HandHistoryParserFactory, IEnumerable <FileInfo> > factories =
                new Dictionary <HandHistoryParserFactory, IEnumerable <FileInfo> >();
            int totalFiles = 0;

            foreach (string siteDetailsString in Settings.Default.Sites)
            {
                SiteDetails details = new SiteDetails(siteDetailsString);
                HandHistoryParserFactory parserFactory = HandHistoryParserFactory.GetHandHistoryParserFactory(details);
                DirectoryInfo            info          = new DirectoryInfo(details.HandsLocation);
                IEnumerable <FileInfo>   files         = info.GetFiles().Where(fi => parserFactory.IsHandHistoryFile(fi) &&
                                                                               fi.LastWriteTime > lastUpdate);
                totalFiles += files.Count();
                factories.Add(parserFactory, files);
            }

            handsFound       = 0;
            tournamentsFound = 0;

            float fileProgressInc = 100.0f / totalFiles;
            int   filesProcessed  = 0;

            foreach (HandHistoryParserFactory factory in factories.Keys)
            {
                factory.HandHistoryParser.AmountsAsBigBlindMultiples = true;
                foreach (FileInfo file in factories[factory])
                {
                    int         byteCount  = 0;
                    HandHistory parsedHand = null;

                    TournamentSummary tournamentSummary = null;

                    if (factory.HasTournamentSummaryParser() && File.Exists(factory.GetTournamentFile(file.FullName)))
                    {
                        tournamentSummary = factory.ParseTournamentSummary(file.FullName);
                        DatabaseHandler.Add(tournamentSummary);
                        ++tournamentsFound;
                    }
                    IEnumerable <HandHistory> hands = factory.ParseHandHistories(file.FullName);
                    float totalHands = (float)hands.Count();
                    int   fileHands  = 0;

                    foreach (HandHistory hand in hands)
                    {
                        if (parsingWorker.CancellationPending)
                        {
                            break;
                        }

                        try
                        {
                            parsedHand = hand;
                            string tournamentId = parsedHand.GameDescription.TournamentId;

                            if (tournamentSummary != null)
                            {
                                parsedHand.GameDescription.TournamentSummary = tournamentSummary;
                            }
                            DatabaseHandler.Add(parsedHand);
                            byteCount += parsedHand.FullHandHistoryText.Length;
                            ++handsFound;
                            ++fileHands;
                            float progress = (int)((filesProcessed + fileHands / totalHands) * fileProgressInc);
                            parsingWorker.ReportProgress((int)progress);
                        }
                        catch (MongoWriteException ex)
                        {
                            Console.Write("Failed");
                        }
                        catch (HandParseException ex)
                        {
                            Console.Write("Parsing failed for: " + string.Concat(ex.HandText) + "\n");
                        }
                    }
                    if (parsingWorker.CancellationPending)
                    {
                        break;
                    }

                    ++filesProcessed;
                    parsingWorker.ReportProgress((int)(filesProcessed * fileProgressInc));
                }
            }

            parsingWorker.ReportProgress(100);
        }
Exemple #4
0
        protected IHandHistoryParser GetParser()
        {
            HandHistoryParserFactory handHistoryParserFactory = HandHistoryParserFactory.GetHandHistoryParserFactory(Site);

            return(handHistoryParserFactory.HandHistoryParser);
        }