Esempio n. 1
0
 // Initialize the instance, required before running any other method
 // Returns the instance so that the method can be chained to the ctor.
 public IMongoDbSql Initialize(MongoDbTableConfiguration config)
 {
     this.connectionString = config.ConnectionString;
     this.consistencyLevel = config.ConsistencyLevel;
     this.database         = config.Database;
     this.collection       = config.Collection;
     this.RUs         = config.RUs;
     this.initialized = true;
     return(this);
 }
Esempio n. 2
0
        public async Task SetupOutputStorageAsync()
        {
            if (!this.initialized)
            {
                // Note: this is an application bug
                this.log.Error("Initialize() not invoked yet.", () => { });
                throw new ApplicationException("Initialize() not invoked yet.");
            }

            try
            {
                if (this.storageType == AsaOutputStorageType.CosmosDbSql)
                {
                    this.mongoDbCong                  = new MongoDbTableConfiguration();
                    this.mongoDbCong.Collection       = this.cosmosDbConfig.Collection;
                    this.mongoDbCong.ConnectionString = this.cosmosDbConfig.ConnectionString;
                    this.mongoDbCong.Database         = this.cosmosDbConfig.Database;
                    this.mongoDbCong.Collection       = this.cosmosDbConfig.Collection;
                    this.mongoDbCong.RUs              = this.cosmosDbConfig.RUs;
                    this.mongoDbCong.Api              = MongoDbApi.Sql;
                    var storage = this.factory.Resolve <IMongoDbSql>().Initialize(this.mongoDbCong);
                    await storage.CreateDatabaseAndCollectionsIfNotExistAsync();

                    return;
                }
                else if (this.storageType == AsaOutputStorageType.TimeSeriesInsights)
                {
                    this.log.Info("Skip creating output storage because the storage type is Time Series Insights", () => { });
                    return;
                }
                //if (this.storageType == AsaOutputStorageType.MongoDbSql)
                //{
                //    this.mongoDbCong.Collection = this.cosmosDbConfig.Collection;
                //    this.mongoDbCong.ConnectionString = this.cosmosDbConfig.ConnectionString;
                //    this.mongoDbCong.Database = this.cosmosDbConfig.Database;
                //    this.mongoDbCong.Collection = this.cosmosDbConfig.Collection;
                //    var storage = this.factory.Resolve<IMongoDbSql>().Initialize(this.mongoDbCong);
                //    await storage.CreateDatabaseAndCollectionsIfNotExistAsync();
                //    return;
                //}
            }
            catch (Exception e)
            {
                this.log.Error("Error while creating the output storage", () => new { e });
                throw new ExternalDependencyException("Error while creating the output storage", e);
            }

            throw new NotImplementedException();
        }