Esempio n. 1
0
        public SchedulesController()
        {
            var systemTime     = new SystemTime();
            var httpClient     = new HttpClient();
            var client         = new Client(httpClient);
            var scraper        = new Scraper(systemTime, client);
            var serializer     = new ScrapeResultSerializer();
            var pathBuilder    = new PathBuilder();
            var storageClient  = new StorageClient(systemTime, pathBuilder);
            var uniqueClient   = new UniqueClient(storageClient);
            var statusRecorder = new UploadStatusRecorder(storageClient, systemTime);

            _scrapeResultRecorder          = new ScrapeResultRecorder(scraper, serializer, storageClient, uniqueClient, statusRecorder);
            _throttledScrapeResultRecorder = new ThrottledScrapeResultRecorder(systemTime, _scrapeResultRecorder);
            var gtfsConverter      = new GtfsConverter();
            var gtfsCsvSerializer  = new GtfsCsvSerializer();
            var gtfsFeedSerializer = new GtfsFeedSerializer(gtfsCsvSerializer);

            _gtfsFeedArchiveRecord = new GtfsFeedArchiveRecorder(storageClient, uniqueClient, gtfsConverter, gtfsFeedSerializer, statusRecorder);
            var settingsService = new SettingsProvider();

            _settings = new Settings(settingsService);
        }
Esempio n. 2
0
        private static async Task <int> MainAsync(string[] args)
        {
            var result = Parser.Default.ParseArguments <ScrapeOptions, CollapseOptions>(args);

            if (result.Tag == ParserResultType.NotParsed)
            {
                return(1);
            }

            var parsedResult = (Parsed <object>)result;

            if (parsedResult.Value is ScrapeOptions)
            {
                // initialize
                var systemTime       = new SystemTime();
                var httpClient       = new HttpClient();
                var connectorClient  = new Client(httpClient);
                var connectorScraper = new Scraper(systemTime, connectorClient);
                var jsonWriter       = new JsonTextWriter(Console.Out);
                var writer           = new JsonScrapeResultWriter(jsonWriter);

                // act
                await connectorScraper.RealTimeScrapeAsync(writer);

                return(0);
            }

            if (parsedResult.Value is CollapseOptions)
            {
                // initialize
                var options     = (CollapseOptions)parsedResult.Value;
                var pathBuilder = new PathBuilder();
                var collapser   = new Collapser(pathBuilder);
                IAsyncEqualityComparer <Stream> comparer;
                switch (options.ComparisonType)
                {
                case ComparisonType.ScrapeResult:
                    comparer = new ScrapeResultEqualityComparer();
                    break;

                default:
                    comparer = new ZipArchiveEqualityComparer();
                    break;
                }

                var request = new CollapseRequest
                {
                    ConnectionString = options.ConnectionString,
                    PathFormat       = options.PathFormat,
                    Container        = options.Container,
                    Trace            = Console.Out,
                    Comparer         = new AdapterCollapserComparer(StringComparer.Ordinal, comparer)
                };

                // act
                await collapser.CollapseAsync(request);

                return(0);
            }

            return(0);
        }