From d8bf615b0245f183e9681b404dcdf3bb3d1e4244 Mon Sep 17 00:00:00 2001 From: Lunastra Date: Mon, 13 Dec 2021 19:37:39 -0800 Subject: [PATCH 1/5] Add method for testing if the file exist or not --- .../ArchivingTests.cs | 89 +++++++++++++++++-- Source Code/main/Controller.cs | 17 ++-- 2 files changed, 93 insertions(+), 13 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.ArchiveTests/ArchivingTests.cs b/Source Code/TeamHobby.HobbyProjectGenerator.ArchiveTests/ArchivingTests.cs index 88e7b50..3d7be64 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.ArchiveTests/ArchivingTests.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.ArchiveTests/ArchivingTests.cs @@ -40,8 +40,8 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests { Directory.Delete(folderPath, true); } - catch { - Console.WriteLine("Folder failed to be deleted"); + catch { + Console.WriteLine("Folder failed to be deleted"); } } else @@ -75,21 +75,63 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests } - public void CopyingToAFileTest(IDataSource sqlDAO) + // [Test Method] + public void IsCSVFileExist(IDataSource sqlDAO) { // Arrange ArchiveManager archiveManager = new ArchiveManager(sqlDAO); SqlDAO sqlDS = null; - + string folderPath = @"C:/HobbyArchive"; + + try + { + bool folderRes = archiveManager.CreateArchiveFolder(); + } + catch (Exception ex) + { + Console.WriteLine("Folder creation for copying failed"); + } + string filePath = archiveManager.CreateOutFileName(); + bool expectedVal = true; + if (sqlDAO.GetType() == typeof(SqlDAO)) { sqlDS = (SqlDAO)sqlDAO; } // Act - - + bool actualVal = false; + if (sqlDS != null) + { + try + { + actualVal = sqlDS.CopyToFile(filePath); + } + catch (Exception ex) + { + Console.WriteLine("Copying to a file failed !!"); + Console.WriteLine(ex.Message); + } + } // Assert + bool result = File.Exists(filePath); + if (result) + { + Console.WriteLine("Expected: {0}, Actual: {1}. CSV file created correctly", expectedVal, actualVal); + // Clean up the folder use to test. + try + { + Directory.Delete(folderPath, true); + } + catch + { + Console.WriteLine("Folder failed to be deleted"); + } + } + else + { + Console.WriteLine("Expected: {0}, Actual: {1}. CSV file created incorrectly", expectedVal, actualVal); + } } @@ -116,6 +158,41 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests Console.WriteLine(""); + // Testing file creation + test.IsCSVFileExist(sqlDAO); + Console.WriteLine("-----------------"); + Console.WriteLine(""); + + // Testing archive Manager + int i = -10; + while (i < 20) + { + DateTime date1 = new DateTime(2021, 12, 1, 0, 0, 0); + //Console.WriteLine("Testing first of month: {0}", date1.ToString("dd")); + //string currentDate = DateTime.Now.ToString("dd"); + //string currentTime = DateTime.Now.ToString("T"); + string currentTime= "00:00:00 AM"; + string currentDate = i.ToString(); + + if (i == 1) + { + currentDate = date1.ToString("dd"); + //ArchiveManager archive = new ArchiveManager(sqlDAO); + //archive.Controller(); + } + + //Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime); + Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime); + if (String.Equals(currentDate, "01") && String.Equals(currentTime, "00:00:00 AM")) + { + Console.WriteLine("Archiving process Start"); + ArchiveManager archive = new ArchiveManager(sqlDAO); + archive.Controller(); + } + + i++; + } + } } diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs index 33c1916..73488f2 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -66,20 +66,23 @@ namespace TeamHobby.HobbyProjectGenerator.Main Console.WriteLine(""); // Closing the connection - sqlDS.getConnection().Close(); + sqlDS.GetConnection().Close(); // While loop to keep this running forever with UserManagement - // Testing archive Manager - //while (true) - //{ + //Testing archive Manager + while (true) + { string currentDate = DateTime.Now.ToString("dd"); string currentTime = DateTime.Now.ToString("T"); + string activateDate = "01"; + string activateTime = "00:00:00 AM"; Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime); - if (String.Equals(currentDate, "1") && String.Equals(currentTime, "00:00:00 AM")){ + if (String.Equals(currentDate, activateDate) && String.Equals(currentTime, activateTime)) + { ArchiveManager archive = new ArchiveManager(datasource); archive.Controller(); } - //} + } @@ -111,7 +114,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main //// Remove entries fromt the database //sqlDS.RemoveEntries(); - + // 2.Inserting Data into the database: From c021d5f04f47e6aa118df51ec4ca15f88da2187c Mon Sep 17 00:00:00 2001 From: colincreasman Date: Mon, 13 Dec 2021 20:18:42 -0800 Subject: [PATCH 2/5] 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 From dfb32b0e261d028650e28f6de4b2e9dc778fb4fc Mon Sep 17 00:00:00 2001 From: Lunastra Date: Mon, 13 Dec 2021 20:50:24 -0800 Subject: [PATCH 3/5] Changed Removed Entries to throw an Error Tested the clean up sequence for Manager --- .../ArchivingTests.cs | 95 +++++++++++++------ .../Implementations/SqlDAO.cs | 14 ++- .../TeamHobby.HobbyProjectGenerator.sln | 8 +- Source Code/main/Controller.cs | 1 + 4 files changed, 81 insertions(+), 37 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.ArchiveTests/ArchivingTests.cs b/Source Code/TeamHobby.HobbyProjectGenerator.ArchiveTests/ArchivingTests.cs index 3d7be64..05a8baa 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.ArchiveTests/ArchivingTests.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.ArchiveTests/ArchivingTests.cs @@ -135,6 +135,68 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests } + // [Test Method] + public void IsProcessFlowCompleted(IDataSource sqlDAO) + { + // Arrange + ArchiveManager archive = new ArchiveManager(sqlDAO); + + // Act + // Testing archive Manager + int i = -10; + while (i < 20) + { + DateTime date1 = new DateTime(2021, 12, 1, 0, 0, 0); + //Console.WriteLine("Testing first of month: {0}", date1.ToString("dd")); + //string currentDate = DateTime.Now.ToString("dd"); + //string currentTime = DateTime.Now.ToString("T"); + string currentTime = "00:00:00 AM"; + string currentDate = i.ToString(); + + if (i == 1) + { + currentDate = date1.ToString("dd"); + //ArchiveManager archive = new ArchiveManager(sqlDAO); + //archive.Controller(); + } + + //Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime); + Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime); + if (String.Equals(currentDate, "01") && String.Equals(currentTime, "00:00:00 AM")) + { + Console.WriteLine("Archiving process Start"); + //ArchiveManager archive = new ArchiveManager(sqlDAO); + archive.Controller(); + } + + i++; + } + + } + + public void IsCleaningUpCompleted(IDataSource sqlDAO) + { + //Arrange + ArchiveManager archive = new ArchiveManager(sqlDAO); + bool actualVal = false; + bool expectedVal = false; + + // Act + actualVal = archive.Controller(); + + // Assert + //bool result = !(actualVal && expectedVal); + if (expectedVal == actualVal) + { + Console.WriteLine("Expected: {0}, Actual: {1}. Error handle correctly", expectedVal, actualVal); + } + else + { + Console.WriteLine("Expected: {0}, Actual: {1}. Error handle incorrectly", expectedVal, actualVal); + } + + } + public static void Main(string[] args) { string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" + @@ -163,35 +225,12 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests Console.WriteLine("-----------------"); Console.WriteLine(""); - // Testing archive Manager - int i = -10; - while (i < 20) - { - DateTime date1 = new DateTime(2021, 12, 1, 0, 0, 0); - //Console.WriteLine("Testing first of month: {0}", date1.ToString("dd")); - //string currentDate = DateTime.Now.ToString("dd"); - //string currentTime = DateTime.Now.ToString("T"); - string currentTime= "00:00:00 AM"; - string currentDate = i.ToString(); + - if (i == 1) - { - currentDate = date1.ToString("dd"); - //ArchiveManager archive = new ArchiveManager(sqlDAO); - //archive.Controller(); - } - - //Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime); - Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime); - if (String.Equals(currentDate, "01") && String.Equals(currentTime, "00:00:00 AM")) - { - Console.WriteLine("Archiving process Start"); - ArchiveManager archive = new ArchiveManager(sqlDAO); - archive.Controller(); - } - - i++; - } + // Testing clean up sequence + //test.IsCleaningUpCompleted(sqlDAO); + //Console.WriteLine("-----------------"); + //Console.WriteLine(""); } diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/SqlDAO.cs b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/SqlDAO.cs index 06b919b..5cf2f70 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/SqlDAO.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/SqlDAO.cs @@ -238,14 +238,12 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess string sqlCmd = "DELETE FROM log WHERE DATEDIFF(current_timestamp, log.LtimeStamp) > 30"; - try{ - DeleteData(sqlCmd); - return true; - } - catch { - Console.WriteLine("Eeep! an error in Remove Entries, not to worry, will be handled higher up the call stack"); - throw; - } + if (DeleteData(sqlCmd) == false) + { + throw new Exception("Error in removing entries,not to worry, will be handled higher up the call stack"); + }; + + return true; } //public Object ReadPreparedStmt(string table){ diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln index bff6309..56de952 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln @@ -17,7 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.Main", "..\TeamHo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.DataAccess", "..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj", "{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator.ArchiveTests", "..\TeamHobby.HobbyProjectGenerator.ArchiveTests\TeamHobby.HobbyProjectGenerator.ArchiveTests.csproj", "{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.ArchiveTests", "..\TeamHobby.HobbyProjectGenerator.ArchiveTests\TeamHobby.HobbyProjectGenerator.ArchiveTests.csproj", "{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTEst1", "..\UnitTEst1\UnitTEst1.csproj", "{139F060F-EE24-4C34-A3AD-148B0C024EF9}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -54,6 +56,10 @@ Global {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|Any CPU.Build.0 = Debug|Any CPU {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|Any CPU.Build.0 = Release|Any CPU + {139F060F-EE24-4C34-A3AD-148B0C024EF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {139F060F-EE24-4C34-A3AD-148B0C024EF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {139F060F-EE24-4C34-A3AD-148B0C024EF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {139F060F-EE24-4C34-A3AD-148B0C024EF9}.Release|Any CPU.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 73488f2..5f6c8b2 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -56,6 +56,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main reader = (OdbcDataReader)result; } + // [Logname, loglevel, date, time, ...] Console.WriteLine("Reading from the database"); while (reader.Read()) From cdba27ee1297fcc28fa0a8b70320d11d117d614d Mon Sep 17 00:00:00 2001 From: Lunastra Date: Mon, 13 Dec 2021 20:52:58 -0800 Subject: [PATCH 4/5] Delete a blank space --- .../ArchivingTests.cs | 2 +- .../TeamHobby.HobbyProjectGenerator.sln | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.ArchiveTests/ArchivingTests.cs b/Source Code/TeamHobby.HobbyProjectGenerator.ArchiveTests/ArchivingTests.cs index 05a8baa..7da2223 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.ArchiveTests/ArchivingTests.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.ArchiveTests/ArchivingTests.cs @@ -225,7 +225,7 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests Console.WriteLine("-----------------"); Console.WriteLine(""); - + // Testing clean up sequence //test.IsCleaningUpCompleted(sqlDAO); diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln index 56de952..ac07ef1 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln @@ -19,8 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGener EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.ArchiveTests", "..\TeamHobby.HobbyProjectGenerator.ArchiveTests\TeamHobby.HobbyProjectGenerator.ArchiveTests.csproj", "{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTEst1", "..\UnitTEst1\UnitTEst1.csproj", "{139F060F-EE24-4C34-A3AD-148B0C024EF9}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -56,10 +54,6 @@ Global {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|Any CPU.Build.0 = Debug|Any CPU {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|Any CPU.Build.0 = Release|Any CPU - {139F060F-EE24-4C34-A3AD-148B0C024EF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {139F060F-EE24-4C34-A3AD-148B0C024EF9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {139F060F-EE24-4C34-A3AD-148B0C024EF9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {139F060F-EE24-4C34-A3AD-148B0C024EF9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From ba6db79f09a22c442d77b6d30cb0edfd98c910eb Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 02:16:21 -0800 Subject: [PATCH 5/5] removed unused files --- .../Class1.cs | 7 - .../Credentials.cs | 10 -- .../TeamHobby.HobbyProjectGenerator.sln | 64 +-------- Source Code/main/MainMenu.cs | 134 ------------------ Source Code/main/SqlDAO.cs | 50 ------- 5 files changed, 4 insertions(+), 261 deletions(-) delete mode 100644 Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Class1.cs delete mode 100644 Source Code/TeamHobby.HobbyProjectGenerator.Models/Credentials.cs delete mode 100644 Source Code/main/MainMenu.cs delete mode 100644 Source Code/main/SqlDAO.cs diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Class1.cs b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Class1.cs deleted file mode 100644 index e92f039..0000000 --- a/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace TeamHobby.HobbyProjectGenerator.DataAccess -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Models/Credentials.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Models/Credentials.cs deleted file mode 100644 index 2670e8f..0000000 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Models/Credentials.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace TeamHobby.HobbyProjectGenerator.Models -{ - public class Credentials - { - public string userName { get; set; } - - // Syntactic sugar - public string Password { get; set; } - } -} \ No newline at end of file diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln index dafe8e1..c386760 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln @@ -3,110 +3,54 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31919.166 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.UserManagement.Tests", "..\TeamHobby.UserManagement.Tests\TeamHobby.UserManagement.Tests.csproj", "{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Models", "..\TeamHobby.HobbyProjectGenerator.Models\TeamHobby.HobbyProjectGenerator.Models.csproj", "{75DED6C2-D404-4E71-A58B-0F616DB5C062}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "main", "..\main\main.csproj", "{30C7EBF3-3957-46E5-86C1-C13356841ECA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Archive", "..\TeamHobby.HobbyProjectGenerator.Archive\TeamHobby.HobbyProjectGenerator.Archive.csproj", "{B88ED0D9-72E2-4245-BD8F-856FF42E500C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.Main", "..\TeamHobby.Main\TeamHobby.Main.csproj", "{ED126EFB-B337-42F9-BE4B-65A5AE90503B}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.DataAccess", "..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj", "{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Logging", "..\TeamHobby.HobbyProjectGenerator.Logging\TeamHobby.HobbyProjectGenerator.Logging.csproj", "{C0494115-838E-43A3-8896-133E5D1E874A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.UserManagement", "..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj", "{2E7193B8-86B6-48DA-9671-CD84615A5F5D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Logging.Tests", "..\TeamHobby.HobbyProjectGenerator.Logging.Tests\TeamHobby.HobbyProjectGenerator.Logging.Tests.csproj", "{CA8D11CF-807C-4C90-A529-0371F73518F6}" -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator.ArchiveTests", "..\TeamHobby.HobbyProjectGenerator.ArchiveTests\TeamHobby.HobbyProjectGenerator.ArchiveTests.csproj", "{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.ArchiveTests", "..\TeamHobby.HobbyProjectGenerator.ArchiveTests\TeamHobby.HobbyProjectGenerator.ArchiveTests.csproj", "{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU 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|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 - {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|Any CPU.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 - {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|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 - {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|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 - {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|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 - {ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Debug|Any CPU.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 - {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|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 - {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|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 - {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|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 - {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|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 + {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Source Code/main/MainMenu.cs b/Source Code/main/MainMenu.cs deleted file mode 100644 index 64a8930..0000000 --- a/Source Code/main/MainMenu.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; - -namespace TeamHobby.HobbyProjectGenerator.Main -{ - public class MainMenu - { - /*static void Main(string[] args) - { - /* ExampleDAO z = new ExampleDAO(); - z.UserData("Tomato"); - Console.Read();*/ - /*bool menu = true; - - // Set up menu loop - while (menu == true) - { - // 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; - - - // Create intial menu - Console.WriteLine("What would you like to do?"); - int num = 1; - Console.WriteLine(num + ".Create a new user account."); - num += 1; - Console.WriteLine(num + ".Acess Admin Features."); - - // Set up try-catch for invalid inputs - try - { - // Get user choice - string initialChoice = Console.ReadLine(); - // Convert to integer - int Choice = Convert.ToInt32(initialChoice); - - switch (Choice) - { - // Create a new account - case 1: - // Get username - Console.WriteLine("Please enter a username:"); - string userName = Console.ReadLine(); - - // Get Password - Console.WriteLine("Please enter a password:"); - string userPassword = Console.ReadLine(); - - // Create bool value for password confirm loop - bool conPsswrd = true; - // Loop until password is confirmed - while (conPsswrd == true) - { - // Confirm Password - Console.WriteLine("Please re-enter the password:"); - string checkPsswd = Console.ReadLine(); - // Check if passwords match - if (userPassword == checkPsswd) - { - // Get Security question for password reset - Console.WriteLine("Please enter a security question.\n" + - "(EX: What is your favorite food?"); - string SecQuest = Console.ReadLine(); - // Get Security question answer - Console.WriteLine("Please enter the answer for your security question:"); - String SecAnswer = Console.ReadLine(); - - // Call user manager method to create the new user - //int userCreateConfirm = new CreateUser(userName,userPassword,SecQuest,SecAnswer); - - // Check if user creation was successful - /* if (userCreateConfirm = 1) - { - - // Confirm to user that the account has been created - Console.WriteLine("Account created succesfully with the username of" + userName); - } - else - { - - }*/ - /* conPsswrd = false; - } - else - { - Console.WriteLine("Passwords did not match, please try again."); - } - } - break; - // Access Admin features - case 2: - // Ask for Admin login credentials - Console.WriteLine("Please enter a username:"); - string AdminUser = Console.ReadLine(); - Console.WriteLine("Please enter the password for" + AdminUser); - string AdminPsswrd = Console.ReadLine(); - - // Check if the username and password match a record within the administrators - - - // Show new administrator menu - int AdminNum = 0; - Console.WriteLine("Welcome" + AdminUser); - Console.WriteLine("What would you like to do?"); - Console.WriteLine("1.View normal user records."); - Console.WriteLine("2.View Administrator user records."); - Console.WriteLine("3."); - Console.WriteLine(""); - Console.WriteLine(""); - Console.WriteLine(""); - Console.WriteLine(""); - Console.WriteLine(""); - - - break; - default: - menu = false; - break; - }; - } - // Catch invalid keys such as spamming enter - catch - { - menu = false; - }; - }*/ - - //} - } -} diff --git a/Source Code/main/SqlDAO.cs b/Source Code/main/SqlDAO.cs deleted file mode 100644 index 8e331a7..0000000 --- a/Source Code/main/SqlDAO.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.Data.SqlClient; -using TeamHobby.HobbyProjectGenerator.Models; - -namespace TeamHobby.HobbyProjectGenerator.DAL -{ - public class SqlDAO - { - public IList GetUserData(string username) - { - // Sql server connection string, needs to be changed accordingly to connect - var connString = "server=localhost;userid=root;password=Plop20;database=users"; // Using @" " makes the string literal - - // ADO.NET - ODBC - using (var conn = new SqlConnection(connString)) - { - // More complex sql commands are done in this method instead - var sql = "Select * from roles"; - using (var command = new SqlCommand(sql, conn)) - { - // Get the results from the query - SqlDataReader r = command.ExecuteReader(); - - // If you wanted to get a singular value back such as a count of a certain item - //command.ExecuteScalar(); - - // To execute something that doesn't expect results to come back - // Use this method instead, IE. Update command - //command.ExecuteNonQuery(); - - // Read data from query - while (r.Read()) - { - Console.WriteLine(r.ToString()); - } - return null; - } - - /*// this is meant for specific basic sql commands - using (var adapter = new SqlDataAdapter()) - { - adapter.UpdateCommand - adapter.DeleteCommand - adapter.InsertCommand - adapter.SelectCommand - }*/ - - } - } - } -}