Skip to content

Commit

Permalink
Merge branch 'dev' into LNK-3055-Update-measure-eval-to-use-3.12-CQFr…
Browse files Browse the repository at this point in the history
…amework-libraries
  • Loading branch information
seanmcilvenna authored Oct 22, 2024
2 parents 446e059 + aedfbd5 commit 0ca9d01
Show file tree
Hide file tree
Showing 17 changed files with 714 additions and 69 deletions.
368 changes: 368 additions & 0 deletions Azure_Pipelines/azure-pipelines.db-schema-creation.yaml

Large diffs are not rendered by default.

65 changes: 51 additions & 14 deletions DotNet/Account/Persistence/AccountDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,61 @@
using Link.Authorization.Infrastructure;
using Link.Authorization.Permissions;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using System.Reflection.Emit;

namespace LantanaGroup.Link.Account.Persistence
{
public class AccountDbContext : DbContext
{

public AccountDbContext(DbContextOptions<AccountDbContext> options) : base(options)
{
}
namespace LantanaGroup.Link.Account.Persistence;

public class AccountDbContext : DbContext
{

public AccountDbContext() : base()
{
}

public AccountDbContext(DbContextOptions<AccountDbContext> options) : base(options)
{
}

public DbSet<LinkUser> Users { get; set; } = null!;
public DbSet<LinkRole> Roles { get; set; } = null!;

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfigurationsFromAssembly(typeof(AccountDbContext).Assembly);
base.OnModelCreating(modelBuilder);
}

public DbSet<LinkUser> Users { get; set; } = null!;
public DbSet<LinkRole> Roles { get; set; } = null!;
public class AccountDbContextFactory : IDesignTimeDbContextFactory<AccountDbContext>
{
public AccountDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<AccountDbContext>();
optionsBuilder.UseSqlServer();

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfigurationsFromAssembly(typeof(AccountDbContext).Assembly);
base.OnModelCreating(modelBuilder);
return new AccountDbContext(optionsBuilder.Options);
}
}
}

//public class AccountDbContextFactory : IDesignTimeDbContextFactory<AccountDbContext>
//{
// public AccountDbContext CreateDbContext(string[] args)
// {
// string env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development";

// IConfiguration config = new ConfigurationBuilder()
// .SetBasePath(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Account"))
// .AddJsonFile("appsettings.json")
// .AddJsonFile($"appsettings.{env}.json", optional: true)
// //.AddEnvironmentVariables()
// .Build();

// var optionsBuilder = new DbContextOptionsBuilder<AccountDbContext>();
// var connectionString = config.GetConnectionString("SqlServer");
// connectionString = string.IsNullOrWhiteSpace(connectionString) ? "Data Source;Initial;Integrated Security=True;" : connectionString;
// optionsBuilder.UseSqlServer(connectionString);

// return new AccountDbContext(optionsBuilder.Options);
// }
//}
2 changes: 1 addition & 1 deletion DotNet/Account/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"GroupId": ""
},
"ConnectionStrings": {
"DatabaseConnection": "",
"DatabaseConnection": "Data Source;Initial;Integrated Security=True;",
"AzureAppConfiguration": ""
},
"DatabaseProvider": "SqlServer",
Expand Down
50 changes: 36 additions & 14 deletions DotNet/Audit/Persistance/AuditDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
using LantanaGroup.Link.Audit.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;

namespace LantanaGroup.Link.Audit.Persistance
namespace LantanaGroup.Link.Audit.Persistance;

public class AuditDbContext : DbContext
{
public class AuditDbContext : DbContext
public AuditDbContext(DbContextOptions<AuditDbContext> options) : base(options)
{
}

public DbSet<AuditLog> AuditLogs { get; set; } = null!;

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
public AuditDbContext(DbContextOptions<AuditDbContext> options) : base(options)
{
}

public DbSet<AuditLog> AuditLogs { get; set; } = null!;

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfigurationsFromAssembly(typeof(AuditDbContext).Assembly);
base.OnModelCreating(modelBuilder);
}

modelBuilder.ApplyConfigurationsFromAssembly(typeof(AuditDbContext).Assembly);
base.OnModelCreating(modelBuilder);
}

}

public class AuditDbContextFactory : IDesignTimeDbContextFactory<AuditDbContext>
{
public AuditDbContext CreateDbContext(string[] args)
{
string env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development";

IConfiguration config = new ConfigurationBuilder()
.SetBasePath(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Audit"))
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env}.json", optional: true)
//.AddEnvironmentVariables()
.Build();

var optionsBuilder = new DbContextOptionsBuilder<AuditDbContext>();
var connectionString = config.GetConnectionString("SqlServer");
connectionString = string.IsNullOrWhiteSpace(connectionString) ? "Data Source;Initial;Integrated Security=True;" : connectionString;
optionsBuilder.UseSqlServer(connectionString);

return new AuditDbContext(optionsBuilder.Options);
}
}
4 changes: 4 additions & 0 deletions DotNet/Audit/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"ClientId": "audit-events"
},
"DatabaseProvider": "SqlServer",
"ConnectionStrings": {
"DatabaseConnection": "Data Source;Initial;Integrated Security=True;",
"AzureAppConfiguration": ""
},
"CORS": {
"AllowAllOrigins": true,
"AllowedOrigins": [ "http://localhost:5218", "http://localhost:4200" ],
Expand Down
14 changes: 13 additions & 1 deletion DotNet/Census/Domain/Context/CensusContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using LantanaGroup.Link.Census.Domain.Entities;
using LantanaGroup.Link.Shared.Application.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using System.Text.Json;

namespace LantanaGroup.Link.Census.Domain.Context;
Expand Down Expand Up @@ -55,4 +56,15 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
v => JsonSerializer.Deserialize<Dictionary<string, string>>(v, new JsonSerializerOptions())
);
}
}

public class CensusContextFactory : IDesignTimeDbContextFactory<CensusContext>
{
public CensusContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<CensusContext>();
optionsBuilder.UseSqlServer();

return new CensusContext(optionsBuilder.Options);
}
}
}
3 changes: 3 additions & 0 deletions DotNet/Census/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"ClientId": ""
},
"DatabaseProvider": "SqlServer",
"ConnectionStrings": {
"DatabaseConnection": "Data Source;Initial;Integrated Security=True;"
},
"ServiceRegistry": {
"TenantService": {
"TenantServiceUrl": "https://localhost:7332",
Expand Down
14 changes: 14 additions & 0 deletions DotNet/Normalization/Domain/NormalizationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using LantanaGroup.Link.Normalization.Domain.JsonObjects;
using LantanaGroup.Link.Shared.Application.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;

namespace LantanaGroup.Link.Normalization.Domain.Entities;

Expand Down Expand Up @@ -48,4 +49,17 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
v => JsonSerializer.Deserialize<Dictionary<string, string>>(v, new JsonSerializerOptions())
);
}

partial void OnModelCreatingPartial(ModelBuilder modelBuilder);

public class NormalizationDbContextFactory : IDesignTimeDbContextFactory<NormalizationDbContext>
{
public NormalizationDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<NormalizationDbContext>();
optionsBuilder.UseSqlServer();

return new NormalizationDbContext(optionsBuilder.Options);
}
}
}
5 changes: 4 additions & 1 deletion DotNet/Normalization/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"ClientId": "normalization"
},
"EnableSwagger": true,

"AutoMigrate": true,
"ConnectionStrings": {
"DatabaseConnection": "Data Source;Initial;Integrated Security=True;"
},
"Authentication": {
"EnableAnonymousAccess": false,
"Schemas": {
Expand Down
4 changes: 4 additions & 0 deletions DotNet/Notification/Notification.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<PackageReference Include="MailKit" Version="4.*" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.*" />
<PackageReference Include="Microsoft.Azure.AppConfiguration.AspNetCore" Version="7.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Compliance.Redaction" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Telemetry" Version="8.*" />
Expand Down
35 changes: 23 additions & 12 deletions DotNet/Notification/Persistence/NotificationDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
using LantanaGroup.Link.Notification.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using System.Linq.Expressions;

namespace LantanaGroup.Link.Notification.Persistence
namespace LantanaGroup.Link.Notification.Persistence;

public class NotificationDbContext : DbContext
{
public class NotificationDbContext : DbContext
public NotificationDbContext(DbContextOptions<NotificationDbContext> options) : base(options)
{
public NotificationDbContext(DbContextOptions<NotificationDbContext> options) : base(options)
{
}
}

public DbSet<NotificationEntity> Notifications { get; set; } = null!;
public DbSet<NotificationConfig> NotificationConfigs { get; set; } = null!;
public DbSet<NotificationEntity> Notifications { get; set; } = null!;
public DbSet<NotificationConfig> NotificationConfigs { get; set; } = null!;

protected override void OnModelCreating(ModelBuilder modelBuilder)
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfigurationsFromAssembly(typeof(NotificationDbContext).Assembly);
base.OnModelCreating(modelBuilder);
}

public class NotificationDbContextFactory : IDesignTimeDbContextFactory<NotificationDbContext>
{
public NotificationDbContext CreateDbContext(string[] args)
{
modelBuilder.ApplyConfigurationsFromAssembly(typeof(NotificationDbContext).Assembly);
base.OnModelCreating(modelBuilder);
}
var optionsBuilder = new DbContextOptionsBuilder<NotificationDbContext>();
optionsBuilder.UseSqlServer();

return new NotificationDbContext(optionsBuilder.Options);
}
}
}
}
3 changes: 3 additions & 0 deletions DotNet/Notification/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
},
"EnableSwagger": true,
"DatabaseProvider": "SqlServer",
"ConnectionStrings": {
"DatabaseConnection": "Data Source;Initial;Integrated Security=True;"
},
"KafkaConnection": {
"BootstrapServers": [ "localhost:9092/" ],
"ClientId": "notification"
Expand Down
18 changes: 9 additions & 9 deletions DotNet/QueryDispatch/Domain/Context/QueryDispatchDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
//dotnet ef migrations add <NAME OF MIGRATION>
//dotnet ef database update

//public class QueryDispatchDbContextFactory : IDesignTimeDbContextFactory<QueryDispatchDbContext>
//{
// public QueryDispatchDbContext CreateDbContext(string[] args)
// {
// var optionsBuilder = new DbContextOptionsBuilder<QueryDispatchDbContext>();
// optionsBuilder.UseSqlServer("");
public class QueryDispatchDbContextFactory : IDesignTimeDbContextFactory<QueryDispatchDbContext>
{
public QueryDispatchDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<QueryDispatchDbContext>();
optionsBuilder.UseSqlServer("");

// return new QueryDispatchDbContext(optionsBuilder.Options);
// }
//}
return new QueryDispatchDbContext(optionsBuilder.Options);
}
}
}
2 changes: 1 addition & 1 deletion DotNet/QueryDispatch/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
},
"ConnectionStrings": {
//"DatabaseConnection": "Server=localhost\\SQLEXPRESS; Initial Catalog=link-dev-botw-querydispatch;Integrated Security=true;Encrypt=false;TrustServerCertificate=True"
"DatabaseConnection": "Server=localhost\\SQLEXPRESS; Initial Catalog=link-dev-botw-querydispatch;Integrated Security=true;Encrypt=false;TrustServerCertificate=True"
},
"ServiceRegistry": {
"TenantService": {
Expand Down
3 changes: 3 additions & 0 deletions DotNet/Submission/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
"TokenLifespan": 10
},
"DatabaseProvider": "SqlServer",
"ConnectionStrings": {
"DatabaseConnection": "Data Source;Initial;Integrated Security=True;"
},
"CORS": {
"AllowAllOrigins": true,
"AllowedOrigins": [ "http://localhost:5218", "http://localhost:4200" ],
Expand Down
42 changes: 26 additions & 16 deletions DotNet/Tenant/Repository/Context/FacilityDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
using LantanaGroup.Link.Tenant.Entities;
using LantanaGroup.Link.Tenant.Repository.Mapping;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;

namespace LantanaGroup.Link.Tenant.Repository.Context
namespace LantanaGroup.Link.Tenant.Repository.Context;

public class FacilityDbContext : DbContext
{
public class FacilityDbContext : DbContext
public FacilityDbContext(DbContextOptions<FacilityDbContext> options) : base(options)
{
public FacilityDbContext(DbContextOptions<FacilityDbContext> options) : base(options)
{
}
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new FacilityConfigMap());
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new FacilityConfigMap());

modelBuilder.Entity<FacilityConfigModel>()
.Property(b => b.Id)
.HasConversion(
v => new Guid(v),
v => v.ToString()
);
modelBuilder.Entity<FacilityConfigModel>()
.Property(b => b.Id)
.HasConversion(
v => new Guid(v),
v => v.ToString()
);

}
}

public DbSet<FacilityConfigModel> Facilities { get; set; }

public DbSet<FacilityConfigModel> Facilities { get; set; }
public class FacilityDbContextFactory : IDesignTimeDbContextFactory<FacilityDbContext>
{
public FacilityDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<FacilityDbContext>();
optionsBuilder.UseSqlServer();

return new FacilityDbContext(optionsBuilder.Options);
}
}
}
Loading

0 comments on commit 0ca9d01

Please sign in to comment.