Exemplo n.º 1
0
        public MainProcessor(
            AzureUtils.ApplicationClientInfo applicationClientInfo,
            AzureUtils.StorageAccountInfo storageAccountInfo,
            string tsidCheckpointingTableName,
            string stationObservationsCheckpointingPartitionKey,
            string eventHubConnectionString,
            string azureMapsSubscriptionKey,
            string azureMapsCacheTableName,
            string tsiEnvironmentFqdn)
        {
            _noaaClient = new NoaaClient();

            _stationsProcessor = new StastionsProcessor(
                _noaaClient,
                TsiDataClient.AadLoginAsApplication(applicationClientInfo),
                tsiEnvironmentFqdn,
                new AzureMapsClient(
                    azureMapsSubscriptionKey,
                    AzureUtils.GetOrCreateTableAsync(storageAccountInfo, azureMapsCacheTableName).Result));

            _stationObservationsCheckpointing = new TsidCheckpointing(
                AzureUtils.GetOrCreateTableAsync(storageAccountInfo, tsidCheckpointingTableName).Result,
                stationObservationsCheckpointingPartitionKey);

            _stationObservationProcessors = new Dictionary <string, StationObservationsProcessor>();

            _eventHubClient = EventHubClient.CreateFromConnectionString(eventHubConnectionString);
        }
Exemplo n.º 2
0
        private async Task CacheSearchAddressReverseAsync(string key, Address address)
        {
            if (address != null)
            {
                using (var stringWriter = new StringWriter())
                {
                    JsonUtils.WriteJson(stringWriter, address);
                    stringWriter.Flush();

                    TableOperation replaceOperation = TableOperation.InsertOrMerge(
                        new CacheEntry(SearchAddressReversePartitionKey, key, stringWriter.GetStringBuilder().ToString()));

                    await _cacheCloudTable.ExecuteAsync(replaceOperation);
                }
            }
            else
            {
                await AzureUtils.DeleteTableRowIfExistsAsync(_cacheCloudTable, SearchAddressReversePartitionKey, key);
            }
        }
Exemplo n.º 3
0
 public static TsiDataClient AadLoginAsApplication(AzureUtils.ApplicationClientInfo applicationClientInfo)
 {
     return(new TsiDataClient(() => AzureUtils.AadLoginAsApplicationAsync("https://api.timeseries.azure.com/", applicationClientInfo)));
 }