예제 #1
0
        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);

            var data = new TransitFeedData();

            data.Read(gtfsDataFolder);

            await WriteDataToCosmos(settings.CosmosDatabaseName, settings.CosmosCollectionName, data);
        }
예제 #2
0
        private async Task WriteDataToCosmos(string databaseName, string collectionName, TransitFeedData data)
        {
            var documentCollection = UriFactory.CreateDocumentCollectionUri(databaseName, collectionName);

            await CreateDocumentsAsync(documentCollection, data.Stops.ToList());
            await CreateDocumentsAsync(documentCollection, data.Trips);
        }