From 6cd2b3812052e842d405904fd4f7321ccfcaf842 Mon Sep 17 00:00:00 2001 From: bolsson Date: Thu, 26 Oct 2023 11:41:36 +0200 Subject: [PATCH] #1351 Added RavenDb connectionstring to appsettings and retrieved it from there on the client --- Assessments.Transformation/Helpers/Storage.cs | 25 +++++++++++++------ Assessments.Transformation/appsettings.json | 14 ++++++----- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/Assessments.Transformation/Helpers/Storage.cs b/Assessments.Transformation/Helpers/Storage.cs index 54256c27..236a97d1 100644 --- a/Assessments.Transformation/Helpers/Storage.cs +++ b/Assessments.Transformation/Helpers/Storage.cs @@ -13,11 +13,11 @@ namespace Assessments.Transformation.Helpers public static class Storage { private static BlobContainerClient _blobContainer; - + public static async Task UploadToBlob(IConfigurationRoot configuration, string key, string value) { var connectionString = configuration.GetConnectionString("AzureBlobStorage"); - + if (string.IsNullOrEmpty(connectionString)) throw new Exception("ConnectionStrings:AzureBlobStorage (app secret) mangler"); @@ -100,17 +100,27 @@ public static IDocumentStore Store private static IDocumentStore CreateStore() { + IConfigurationRoot configuration = GetConfiguration(); + IDocumentStore store = new DocumentStore() - { - Url = "http://it-webadbtest01.it.ntnu.no:8181", - DefaultDatabase = "DynamicPropertiesTest" - //ConnectionStringName = "DatabankRavenDB", - + { + + Url = configuration.GetConnectionString("RavenDBUrl"), + DefaultDatabase = configuration.GetConnectionString("RavenDB") + }.Initialize(); return store; } + private static IConfigurationRoot GetConfiguration() + { + return new ConfigurationBuilder() + .AddJsonFile("appsettings.json") + .AddUserSecrets() + .Build(); + } + public static IDocumentSession RavenSession { get @@ -118,7 +128,6 @@ public static IDocumentSession RavenSession if (ravenSession == null) { ravenSession = Store.OpenSession(); - //ravenSession.Advanced.MaxNumberOfRequestsPerSession = 100; } return ravenSession; } diff --git a/Assessments.Transformation/appsettings.json b/Assessments.Transformation/appsettings.json index 3b5390e3..be9d2a32 100644 --- a/Assessments.Transformation/appsettings.json +++ b/Assessments.Transformation/appsettings.json @@ -1,8 +1,10 @@ { - "FilesFolder": "../../../../Assessments.Frontend.Web/Cache/", - "ConnectionStrings": { - "AzureBlobStorage": "UseDevelopmentStorage=true", // from configuration or user secrets - "Fab4": "", // from configuration or user secrets - "Rodliste2020": "" // from configuration or user secrets - } + "FilesFolder": "../../../../Assessments.Frontend.Web/Cache/", + "ConnectionStrings": { + "AzureBlobStorage": "UseDevelopmentStorage=true", // from configuration or user secrets + "RavenDBUrl": "localhost:8000", + "RavenDB": "DynamicPropertiesTest", + "Fab4": "", // from configuration or user secrets + "Rodliste2020": "" // from configuration or user secrets + } }