Ejemplo n.º 1
0
        public CdbRevisionDataService(IOptions <CosmosDbOptions> cosmosDbOptions)
        {
            this.CosmosDbConfig = cosmosDbOptions.Value;

            // Beware: This source code is duplicated since we are use DomainString for single container to save cost
            this.CosmosDbContainer = new CosmosDbHelper(this.CosmosDbConfig.ConnectionString, this.CosmosDbConfig.DomainString, this.CosmosDbConfig.DomainString);
        }
Ejemplo n.º 2
0
        public CosmosDmvDbHandler(IDocumentClient documentClient, IOptions <CosmosDbOptions> settings)
        {
            _documentClient = documentClient ??
                              throw new ArgumentNullException(nameof(documentClient));

            _options = settings.Value ??
                       throw new ArgumentNullException(nameof(settings));
        }
Ejemplo n.º 3
0
        public CosmosDbRepository(ILoggerFactory loggerFactory, IDocumentClient client, IEventStoreJsonSerializerSettings settings, IOptions <CosmosDbOptions> options)
        {
            _logger = loggerFactory.CreateLogger(GetType());

            _client       = client ?? throw new ArgumentNullException(nameof(client));
            _options      = options.Value;
            _jsonSettings = (JsonSerializerSettings)settings ?? new JsonSerializerSettings();;
        }
Ejemplo n.º 4
0
 public RevisionsController(IOptions <CosmosDbOptions> CosmosDbConfig, IOptions <AzureAdOptions> AzureAdConfig,
                            IRevisionDataService revisionDataService, IProjectDataService projectDataService, IAzureDevOpsService azureDevOpsService)
 {
     this.CosmosDbConfig      = CosmosDbConfig.Value;
     this.AzureAdConfig       = AzureAdConfig.Value;
     this.RevisionDataService = revisionDataService;
     this.ProjectDataService  = projectDataService;
     this.AzureDevOpsService  = azureDevOpsService;
 }
Ejemplo n.º 5
0
 public DocumentDbClient(
     IOptions <CosmosDbOptions> options,
     ILogger <DocumentDbClient> logger,
     DocumentClient documentClient)
 {
     _options        = options.Value;
     _logger         = logger;
     _documentClient = documentClient;
 }
Ejemplo n.º 6
0
 public TemplateApiController(IServicePrincipalRepository servicePrincipalRepo,
                              IResourceManagerRepository resourceManagerRepo,
                              IOptions <CosmosDbOptions> cosmosDbOptions,
                              ILogger <TemplateApiController> logger)
     : base(servicePrincipalRepo, resourceManagerRepo)
 {
     this.cosmosDbOptions = cosmosDbOptions.Value;
     this.logger          = logger;
 }
Ejemplo n.º 7
0
        public CosmosDbContext(CosmosDbOptions options)
        {
            if (options == null)
            {
                throw new InvalidOperationException("The options argument at CosmosDbContext is mandatory.");
            }

            CosmosClient = options.CosmosClient;
            DiscoverAndInitializeCollections();
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Main Constructor
 /// </summary>
 /// <param name="templateRepo">Repository Template Service</param>
 /// <param name="categoryRepo">Repository Category Service</param>
 /// <param name="userProfile">User Profile Service</param>
 public TemplateApiController(ICosmosDBRepository <Template> templateRepo,
                              ICosmosDBRepository <Category> categoryRepo, IUserProfileService userProfile,
                              ILogger <TemplateApiController> logger, IOptions <CosmosDbOptions> cosmosDbOptions, IOptions <AzureAdOptions> azureOptions)
     : base(userProfile)
 {
     _templateRepo    = templateRepo;
     _categoryRepo    = categoryRepo;
     this.logger      = logger;
     _cosmosDbOptions = cosmosDbOptions.Value;
     _azureOptions    = azureOptions.Value;
 }
Ejemplo n.º 9
0
 public ReleasesController(IOptions <CosmosDbOptions> CosmosDbConfig, IOptions <AzureAdOptions> AzureAdConfig,
                           IReleaseDataService releaseDataService, IRevisionDataService revisionDataService, IProjectDataService projectDataService,
                           IAzureDevOpsService azureDevOpsService, IHubContext <Hubs.BroadcastStatusHub> broadcastStatusHubContext)
 {
     this.CosmosDbConfig            = CosmosDbConfig.Value;
     this.AzureAdConfig             = AzureAdConfig.Value;
     this.ReleaseDataService        = releaseDataService;
     this.RevisionDataService       = revisionDataService;
     this.ProjectDataService        = projectDataService;
     this.AzureDevOpsService        = azureDevOpsService;
     this.BroadcastStatusHubContext = broadcastStatusHubContext;
 }
Ejemplo n.º 10
0
 public ProceduresController(IOptions <CosmosDbOptions> CosmosDbConfig,
                             IProjectDataService projectDataService,
                             IRevisionDataService revisionDataService,
                             IProcedureDataService procedureDataService,
                             IProcedureExecutionDataService procedureExecutionDataService,
                             IHubContext <Hubs.BroadcastStatusHub> broadcastStatusHubContext)
 {
     this.CosmosDbConfig           = CosmosDbConfig.Value;
     ProjectDataService            = projectDataService;
     RevisionDataService           = revisionDataService;
     ProcedureDataService          = procedureDataService;
     ProcedureExecutionDataService = procedureExecutionDataService;
     BroadcastStatusHubContext     = broadcastStatusHubContext;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Main Controller
 /// </summary>
 /// <param name="userProfile">User Service</param>
 /// <param name="blobRepo">Blob Repository</param>
 public AzureBlobStorageController(IUserProfileService userProfile,
                                   IBlobStorageRepository blobRepo,
                                   IOptionsSnapshot <IoTHubOptions> iotOptions,
                                   IOptionsSnapshot <BlobOptions> blobOptions,
                                   IOptionsSnapshot <CosmosDbOptions> cosmostOptions,
                                   ILogger <AzureBlobStorageController> logger)
     : base(userProfile)
 {
     _blobRepo           = blobRepo;
     this.logger         = logger;
     this.cosmostOptions = cosmostOptions.Value;
     this.iotOptions     = iotOptions.Value;
     this.blobOptions    = blobOptions.Value;
 }
Ejemplo n.º 12
0
        private Option <CosmosDbOptions> GetCosmosDbOptions()
        {
            CosmosDbOptions cosmosDbOptions = new CosmosDbOptions();

            Configuration.GetSection("CosmosDb").Bind(cosmosDbOptions);
            cosmosDbOptions.AccountEndpoint = Configuration["CosmosDb:AccountEndpoint"];
            cosmosDbOptions.AccountKey      = Configuration["CosmosDb:AccountKey"];

            if (cosmosDbOptions.AccountEndpoint != null &&
                cosmosDbOptions.AccountKey != null &&
                cosmosDbOptions.DatabaseName != null)
            {
                return(cosmosDbOptions);
            }
            else
            {
                return(Prelude.None);
            }
        }
Ejemplo n.º 13
0
        private static void ConfigureCosmosDb(IServiceCollection aServiceCollection)
        {
            using IServiceScope scope = aServiceCollection.BuildServiceProvider().CreateScope();
            {
                CosmosDbOptions cosmosOptions = scope.ServiceProvider.GetRequiredService <IOptions <CosmosDbOptions> >().Value;

                aServiceCollection.AddDbContext <CosmosDbContext>
                (
                    aDbContextOptionsBuilder =>
                    aDbContextOptionsBuilder
                    .UseCosmos
                    (
                        accountEndpoint: cosmosOptions.EndPoint,
                        accountKey: cosmosOptions.AccessKey,
                        databaseName: nameof(CosmosDbContext)
                    )
                );
            }
        }
Ejemplo n.º 14
0
    public static IServiceCollection AddCosmosDb(this IServiceCollection services, CosmosDbOptions cosmosDbOptions)
    {
        var documentClient = new DocumentClient(cosmosDbOptions.Endpoint, cosmosDbOptions.Key, new JsonSerializerSettings
        {
            NullValueHandling    = NullValueHandling.Ignore,
            DefaultValueHandling = DefaultValueHandling.Ignore,
            ContractResolver     = new CamelCasePropertyNamesContractResolver()
        });

        documentClient.OpenAsync().Wait();

        var collectionNames = cosmosDbOptions.Collections.Select(n => n.Name).ToList();

        var cosmosDbClientFactory = new CosmosDbClientFactory(cosmosDbOptions.DatabaseName, collectionNames, documentClient);

        cosmosDbClientFactory.EnsureDbSetupAsync().Wait();

        services.AddSingleton <ICosmosDbClientFactory>(cosmosDbClientFactory);

        return(services);
    }
Ejemplo n.º 15
0
 public CosmosDomainDbContext(DbContextOptions <DomainDbContext> options, CosmosDbOptions settings)
     : base(options)
 {
     _settings = settings;
 }
 public ApiDatabaseOptions(CosmosDbOptions cosmosDbOptions)
 {
     this.cosmosDbOptions = cosmosDbOptions ?? throw new System.ArgumentNullException(nameof(cosmosDbOptions));
 }
 public VideoStoreContext(CosmosDbOptions <VideoStoreContext> options)
     : base(options)
 {
 }
Ejemplo n.º 18
0
 public CosmosDatabaseProvider(IOptions <CosmosDbOptions> settings)
 {
     _settings = settings.Value;
 }
Ejemplo n.º 19
0
 public DatabaseOptions(CosmosDbOptions cosmosDbOptions)
 {
     this.cosmosDbOptions = cosmosDbOptions;
 }
Ejemplo n.º 20
0
 public CosmosDbOptionBuilder(CosmosDbOptions options)
 {
     _cosmosDbOptions      = options;
     _cosmosDbOption       = new CosmosDbOption();
     _cosmosClientSettings = new CosmosClientOptions();
 }
Ejemplo n.º 21
0
 public CosmosDocumentRepository(CosmosDbOptions options)
 {
     _cosmosDb         = new CosmosClient(options.Account, options.Key).GetDatabase(options.Database);
     _collectionLookup = options.CollectionLookup;
 }
Ejemplo n.º 22
0
 public ProjectsController(IOptions <CosmosDbOptions> CosmosDbConfig, IProjectDataService projectDataService)
 {
     this.CosmosDbConfig     = CosmosDbConfig.Value;
     this.ProjectDataService = projectDataService;
 }
Ejemplo n.º 23
0
        // ReSharper disable once UnusedMember.Local
        private static async Task <ItemsRepoCosmos> InitializeCosmosClientInstanceAsync(CosmosDbOptions cosmosDbOptions)
        {
            var client = new Microsoft.Azure.Cosmos.CosmosClient(
                cosmosDbOptions.Account, cosmosDbOptions.Key);

            var cosmosDbService = new ItemsRepoCosmos(
                client, cosmosDbOptions.DatabaseName, cosmosDbOptions.ContainerName);

            var database = await client.CreateDatabaseIfNotExistsAsync(
                cosmosDbOptions.DatabaseName);

            await database.Database.CreateContainerIfNotExistsAsync(
                cosmosDbOptions.ContainerName, "/id");

            return(cosmosDbService);
        }