Skip to content

Commit

Permalink
#1351 Added RavenDb connectionstring to appsettings and retrieved it …
Browse files Browse the repository at this point in the history
…from there on the client
  • Loading branch information
bolsson committed Oct 26, 2023
1 parent 623ce54 commit 6cd2b38
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
25 changes: 17 additions & 8 deletions Assessments.Transformation/Helpers/Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -100,25 +100,34 @@ 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<Program>()
.Build();
}

public static IDocumentSession RavenSession
{
get
{
if (ravenSession == null)
{
ravenSession = Store.OpenSession();
//ravenSession.Advanced.MaxNumberOfRequestsPerSession = 100;
}
return ravenSession;
}
Expand Down
14 changes: 8 additions & 6 deletions Assessments.Transformation/appsettings.json
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 6cd2b38

Please sign in to comment.