Exemplo n.º 1
0
        public static Research ParseResearch(string html)
        {
            Research             research = new Research();
            ReportResearchParser parser   = new ReportResearchParser(research);

            parser.Parse(html);
            return(research);
        }
Exemplo n.º 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);
        }
 public InternalResearchParser(Research research) : base(research)
 {
     //>Technologia kopalni</a> (Poziom 19)
     _pattern = @">{0}</a> \(Poziom\s+(?<level>[0-9]+)\)";
     _parser  = new ObjectParser
     {
         Object   = _research,
         Pattern  = _pattern,
         Patterns = ResearchParser.Patterns
     };
 }
Exemplo n.º 4
0
 public ReportResearchParser(Research research) : base(research)
 {
     _pattern = @"<td class=nachricht width=120>{0}</td>\s*" +
                @"<td width=20 class=nachricht>(?<level>[^<]+)</td>";
     _parser = new ObjectParser
     {
         Object   = _research,
         Pattern  = _pattern,
         Patterns = ResearchParser.Patterns
     };
 }
Exemplo n.º 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);
        }
Exemplo n.º 6
0
 protected ResearchParser(Research research)
 {
     _research = research;
     _pattern  = "";
 }