This commit is contained in:
Janus Knudsen 2025-02-12 17:38:01 +01:00
parent 6839cd82e2
commit cf25e6fa0a
5 changed files with 44 additions and 17 deletions

View file

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