예제 #1
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);
        }
예제 #2
0
        public static Report Parse(string html)
        {
            Report report = new Report();

            try
            {
                if (html.Contains("Nie znaleziono"))
                {
                    return(null);
                }
                report.LastUpdate = ParseDate(html);

                report.Resource = ReportResourceParser.ParseResource(html);
                report.Building = ReportBuildingParser.ParseBuilding(html);
                report.Research = ReportResearchParser.ParseResearch(html);
                report.Fleet    = ReportFleetParser.ParseFleet(html);
                report.Defence  = ReportDefenceParser.ParseDefence(html);
            }catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return(report);
        }