From 487138890ae5f7278fc935f0501c962d20a6510d Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Mon, 13 Dec 2021 21:41:27 -0800 Subject: [PATCH 01/16] adjusted files to build menu and start testing --- .../Contracts/ILogger.cs | 3 +- .../Contracts/ILoggerFactory.cs | 3 +- .../Implementations/ConsoleLogger.cs | 3 +- .../Implementations/DBLogger.cs | 4 +- .../Implementations/DBLoggerFactory.cs | 3 +- .../Implementations/FileLogger.cs | 4 +- .../Implementations/InMemoryLogger.cs | 4 +- .../LogEntry.cs | 3 +- .../LoggingController.cs | 3 +- .../SystemAccountManager.cs | 22 ++++++--- .../TeamHobby.HobbyProjectGenerator.sln | 28 +++++++----- .../TeamHobby.UserManagement.xTests.csproj | 23 ++++++++++ .../UnitTest1.cs | 13 ++++++ Source Code/main/Controller.cs | 22 ++++----- src/dbCode/UserManagementDDL.txt | 45 ++++++++++--------- 15 files changed, 119 insertions(+), 64 deletions(-) create mode 100644 Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/TeamHobby.UserManagement.xTests.csproj create mode 100644 Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILogger.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILogger.cs index 75e8078..e24ee79 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILogger.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILogger.cs @@ -1,4 +1,4 @@ -using System; +/*using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -14,3 +14,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging } } +*/ \ No newline at end of file diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILoggerFactory.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILoggerFactory.cs index 6de5ce3..430df4c 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILoggerFactory.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Contracts/ILoggerFactory.cs @@ -1,4 +1,4 @@ -using System; +/*using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -13,3 +13,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging.Contracts } } } +*/ \ No newline at end of file diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/ConsoleLogger.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/ConsoleLogger.cs index 28195f5..a7e9f89 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/ConsoleLogger.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/ConsoleLogger.cs @@ -1,4 +1,4 @@ -using System; +/*using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -19,3 +19,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging } } } +*/ \ No newline at end of file diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/DBLogger.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/DBLogger.cs index 132ee82..59e7d2a 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/DBLogger.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/DBLogger.cs @@ -1,4 +1,4 @@ -using System; +/*using System; namespace TeamHobby.HobbyProjectGenerator.Logging { @@ -21,4 +21,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging } -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/DBLoggerFactory.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/DBLoggerFactory.cs index f790cbb..c996ba2 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/DBLoggerFactory.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/DBLoggerFactory.cs @@ -1,4 +1,4 @@ -using System; +/*using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -18,3 +18,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging.Implementations } } } +*/ \ No newline at end of file diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/FileLogger.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/FileLogger.cs index 1ca93a8..7f3582d 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/FileLogger.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/FileLogger.cs @@ -1,4 +1,4 @@ -using System; +/*using System; namespace TeamHobby.HobbyProjectGenerator.Logging { @@ -15,4 +15,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging } } -} \ No newline at end of file +}*/ \ 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..6e51ed9 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/InMemoryLogger.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/Implementations/InMemoryLogger.cs @@ -1,4 +1,4 @@ -using System; +/*using System; using System.Collections.Generic; namespace TeamHobby.HobbyProjectGenerator.Logging { @@ -35,4 +35,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging } } -} \ No newline at end of file +}*/ \ 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..bfd99fe 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/LogEntry.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/LogEntry.cs @@ -1,4 +1,4 @@ -using System; +/*using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -28,3 +28,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging } } +*/ \ No newline at end of file diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/LoggingController.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/LoggingController.cs index 09de227..cea8e12 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Logging/LoggingController.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Logging/LoggingController.cs @@ -1,4 +1,4 @@ -using System; +/*using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -42,3 +42,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging } } +*/ \ No newline at end of file diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs index 28d621e..954d9fa 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs @@ -171,7 +171,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement Console.WriteLine(""); // Closing the connection - sqlDS.getConnection().Close(); + sqlDS.GetConnection().Close(); if (checkSql == "Admin") { @@ -204,12 +204,12 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement AccountService accountService = new AccountService(); // Create credentials object for new inptus GetCredentials newCredentials = new GetCredentials(); - // Print User Management menu - ui.UserManagementMenu(user.username); // Create bool object for menu loop bool menuLoop = true; // Create loop for menu while (menuLoop is true) { + // Print User Management menu + ui.UserManagementMenu(user.username); // Get user choice int menuChoice = Convert.ToInt32(Console.ReadLine()); // Complete the appropriate action @@ -224,8 +224,17 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement UserAccount newUser = new UserAccount(newCredentials.GetUserName(), newCredentials.GetPassword(), newCredentials.GetEmail(), newCredentials.GetRole(), DateTime.UtcNow); - accountService.CreateUserRecord(newUser,user.username, dbSource); - break; + bool accountValid = accountService.CreateUserRecord(newUser,user.username, dbSource); + if (accountValid is true) + { + Console.WriteLine("Account created Successfully"); + break; + } + else + { + return "Database Timed out"; + } + //break; // Edit account case 2: /* UserAccount newEditUser = new UserAccount(newCredentials.GetUserName(), @@ -257,7 +266,8 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement case 7: break; default: - Console.WriteLine("Invalid input.\nPlease enter a valid option.\n"); + Console.WriteLine("Invalid input.\nPlease enter a valid option.\n" + + "------------------------------------\n\n"); break; } } diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln index 0af8103..b7c8ff3 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln @@ -20,7 +20,10 @@ 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}" +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}") = "TeamHobby.UserManagement.xTests", "TeamHobby.UserManagement.xTests\TeamHobby.UserManagement.xTests.csproj", "{6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -30,14 +33,6 @@ Global 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}.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}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -61,7 +56,6 @@ Global {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}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -83,7 +77,6 @@ Global {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}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -107,9 +100,20 @@ Global {CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|x86.ActiveCfg = Release|Any CPU {CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|x86.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}.Debug|x86.ActiveCfg = Debug|Any CPU + {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|x86.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 + {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|x86.ActiveCfg = Release|Any CPU + {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|x86.Build.0 = Release|Any CPU + {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|x86.ActiveCfg = Debug|Any CPU + {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|x86.Build.0 = Debug|Any CPU + {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|Any CPU.Build.0 = Release|Any CPU + {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|x86.ActiveCfg = Release|Any CPU + {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/TeamHobby.UserManagement.xTests.csproj b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/TeamHobby.UserManagement.xTests.csproj new file mode 100644 index 0000000..9f77f5f --- /dev/null +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/TeamHobby.UserManagement.xTests.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + enable + + false + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs new file mode 100644 index 0000000..4f483ad --- /dev/null +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs @@ -0,0 +1,13 @@ +using Xunit; + +namespace TeamHobby.UserManagement.xTests +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + + } + } +} \ No newline at end of file diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs index 0f4e830..47ae7e5 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -2,7 +2,6 @@ using System.Data.Odbc; using TeamHobby.HobbyProjectGenerator.Archive; using TeamHobby.HobbyProjectGenerator.DataAccess; -using TeamHobby.HobbyProjectGenerator.Logging; using TeamHobby.HobbyProjectGenerator.UserManagement; namespace TeamHobby.HobbyProjectGenerator.Main @@ -39,9 +38,11 @@ namespace TeamHobby.HobbyProjectGenerator.Main // Creating the Factory class // Logger log = new Logger(); //Logger.PrintTest(); - //GetCredentials credentials = new GetCredentials(); - //string? username = credentials.GetUserName(); - //string? password = credentials.GetPassword(); + + // Admin login + GetCredentials credentials = new GetCredentials(); + string? username = credentials.GetUserName(); + string? password = credentials.GetPassword(); //Console.WriteLine(value: $"username is {username}\npassword is {password}"); @@ -60,20 +61,14 @@ namespace TeamHobby.HobbyProjectGenerator.Main "UID=root;" + "PASSWORD=Teamhobby;" + "OPTION=3"; - IDataSource datasource = factory.getDataSource(dbType, dbInfo); - "PORT=3306;"; - - - "OPTION=3"; - IDataSource datasource = dbFactory.getDataSource(dbType, dbInfo); // Create manager class from UserManagement SystemAccountManager manager = new SystemAccountManager(); - // Admin Sign in + /* // Admin Sign in GetCredentials credentials = new GetCredentials(); string? username = credentials.GetUserName(); - string? password = credentials.GetPassword(); + string? password = credentials.GetPassword();*/ // Get time of login attempt DateTime TimeStamp = DateTime.UtcNow; @@ -242,8 +237,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main { MainMenu = false; };*/ - //} - + } } } } diff --git a/src/dbCode/UserManagementDDL.txt b/src/dbCode/UserManagementDDL.txt index c8419fc..25da27a 100644 --- a/src/dbCode/UserManagementDDL.txt +++ b/src/dbCode/UserManagementDDL.txt @@ -1,23 +1,3 @@ -create table users -( - UserName varchar(50) charset utf8mb3 not null, - Password varchar(50) charset utf8mb3 not null, - Role varchar(50) charset utf8mb3 not null, - IsActive int default 1 not null, - CreatedBy varchar(50) charset utf8mb3 not null, - CreatedDate datetime not null, - constraint userRole_fk foreign key (Role) references roles (Role), - constraint user_pk primary key (UserName) -); - -INSERT INTO hobby.users (UserName, Password, Role, IsActive, CreatedBy, CreatedDate, Email) VALUES -('Colin ', 'Waffle', 'Admin', 1, 'Jacob', '2021-12-13 04:27:42', null), -('Danny', 'Spartan', 'Admin', 1, 'Jacob', '2021-12-13 04:29:54', null), -('Jacob', 'Teamhobby1234', 'Admin', 1, 'SystemCreator', '2021-12-13 03:25:14', null), -('Long', 'Joystick', 'regular', 1, 'Jacob', '2021-12-13 04:29:57', null), -('Rifat', 'ApproveDar', 'Admin', 1, 'Jacob', '2021-12-13 04:29:55', null); - - create table roles ( RoleID int not null, @@ -28,6 +8,31 @@ create table roles primary key (Role) ); +create table users +( + UserName varchar(50) charset utf8mb3 not null + primary key, + Password varchar(50) charset utf8mb3 not null, + Role varchar(50) charset utf8mb3 not null, + IsActive int default 1 not null, + CreatedBy varchar(50) charset utf8mb3 not null, + CreatedDate datetime not null, + Email varchar(50) null, + constraint users_Email_uindex + unique (Email), + constraint userRole_fk + foreign key (Role) references roles (Role) +); + + +INSERT INTO hobby.users (UserName, Password, Role, IsActive, CreatedBy, CreatedDate, Email) VALUES +('Colin ', 'Waffle', 'Admin', 1, 'Jacob', '2021-12-13 04:27:42', null), +('Danny', 'Spartan', 'Admin', 1, 'Jacob', '2021-12-13 04:29:54', null), +('Jacob', 'Teamhobby1234', 'Admin', 1, 'SystemCreator', '2021-12-13 03:25:14', null), +('Long', 'Joystick', 'regular', 1, 'Jacob', '2021-12-13 04:29:57', null), +('Rifat', '1234', 'Admin', 1, 'Jacob', '2021-12-13 04:29:55', null); + + INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('Admin', 'Jacob', '2021-12-13 03:25:14'), ('regular', 'Colin', '2021-12-13 03:25:14'); From 6f9c6f0f12ed7d62ba3da58ab8126feb46e40e18 Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Mon, 13 Dec 2021 21:48:46 -0800 Subject: [PATCH 02/16] removed roleID --- src/dbCode/UserManagementDDL.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dbCode/UserManagementDDL.txt b/src/dbCode/UserManagementDDL.txt index 25da27a..c4d451b 100644 --- a/src/dbCode/UserManagementDDL.txt +++ b/src/dbCode/UserManagementDDL.txt @@ -1,6 +1,5 @@ create table roles ( - RoleID int not null, Role varchar(50) charset utf8mb3 not null, CreatedBy varchar(200) charset utf8mb3 not null, CreatedDate datetime not null, From a4a133b0cd299aa6fe725f6797b939405e3d4a7c Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Mon, 13 Dec 2021 23:28:47 -0800 Subject: [PATCH 03/16] Menu completed Commented out database connecting lines and added successful login in instead. --- .../Implementations/SqlDAO.cs | 4 +- .../Implementations/UiPrint.cs | 3 +- .../SystemAccountManager.cs | 5 +- Source Code/main/Controller.cs | 85 ++++++++++--------- 4 files changed, 52 insertions(+), 45 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/SqlDAO.cs b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/SqlDAO.cs index 7a14a05..d7bf3e1 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/SqlDAO.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/SqlDAO.cs @@ -17,9 +17,9 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess public SqlDAO(string info) { try { - Console.WriteLine("Establising Connection..."); + //Console.WriteLine("Establising Connection..."); _conn = new OdbcConnection(info); - Console.WriteLine("Connection established."); + //Console.WriteLine("Connection established."); } catch { //_conn = null; diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/UiPrint.cs b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/UiPrint.cs index e197fbb..e94b6be 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/UiPrint.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/UiPrint.cs @@ -17,7 +17,8 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess { // Menu for all UserManagement options int menu = 0; - Console.WriteLine($"Welcome {username} to User Management.\n"); + Console.WriteLine("-------------------------------------\n"); + Console.WriteLine($"\nWelcome {username} to User Management.\n"); Console.WriteLine("What would you like to do?\n"); Console.WriteLine(menu + ") To exit User Management.\n"); menu += 1; diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs index 954d9fa..a159178 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs @@ -175,6 +175,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement if (checkSql == "Admin") { + Console.WriteLine("-- Logged in successfully."); return true; } else @@ -218,7 +219,6 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement // Exit menu case 0: return "Exiting UserManagement.\n"; - break; // Create account case 1: UserAccount newUser = new UserAccount(newCredentials.GetUserName(), @@ -266,8 +266,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement case 7: break; default: - Console.WriteLine("Invalid input.\nPlease enter a valid option.\n" + - "------------------------------------\n\n"); + Console.WriteLine("Invalid input.\nPlease enter a valid option.\n"); break; } } diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs index 47ae7e5..da78001 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -33,51 +33,58 @@ namespace TeamHobby.HobbyProjectGenerator.Main // Change terminal height Console.WindowHeight = 40; - Console.WriteLine(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss")); - // Creating the Factory class // Logger log = new Logger(); //Logger.PrintTest(); - // Admin login - GetCredentials credentials = new GetCredentials(); - string? username = credentials.GetUserName(); - string? password = credentials.GetPassword(); + // Loop login terminal + bool mainMenu = true; + + // Loop Admin login + while (mainMenu is true) + { + // Admin Sign in + GetCredentials credentials = new GetCredentials(); + Console.WriteLine("\nPlease Enter Admin Credentials.\n"); + string? username = credentials.GetUserName(); + string? password = credentials.GetPassword(); + + // Get time of login attempt + DateTime TimeStamp = DateTime.UtcNow; + + // String for checking query return type + string dbType = "sql"; + // Creating the Factory class + RDSFactory dbFactory = new RDSFactory(); + + // Testing Data Access Layer + string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" + + "TCPIP=1;" + + "SERVER=localhost;" + + "DATABASE=hobby;" + + "UID=root;" + + "PASSWORD=Teamhobby;" + + "OPTION=3"; + IDataSource datasource = dbFactory.getDataSource(dbType, dbInfo); + // Create manager class from UserManagement + SystemAccountManager manager = new SystemAccountManager(); + + // Create UserAccount class + UserAccount user = new UserAccount(username, password, TimeStamp); + + string isLogin = manager.CreateUserRecord(user, datasource); - //Console.WriteLine(value: $"username is {username}\npassword is {password}"); - - // Creating the Factory class - // Creating the Factory class - - string dbType = "sql"; - RDSFactory dbFactory = new RDSFactory(); - - // Testing Data Access Layer - string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" + - "TCPIP=1;" + - "SERVER=localhost;" + - "DATABASE=hobby;" + - "UID=root;" + - "PASSWORD=Teamhobby;" + - "OPTION=3"; - IDataSource datasource = dbFactory.getDataSource(dbType, dbInfo); - // Create manager class from UserManagement - SystemAccountManager manager = new SystemAccountManager(); - - /* // Admin Sign in - GetCredentials credentials = new GetCredentials(); - string? username = credentials.GetUserName(); - string? password = credentials.GetPassword();*/ - - // Get time of login attempt - DateTime TimeStamp = DateTime.UtcNow; - - // Create UserAccount class - UserAccount user = new UserAccount(username, password, TimeStamp); - - Console.Write(manager.CreateUserRecord(user, datasource)); - + if (isLogin != "Access Denied: Unauthorized\n") + { + mainMenu = false; + } + else + { + Console.WriteLine("******Access Denied: Unauthorized******"); + } + + } //Console.WriteLine(value: $"Welcome {username}\n"); /* string sqlQuery = "Select * from log;"; From 484c725ba8279478733b73ee77b3ff087e37dad2 Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 00:23:52 -0800 Subject: [PATCH 04/16] Infinite menu completed both main menu and sub menu will run forever unless user enters a specified input --- .../SystemAccountManager.cs | 8 ++- .../TeamHobby.HobbyProjectGenerator.sln | 22 ++++---- Source Code/main/Controller.cs | 14 +++++- Source Code/main/SqlDAO.cs | 50 ------------------- Source Code/main/main.csproj | 1 - 5 files changed, 25 insertions(+), 70 deletions(-) delete mode 100644 Source Code/main/SqlDAO.cs diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs index a159178..e1129a2 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs @@ -218,7 +218,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement { // Exit menu case 0: - return "Exiting UserManagement.\n"; + return "Back to Login"; // Create account case 1: UserAccount newUser = new UserAccount(newCredentials.GetUserName(), @@ -227,7 +227,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement bool accountValid = accountService.CreateUserRecord(newUser,user.username, dbSource); if (accountValid is true) { - Console.WriteLine("Account created Successfully"); + Console.WriteLine("\nAccount created Successfully"); break; } else @@ -270,9 +270,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement break; } } - - string dbAction = user.username; - return dbAction; + return "Back to Login"; } } } diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln index b7c8ff3..8e45f2d 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln @@ -4,8 +4,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 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}" + ProjectSection(ProjectDependencies) = postProject + {AA48A66C-FA36-4AF9-A782-CEC22838EB8F} = {AA48A66C-FA36-4AF9-A782-CEC22838EB8F} + {2E7193B8-86B6-48DA-9671-CD84615A5F5D} = {2E7193B8-86B6-48DA-9671-CD84615A5F5D} + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "main", "..\main\main.csproj", "{30C7EBF3-3957-46E5-86C1-C13356841ECA}" EndProject @@ -23,7 +25,12 @@ 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}") = "TeamHobby.UserManagement.xTests", "TeamHobby.UserManagement.xTests\TeamHobby.UserManagement.xTests.csproj", "{6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.UserManagement.xTests", "TeamHobby.UserManagement.xTests\TeamHobby.UserManagement.xTests.csproj", "{6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D29D9225-3748-4067-AF07-E677A525EF39}" + ProjectSection(SolutionItems) = preProject + TeamHobby.HobbyProjectGenerator.csproj = TeamHobby.HobbyProjectGenerator.csproj + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -39,14 +46,6 @@ Global {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}.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 @@ -107,7 +106,6 @@ Global {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|x86.ActiveCfg = Release|Any CPU {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|x86.Build.0 = Release|Any CPU {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|Any CPU.Build.0 = Debug|Any CPU {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|x86.ActiveCfg = Debug|Any CPU {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|x86.Build.0 = Debug|Any CPU {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs index da78001..f65ab47 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -45,12 +45,21 @@ namespace TeamHobby.HobbyProjectGenerator.Main { // Admin Sign in GetCredentials credentials = new GetCredentials(); - Console.WriteLine("\nPlease Enter Admin Credentials.\n"); + Console.WriteLine("\nPlease Enter Admin Credentials " + + "or enter 0 to exit the machine\n"); string? username = credentials.GetUserName(); + //int menuExit = Convert.ToInt32(username); + // Exit Infinite Menu + if (username == "0") + { + break; + } string? password = credentials.GetPassword(); // Get time of login attempt DateTime TimeStamp = DateTime.UtcNow; + + // String for checking query return type string dbType = "sql"; @@ -77,7 +86,8 @@ namespace TeamHobby.HobbyProjectGenerator.Main if (isLogin != "Access Denied: Unauthorized\n") { - mainMenu = false; + Console.WriteLine("Returning to login...\n"); + Console.WriteLine("-------------------------------------\n"); } else { 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 - }*/ - - } - } - } -} diff --git a/Source Code/main/main.csproj b/Source Code/main/main.csproj index 18aba0a..9c91e92 100644 --- a/Source Code/main/main.csproj +++ b/Source Code/main/main.csproj @@ -16,7 +16,6 @@ - From 53aaf77c6bf6fabf83bba7acf1bc493a49c291cb Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 02:01:28 -0800 Subject: [PATCH 05/16] finished all UM features create account edit account delete account disable account enable account --- .../AccountService.cs | 93 ++++++++++++------- .../SystemAccountManager.cs | 64 +++++++++++-- .../UserAccount.cs | 6 ++ Source Code/main/Controller.cs | 23 ----- 4 files changed, 117 insertions(+), 69 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/AccountService.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/AccountService.cs index 198f16c..cf332f7 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/AccountService.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/AccountService.cs @@ -29,53 +29,74 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement return false; } } - public bool EditUserRecord(UserAccount newUser, string CreatedBy, IDataSource dbSource) + public bool EditUserRecord(UserAccount editUser, string CreatedBy, IDataSource dbSource) { -/* // Insert into users table - string sqlUser = $"UPDATE hobby.roles r SET r.Role = 'regular',r.CreatedBy = 'colin'WHERE r.RoleID = 5; "; - - Object insertNewUser = dbSource.WriteData(sqlUser); - // Insert into users table - string sqlRoles = $"INSERT INTO roles (Role, CreatedBy, CreatedDate) " + - $"VALUES ('{newUser.NewRole}', '{CreatedBy}', NOW());"; - Object insertNewRole = dbSource.WriteData(sqlUser); - // Create string for confirming user account - string confirmUser = $"Select * from users where username = {newUser.NewUserName} " + - $"and password = {newUser.NewPassword};"; - Object conUser = dbSource.ReadData(confirmUser); - - //Console.WriteLine("type of Reesult:" + confirmAdmin.GetType()); - OdbcDataReader reader = null; - - if (conUser.GetType() == typeof(OdbcDataReader)) + try { - reader = (OdbcDataReader)conUser; - } + // Insert into users table + string sqlUser = $"UPDATE users t SET t.Password = '{editUser.password}', " + + $"t.Role = '{editUser.role}',t.Email = '{editUser.email}' " + + $"WHERE t.UserName = '{editUser.username}';"; - // Read Sql query results - while (reader.Read()) + bool updateNewUser = dbSource.UpdateData(sqlUser); + return updateNewUser; + + } + catch (Exception ex) { - Console.WriteLine(reader.GetString(0)); + return false; } + } + public bool DeleteUserRecord(UserAccount deleteUser, string CreatedBy, IDataSource dbSource) + { + try + { + // Insert into users table + string sqlUser = $"DELETE from users WHERE UserName = '{deleteUser.username}' " + + $"and Password = '{deleteUser.password}';"; - SqlDAO sqlDS = (SqlDAO)dbSource; - Console.WriteLine(""); + bool deleteNewUser = dbSource.DeleteData(sqlUser); + return deleteNewUser; - // Closing the connection - sqlDS.getConnection().Close();*/ - return true; + } + catch (Exception ex) + { + return false; + } } - public bool DeleteUserRecord(UserAccount newUser, IDataSource dbSource) + public bool DisableUser(UserAccount disableUser, string CreatedBy, IDataSource dbSource) { - return true; + try + { + // Insert into users table + string sqlUser = $"UPDATE users u SET u.IsActive = 0 WHERE u.UserName = '{disableUser.username}'" + + $"and u.Role = '{disableUser.role}';"; + + bool disableNewUser = dbSource.UpdateData(sqlUser); + return disableNewUser; + + } + catch (Exception ex) + { + return false; + } } - public bool DisableUser(UserAccount newUser, IDataSource dbSource) + public bool EnableUser(UserAccount enableUser, string CreatedBy, IDataSource dbSource) { - return true; - } - public bool EnableUser(UserAccount newUser, IDataSource dbSource) - { - return true; + try + { + // Insert into users table + string sqlUser = $"UPDATE users u SET u.IsActive = 1 WHERE u.UserName = '{enableUser.username}'" + + $"and u.Role = '{enableUser.role}';"; + + bool disableNewUser = dbSource.UpdateData(sqlUser); + return disableNewUser; + + } + catch (Exception ex) + { + return false; + } } } } diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs index e1129a2..d124ccb 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs @@ -224,7 +224,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement UserAccount newUser = new UserAccount(newCredentials.GetUserName(), newCredentials.GetPassword(), newCredentials.GetEmail(), newCredentials.GetRole(), DateTime.UtcNow); - bool accountValid = accountService.CreateUserRecord(newUser,user.username, dbSource); + bool accountValid = accountService.CreateUserRecord(newUser, user.username, dbSource); if (accountValid is true) { Console.WriteLine("\nAccount created Successfully"); @@ -234,30 +234,74 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement { return "Database Timed out"; } - //break; // Edit account case 2: - /* UserAccount newEditUser = new UserAccount(newCredentials.GetUserName(), - newCredentials.GetPassword(), DateTime.UtcNow); - accountService.EditUserRecord(newEditUser, dbSource);*/ + // State what account is being edited + string userName = newCredentials.GetUserName(); + string userRole = newCredentials.GetRole(); + + // Notify the user of what can be edited + Console.WriteLine($"\n****The following information will be used to update {userName}"); + + // Get updated parameters + UserAccount newEditUser = new UserAccount(userName, + newCredentials.GetPassword(), newCredentials.GetEmail(), + newCredentials.GetRole(), DateTime.UtcNow); + bool editValid = accountService.EditUserRecord(newEditUser, user.username, dbSource); + if (editValid is true) + { + Console.WriteLine("\nAccount updated Successfully"); + break; + } + else + { + return "Database Timed out"; + } break; // Delete account case 3: UserAccount newDeleteUser = new UserAccount(newCredentials.GetUserName(), newCredentials.GetPassword(), DateTime.UtcNow); - accountService.DeleteUserRecord(newDeleteUser, dbSource); + bool deleteValid = accountService.DeleteUserRecord(newDeleteUser, user.username , dbSource); + if (deleteValid is true) + { + Console.WriteLine("\nAccount deleted Successfully"); + break; + } + else + { + return "User does not exist"; + } break; // Disable account case 4: UserAccount newDisableUser = new UserAccount(newCredentials.GetUserName(), - newCredentials.GetPassword(), DateTime.UtcNow); - accountService.DisableUser(newDisableUser, dbSource); + newCredentials.GetRole()); + bool disableValid = accountService.DisableUser(newDisableUser, user.username , dbSource); + if (disableValid is true) + { + Console.WriteLine("\nAccount disabled Successfully"); + break; + } + else + { + return "Database Timed out"; + } break; // Enable account case 5: UserAccount newEnableUser = new UserAccount(newCredentials.GetUserName(), - newCredentials.GetPassword(), DateTime.UtcNow); - accountService.EnableUser(newEnableUser, dbSource); + newCredentials.GetRole()); + bool enableValid = accountService.EnableUser(newEnableUser, user.username , dbSource); + if (enableValid is true) + { + Console.WriteLine("\nAccount enabled Successfully"); + break; + } + else + { + return "Database Timed out"; + } break; // View logs case 6: diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/UserAccount.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/UserAccount.cs index 4b9a38f..a40deef 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/UserAccount.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/UserAccount.cs @@ -52,6 +52,12 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement _password = pwd; _Time = TimeStamp; } + public UserAccount(string un, string role) + { + _userName = un; + _Role = role; + _Time = DateTime.UtcNow; + } public UserAccount(string newUN, string newPWD, string Email, string role, DateTime newTime) { _userName = newUN; diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs index f65ab47..97bcb58 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -95,29 +95,6 @@ namespace TeamHobby.HobbyProjectGenerator.Main } } - //Console.WriteLine(value: $"Welcome {username}\n"); - - /* string sqlQuery = "Select * from log;"; - Object result = datasource.ReadData(sqlQuery); - Console.WriteLine("type of Result: " + result.GetType()); - OdbcDataReader reader = null; - - if (result.GetType() == typeof(OdbcDataReader)) - { - reader = (OdbcDataReader)result; - - } - - Console.WriteLine("Reading from the database"); - while (reader.Read()) - { - Console.WriteLine("Date={0} {1} {2} {3} {4} {5}", reader[0], reader[1], reader[2], reader[3], reader[4], reader[5]); - } - SqlDAO sqlDS = (SqlDAO)datasource; - Console.WriteLine(""); - - // Closing the connection - sqlDS.getConnection().Close();*/ /* // While loop to keep this running forever with UserManagement // Testing archive Manager From cc71d41cca6b4d0e9607ab5fbac79177d7c71196 Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 02:02:56 -0800 Subject: [PATCH 06/16] reworded for easier implementation --- .../Implementations/UiPrint.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/UiPrint.cs b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/UiPrint.cs index e94b6be..6d06cb8 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/UiPrint.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/Implementations/UiPrint.cs @@ -4,15 +4,6 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess { public class UiPrint { - public void InitialMenu() - { - // Create intial menu - Console.WriteLine("What would you like to access?"); - int num = 1; - Console.WriteLine(num + ".User Management"); - num += 1; - Console.WriteLine(num + ".Logging"); - } public void UserManagementMenu(string username) { // Menu for all UserManagement options @@ -32,9 +23,9 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess menu += 1; Console.WriteLine(menu + ") Enable an account.\n"); menu += 1; - Console.WriteLine(menu + ") View logs.\n"); + Console.WriteLine(menu + ") View log path.\n"); menu += 1; - Console.WriteLine(menu + ") View archive.\n"); + Console.WriteLine(menu + ") View archive path.\n"); } } } From 75753547974c4131ee0c626a5fe5770c0ae0e3cd Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 02:12:24 -0800 Subject: [PATCH 07/16] Added confirmation password loop removed commented code and unused files --- .../SystemAccountManager.cs | 3 +- .../UserAccount.cs | 25 +++- Source Code/main/Controller.cs | 93 +----------- Source Code/main/MainMenu.cs | 134 ------------------ 4 files changed, 23 insertions(+), 232 deletions(-) delete mode 100644 Source Code/main/MainMenu.cs diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs index d124ccb..e8eb903 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs @@ -221,8 +221,9 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement return "Back to Login"; // Create account case 1: + // Get all credentials and create newUser UserAccount newUser = new UserAccount(newCredentials.GetUserName(), - newCredentials.GetPassword(), newCredentials.GetEmail(), + newCredentials.ConfirmPassword(), newCredentials.GetEmail(), newCredentials.GetRole(), DateTime.UtcNow); bool accountValid = accountService.CreateUserRecord(newUser, user.username, dbSource); if (accountValid is true) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/UserAccount.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/UserAccount.cs index a40deef..58d6b13 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/UserAccount.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/UserAccount.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; namespace TeamHobby.HobbyProjectGenerator.UserManagement -{ +{ // Class for getting user credentials public class GetCredentials { public string? GetUserName() @@ -20,11 +20,26 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement string? userPassword = Console.ReadLine(); return userPassword; } - /*public string ConfirmPassword() + public string ConfirmPassword() { - Console.WriteLine(); - string confirmPassword = newUser.NewPassword; - }*/ + while (true) + { + Console.WriteLine("Please enter a password:"); + string? userPassword = Console.ReadLine(); + // Confirm Password + Console.WriteLine("Please re-enter the password:"); + string checkPsswd = Console.ReadLine(); + // Check if passwords match + if (userPassword == checkPsswd) + { + return userPassword; + } + else + { + Console.WriteLine("Passwords do not match.\n"); + } + } + } public string GetEmail() { Console.WriteLine("Please enter an email:"); diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs index 97bcb58..1d33e85 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -5,22 +5,7 @@ using TeamHobby.HobbyProjectGenerator.DataAccess; using TeamHobby.HobbyProjectGenerator.UserManagement; namespace TeamHobby.HobbyProjectGenerator.Main -{ - public class GetCredentials - { - public string? GetUserName() - { - Console.WriteLine("Please enter a username:"); - string? userName = Console.ReadLine(); - return userName; - } - public string? GetPassword() - { - Console.WriteLine("Please enter " + - "a password:"); - string? userPassword = Console.ReadLine(); - return userPassword; - } +{ public class Controller { public static void Main(string[] args) @@ -156,82 +141,6 @@ namespace TeamHobby.HobbyProjectGenerator.Main //Console.WriteLine("Writing to the database... "); //datasource.WriteData(sqlRemove); //Console.WriteLine("Writing completed. "); - - /* bool MainMenu = true; - - // Set up menu loop - while (MainMenu == 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 class objects - UiPrint menu = new UiPrint(); - - - // Print main menu - menu.InitialMenu(); - - // 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) - { - case 0: - MainMenu = false; - break; - // Create a new account - case 1: - user.newUser(); - 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.View log files."); - Console.WriteLine(""); - Console.WriteLine(""); - Console.WriteLine(""); - Console.WriteLine(""); - Console.WriteLine(""); - - - break; - default: - Console.WriteLine("Invalid choice, please enter a valid number."); - break; - }; - } - // Catch invalid keys such as spamming enter - catch - { - MainMenu = 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; - }; - }*/ - - //} - } -} From ba6db79f09a22c442d77b6d30cb0edfd98c910eb Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 02:16:21 -0800 Subject: [PATCH 08/16] 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 - }*/ - - } - } - } -} From 084e0de6ec2cd73d19bea3981c892a1a693a7cd1 Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 02:23:11 -0800 Subject: [PATCH 09/16] changed everything so that the branch is running again --- .../TeamHobby.HobbyProjectGenerator.sln | 28 ++----------------- Source Code/main/Controller.cs | 2 +- Source Code/main/main.csproj | 1 - 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln index 7868d26..60e405e 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln @@ -8,6 +8,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.UserManagement.Te {AA48A66C-FA36-4AF9-A782-CEC22838EB8F} = {AA48A66C-FA36-4AF9-A782-CEC22838EB8F} {2E7193B8-86B6-48DA-9671-CD84615A5F5D} = {2E7193B8-86B6-48DA-9671-CD84615A5F5D} EndProjectSection +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}" @@ -16,12 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGener 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}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.ArchiveTests", "..\TeamHobby.HobbyProjectGenerator.ArchiveTests\TeamHobby.HobbyProjectGenerator.ArchiveTests.csproj", "{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.UserManagement.xTests", "TeamHobby.UserManagement.xTests\TeamHobby.UserManagement.xTests.csproj", "{6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}" @@ -30,7 +27,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject TeamHobby.HobbyProjectGenerator.csproj = TeamHobby.HobbyProjectGenerator.csproj EndProjectSection -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 @@ -39,13 +35,9 @@ Global EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {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}.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}.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 @@ -53,39 +45,23 @@ Global {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|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.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 {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 - {C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.ActiveCfg = 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.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 {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 {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|x86.ActiveCfg = Debug|Any CPU - {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|x86.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 - {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|x86.ActiveCfg = Release|Any CPU - {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|x86.Build.0 = Release|Any CPU {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|x86.ActiveCfg = Debug|Any CPU - {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|x86.Build.0 = Debug|Any CPU + {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|Any CPU.Build.0 = Debug|Any CPU {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|Any CPU.ActiveCfg = Release|Any CPU {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|Any CPU.Build.0 = Release|Any CPU - {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|x86.ActiveCfg = Release|Any CPU - {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.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 06cf78c..444e89f 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -144,7 +144,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main //Console.WriteLine("Writing completed. "); } } - } } + diff --git a/Source Code/main/main.csproj b/Source Code/main/main.csproj index 73a9e47..6236e85 100644 --- a/Source Code/main/main.csproj +++ b/Source Code/main/main.csproj @@ -16,7 +16,6 @@ - From c9f60c2f7601c65d5b2e85aca09b8e7f6f4f25d7 Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 02:53:20 -0800 Subject: [PATCH 10/16] moved archive check into menu loop requires confirmation with the rest of the commented code --- .../TeamHobby.HobbyProjectGenerator.sln | 17 +--------- Source Code/main/Controller.cs | 31 +++++++++---------- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln index 7868d26..ba3e00b 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln @@ -8,6 +8,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.UserManagement.Te {AA48A66C-FA36-4AF9-A782-CEC22838EB8F} = {AA48A66C-FA36-4AF9-A782-CEC22838EB8F} {2E7193B8-86B6-48DA-9671-CD84615A5F5D} = {2E7193B8-86B6-48DA-9671-CD84615A5F5D} EndProjectSection +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}" @@ -30,7 +31,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject TeamHobby.HobbyProjectGenerator.csproj = TeamHobby.HobbyProjectGenerator.csproj EndProjectSection -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 @@ -39,11 +39,8 @@ Global EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {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}.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}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -53,8 +50,6 @@ Global {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|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.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 @@ -63,8 +58,6 @@ Global {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|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.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 @@ -73,19 +66,11 @@ Global {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 {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|x86.ActiveCfg = Debug|Any CPU - {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|x86.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 - {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|x86.ActiveCfg = Release|Any CPU - {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|x86.Build.0 = Release|Any CPU {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|x86.ActiveCfg = Debug|Any CPU - {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|x86.Build.0 = Debug|Any CPU {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|Any CPU.ActiveCfg = Release|Any CPU {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|Any CPU.Build.0 = Release|Any CPU - {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|x86.ActiveCfg = Release|Any CPU - {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.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 06cf78c..385a928 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -61,6 +61,21 @@ namespace TeamHobby.HobbyProjectGenerator.Main "PASSWORD=Teamhobby;" + "OPTION=3"; IDataSource datasource = dbFactory.getDataSource(dbType, dbInfo); + + // While loop to keep this running forever with UserManagement + // Testing archive Manager + //while (true) + //{ + string currentDate = DateTime.Now.ToString("dd"); + string currentTime = DateTime.Now.ToString("T"); + Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime); + if (String.Equals(currentDate, "1") && String.Equals(currentTime, "00:00:00 AM")) + { + ArchiveManager archive = new ArchiveManager(datasource); + archive.Controller(); + } + //} + // Create manager class from UserManagement SystemAccountManager manager = new SystemAccountManager(); @@ -82,22 +97,6 @@ namespace TeamHobby.HobbyProjectGenerator.Main } - /* // While loop to keep this running forever with UserManagement - // Testing archive Manager - //while (true) - //{ - string currentDate = DateTime.Now.ToString("dd"); - string currentTime = DateTime.Now.ToString("T"); - Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime); - if (String.Equals(currentDate, "1") && String.Equals(currentTime, "00:00:00 AM")) - { - ArchiveManager archive = new ArchiveManager(datasource); - archive.Controller(); - } - //}*/ - - - //Creating the folder Archive //Console.WriteLine("Creating a new folder ..."); //archive.CreateArchiveFolder(); From bca0875ec7267ecc49203441c6daea7f590f956a Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 02:54:23 -0800 Subject: [PATCH 11/16] rechecked DDL for full DB --- Source Code/main/Controller.cs | 34 ++++++++-------- src/dbCode/UserManagementDDL.txt | 2 +- src/dbCode/fullDDL.txt | 66 ++++++++++++++------------------ 3 files changed, 46 insertions(+), 56 deletions(-) diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs index 444e89f..d4dcfd0 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -29,6 +29,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main // Loop Admin login while (mainMenu is true) { + // Admin Sign in GetCredentials credentials = new GetCredentials(); Console.WriteLine("\nPlease Enter Admin Credentials " + @@ -61,6 +62,21 @@ namespace TeamHobby.HobbyProjectGenerator.Main "PASSWORD=Teamhobby;" + "OPTION=3"; IDataSource datasource = dbFactory.getDataSource(dbType, dbInfo); + + // While loop to keep this running forever with UserManagement + // Testing archive Manager + //while (true) + //{ + string currentDate = DateTime.Now.ToString("dd"); + string currentTime = DateTime.Now.ToString("T"); + //Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime); + if (String.Equals(currentDate, "1") && String.Equals(currentTime, "00:00:00 AM")) + { + ArchiveManager archive = new ArchiveManager(datasource); + archive.Controller(); + } + //} + // Create manager class from UserManagement SystemAccountManager manager = new SystemAccountManager(); @@ -82,22 +98,6 @@ namespace TeamHobby.HobbyProjectGenerator.Main } - /* // While loop to keep this running forever with UserManagement - // Testing archive Manager - //while (true) - //{ - string currentDate = DateTime.Now.ToString("dd"); - string currentTime = DateTime.Now.ToString("T"); - Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime); - if (String.Equals(currentDate, "1") && String.Equals(currentTime, "00:00:00 AM")) - { - ArchiveManager archive = new ArchiveManager(datasource); - archive.Controller(); - } - //}*/ - - - //Creating the folder Archive //Console.WriteLine("Creating a new folder ..."); //archive.CreateArchiveFolder(); @@ -127,8 +127,6 @@ namespace TeamHobby.HobbyProjectGenerator.Main //sqlDS.RemoveEntries(); - - // 2.Inserting Data into the database: //string sqlWrite = "INSERT into log(lvname, catname, userop, logmessage) values " + // "('Info', 'View', 'Testing DAL stuffs', 'new DAL method tested');"; diff --git a/src/dbCode/UserManagementDDL.txt b/src/dbCode/UserManagementDDL.txt index c4d451b..d8775ac 100644 --- a/src/dbCode/UserManagementDDL.txt +++ b/src/dbCode/UserManagementDDL.txt @@ -34,4 +34,4 @@ INSERT INTO hobby.users (UserName, Password, Role, IsActive, CreatedBy, CreatedD INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('Admin', 'Jacob', '2021-12-13 03:25:14'), -('regular', 'Colin', '2021-12-13 03:25:14'); +('regular', 'Jacob', '2021-12-13 03:25:14'); diff --git a/src/dbCode/fullDDL.txt b/src/dbCode/fullDDL.txt index f77d833..ffcc31a 100644 --- a/src/dbCode/fullDDL.txt +++ b/src/dbCode/fullDDL.txt @@ -2,52 +2,44 @@ create database Hobby; use hobby; +create table roles +( + Role varchar(50) charset utf8mb3 not null, + CreatedBy varchar(200) charset utf8mb3 not null, + CreatedDate datetime not null, + constraint role_pk + primary key (Role) +); + create table users ( UserName varchar(50) charset utf8mb3 not null primary key, - Password varchar(50) charset utf8mb3 null, - RoleID int auto_increment, - IsActive int default 1 null, - CreatedBy varchar(50) charset utf8mb3 null, - CreatedDate datetime null, - constraint users_UserName_uindex - unique (UserName), - constraint users_roles_RoleID_fk - foreign key (RoleID) references roles (RoleID) + Password varchar(50) charset utf8mb3 not null, + Role varchar(50) charset utf8mb3 not null, + IsActive int default 1 not null, + CreatedBy varchar(50) charset utf8mb3 not null, + CreatedDate datetime not null, + Email varchar(50) null, + constraint users_Email_uindex + unique (Email), + constraint userRole_fk + foreign key (Role) references roles (Role) ); -INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Colin ', 'Waffle', 'Jacob', '2021-12-13 04:27:42'); -INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Danny', 'Spartan', 'Jacob', '2021-12-13 04:29:54'); -INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Jacob', 'Teamhobby1234', 'SystemCreator', '2021-12-13 03:25:14'); -INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Long', 'Joystick', 'Jacob', '2021-12-13 04:29:57'); -INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Rifat', 'ApproveDar', 'Jacob', '2021-12-13 04:29:55'); + +INSERT INTO hobby.users (UserName, Password, Role, IsActive, CreatedBy, CreatedDate, Email) VALUES +('Colin ', 'Waffle', 'Admin', 1, 'Jacob', '2021-12-13 04:27:42', null), +('Danny', 'Spartan', 'Admin', 1, 'Jacob', '2021-12-13 04:29:54', null), +('Jacob', 'Teamhobby1234', 'Admin', 1, 'SystemCreator', '2021-12-13 03:25:14', null), +('Long', 'Joystick', 'regular', 1, 'Jacob', '2021-12-13 04:29:57', null), +('Rifat', '1234', 'Admin', 1, 'Jacob', '2021-12-13 04:29:55', null); -create table roles -( - RoleID int auto_increment - primary key, - Role varchar(50) charset utf8mb3 null, - CreatedBy varchar(200) charset utf8mb3 null, - CreatedDate datetime null -); +INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES +('Admin', 'Jacob', '2021-12-13 03:25:14'), +('regular', 'Jacob', '2021-12-13 03:25:14'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('Admin', 'SystemCreator', '2021-12-13 03:25:14'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Colin', '2021-12-13 03:25:14'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Colin', '2021-12-13 03:25:14'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:44'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:46'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:47'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:47'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:49'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:50'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:51'); - - -alter table users - add constraint users_roles_RoleID_fk - foreign key (RoleID) references roles (RoleID); SET Global innodb_file_per_table=ON; -- SET GLOBAL innodb_file_format='Barracuda'; From 510ea554213f07555f53db171c41678de898d25f Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 02:57:01 -0800 Subject: [PATCH 12/16] changed return strings to match design diagram --- .../SystemAccountManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs index e8eb903..49b0e48 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs @@ -286,7 +286,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement } else { - return "Database Timed out"; + return "User does not exist"; } break; // Enable account @@ -301,7 +301,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement } else { - return "Database Timed out"; + return "User does not exist"; } break; // View logs From 9c0472f061549b17683cab636410c44e04c1bc26 Mon Sep 17 00:00:00 2001 From: Rifat Hasan Date: Tue, 14 Dec 2021 13:30:22 -0800 Subject: [PATCH 13/16] Update UnitTest1.cs --- .../UnitTest1.cs | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs index 4f483ad..eca9743 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs @@ -1,13 +1,47 @@ +using System; using Xunit; +using Xunit.Abstractions; +using System.Threading; namespace TeamHobby.UserManagement.xTests { public class UnitTest1 { - [Fact] - public void Test1() + + ITestOutputHelper output; + public Example(ITestOutputHelper output) { + this.output = output; + } + [Fact] + public void SingleOperationinFiveSec() + { + DateTime start = DateTime.Now; + Thread.Sleep(5000); + // create a file + DateTime end = DateTime.Now; + TimeSpan timeSpan = (end - start); + var sec = timeSpan.TotalSeconds; + //throw new Exception(sec.ToString()); + if (sec > 1) + { + throw new Exception("Greater than 5 seconds"); + } + throw new Exception("Less than 5 seconds"); + //output.WriteLine("check"); + //output.WriteLine("Elapsed time is {0} ms", timeSpan.TotalSeconds); + + var s = DateTime.Now; + output.WriteLine(s); + output.WriteLine("Time is ", DateTime.Now); + aTimer.Start(); + Assert.True(false); + aTimer.Stop(); + var e = DateTime.Now; + var diff = s - e; + output.WriteLine("Diff time ", diff); + Assert.True(true); } } } \ No newline at end of file From 97cc4369bdaf4d54a97bbf8b47def85e8a367e05 Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 13:33:23 -0800 Subject: [PATCH 14/16] cleaned solution --- .../TeamHobby.UserManagement.xTests.csproj | 5 +++++ Source Code/main/Controller.cs | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/TeamHobby.UserManagement.xTests.csproj b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/TeamHobby.UserManagement.xTests.csproj index 9f77f5f..ef2ea1d 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/TeamHobby.UserManagement.xTests.csproj +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/TeamHobby.UserManagement.xTests.csproj @@ -20,4 +20,9 @@ + + + + + diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs index d4dcfd0..1d74a58 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -82,15 +82,16 @@ namespace TeamHobby.HobbyProjectGenerator.Main // Create UserAccount class UserAccount user = new UserAccount(username, password, TimeStamp); - + // Call user object and wait for return string string isLogin = manager.CreateUserRecord(user, datasource); - + // If login is not incorrect and user is returning to login menu if (isLogin != "Access Denied: Unauthorized\n") { Console.WriteLine("Returning to login...\n"); Console.WriteLine("-------------------------------------\n"); } + // If login is incorrect else { Console.WriteLine("******Access Denied: Unauthorized******"); From e012dde28c7e1615f158050e9003c5affc765ada Mon Sep 17 00:00:00 2001 From: Rifat Hasan Date: Tue, 14 Dec 2021 14:43:50 -0800 Subject: [PATCH 15/16] Add single and bulk tests --- .../UnitTest1.cs | 117 ++++++++++++++---- 1 file changed, 90 insertions(+), 27 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs index eca9743..9128ac4 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs @@ -2,6 +2,8 @@ using System; using Xunit; using Xunit.Abstractions; using System.Threading; +using TeamHobby.HobbyProjectGenerator.UserManagement; +using TeamHobby.HobbyProjectGenerator.DataAccess; namespace TeamHobby.UserManagement.xTests { @@ -9,39 +11,100 @@ namespace TeamHobby.UserManagement.xTests { ITestOutputHelper output; - public Example(ITestOutputHelper output) + public UnitTest1(ITestOutputHelper output) { this.output = output; - } + }/* [Fact] public void SingleOperationinFiveSec() { - DateTime start = DateTime.Now; - Thread.Sleep(5000); - // create a file - DateTime end = DateTime.Now; - TimeSpan timeSpan = (end - start); - var sec = timeSpan.TotalSeconds; - //throw new Exception(sec.ToString()); - if (sec > 1) - { - throw new Exception("Greater than 5 seconds"); - } - throw new Exception("Less than 5 seconds"); - //output.WriteLine("check"); - //output.WriteLine("Elapsed time is {0} ms", timeSpan.TotalSeconds); - - var s = DateTime.Now; - output.WriteLine(s); - output.WriteLine("Time is ", DateTime.Now); - aTimer.Start(); + // Arrange + DateTime sTime = DateTime.Now; + var TestAcc = new UserAccount("newUser", "4567", "email@a.com", "regular", sTime); + var serviceTest = new AccountService(); + string dbType = "sql"; + RDSFactory dbFactory = new RDSFactory(); - Assert.True(false); - aTimer.Stop(); - var e = DateTime.Now; - var diff = s - e; - output.WriteLine("Diff time ", diff); - Assert.True(true); + + // Testing Data Access Layer + string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" + + "TCPIP=1;" + + "SERVER=localhost;" + + "DATABASE=hobby;" + + "UID=root;" + + "PASSWORD=hobby;" + + "OPTION=3"; + IDataSource datasource = dbFactory.getDataSource(dbType, dbInfo); + + // Act + // Create a file + serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource); + DateTime eTime = DateTime.Now; + TimeSpan timeDiff = (eTime - sTime); + var sec = timeDiff.TotalSeconds; + + + // Assert + if (sec > 5) + { + Assert.False(false); + output.WriteLine("Greater than 5 seconds"); + + } + else + { + Assert.True(true); + output.WriteLine("Less than 5 seconds"); + } } + */ + [Fact] + public void BulkOperationforSixty() + { + // Arrange + DateTime sTime = DateTime.Now; + + var serviceTest = new AccountService(); + string dbType = "sql"; + RDSFactory dbFactory = new RDSFactory(); + + + // Testing Data Access Layer + string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" + + "TCPIP=1;" + + "SERVER=localhost;" + + "DATABASE=hobby;" + + "UID=root;" + + "PASSWORD=hobby;" + + "OPTION=3"; + IDataSource datasource = dbFactory.getDataSource(dbType, dbInfo); + + // Act + // Create a file + for (int i = 0; i < 10000; i++) + { + var TestAcc = new UserAccount("newUser" + $"{i}", "4567", $"email{i}@a.com", "regular", sTime); + serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource); + } + + DateTime eTime = DateTime.Now; + TimeSpan timeDiff = (eTime - sTime); + var sec = timeDiff.TotalSeconds; + + + // Assert + if (sec > 60) + { + Assert.False(false); + output.WriteLine("Greater than 60 seconds"); + + } + else + { + Assert.True(true); + output.WriteLine("Less than 60 seconds"); + } + } + } } \ No newline at end of file From 6bf376802d55500add41f60806e3a336682859f1 Mon Sep 17 00:00:00 2001 From: Rifat Hasan Date: Tue, 14 Dec 2021 15:15:40 -0800 Subject: [PATCH 16/16] Add correct failure case --- .../UnitTest1.cs | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs index 9128ac4..60baa67 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs @@ -14,7 +14,7 @@ namespace TeamHobby.UserManagement.xTests public UnitTest1(ITestOutputHelper output) { this.output = output; - }/* + } [Fact] public void SingleOperationinFiveSec() { @@ -25,7 +25,6 @@ namespace TeamHobby.UserManagement.xTests string dbType = "sql"; RDSFactory dbFactory = new RDSFactory(); - // Testing Data Access Layer string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" + "TCPIP=1;" + @@ -43,21 +42,19 @@ namespace TeamHobby.UserManagement.xTests TimeSpan timeDiff = (eTime - sTime); var sec = timeDiff.TotalSeconds; - // Assert if (sec > 5) - { - Assert.False(false); - output.WriteLine("Greater than 5 seconds"); - + { + output.WriteLine("Single Operation was unsuccessful"); + Assert.False(true); } else { Assert.True(true); - output.WriteLine("Less than 5 seconds"); + output.WriteLine("Single Operation was successful"); } } - */ + [Fact] public void BulkOperationforSixty() { @@ -95,16 +92,14 @@ namespace TeamHobby.UserManagement.xTests // Assert if (sec > 60) { - Assert.False(false); - output.WriteLine("Greater than 60 seconds"); - + output.WriteLine("Bulk Operation was unsuccessful"); + Assert.False(true); } else { Assert.True(true); - output.WriteLine("Less than 60 seconds"); + output.WriteLine("Bulk Operation was successful"); } } - } } \ No newline at end of file