Пример #1
0
        public static void Main()
        {
            ParserExample parser = new ParserExample();

            try
            {
                int parsedHands    = 0;
                int thrownOutHands = 0;
                // Open the text file using a stream reader.
                //using (StreamReader sr = new StreamReader("C:\\Users\\rcotter\\Downloads\\PS-2009-07-01_2009-07-23_1000NLH_OBFU\\10\\ps NLH handhq_1-OBFUSCATED.txt"))
                {
                    SiteName site       = SiteName.PokerStars;
                    string   folderPath = " C:\\Users\\rcotter\\Downloads\\PS-2009-07-01_2009-07-23_1000NLH_OBFU\\10\\";
                    foreach (string file in Directory.EnumerateFiles(folderPath, "*.txt"))
                    {
                        string contents = File.ReadAllText(file);

                        HandHistory hand = parser.ParseHand(site, contents, ref parsedHands, ref thrownOutHands);
                    }
                    // Read the stream to a string, and write the string to the console.
                    //String line = sr.ReadToEnd();
                    Console.WriteLine("Number of parsed hands:" + parsedHands);
                    Console.WriteLine("Number of thrown hands:" + thrownOutHands);
                    Console.Read();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }
        }
        public IHandHistorySummaryParser GetHandHistorySummaryParser(SiteName siteName)
        {
            switch (siteName)
            {
            case SiteName.PartyPokerEs:
            case SiteName.PartyPokerFr:
            case SiteName.PartyPokerNJ:
            case SiteName.PartyPokerIt:
            case SiteName.PartyPoker:
                return(new PartyPokerFastParserImpl(siteName));

            case SiteName.PokerStars:
            case SiteName.PokerStarsFr:
            case SiteName.PokerStarsIt:
            case SiteName.PokerStarsEs:
                return(GetFullHandHistoryParser(siteName));

            case SiteName.Merge:
                return(new MergeFastParserImpl());

            case SiteName.IPoker:
                return(new IPokerFastParserImpl());

            case SiteName.IPoker2:
                return(new IPokerFastParserImpl(true));

            case SiteName.Pacific:
                return(new Poker888FastParserImpl());

            case SiteName.Entraction:
                return(new EntractionFastParserImpl());

            case SiteName.OnGame:
                return(new OnGameFastParserImpl());

            case SiteName.OnGameFr:
                return(new OnGameFastParserImpl(SiteName.OnGameFr));

            case SiteName.OnGameIt:
                return(new OnGameFastParserImpl(SiteName.OnGameIt));

            case SiteName.FullTilt:
                return(new FullTiltPokerFastParserImpl());

            case SiteName.MicroGaming:
                return(new MicroGamingFastParserImpl());

            case SiteName.Winamax:
                return(new WinamaxFastParserImpl());

            case SiteName.WinningPoker:
                return(new WinningPokerNetworkFastParserImpl());

            case SiteName.BossMedia:
                return(new BossMediaFastParserImpl());

            default:
                throw new NotImplementedException("GetHandHistorySummaryParser: No summary regex parser for " + siteName);
            }
        }
    /// <summary>
    /// Parses the notification template site and name and returns proper Info object.
    /// </summary>
    private NotificationTemplateInfo GetTemplateInfo(string templateName)
    {
        if (!string.IsNullOrEmpty(templateName))
        {
            // Get current site name
            string siteName = CurrentSiteName;

            // If SiteName is not "#current#" or "-" get site name from property
            if (!(SiteName.EqualsCSafe("#current#", true) || (SiteName == "-")))
            {
                siteName = SiteName;
            }

            if (templateName.StartsWithCSafe(siteName + ".", true))
            {
                // Remove site name from template name
                templateName = templateName.Remove(0, siteName.Length + 1);

                // Site template
                SiteInfo tempSite = SiteInfoProvider.GetSiteInfo(siteName);
                if (tempSite != null)
                {
                    return(NotificationTemplateInfoProvider.GetNotificationTemplateInfo(templateName, tempSite.SiteID));
                }
            }
            else
            {
                // Global template
                return(NotificationTemplateInfoProvider.GetNotificationTemplateInfo(templateName));
            }
        }

        return(null);
    }
        private void BuildStreetAddress(StringBuilder builder, bool includeSiteName = true)
        {
            // street_address = name_part number_part street_part
            //     name_part = (address_site_name SP / building_part)
            //         building_part = ( / building_name SP)
            //     street_part = street_name ( / SP street_type) ( / SP street_suffix)

            // name_part
            if (includeSiteName && SiteName.HasValue())
            {
                builder.Append(SiteName);
                builder.Append(Sp);
                // need building_name from datasets
            }

            number_part(builder);

            // street_part
            builder.Append(StreetName);
            if (StreetType.HasValue())
            {
                builder.Append(Sp);
                builder.Append(StreetType);
            }
            if (StreetSuffix.HasValue())
            {
                builder.Append(Sp);
                builder.Append(StreetSuffix);
            }
        }
 public IHandHistorySummaryParser GetHandHistorySummaryParser(SiteName siteName)
 {
     switch (siteName)
     {
         case SiteName.PartyPoker:
             return new PartyHandHistoryRegexParserImpl();
         case SiteName.PokerStars:
         case SiteName.PokerStarsFr:
         case SiteName.PokerStarsIt:
         case SiteName.PokerStarsEs:
             return GetFullHandHistoryParser(siteName);
         case SiteName.Merge:
             return new MergeFastParserImpl();
         case SiteName.IPoker:
             return new IPokerFastParserImpl();
         case SiteName.IPoker2:
             return new IPokerFastParserImpl(true);
         case SiteName.Pacific:
             return new Poker888FastParserImpl();
         case SiteName.Entraction:
             return new EntractionFastParserImpl();
         case SiteName.OnGame:
             return new OnGameFastParserImpl();
         case SiteName.OnGameFr:
             return new OnGameFastParserImpl(SiteName.OnGameFr);
         case SiteName.OnGameIt:
             return new OnGameFastParserImpl(SiteName.OnGameIt);
         case SiteName.FullTilt:
             return new FullTiltPokerFastParserImpl();
         default:
             throw new NotImplementedException("GetHandHistorySummaryParser: No summary regex parser for " + siteName);
     }
 }
        // So the same parser can be used for It and Fr variations
        public OnGameFastParserImpl(SiteName siteName = SiteName.OnGame)
        {
            _siteName = siteName;

            _numberFormatInfo = new NumberFormatInfo
            {
                NegativeSign = "-",
                CurrencyDecimalSeparator = ".",
                CurrencyGroupSeparator = ",",
            };

            switch (siteName)
            {
                case SiteName.OnGameIt:
                case SiteName.OnGameFr:
                    _numberFormatInfo.CurrencySymbol = "€";
                    _currency = Currency.EURO;
                    break;
                default:
                    _numberFormatInfo.CurrencySymbol = "$";
                    _currency = Currency.USD;
                    break;

            }
        }
Пример #7
0
        // So the same parser can be used for It and Fr variations
        public OnGameFastParserImpl(SiteName siteName = SiteName.OnGame)
        {
            _siteName = siteName;

            _numberFormatInfo = new NumberFormatInfo
            {
                NegativeSign             = "-",
                CurrencyDecimalSeparator = ".",
                CurrencyGroupSeparator   = ",",
            };

            switch (siteName)
            {
            case SiteName.OnGameIt:
            case SiteName.OnGameFr:
                _numberFormatInfo.CurrencySymbol = "€";
                _currency = Currency.EURO;
                break;

            default:
                _numberFormatInfo.CurrencySymbol = "$";
                _currency = Currency.USD;
                break;
            }
        }
Пример #8
0
        //ported from IISOOB\projects\ui\wm\Deployment\Data\Profiles\PublishProfile.cs
        private string ConstructServiceUrlForDeployThruWMSVC(string serviceUrl)
        {
            const string https     = "https://";
            const string http      = "http://";
            const string msddepaxd = "msdeploy.axd";

            System.UriBuilder serviceUriBuilder = null;

            // We want to try adding https:// if there is no schema. However abc:123 is parsed as a schema=abc and path=123
            // so the goal is to isolate this case and add the https:// but allow for http if the user chooses to
            // since we do not allow for any schema other than http or https, it's safe to assume we can add it if none exist
            try
            {
                if (!(serviceUrl.StartsWith(http, StringComparison.OrdinalIgnoreCase) || serviceUrl.StartsWith(https, StringComparison.OrdinalIgnoreCase)))
                {
                    serviceUrl = string.Concat(https, serviceUrl.TrimStart());
                }

                serviceUriBuilder = new UriBuilder(serviceUrl);
            }
            catch (NullReferenceException)
            {
                return(string.Empty);
            }
            catch (ArgumentNullException)
            {
                return(string.Empty);
            }
            catch (UriFormatException)
            {
                return(serviceUrl);
            }

            // if the user did not explicitly defined a port
            if (serviceUrl.IndexOf(":" + serviceUriBuilder.Port.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase) == -1)
            {
                serviceUriBuilder.Port = 8172;
            }

            // user did not explicitly set a path
            if (string.IsNullOrEmpty(serviceUriBuilder.Path) || serviceUriBuilder.Path.Equals("/", StringComparison.OrdinalIgnoreCase))
            {
                serviceUriBuilder.Path = msddepaxd;
            }

            // user did not explicityly set the scheme
            if (serviceUrl.IndexOf(serviceUriBuilder.Scheme, StringComparison.OrdinalIgnoreCase) == -1)
            {
                serviceUriBuilder.Scheme = https;
            }

            if (string.IsNullOrEmpty(serviceUriBuilder.Query))
            {
                string[] fragments = SiteName.Trim().Split(new char[] { '/', '\\' });
                serviceUriBuilder.Query = "site=" + fragments[0];
            }

            return(serviceUriBuilder.Uri.AbsoluteUri);
        }
Пример #9
0
        private List <string> ParseHands(SiteName site, string handText, ref int parsedHands, ref int thrownOutHands)
        {
            List <string> messages = new List <string>();
            // Each poker site has its own parser so we use a factory to get the right parser.
            IHandHistoryParserFactory handHistoryParserFactory = new HandHistoryParserFactoryImpl();

            // Get the correct parser from the factory.
            IHandHistoryParser handHistoryParser = handHistoryParserFactory.GetFullHandHistoryParser(site);

            try
            {
                List <string> hands = new List <string>();
                hands = handHistoryParser.SplitUpMultipleHands(handText).ToList();
                db.Configuration.AutoDetectChangesEnabled = false;
                foreach (string hand in hands)
                {
                    try
                    {
                        // The true causes hand-parse errors to get thrown. If this is false, hand-errors will
                        // be silent and null will be returned.
                        HandHistory handHistory = handHistoryParser.ParseFullHandHistory(hand, true);

                        //handhistory can now be broken down to be put into the database

                        // Add to player table
                        Dictionary <string, player> playerDict = addPlayersToDB(handHistory);

                        // Add to table table
                        table dbTable = addTableToDB(handHistory);

                        db.SaveChanges();

                        //Add to hand table
                        hand dbHand = addHandToDB(handHistory, dbTable);

                        // Add to hand_action table
                        addHandActionToDB(handHistory, dbHand, playerDict);

                        // Add to plays table
                        addPlaysToDB(handHistory, playerDict);

                        db.SaveChanges();

                        parsedHands++;
                    }
                    catch (Exception ex)
                    {
                        messages.Add("Parsing Error: " + ex.Message);
                        thrownOutHands++;
                    }
                }
            }
            catch (Exception ex) // Catch hand-parsing exceptions
            {
                messages.Add("Parsing Error: " + ex.Message);
            }
            db.Configuration.AutoDetectChangesEnabled = true;
            return(messages);
        }
 public GameDescriptor(SiteName siteName,
                       GameType gameType,
                       Limit limit,
                       TableType tableType,
                       SeatType seatType)
     : this(PokerFormat.CashGame, siteName, gameType, limit, tableType, seatType)
 {
 }
 public GameDescriptor(SiteName siteName,
                       GameType gameType,
                       Buyin buyin,
                       TableType tableType,
                       SeatType seatType)
     : this(PokerFormat.SitAndGo, siteName, gameType, buyin, tableType, seatType)
 {
 }
Пример #12
0
        public void BtnSiteDone()
        {
            try
            {
                DataSet.Site.GpsLocation = GPSCoords.Parse(Latitude, Longitude);
                DataSet.Site.Owner       = Owner;
                OwnerHelper.Add(Owner);
                DataSet.Site.SiteNotes        = Notes;
                DataSet.Site.PrimaryContact   = PrimaryContact;
                DataSet.Site.SecondaryContact = SecondaryContact;
                DataSet.Site.Elevation        = float.Parse(Elevation);
                DataSet.Site.Images           = _siteImages.ToList();

                var bw = new BackgroundWorker();

                bw.DoWork += (o, e) =>
                {
                    var oldFile = DataSet.SaveLocation;
                    var oldName = DataSet.Site.Name;
                    DataSet.Site.Name = SiteName;
                    DataSet.SaveToFile(false);

                    if (SiteName.CompareTo(oldName) != 0)
                    {
                        File.Delete(oldFile);
                    }
                };

                bw.RunWorkerCompleted += (o, e) =>
                {
                    EventLogger.LogInfo(DataSet, GetType().ToString(), "Site saved. Site name: " + DataSet.Site.Name);

                    CreateEditDeleteVisible = Visibility.Visible;
                    DoneCancelVisible       = Visibility.Collapsed;
                    DoneCancelEnabled       = true;
                    SiteControlsEnabled     = false;
                    ApplicationCursor       = Cursors.Arrow;

                    if (!IsNewSite)
                    {
                        return;
                    }

                    WasCompleted = true;
                    TryClose();
                };

                ApplicationCursor = Cursors.Wait;
                DoneCancelEnabled = false;
                bw.RunWorkerAsync();
            }
            catch (Exception e)
            {
                Common.ShowMessageBox("Error", e.Message, false, true);
                EventLogger.LogError(DataSet, GetType().ToString(), "Tried to create site but failed. Details: " + e.Message);
            }
        }
Пример #13
0
 public override int GetHashCode()
 {
     unchecked // disable overflow, for the unlikely possibility that you
     {         // are compiling with overflow-checking enabled
         int hash = 27;
         hash = (13 * hash) + SiteName.GetHashCode();
         hash = (13 * hash) + SiteLang.GetHashCode();
         return(hash);
     }
 }
 // So the same parser can be used for It and Fr variations
 public PokerStarsFastParserImpl(SiteName siteName = SiteName.PokerStars)
 {
     _siteName = siteName;
     _numberFormatInfo = new NumberFormatInfo
     {
         NegativeSign = "-",
         CurrencyDecimalSeparator = ".",
         CurrencyGroupSeparator = ",",
         CurrencySymbol = "$"
     };
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         SiteName.Text = "";
         SiteName.Focus();
         SysCategoryDAL dal = new SysCategoryDAL();
         int            max = dal.GetMaxOrder();
         max           = max + 1;
         txtOrder.Text = max.ToString();
     }
 }
        private string GetHandText(PokerFormat pokerFormat, SiteName siteName, string subFolderName, string textFileName)
        {
            string subFolder = System.IO.Path.Combine(GetSampleHandHistoryFolder(pokerFormat, siteName), subFolderName);
            string path = System.IO.Path.Combine(subFolder, textFileName) + ".txt";

            if (_fileReader.FileExists(path) == false)
            {
                return null;
            }

            return _fileReader.ReadAllText(path);
        }
        private string GetHandText(PokerFormat pokerFormat, SiteName siteName, string subFolderName, string textFileName)
        {
            string subFolder = System.IO.Path.Combine(GetSampleHandHistoryFolder(pokerFormat, siteName), subFolderName);
            string path      = System.IO.Path.Combine(subFolder, textFileName) + ".txt";

            if (_fileReader.FileExists(path) == false)
            {
                return(null);
            }

            return(_fileReader.ReadAllText(path, Encoding.UTF8));
        }
 public static bool HasHandHistoryParserFactory(SiteName siteName)
 {
     try
     {
         GetHandHistoryParserFactory(siteName);
         return(true);
     }
     catch (NotImplementedException e)
     {
         return(false);
     }
 }
Пример #19
0
        protected bool IsIPLocked(SiteName siteName, string ip)
        {
            //var ipLock = String.Format(IPLOCK_CACHE, siteName, ip);

            //if (Cache[ipLock] != null)
            //{
            //    return true;
            //}

            //Cache.Insert(ipLock, true, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 0, 2),
            //             CacheItemPriority.Default, null);

            return(false);
        }
 public GameDescriptor(PokerFormat pokerFormat,
                       SiteName siteName,
                       GameType gameType,
                       Buyin buyin,
                       TableType tableType,
                       SeatType seatType)
 {
     PokerFormat = pokerFormat;
     Site = siteName;
     GameType = gameType;
     Buyin = buyin;
     TableType = tableType;
     SeatType = seatType;
 }
 public GameDescriptor(PokerFormat pokerFormat,
                       SiteName siteName,
                       GameType gameType,
                       Limit limit,
                       TableType tableType,
                       SeatType seatType)
 {
     PokerFormat = pokerFormat;
     Site = siteName;
     GameType = gameType;
     Limit = limit;
     TableType = tableType;
     SeatType = seatType;
 }
Пример #22
0
        private DailyReport GetDailyReport(DateTimeOffset day, SQLiteConnection conn)
        {
            Attribute   attr             = new Attribute();
            string      software_version = attr.Get("software.version", conn);
            SiteName    site_name        = new SiteName();
            CountryCode country_code     = new CountryCode();
            DailyReport report           = new DailyReport(country_code.GetValue(conn), site_name.GetValue(conn), day, software_version);

            string sql = string.Format("SELECT C.Name, C.CollectorType, D.Value, D.Timestamp FROM Data D INNER JOIN Collectors C ON D.CollectorID = C.CollectorID WHERE D.Timestamp BETWEEN '{0}' AND '{1}' ORDER BY D.TimeStamp ASC;",
                                       day.DayBeginAs8601(), day.DayEndAs8601());

            string first_of_month = string.Format("{0:D4}-{1:D2}-01T00:00:00.000", day.Year, day.Month);

            try
            {
                if (day.DayBeginAs8601() == first_of_month)
                {
                    DailyReport.Record config_record = GetConfigurationRecord(day, conn);
                    if (config_record != null)
                    {
                        report.records.Add(config_record);
                    }
                }

                SQLiteCommand command = new SQLiteCommand(sql, conn);
                using (command)
                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            DailyReport.Record record = new DailyReport.Record()
                            {
                                collector = reader.GetString(0),
                                type      = (ECollectorType)reader.GetInt32(1),
                                value     = reader.GetString(2),
                                timestamp = DateTimeOffset.Parse(reader.GetString(3))
                            };
                            report.records.Add(record);
                        }
                    }
            }
            catch (Exception ex)
            {
                ILog log = LogManager.GetLogger(typeof(Retriever));
                log.Error("GetDailyReport: " + sql);
                log.Error(ex);
            }

            return(report);
        }
 public IHandHistorySummaryParser GetHandHistorySummaryParser(SiteName siteName)
 {
     switch (siteName)
     {
         case SiteName.PartyPokerEs:
         case SiteName.PartyPokerFr:
         case SiteName.PartyPokerNJ:
         case SiteName.PartyPokerIt:
         case SiteName.PartyPoker:
             return new PartyPokerFastParserImpl(siteName);
         case SiteName.PokerStars:
         case SiteName.PokerStarsFr:
         case SiteName.PokerStarsIt:
         case SiteName.PokerStarsEs:
             return GetFullHandHistoryParser(siteName);
         case SiteName.Merge:
             return new MergeFastParserImpl();
         case SiteName.IPoker:
             return new IPokerFastParserImpl();
         case SiteName.IPoker2:
             return new IPokerFastParserImpl(true);
         case SiteName.Pacific:
             return new Poker888FastParserImpl();
         case SiteName.Entraction:
             return new EntractionFastParserImpl();
         case SiteName.OnGame:
             return new OnGameFastParserImpl();
         case SiteName.OnGameFr:
             return new OnGameFastParserImpl(SiteName.OnGameFr);
         case SiteName.OnGameIt:
             return new OnGameFastParserImpl(SiteName.OnGameIt);
         case SiteName.FullTilt:
             return new FullTiltPokerFastParserImpl();
         case SiteName.MicroGaming:
             return new MicroGamingFastParserImpl();
         case SiteName.Winamax:
             return new WinamaxFastParserImpl();
         case SiteName.WinningPoker:
             return new WinningPokerNetworkFastParserImpl();
         case SiteName.BossMedia:
             return new BossMediaFastParserImpl();
         default:
             throw new NotImplementedException("GetHandHistorySummaryParser: No summary regex parser for " + siteName);
     }
 }
Пример #24
0
 public static string GetDisplaySiteName(SiteName siteName)
 {
     switch (siteName)
     {
         case SiteName.PokerStars:
             return "Poker Stars";
         case SiteName.PartyPoker:
             return "Party Poker";
         case SiteName.Pacific:
             return "888";
         case SiteName.PokerStarsIt:
             return "Poker Stars It";
         case SiteName.PokerStarsFr:
             return "Poker Stars Fr";
         default:
             return siteName.ToString();
     }
 }
Пример #25
0
        public IHandHistorySummaryParser GetHandHistorySummaryParser(SiteName siteName)
        {
            switch (siteName)
            {
            case SiteName.PartyPoker:
                return(new PartyHandHistoryRegexParserImpl());

            case SiteName.PokerStars:
            case SiteName.PokerStarsFr:
            case SiteName.PokerStarsIt:
            case SiteName.PokerStarsEs:
                return(GetFullHandHistoryParser(siteName));

            case SiteName.Merge:
                return(new MergeFastParserImpl());

            case SiteName.IPoker:
                return(new IPokerFastParserImpl());

            case SiteName.IPoker2:
                return(new IPokerFastParserImpl(true));

            case SiteName.Pacific:
                return(new Poker888FastParserImpl());

            case SiteName.Entraction:
                return(new EntractionFastParserImpl());

            case SiteName.OnGame:
                return(new OnGameFastParserImpl());

            case SiteName.OnGameFr:
                return(new OnGameFastParserImpl(SiteName.OnGameFr));

            case SiteName.OnGameIt:
                return(new OnGameFastParserImpl(SiteName.OnGameIt));

            case SiteName.FullTilt:
                return(new FullTiltPokerFastParserImpl());

            default:
                throw new NotImplementedException("GetHandHistorySummaryParser: No summary regex parser for " + siteName);
            }
        }
Пример #26
0
 public string[] GenerateCompletionAddresses(string locality, List <string> addresses)
 {
     addresses.Add(GenerateCompletionAddress(locality, true));
     if (SiteName.HasValue())
     {
         addresses.Add(GenerateCompletionAddress(locality, false));
     }
     if (ComplexUnitType.HasValue())
     {
         var addressWithoutUnitType = DeepCopyAttributes();
         addressWithoutUnitType.ComplexUnitType = null;
         addresses.Add(addressWithoutUnitType.GenerateCompletionAddress(locality, true));
         if (SiteName.HasValue())
         {
             addresses.Add(addressWithoutUnitType.GenerateCompletionAddress(locality, false));
         }
     }
     return(addresses.ToArray());
 }
Пример #27
0
        // So the same parser can be used for It and Fr variations
        public PartyPokerFastParserImpl(SiteName.Values siteName = SiteName.Values.PartyPoker)
        {
            _siteName = siteName;

            switch (siteName)
            {
            case SiteName.Values.PartyPokerEs:
            case SiteName.Values.PartyPokerFr:
            case SiteName.Values.PartyPokerIt:
                NumberFormatInfo.CurrencySymbol = "€";
                _currency = Currency.EURO;
                break;

            // PartyPoker + PartyPokerNJ
            default:
                NumberFormatInfo.CurrencySymbol = "$";
                _currency = Currency.USD;
                break;
            }
        }
        // So the same parser can be used for It and Fr variations
        public PartyPokerFastParserImpl(SiteName siteName = SiteName.PartyPoker)
        {
            _siteName = siteName;

            switch (siteName)
            {
                case SiteName.PartyPokerEs:
                case SiteName.PartyPokerFr:
                case SiteName.PartyPokerIt:
                    NumberFormatInfo.CurrencySymbol = "€";
                    _currency = Currency.EURO;
                    break;
                // PartyPoker + PartyPokerNJ
                default:
                    NumberFormatInfo.CurrencySymbol = "$";
                    _currency = Currency.USD;
                    break;

            }
        }
Пример #29
0
        public string ToHtmlString()
        {
            if (!Title.IsNullOrWhiteSpace())
            {
                _builder.Append($"<meta property=\"og:title\" content=\"{Title}\" />");
                _builder.Append(Environment.NewLine);
            }

            if (!SiteName.IsNullOrWhiteSpace())
            {
                _builder.Append($"<meta property=\"og:site_name\" content=\"{SiteName}\" />");
                _builder.Append(Environment.NewLine);
            }

            if (!Type.IsNullOrWhiteSpace())
            {
                _builder.Append($"<meta property=\"og:type\" content=\"{Type}\" />");
                _builder.Append(Environment.NewLine);
            }

            if (!Description.IsNullOrWhiteSpace())
            {
                _builder.Append($"<meta property=\"og:description\" content=\"{Description}\" />");
                _builder.Append(Environment.NewLine);
            }

            if (!Url.IsNullOrWhiteSpace())
            {
                _builder.Append($"<meta property=\"og:url\" content=\"{Url}\" />");
                _builder.Append(Environment.NewLine);
            }

            if (!Image.IsNullOrWhiteSpace())
            {
                _builder.Append($"<meta property=\"og:image\" content=\"{Image}\" />");
                _builder.Append(Environment.NewLine);
            }

            return(_builder.ToString());
        }
        public HTMLExtractor(string passedURL)
        {
            URL = passedURL;

            SiteName = SiteDetector(URL);

            using (WebClient client = new WebClient()) // WebClient class inherits IDisposable
            {
                HTML = client.DownloadString(URL);
            }

            if (SiteName.ToLower() == "imdb")
            {
                IMDB imdb = new IMDB(HTML);
                MetaCollector = new MetaCollector(imdb);
            }
            else
            {
                TV tv = new TV(HTML);
                MetaCollector = new MetaCollector(tv);
            }
        }
Пример #31
0
        private List <string> Parse(string filePath)
        {
            List <string> messages = new List <string>();

            try
            {
                int parsedHands    = 0;
                int thrownOutHands = 0;
                // Open the text file using a stream reader.
                {
                    SiteName site     = SiteName.PokerStars;
                    string   contents = System.IO.File.ReadAllText(filePath);
                    messages.AddRange(ParseHands(site, contents, ref parsedHands, ref thrownOutHands));
                    messages.Add("Number of parsed hands:" + parsedHands);
                    messages.Add("Number of thrown hands:" + thrownOutHands);
                }
            }
            catch (Exception e)
            {
                messages.Add("The file could not be read: " + e.Message);
            }
            return(messages);
        }
Пример #32
0
        public HandHistory ParseHand(SiteName site, string handText, ref int parsedHands, ref int thrownOutHands)
        {
            // Each poker site has its own parser so we use a factory to get the right parser.
            IHandHistoryParserFactory handHistoryParserFactory = new HandHistoryParserFactoryImpl();

            // Get the correct parser from the factory.
            IHandHistoryParser handHistoryParser = handHistoryParserFactory.GetFullHandHistoryParser(site);

            try
            {
                // The true causes hand-parse errors to get thrown. If this is false, hand-errors will
                // be silent and null will be returned.
                List <string> hands = new List <string>();
                hands = handHistoryParser.SplitUpMultipleHands(handText).ToList();
                foreach (string hand in hands)
                {
                    try
                    {
                        HandHistory handHistory = handHistoryParser.ParseFullHandHistory(hand, true);
                        Console.WriteLine(handHistory.HandId);
                        parsedHands++;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Parsing Error: {0}", ex.Message);                         // Example logging.
                        thrownOutHands++;
                    }
                }
                return(null);
            }
            catch (Exception ex)                                     // Catch hand-parsing exceptions
            {
                Console.WriteLine("Parsing Error: {0}", ex.Message); // Example logging.
                return(null);
            }
        }
 // Due to issue I reported here have to take site as a string:
 //  http://youtrack.jetbrains.com/issue/RSRP-292611
 protected HandHistoryParserBaseTests(string site)
 {
     SampleHandHistoryRepository = Kernel.Get<ISampleHandHistoryRepository>();
     Site = (SiteName)Enum.Parse(typeof(SiteName), site);
 }
 public string GetFormatHandHistoryText(PokerFormat pokerFormat, SiteName siteName, string name)
 {
     return GetHandText(pokerFormat, siteName, "FormatTests", name);
 }
 public string GetLimitExampleHandHistoryText(PokerFormat pokerFormat, SiteName siteName, string fileName)
 {
     return GetHandText(pokerFormat, siteName, "Limits", fileName);
 }
 public string GetMultipleHandExampleText(PokerFormat pokerFormat, SiteName siteName, int handCount)
 {
     return(GetHandText(pokerFormat, siteName, "MultipleHandsTests", handCount + "MultipleHands"));
 }
 public string GetGameTypeHandHistoryText(PokerFormat pokerFormat, SiteName siteName, GameType gameType)
 {
     return(GetHandText(pokerFormat, siteName, "GameTypeTests", gameType.ToString()));
 }
 public string GetGeneralHandHistoryText(PokerFormat pokerFormat, SiteName siteName, string testName)
 {
     return(GetHandText(pokerFormat, siteName, "GeneralHands", testName));
 }
 private string GetSampleHandHistoryFolder(PokerFormat pokerFormat, SiteName siteName)
 {
     return string.Format(@"SampleHandHistories\{0}\{1}\", siteName, pokerFormat);
 }
 public string GetCommunityCardsHandHistoryText(PokerFormat pokerFormat, SiteName siteName, Street street)
 {
     return GetHandText(pokerFormat, siteName, "StreetTests", street.ToString());
 }
 public HandParseError(string handText, SiteName site, Exception ex)
 {
     HandText = handText;
     Site = site;
     Exception = ex;
 }
 public string GetGameTypeHandHistoryText(PokerFormat pokerFormat, SiteName siteName, GameType gameType)
 {
     return GetHandText(pokerFormat, siteName, "GameTypeTests", gameType.ToString());
 }
 public string GetHandExample(PokerFormat pokerFormat, SiteName siteName, string subFolder, string fileName)
 {
     return GetHandText(pokerFormat, siteName, subFolder, fileName);
 }
 public PartyHandHistoryRegexParserImpl(SiteName site = SiteName.PartyPoker)
     : base()
 {
     _siteName = site;
 }
 // So the same parser can be used for It and Fr variations
 public PokerStarsFastParserImpl(SiteName siteName = SiteName.PokerStars)
 {
     _siteName = siteName;
 }
 public string GetValidHandHandHistoryText(PokerFormat pokerFormat, SiteName siteName, bool isValid)
 {
     return GetHandText(pokerFormat, siteName, "ValidHandTests", (isValid) ? "ValidHand" : "InvalidHand");
 }
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n    <meta charset=\"utf-8\">\r\n    <title" +
                       ">");

            #line 7 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DbEntry.Title.HtmlEncode()));

            #line default
            #line hidden
            this.Write("</title>\r\n    <meta name=\"description\" content=\"");

            #line 8 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DbEntry.Summary.HtmlEncode()));

            #line default
            #line hidden
            this.Write("\">\r\n    <meta name=\"author\" content=\"");

            #line 9 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DbEntry.CreatedBy.HtmlEncode()));

            #line default
            #line hidden
            this.Write("\">\r\n    <meta name=\"keywords\" content=\"");

            #line 10 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DbEntry.Tags.HtmlEncode()));

            #line default
            #line hidden
            this.Write("\" >\r\n\r\n    <meta property=\"og:site_name\" content=\"");

            #line 12 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(SiteName.HtmlEncode()));

            #line default
            #line hidden
            this.Write("\" />\r\n    <meta property=\"og:url\" content=\"https:");

            #line 13 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(PageUrl));

            #line default
            #line hidden
            this.Write("\" />\r\n    <meta property=\"og:type\" content=\"article\" />\r\n    <meta property=\"og:t" +
                       "itle\" content=\"");

            #line 15 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DbEntry.Title.HtmlEncode()));

            #line default
            #line hidden
            this.Write("\" />\r\n    <meta property=\"og:description\" content=\"");

            #line 16 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DbEntry.Summary.HtmlEncode()));

            #line default
            #line hidden
            this.Write("\" />\r\n\r\n    ");

            #line 18 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Tags.OpenGraphImageMetaTags(MainImage)));

            #line default
            #line hidden
            this.Write("\r\n\r\n    <link rel = \"schema.DC\" href = \"http://purl.org/DC/elements/1.0/\">\r\n    <" +
                       "meta name=\"DC.Title\" content=\"");

            #line 21 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DbEntry.Title.HtmlEncode()));

            #line default
            #line hidden
            this.Write("\">\r\n    <meta name =\"DC.Creator\" content=\"");

            #line 22 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DbEntry.CreatedBy.HtmlEncode()));

            #line default
            #line hidden
            this.Write("\">\r\n    <meta name =\"DC.Publisher\" content=\"");

            #line 23 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(SiteName.HtmlEncode()));

            #line default
            #line hidden
            this.Write("\">\r\n    <meta name=\"DC.Description\" content=\"");

            #line 24 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DbEntry.Summary.HtmlEncode()));

            #line default
            #line hidden
            this.Write("\">\r\n    <meta name=\"DC.Date\" content=\"");

            #line 25 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DbEntry.CreatedOn.ToString("yyyy-MM-dd").HtmlEncode()));

            #line default
            #line hidden
            this.Write("\">\r\n    <meta name=\"DC.Format\" content=\"text/html\">\r\n    <meta name=\"DC.Language\"" +
                       " content=\"en-US\">\r\n\r\n    <link rel=\"alternate\" type=\"application/rss+xml\" \r\n    " +
                       "  title=\"");

            #line 31 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture($"RSS Feed for {UserSettingsSingleton.CurrentSettings().SiteName} - Files"));

            #line default
            #line hidden
            this.Write("\"\r\n      href=\"https:");

            #line 33 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(UserSettingsSingleton.CurrentSettings().FileRssUrl()));

            #line default
            #line hidden
            this.Write("\" />\r\n\r\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"" +
                       ">\r\n\r\n    ");

            #line 38 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Tags.CssStyleFileString()));

            #line default
            #line hidden
            this.Write("\r\n    ");

            #line 39 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Tags.FavIconFileString()));

            #line default
            #line hidden
            this.Write("\r\n\r\n</head>\r\n\r\n<body>\r\n    ");

            #line 44 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Tags.StandardHeader().ToString()));

            #line default
            #line hidden
            this.Write("\r\n    ");

            #line 45 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(HorizontalRule.StandardRule()));

            #line default
            #line hidden
            this.Write("\r\n    ");

            #line 46 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Tags.TitleDiv(DbEntry).ToString()));

            #line default
            #line hidden
            this.Write("\r\n    ");

            #line 47 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Tags.PostCreatedByAndUpdatedOnDiv(DbEntry).ToString()));

            #line default
            #line hidden
            this.Write("\r\n    ");

            #line 49 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Tags.PostBodyDiv(DbEntry).ToString()));

            #line default
            #line hidden
            this.Write("\r\n    ");

            #line 50 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(HorizontalRule.StandardRule()));

            #line default
            #line hidden
            this.Write("\r\n    ");

            #line 51 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DownloadLinkTag()));

            #line default
            #line hidden
            this.Write("\r\n    ");

            #line 52 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(HorizontalRule.StandardRuleIfNotEmptyTag(DownloadLinkTag())));

            #line default
            #line hidden
            this.Write("\r\n    <div class=\"information-section\">\r\n        ");

            #line 55 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Tags.TagList(DbEntry).ToString()));

            #line default
            #line hidden
            this.Write("\r\n        ");

            #line 56 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(BodyContentReferences.RelatedContentTag(DbEntry.ContentId, DbEntry.BodyContent).Result));

            #line default
            #line hidden
            this.Write("\r\n        ");

            #line 58 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Tags.CreatedByAndUpdatedOnDiv(DbEntry).ToString()));

            #line default
            #line hidden
            this.Write("\r\n        ");

            #line 60 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Tags.UpdateNotesDiv(DbEntry).ToString()));

            #line default
            #line hidden
            this.Write("\r\n    </div>\r\n    ");

            #line 62 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(HorizontalRule.StandardRule()));

            #line default
            #line hidden
            this.Write("\r\n    ");

            #line 63 "C:\Code\PointlessWaymarksCmsSpatiaLite\PointlessWaymarksCmsData\Html\FileHtml\SingleFilePage.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Footer.StandardFooterDiv()));

            #line default
            #line hidden
            this.Write("\r\n</body>\r\n\r\n</html>");
            return(this.GenerationEnvironment.ToString());
        }
 public string GetTableExampleHandHistoryText(PokerFormat pokerFormat, SiteName siteName, int tableTestNumber)
 {
     return(GetHandText(pokerFormat, siteName, "Tables", "Table" + tableTestNumber));
 }
 public string GetSeatExampleHandHistoryText(PokerFormat pokerFormat, SiteName siteName, SeatType seatType)
 {
     return GetHandText(pokerFormat, siteName, "Seats", seatType.ToString());
 }
 public string GetFormatHandHistoryText(PokerFormat pokerFormat, SiteName siteName, string name)
 {
     return(GetHandText(pokerFormat, siteName, "FormatTests", name));
 }
 public WinningPokerNetworkFastParserImpl()
 {
     _siteName = Objects.GameDescription.SiteName.WinningPoker;
 }
 public string GetCommunityCardsHandHistoryText(PokerFormat pokerFormat, SiteName siteName, Street street)
 {
     return(GetHandText(pokerFormat, siteName, "StreetTests", street.ToString()));
 }
 public string GetTableExampleHandHistoryText(PokerFormat pokerFormat, SiteName siteName, int tableTestNumber)
 {
     return GetHandText(pokerFormat, siteName, "Tables", "Table" + tableTestNumber);
 }
 public string GetHandExample(PokerFormat pokerFormat, SiteName siteName, string subFolder, string fileName)
 {
     return(GetHandText(pokerFormat, siteName, subFolder, fileName));
 }
 // So the same parser can be used for It and Fr variations
 public OnGameFastParserImpl(SiteName siteName = SiteName.OnGame)
 {
     _siteName = siteName;
 }
 private string GetSampleHandHistoryFolder(PokerFormat pokerFormat, SiteName siteName)
 {
     return(string.Format(@"SampleHandHistories\{0}\{1}\", siteName, pokerFormat));
 }
 public string GetMultipleHandExampleText(PokerFormat pokerFormat, SiteName siteName, int handCount)
 {
     return GetHandText(pokerFormat, siteName, "MultipleHandsTests", handCount + "MultipleHands");
 }
 public string GetGeneralHandHistoryText(PokerFormat pokerFormat, SiteName siteName, string testName)
 {
     return GetHandText(pokerFormat, siteName, "GeneralHands", testName);
 }
 public string GetCancelledHandHandHistoryText(PokerFormat pokerFormat, SiteName siteName)
 {
     return GetHandText(pokerFormat, siteName, "ValidHandTests", "CancelledHand");
 }