コード例 #1
0
        private static void ParseScorecard(FileStore dataStore, ScorecardDetails md)
        {
            CricketMatch m = dataStore.Load <CricketMatch>(CricketMatch.GenerateId(md.Season, md.MatchCode));

            if (m != null)
            {
                Log.InfoFormat("Match {0} ({1}) has already been imported", md.MatchCode, m);
                return;
            }

            Log.InfoFormat("Parsing scorecard for {0}", md);

            string scorecard = dataStore.LoadText(md.GenerateScorecardKey(), "html");

            if (string.IsNullOrEmpty(scorecard))
            {
                return;
            }

            DependencyFinder finder = new DependencyFinder(dataStore);
            ScorecardParser  parser = new ScorecardParser(md, finder);

            parser.Parse(scorecard);

            CricketMatch match = parser.Match;

            dataStore.Save(match, match.Id);

            Log.Info(match.ToLongString());
        }
コード例 #2
0
        private static void SaveScorecard(ScorecardDetails details, Task <string> task, FileStore dataStore)
        {
            if (task.Exception != null)
            {
                Log.Error(string.Format("Failed to download file from http://www.cricketarchive.com{0}", details.ScorecardUrl),
                          task.Exception);
                return;
            }

            string scorecard = task.Result;

            if (string.IsNullOrEmpty(scorecard))
            {
                Log.WarnFormat("Nothing returned from http://www.cricketarchive.com{0}", details.ScorecardUrl);
                return;
            }

            dataStore.StoreText(scorecard, details.GenerateScorecardKey(), "html");
        }