private async Task Start() { var settings = Settings(); var connectionPolicy = new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp, MaxConnectionLimit = 100 }; this.client = new DocumentClient(new Uri(settings.CosmosEndpointUri), settings.CosmosPrimaryKey, connectionPolicy); var gtfsDataFolder = await DownloadGtfsData(settings); await CreateCollectionIfNotExists(settings); // Read the downloaded. None of the data is processed here, it's // just loaded into objects to be processed later. var rawData = new TransitFeedData().Read(gtfsDataFolder); // Convert the transit feed from raw data objects to the structure // to be uploaded to Cosmos. var processedData = new ProcessedTransitFeedData().Process(rawData); await WriteDataToCosmos(settings.CosmosDatabaseName, settings.CosmosCollectionName, processedData); }
private async Task WriteDataToCosmos(string databaseName, string collectionName, ProcessedTransitFeedData data) { var documentCollection = UriFactory.CreateDocumentCollectionUri(databaseName, collectionName); await CreateDocumentsAsync(documentCollection, data.Stops); await CreateDocumentsAsync(documentCollection, data.Trips); }