From c021d5f04f47e6aa118df51ec4ca15f88da2187c Mon Sep 17 00:00:00 2001 From: colincreasman Date: Mon, 13 Dec 2021 20:18:42 -0800 Subject: [PATCH] Added initial Logging library --- ...Hobby.HobbyProjectGenerator.Archive.csproj | 1 + .../Contracts/ILogger.cs | 2 +- .../Contracts/ILoggerFactory.cs | 1 + .../Implementations/ConsoleLogger.cs | 35 ++++---- .../Implementations/FileLogger.cs | 35 ++++---- .../Implementations/InMemoryLogger.cs | 86 ++++++++++++------- .../LogEntry.cs | 24 ++++++ ...LoggingController.cs => LoggingManager.cs} | 10 +-- ...Hobby.HobbyProjectGenerator.Logging.csproj | 1 + .../TeamHobby.HobbyProjectGenerator.sln | 80 ++++++++--------- Source Code/main/Controller.cs | 38 +++++--- Source Code/main/main.csproj | 3 +- 12 files changed, 188 insertions(+), 128 deletions(-) rename Source Code/TeamHobby.HobbyProjectGenerator.Logging/{LoggingController.cs => LoggingManager.cs} (81%) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/TeamHobby.HobbyProjectGenerator.Archive.csproj b/Source Code/TeamHobby.HobbyProjectGenerator.Archive/TeamHobby.HobbyProjectGenerator.Archive.csproj index 09da541..65fcde5 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/TeamHobby.HobbyProjectGenerator.Archive.csproj +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Archive/TeamHobby.HobbyProjectGenerator.Archive.csproj @@ -4,6 +4,7 @@ net6.0 enable enable + AnyCPU;x86 diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILogger.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILogger.cs index 75e8078..9aee5ba 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILogger.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILogger.cs @@ -10,7 +10,7 @@ namespace TeamHobby.HobbyProjectGenerator.Logging { bool Log(LogEntry log); - IList GetAllLogs(); + // IList GetAllLogs(); } } diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILoggerFactory.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILoggerFactory.cs index 6de5ce3..cf0d199 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILoggerFactory.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILoggerFactory.cs @@ -10,6 +10,7 @@ namespace TeamHobby.HobbyProjectGenerator.Logging.Contracts { ILogger CreateLogger() { + return new DBLogger(); } } } diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/ConsoleLogger.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/ConsoleLogger.cs index 28195f5..ba0c24d 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/ConsoleLogger.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/ConsoleLogger.cs @@ -1,21 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +// using System; +// using System.Collections.Generic; +// using System.Linq; +// using System.Text; +// using System.Threading.Tasks; -namespace TeamHobby.HobbyProjectGenerator.Logging -{ - public class ConsoleLogger : ILogger - { - public IList GetAllLogs() - { - throw new NotImplementedException(); - } - - public bool Log(string description) - { - throw new NotImplementedException(); - } - } -} +// namespace TeamHobby.HobbyProjectGenerator.Logging +// { +// public class ConsoleLogger : ILogger +// { +// public bool Log(LogEntry log) +// { +// return true; +// } +// } +// } diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/FileLogger.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/FileLogger.cs index 1ca93a8..522f7ab 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/FileLogger.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/FileLogger.cs @@ -1,18 +1,23 @@ -using System; +// using System; -namespace TeamHobby.HobbyProjectGenerator.Logging -{ - public class FileLogger : ILogger - { - public IList GetAllLogs() - { - throw new NotImplementedException(); - } +// namespace TeamHobby.HobbyProjectGenerator.Logging +// { +// public class FileLogger : Ilogger +// { +// public FileLogger() +// { +// } - public bool Log(string description) - { - throw new NotImplementedException(); - } - } +// public IList GetAllLogs() +// { +// throw new NotImplementedException(); +// } -} \ No newline at end of file +// public bool Log(LogEntry log) +// { +// throw new NotImplementedException(); +// } + +// } + +// } \ No newline at end of file diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/InMemoryLogger.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/InMemoryLogger.cs index 80dacb7..233e083 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/InMemoryLogger.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/InMemoryLogger.cs @@ -1,38 +1,58 @@ -using System; -using System.Collections.Generic; -namespace TeamHobby.HobbyProjectGenerator.Logging -{ - // implementation of ILogger that stores logs as they initialize - public class InMemoryLogger : ILogger - { - // make readonly to prevent it from being changed somewhere other than in the constructor - private readonly IList _logStore; +// using System; +// using System.Collections.Generic; +// namespace TeamHobby.HobbyProjectGenerator.Logging +// { +// // implementation of ILogger that stores logs as they initialize +// public class InMemoryLogger : ILogger +// { +// // make readonly to prevent it from being changed somewhere other than in the constructor +// private readonly IList _logStore; - public InMemoryLogger() - { - // list of current logs - _logStore = new List(); - } +// public InMemoryLogger() +// { +// // list of current logs +// _logStore = new List(); +// } +// public InMemoryLogger(IList logStore) +// { +// _logStore = logStore; +// } +// public bool Log(LogEntry entry) +// { +// if (entry is null) +// { +// throw new ArgumentNullException(nameof(entry)); +// } - public bool Log(string description) - { - try - { - // string interpolation to add UTC timestamp to log description - _logStore.Add($"{DateTime.UtcNow}-> {description}"); - return true; - } - catch - { - return false; - } - } - public IList GetAllLogs() - { - return _logStore; - } - } +// try +// { +// // string interpolation to add UTC timestamp to log description +// //_logStore.Add($"{DateTime.UtcNow}-> {description}"); +// return true; +// } +// catch +// { +// return false; +// } +// } +// public IList GetAllLogs() +// { +// return _logStore; +// } -} \ No newline at end of file + +// public override bool Equals(object? obj) +// { +// return obj is InMemoryLogger logger && +// EqualityComparer>.Default.Equals(_logStore, logger._logStore); +// } + +// public override int GetHashCode() +// { +// return HashCode.Combine(_logStore); +// } +// } + +// } \ No newline at end of file diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/LogEntry.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/LogEntry.cs index fb85775..af049d1 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/LogEntry.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/LogEntry.cs @@ -26,5 +26,29 @@ namespace TeamHobby.HobbyProjectGenerator.Logging public string description { get; init; } public DateTime timestamp { get; init; } + + // Constructor requireing only the description as an arg + // Assigns default values for LogLevel (Info), LogCategory (Server), user ("System"), and the UTC time at initialization for timestamp + public LogEntry(string description) + { + this.level = LogLevel.Info; + this.category = LogCategory.Server; + this.user = "System"; + this.description = description; + this.timestamp = DateTime.UtcNow; + } + // Constructor with args for all fields except timestamp + // timestamp is always set to the UTC time at the time of initialization + public LogEntry(LogLevel level, string user, LogCategory category, string description) + { + this.level = level; + this.category = category; + this.user = user; + this.description = description; + this.timestamp = DateTime.UtcNow; + } + + } } + diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/LoggingController.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/LoggingManager.cs similarity index 81% rename from Source Code/TeamHobby.HobbyProjectGenerator.Logging/LoggingController.cs rename to Source Code/TeamHobby.HobbyProjectGenerator.Logging/LoggingManager.cs index 09de227..ca367fe 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/LoggingController.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/LoggingManager.cs @@ -9,23 +9,23 @@ using TeamHobby.HobbyProjectGenerator.Logging.Implementations; namespace TeamHobby.HobbyProjectGenerator.Logging { - internal class LoggingController + internal class LoggingManager { private readonly IDataSource _conn; private readonly ILogger _logger; private readonly ILoggerFactory _factory; - // private readonly LogEntry _logEntry; + private readonly LogEntry _logEntry; // Both Constructors take an IDataSource arg to make logging extensible to future data sources // first constructor has no additional args - defaults to using the DBFactiry implementation - public LoggingController(IDataSource dataSource) + public LoggingManager(IDataSource dataSource) { _conn = dataSource; _factory = new DBLoggerFactory(); _logger = _factory.CreateLogger(); } // second constructor takes an additional ILoggerFactory arg - allows for extensible logger types - public LoggingController(IDataSource dataSource, ILoggerFactory factory) + public LoggingManager(IDataSource dataSource, ILoggerFactory factory) { _conn = dataSource; _factory = factory; @@ -35,7 +35,7 @@ namespace TeamHobby.HobbyProjectGenerator.Logging public void Process() { - _logger.Log(); + _logger.Log(_logEntry); } diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/TeamHobby.HobbyProjectGenerator.Logging.csproj b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/TeamHobby.HobbyProjectGenerator.Logging.csproj index 20a5fff..c9596e5 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/TeamHobby.HobbyProjectGenerator.Logging.csproj +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/TeamHobby.HobbyProjectGenerator.Logging.csproj @@ -4,6 +4,7 @@ net6.0 enable enable + AnyCPU;x86 diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln index 3f2c1f0..588b307 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln @@ -26,87 +26,87 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Debug|x86 = Debug|x86 + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU - Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|x86.ActiveCfg = Debug|Any CPU - {C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|x86.Build.0 = Debug|Any CPU + {C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.Build.0 = Release|Any CPU {C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU {C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.Build.0 = Release|Any CPU - {C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|x86.ActiveCfg = Release|Any CPU - {C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|x86.Build.0 = Release|Any CPU {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|x86.ActiveCfg = Debug|Any CPU + {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.Build.0 = Release|Any CPU {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.ActiveCfg = Release|Any CPU {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.Build.0 = Release|Any CPU - {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|x86.ActiveCfg = Release|Any CPU - {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|x86.Build.0 = Release|Any CPU {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.Build.0 = Debug|Any CPU - {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|x86.ActiveCfg = Debug|Any CPU - {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|x86.Build.0 = Debug|Any CPU + {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.Build.0 = Debug|Any CPU + {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.ActiveCfg = Release|Any CPU + {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.Build.0 = Release|Any CPU {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.ActiveCfg = Release|Any CPU {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.Build.0 = Release|Any CPU - {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|x86.ActiveCfg = Release|Any CPU - {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|x86.Build.0 = Release|Any CPU {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|x86.ActiveCfg = Debug|Any CPU - {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|x86.Build.0 = Debug|Any CPU + {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.Build.0 = Release|Any CPU {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.ActiveCfg = Release|Any CPU {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.Build.0 = Release|Any CPU - {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|x86.ActiveCfg = Release|Any CPU - {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|x86.Build.0 = Release|Any CPU {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|x86.ActiveCfg = Debug|Any CPU - {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|x86.Build.0 = Debug|Any CPU + {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.Build.0 = Release|Any CPU {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.ActiveCfg = Release|Any CPU {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.Build.0 = Release|Any CPU - {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|x86.ActiveCfg = Release|Any CPU - {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|x86.Build.0 = Release|Any CPU {ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Debug|x86.ActiveCfg = Debug|Any CPU + {ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.Build.0 = Release|Any CPU {ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.ActiveCfg = Release|Any CPU {ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.Build.0 = Release|Any CPU - {ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|x86.ActiveCfg = Release|Any CPU - {ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|x86.Build.0 = Release|Any CPU {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|x86.ActiveCfg = Debug|x86 - {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|x86.Build.0 = Debug|x86 + {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.Build.0 = Release|Any CPU {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.ActiveCfg = Release|Any CPU {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.Build.0 = Release|Any CPU - {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|x86.ActiveCfg = Release|Any CPU - {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|x86.Build.0 = Release|Any CPU {C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C0494115-838E-43A3-8896-133E5D1E874A}.Debug|x86.ActiveCfg = Debug|Any CPU - {C0494115-838E-43A3-8896-133E5D1E874A}.Debug|x86.Build.0 = Debug|Any CPU + {C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.Build.0 = Release|Any CPU {C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.ActiveCfg = Release|Any CPU {C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.Build.0 = Release|Any CPU - {C0494115-838E-43A3-8896-133E5D1E874A}.Release|x86.ActiveCfg = Release|Any CPU - {C0494115-838E-43A3-8896-133E5D1E874A}.Release|x86.Build.0 = Release|Any CPU {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|x86.ActiveCfg = Debug|Any CPU - {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|x86.Build.0 = Debug|Any CPU + {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|Any CPU.Build.0 = Release|Any CPU {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|Any CPU.Build.0 = Release|Any CPU - {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|x86.ActiveCfg = Release|Any CPU - {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|x86.Build.0 = Release|Any CPU {CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|x86.ActiveCfg = Debug|x86 - {CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|x86.Build.0 = Debug|x86 + {CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|Any CPU.Build.0 = Release|Any CPU {CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|Any CPU.ActiveCfg = Release|Any CPU {CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|Any CPU.Build.0 = Release|Any CPU - {CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|x86.ActiveCfg = Release|Any CPU - {CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs index d44e163..557eb25 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -6,8 +6,10 @@ using TeamHobby.HobbyProjectGenerator.Logging; using TeamHobby.HobbyProjectGenerator.UserManagement; namespace TeamHobby.HobbyProjectGenerator.Main { + public class GetCredentials { + public string? GetUserName() { Console.WriteLine("Please enter a username:"); @@ -24,6 +26,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main } public class Controller { + public static void Main(string[] args) { // Logger log = new Logger(); @@ -31,28 +34,34 @@ namespace TeamHobby.HobbyProjectGenerator.Main //GetCredentials credentials = new GetCredentials(); //string? username = credentials.GetUserName(); //string? password = credentials.GetPassword(); - - +// Console customization + // Change the look of the console + Console.Title = "HobbyProjectGenerator"; + // Change console text color + Console.ForegroundColor = ConsoleColor.Green; + // Change terminal height + Console.WindowHeight = 40; //Console.WriteLine(value: $"username is {username}\npassword is {password}"); // Creating the Factory class // Creating the Factory class - + string dbType = "sql"; RDSFactory factory = new RDSFactory(); // Testing Data Access Layer string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" + - "TCPIP=1;" + - "SERVER=localhost;" + - "DATABASE=hobby;" + - "UID=root;" + - "PASSWORD=Teamhobby;" + - "PORT=3306;"; - IDataSource datasource = dbFactory.getDataSource(dbType, dbInfo); + "TCPIP=1;" + + "SERVER=localhost;" + + "DATABASE=hobby;" + + "UID=root;" + + "PASSWORD=Teamhobby;" + + "PORT=3306;" + + "OPTION=3"; + // IDataSource datasource = factory.getDataSource(dbType, dbInfo); - "OPTION=3"; - IDataSource datasource = factory.getDataSource(dbType, dbInfo);*/ + + IDataSource datasource = factory.getDataSource(dbType, dbInfo); // Create manager class from UserManagement SystemAccountManager manager = new SystemAccountManager(); @@ -190,7 +199,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main break; // Create a new account case 1: - user.newUser(); + user.newUser(); break; // Access Admin features case 2: @@ -232,4 +241,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main } } + } } + + diff --git a/Source Code/main/main.csproj b/Source Code/main/main.csproj index 31ccaf6..6444b61 100644 --- a/Source Code/main/main.csproj +++ b/Source Code/main/main.csproj @@ -5,7 +5,8 @@ net6.0 enable enable - x86 + AnyCPU + AnyCPU