Merge remote-tracking branch 'origin/main'

This commit is contained in:
Janus C. H. Knudsen 2025-02-12 19:56:24 +01:00
commit 48578b216f
5 changed files with 44 additions and 17 deletions

View file

@ -41,7 +41,7 @@ namespace PlanTempus
builder.RegisterModule(new Core.ModuleRegistry.TelemetryModule builder.RegisterModule(new Core.ModuleRegistry.TelemetryModule
{ {
TelemetryConfig = ConfigurationRoot.GetSection(nameof(Core.ModuleRegistry.TelemetryConfig)).Get<Core.ModuleRegistry.TelemetryConfig>() TelemetryConfig = ConfigurationRoot.GetSection(nameof(Core.ModuleRegistry.TelemetryConfig)).ToObject<Core.ModuleRegistry.TelemetryConfig>()
}); });

View file

@ -25,7 +25,7 @@ namespace Database.Core.DCL
{ {
_db = db; _db = db;
} }
public void Setup(string schema = null) public void Setup(string schema = null)
{ {
throw new NotImplementedException(); throw new NotImplementedException();

View file

@ -26,7 +26,7 @@ namespace Database.Core.DDL
/// <param name="schema">The schema name where the tables will be created.</param> /// <param name="schema">The schema name where the tables will be created.</param>
public void With(Command emptyByIntention) public void With(Command emptyByIntention)
{ {
using (_transaction = _db.BeginTransaction()) using (_transaction = _db.OpenWithTransaction())
{ {
try try
{ {
@ -56,7 +56,7 @@ namespace Database.Core.DDL
/// <summary> /// <summary>
/// Creates the users table /// Creates the users table
/// </summary> /// </summary>
public void CreateUsersTable() void CreateUsersTable()
{ {
var sql = @" var sql = @"
CREATE TABLE IF NOT EXISTS users ( CREATE TABLE IF NOT EXISTS users (
@ -80,7 +80,7 @@ namespace Database.Core.DDL
/// <summary> /// <summary>
/// Creates the tenants table /// Creates the tenants table
/// </summary> /// </summary>
public void CreateTenantsTable() void CreateTenantsTable()
{ {
var sql = @" var sql = @"
CREATE TABLE IF NOT EXISTS tenants ( CREATE TABLE IF NOT EXISTS tenants (
@ -98,7 +98,7 @@ namespace Database.Core.DDL
/// <summary> /// <summary>
/// Creates the user_tenants table /// Creates the user_tenants table
/// </summary> /// </summary>
public void CreateUserTenantsTable() void CreateUserTenantsTable()
{ {
var sql = @" var sql = @"
CREATE TABLE IF NOT EXISTS user_tenants ( CREATE TABLE IF NOT EXISTS user_tenants (
@ -116,7 +116,7 @@ namespace Database.Core.DDL
/// <summary> /// <summary>
/// Sets up Row Level Security (RLS) for the tenants and user_tenants tables. /// Sets up Row Level Security (RLS) for the tenants and user_tenants tables.
/// </summary> /// </summary>
public void SetupRLS() void SetupRLS()
{ {
var sql = new[] var sql = new[]
{ {

View file

@ -19,10 +19,12 @@ namespace SetupInfrastructure
internal class Program internal class Program
{ {
static IContainer _container; static IContainer _container;
static ConsoleColor _backgroundColor = Console.BackgroundColor;
static ConsoleColor _foregroundColor = Console.ForegroundColor;
static async Task Main(string[] args) static async Task Main(string[] args)
{ {
Welcome();
string userPass; string userPass;
try try
@ -43,10 +45,17 @@ namespace SetupInfrastructure
if (IsSuperAdmin()) if (IsSuperAdmin())
{ {
var setup = _container.Resolve<Database.Core.DCL.SetupApplicationUser>(); Console.ForegroundColor = ConsoleColor.Green;
setup.With(new Database.Core.DCL.SetupApplicationUser.Command { Password = "3911", Schema = "system", User = "sathumper" }); var setupApplicationUser = _container.Resolve<Database.Core.DCL.SetupApplicationUser>();
setupApplicationUser.With(new Database.Core.DCL.SetupApplicationUser.Command { Password = "3911", Schema = "system", User = "sathumper" });
Console.WriteLine("Database.Core.DCL.SetupApplicationUser done!");
Console.WriteLine();
// SetupApplicationUser //create new container with application user, we use that role from now.
_container = new Startup().ConfigureContainer(new Startup.ConnectionStringTemplateParameters("sathumper", "3911"));
var setupIdentitySystem = _container.Resolve<Database.Core.DDL.SetupIdentitySystem>();
setupIdentitySystem.With(new Database.Core.DDL.SetupIdentitySystem.Command());
// SetupIdentitySystem // SetupIdentitySystem
// SetupConfiguration // SetupConfiguration
@ -56,7 +65,7 @@ namespace SetupInfrastructure
// input configurations!!! TODO:Missing // input configurations!!! TODO:Missing
Console.ForegroundColor = _foregroundColor;
} }
@ -74,8 +83,7 @@ namespace SetupInfrastructure
static bool IsSuperAdmin() static bool IsSuperAdmin()
{ {
var backgroundColor = Console.BackgroundColor;
var foregroundColor = Console.ForegroundColor;
//test db access //test db access
Console.WriteLine("Testing db access..."); Console.WriteLine("Testing db access...");
@ -96,7 +104,7 @@ namespace SetupInfrastructure
Console.WriteLine("TEST SUCCESSFULLY"); Console.WriteLine("TEST SUCCESSFULLY");
Console.WriteLine(); Console.WriteLine();
Console.ForegroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = backgroundColor; Console.BackgroundColor = _backgroundColor;
Console.WriteLine("-------------------------------"); Console.WriteLine("-------------------------------");
Console.WriteLine(); Console.WriteLine();
Console.WriteLine($"Username: {username}"); Console.WriteLine($"Username: {username}");
@ -118,7 +126,7 @@ namespace SetupInfrastructure
Console.WriteLine("TEST WAS NOT SUCCESSFULLY"); Console.WriteLine("TEST WAS NOT SUCCESSFULLY");
Console.WriteLine(); Console.WriteLine();
Console.ForegroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = backgroundColor; Console.BackgroundColor = _backgroundColor;
Console.WriteLine("-------------------------------"); Console.WriteLine("-------------------------------");
Console.WriteLine(); Console.WriteLine();
Console.WriteLine($"Username: {username}"); Console.WriteLine($"Username: {username}");
@ -133,6 +141,25 @@ namespace SetupInfrastructure
return false; return false;
}
static void Welcome()
{
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(@"__________.__ ___________
\______ \ | _____ ___\__ ___/___ _____ ______ __ __ ______
| ___/ | \__ \ / \| |_/ __ \ / \\____ \| | \/ ___/
| | | |__/ __ \| | \ |\ ___/| Y Y \ |_> > | /\___ \
|____| |____(____ /___| /____| \___ >__|_| / __/|____//____ >
\/ \/ \/ \/|__| \/
_________ __
/ _____/ _____/ |_ __ ________
\_____ \_/ __ \ __\ | \____ \
/ \ ___/| | | | / |_> >
/_______ /\___ >__| |____/| __/
\/ \/ |__|");
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.White;
} }
} }
} }

View file

@ -1,7 +1,7 @@
{ {
"AllowedHosts": "*", "AllowedHosts": "*",
"ConnectionStrings": { "ConnectionStrings": {
"DefaultConnection": "Host=192.168.1.57;Port=5432;Database=sandbox;User Id=postgres;Password=3911;" "DefaultConnection": "Host=192.168.1.57;Port=5432;Database=ptmain;User Id=sathumper;Password=3911;"
}, },
"ApplicationInsights": { "ApplicationInsights": {
"ConnectionString": "InstrumentationKey=6d2e76ee-5343-4691-a5e3-81add43cb584;IngestionEndpoint=https://northeurope-0.in.applicationinsights.azure.com/" "ConnectionString": "InstrumentationKey=6d2e76ee-5343-4691-a5e3-81add43cb584;IngestionEndpoint=https://northeurope-0.in.applicationinsights.azure.com/"