public static Defence ParseDefence(string html)
        {
            Defence             defence = new Defence();
            ReportDefenceParser parser  = new ReportDefenceParser(defence);

            parser.Parse(html);
            return(defence);
        }
Example #2
0
        public static bool ParseReport(string html, ReportRecord report)
        {
            try
            {
                if (html.Contains("Nie znaleziono"))
                {
                    report.Status     = "Brak";
                    report.LastUpdate = DateTime.Now;
                }
                else
                {
                    report.Status = "Jest";
                    //report.LastUpdate = ParseDate(html);
                }

                ResourceRecord resource = new ResourceRecord {
                    Id = report.Id
                };
                BuildingRecord building = new BuildingRecord {
                    Id = report.Id
                };
                ResearchRecord research = new ResearchRecord {
                    Id = report.Id
                };
                DefenceRecord defence = new DefenceRecord {
                    Id = report.Id
                };
                FleetRecord fleet = new FleetRecord {
                    Id = report.Id
                };

                Resource r = ReportResourceParser.ParseResource(html);
                if (r != null)
                {
                    r.ToDB(resource);
                }
                Building b = ReportBuildingParser.ParseBuilding(html);
                if (b != null)
                {
                    ObjectDumper.Dump(b, building);
                }
                Research s = ReportResearchParser.ParseResearch(html);
                if (s != null)
                {
                    ObjectDumper.Dump(s, research);
                }
                Fleet f = ReportFleetParser.ParseFleet(html);
                ObjectDumper.Dump(f, fleet);

                Defence d = ReportDefenceParser.ParseDefence(html);
                ObjectDumper.Dump(d, defence);
            }catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return(true);
        }
Example #3
0
 public InternalDefenceParser(Defence defence) : base(defence)
 {
     _pattern = @">{0}</a> \(dost.pne:\s+<b>(?<level>[0-9]+)</b>";
     _parser  = new ObjectParser
     {
         Object   = _defence,
         Pattern  = _pattern,
         Patterns = DefenceParser.Patterns
     };
 }
 public ReportDefenceParser(Defence defence) : base(defence)
 {
     _pattern = @"<td class=nachricht width=120>{0}</td>\s*<td width=20 class=nachricht>(?<level>[^<]+)</td>";
     _parser  = new ObjectParser
     {
         Object   = _defence,
         Pattern  = _pattern,
         Patterns = DefenceParser.Patterns
     };
 }
Example #5
0
        public Planet()
        {
            _building       = new Building();
            _buildingParser = new InternalBuildingParser(_building);

            _research       = new Research();
            _researchParser = new InternalResearchParser(_research);

            _fleet        = new Fleet();
            _orderParser  = new InternalOrderParser(_fleet);
            _weaponParser = new InternalWeaponParser(_fleet);

            _defence       = new Defence();
            _defenceParser = new InternalDefenceParser(_defence);
        }
 protected DefenceParser(Defence defence)
 {
     _defence = defence;
     _pattern = "";
 }