From 8999a71a97116defc4dce5fc1b2bca4621a6867c Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Sat, 11 Dec 2021 23:42:27 -0800 Subject: [PATCH 1/3] Rearranged items and removed dummy DAO --- .../AccountService.cs | 12 ++++++ .../SystemAccountManager.cs | 0 ...obbyProjectGenerator.UserManagement.csproj | 9 +++++ .../UserAccount.cs | 0 .../Contracts/IUserService.cs | 15 -------- .../TeamHobby.HobbyProjectGenerator.sln | 8 +++- Source Code/main/Controller.cs | 12 +++--- Source Code/main/{ExampleDAO.cs => SqlDAO.cs} | 37 +++++++++---------- 8 files changed, 52 insertions(+), 41 deletions(-) create mode 100644 Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/AccountService.cs rename Source Code/{main => TeamHobby.HobbyProjectGenerator.UserManagement}/SystemAccountManager.cs (100%) create mode 100644 Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/TeamHobby.HobbyProjectGenerator.UserManagement.csproj rename Source Code/{main => TeamHobby.HobbyProjectGenerator.UserManagement}/UserAccount.cs (100%) delete mode 100644 Source Code/TeamHobby.HobbyProjectGenerator/Contracts/IUserService.cs rename Source Code/main/{ExampleDAO.cs => SqlDAO.cs} (58%) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/AccountService.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/AccountService.cs new file mode 100644 index 0000000..902cba9 --- /dev/null +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/AccountService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TeamHobby.HobbyProjectGenerator.UserManagement +{ + internal class AccountService + { + } +} diff --git a/Source Code/main/SystemAccountManager.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs similarity index 100% rename from Source Code/main/SystemAccountManager.cs rename to Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/TeamHobby.HobbyProjectGenerator.UserManagement.csproj b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/TeamHobby.HobbyProjectGenerator.UserManagement.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/TeamHobby.HobbyProjectGenerator.UserManagement.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/Source Code/main/UserAccount.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/UserAccount.cs similarity index 100% rename from Source Code/main/UserAccount.cs rename to Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/UserAccount.cs diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/Contracts/IUserService.cs b/Source Code/TeamHobby.HobbyProjectGenerator/Contracts/IUserService.cs deleted file mode 100644 index 96fff23..0000000 --- a/Source Code/TeamHobby.HobbyProjectGenerator/Contracts/IUserService.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TeamHobby.HobbyProjectGenerator -{ - public interface IUserService - { - // Public methods shouldn't be void so it can be tested - bool User(string username); - IList GetAllUsers(); - } -} diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln index 2e9cc83..3911340 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln @@ -15,7 +15,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGener EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.Main", "..\TeamHobby.Main\TeamHobby.Main.csproj", "{ED126EFB-B337-42F9-BE4B-65A5AE90503B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator.DataAccess", "..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj", "{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.DataAccess", "..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj", "{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator.UserManagement", "..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj", "{2E7193B8-86B6-48DA-9671-CD84615A5F5D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -48,6 +50,10 @@ Global {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 + {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 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs index 1932939..956702e 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -26,14 +26,14 @@ namespace TeamHobby.HobbyProjectGenerator.Main public static void Main(string[] args) { - //GetCredentials credentials = new GetCredentials(); - //string? username = credentials.GetUserName(); - //string? password = credentials.GetPassword(); + GetCredentials credentials = new GetCredentials(); + string? username = credentials.GetUserName(); + string? password = credentials.GetPassword(); - //Console.WriteLine(value: $"username is {username}\npassword is {password}"); + Console.WriteLine(value: $"username is {username}\npassword is {password}"); - // Creating the Factory class + /* // Creating the Factory class string dbType = "sql"; RelationalDataSourceFactory dbFactory = new RelationalDataSourceFactory(); @@ -65,7 +65,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main SqlDAO sqlDS = (SqlDAO)datasource; // Closing the connection - sqlDS.getConnection().Close(); + sqlDS.getConnection().Close();*/ // 2.Inserting Data into the database: //string sqlWrite = "INSERT into log(lvname, catname, userop, logmessage) values " + diff --git a/Source Code/main/ExampleDAO.cs b/Source Code/main/SqlDAO.cs similarity index 58% rename from Source Code/main/ExampleDAO.cs rename to Source Code/main/SqlDAO.cs index 64e3b63..8e331a7 100644 --- a/Source Code/main/ExampleDAO.cs +++ b/Source Code/main/SqlDAO.cs @@ -1,23 +1,22 @@ using Microsoft.Data.SqlClient; +using TeamHobby.HobbyProjectGenerator.Models; -namespace TeamHobby.HobbyProjectGenerator.Main +namespace TeamHobby.HobbyProjectGenerator.DAL { - public class ExampleDAO + public class SqlDAO { - - public void UserData(string username) + public IList GetUserData(string username) { // Sql server connection string, needs to be changed accordingly to connect - var connString = "server=localhost,3316;user=root;database=users;password=Plop20"; // Using @" " makes the string literal - + var connString = "server=localhost;userid=root;password=Plop20;database=users"; // Using @" " makes the string literal + // ADO.NET - ODBC - using var conn = new SqlConnection(connString); + 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)) { - conn.Open(); // Get the results from the query SqlDataReader r = command.ExecuteReader(); @@ -33,18 +32,18 @@ namespace TeamHobby.HobbyProjectGenerator.Main { Console.WriteLine(r.ToString()); } - conn.Close(); - + return null; } - // Console.Read(); - /* - * this is meant for specific basic sql commands - using (var adapter = new SqlDataAdapter()) - { - adapter.SelectCommand - } - */ - //return null; + + /*// this is meant for specific basic sql commands + using (var adapter = new SqlDataAdapter()) + { + adapter.UpdateCommand + adapter.DeleteCommand + adapter.InsertCommand + adapter.SelectCommand + }*/ + } } } From e6a751db313cbabb2a07931405f802872e89e5f3 Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Sun, 12 Dec 2021 02:26:21 -0800 Subject: [PATCH 2/3] Finished UserAccount Class --- .../UserAccount.cs | 42 +++++++++++-------- .../Contracts/IDataSource.cs | 12 ------ 2 files changed, 25 insertions(+), 29 deletions(-) delete mode 100644 Source Code/TeamHobby.HobbyProjectGenerator/Contracts/IDataSource.cs diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/UserAccount.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/UserAccount.cs index 92e0c55..687f7ec 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/UserAccount.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/UserAccount.cs @@ -4,31 +4,39 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace main +namespace TeamHobby.HobbyProjectGenerator.UserManagement { public class UserAccount { - /* private string username; - private string password; - private string role; + // Admin Credentials + private string UserName; + private string Password; + private DateTime Time; - public UserAccount(string un,string pwd,string rol) + public UserAccount(string un, string pwd, DateTime TimeStamp) { - username = un; - password = pwd; - role = rol; - + UserName = un; + Password = pwd; + Time = TimeStamp; } + public string username { get { return UserName; } } + public string password { get { return Password; } } - public void UserAccount() + // New User Credentials + private string newusername; + private string newpassword; + private string newemail; + private DateTime newtime; + public void NewUser(string newUN, string newPWD, string Email, DateTime newTime) { - password = "1234"; - role = "Regular"; + newusername = newUN; + newpassword = newPWD; + newemail = Email; + newtime = newTime; } - - public void newUser() - { - - }*/ + public string NewUserName { get { return newusername; } } + public string NewPassword { get { return newpassword; } } + public string NewEmail { get { return newemail; } } + public DateTime Newtime { get { return newtime;} } } } diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/Contracts/IDataSource.cs b/Source Code/TeamHobby.HobbyProjectGenerator/Contracts/IDataSource.cs deleted file mode 100644 index 7db156f..0000000 --- a/Source Code/TeamHobby.HobbyProjectGenerator/Contracts/IDataSource.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TeamHobby.HobbyProjectGenerator.Contracts -{ - internal interface IDataSource - { - } -} From c7815d215c06eb29f0d318bcd5719de8be878b99 Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Sun, 12 Dec 2021 04:43:20 -0800 Subject: [PATCH 3/3] renamed and reorganized solution file completed isInputValid method --- ...onalDataSourceFactory.cs => RDSFactory.cs} | 2 +- .../SystemAccountManager.cs | 64 ++++++++++++++++++- ...obbyProjectGenerator.UserManagement.csproj | 4 ++ .../Implementations/Database_Users.cs | 21 ------ .../Implementations/InMemoryUserService.cs | 2 +- .../Implementations}/UiPrint.cs | 4 +- .../Implementations/User_Authentication.cs | 2 +- .../Implementations/User_Manager.cs | 2 +- .../TeamHobby.HobbyProjectGenerator.csproj | 4 ++ .../TeamHobby.HobbyProjectGenerator.sln | 5 +- Source Code/main/Controller.cs | 53 ++++++++------- Source Code/main/main.csproj | 3 + 12 files changed, 110 insertions(+), 56 deletions(-) rename Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/{RelationalDataSourceFactory.cs => RDSFactory.cs} (95%) delete mode 100644 Source Code/TeamHobby.HobbyProjectGenerator/Implementations/Database_Users.cs rename Source Code/{main => TeamHobby.HobbyProjectGenerator/Implementations}/UiPrint.cs (92%) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/RelationalDataSourceFactory.cs b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/RDSFactory.cs similarity index 95% rename from Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/RelationalDataSourceFactory.cs rename to Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/RDSFactory.cs index 656ebd1..6eb1899 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/RelationalDataSourceFactory.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.DataAccess/RDSFactory.cs @@ -7,7 +7,7 @@ using TeamHobby.HobbyProjectGenerator.DataAccess; namespace TeamHobby.HobbyProjectGenerator.DataAccess { - public class RelationalDataSourceFactory + public class RDSFactory { // Mehthod to create a specific data source suitable to the need public IDataSource getDataSource(string name, string info) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs index 78a9ff3..9cb4617 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs @@ -3,11 +3,69 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using TeamHobby.HobbyProjectGenerator.UserManagement; +using TeamHobby.HobbyProjectGenerator.Implementations; -namespace main +namespace TeamHobby.HobbyProjectGenerator.UserManagement { - internal class SystemAccountManager + public class SystemAccountManager { + public string IsInputValid(string checkUN, string checkPWD) + { + // Create bool variables to check if username and password are valid + bool ValidUN = checkUN.All(un=>Char.IsLetterOrDigit(un) || un=='@' + || un == '.' || un == ',' || un == '!'); + + bool ValidPwd = checkPWD.All(Char.IsLetterOrDigit); + + + if (checkUN == null || checkPWD == null) + { + return "Invalid input\n"; + } + else if (checkUN.Length > 15 || checkUN.Length <= 0 + || ValidUN is false) + { + return "Invalid Username\n"; + } + else if (checkPWD.Length > 18 || checkPWD.Length <= 0 + || ValidPwd is false) + { + return "Invalid Password\n"; + } + else if (checkUN.Length <= 15 && checkUN.Length > 0 + || ValidUN is true && checkPWD.Length <= 18 + && checkPWD.Length > 0 || ValidPwd is true) + { + return "Username and password is valid.\n"; + } + else if (checkUN.Length <= 15 && checkUN.Length > 0 + || ValidUN is true) + { + return "Valid Username\n"; + } + else if (checkPWD.Length <= 18 && checkPWD.Length > 0 + || ValidPwd is true) + { + return "Valid Password\n"; + } + else + { + return "Invalid Input\n"; + } + } + public bool isAdmin() + { + return false; + } + public void CreateUserRecord(UserAccount user) + { + Console.Write(IsInputValid(user.username, user.password)); + + } + + + /*public NewUserName() { @@ -60,7 +118,7 @@ namespace main public void AccountController() { // Create objects - UserAccount user = new UserAccount(); + //UserAccount user = new UserAccount(); UiPrint ui = new UiPrint(); bool foo = true; diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/TeamHobby.HobbyProjectGenerator.UserManagement.csproj b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/TeamHobby.HobbyProjectGenerator.UserManagement.csproj index 132c02c..9299c5f 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/TeamHobby.HobbyProjectGenerator.UserManagement.csproj +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/TeamHobby.HobbyProjectGenerator.UserManagement.csproj @@ -6,4 +6,8 @@ enable + + + + diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/Database_Users.cs b/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/Database_Users.cs deleted file mode 100644 index 29bf72b..0000000 --- a/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/Database_Users.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TeamHobby.HobbyProjectGenerator.Implementations -{ - internal class Database_Users : IUserService - { - public IList GetAllUsers() - { - throw new NotImplementedException(); - } - - public bool User(string username) - { - throw new NotImplementedException(); - } - } -} diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/InMemoryUserService.cs b/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/InMemoryUserService.cs index 3b14f48..db60f66 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/InMemoryUserService.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/InMemoryUserService.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace TeamHobby.HobbyProjectGenerator.Implementations { - public class InMemoryUserService : IUserService + public class InMemoryUserService { // Make it readonly so it can't be changed private readonly IList _logstore; diff --git a/Source Code/main/UiPrint.cs b/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/UiPrint.cs similarity index 92% rename from Source Code/main/UiPrint.cs rename to Source Code/TeamHobby.HobbyProjectGenerator/Implementations/UiPrint.cs index 98378f8..d4e3cc5 100644 --- a/Source Code/main/UiPrint.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/UiPrint.cs @@ -6,9 +6,9 @@ using System.Threading.Tasks; // Print Statements used throughout the program. -namespace main +namespace TeamHobby.HobbyProjectGenerator { - internal class UiPrint + public class UiPrint { public void InitialMenu() { diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/User_Authentication.cs b/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/User_Authentication.cs index 718f331..c92ae09 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/User_Authentication.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/User_Authentication.cs @@ -1,6 +1,6 @@ namespace TeamHobby.HobbyProjectGenerator { - public class User_Authentication : IUserService + public class User_Authentication { public IList GetAllUsers() { diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/User_Manager.cs b/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/User_Manager.cs index 56b859f..3d463a9 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/User_Manager.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator/Implementations/User_Manager.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace TeamHobby.HobbyProjectGenerator.Implementations { - public class User_Manager : IUserService + public class User_Manager { public IList GetAllUsers() { diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.csproj b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.csproj index 132c02c..0a03a26 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.csproj +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.csproj @@ -6,4 +6,8 @@ enable + + + + diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln index 3911340..b41037d 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln @@ -17,7 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.Main", "..\TeamHo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.DataAccess", "..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj", "{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator.UserManagement", "..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj", "{2E7193B8-86B6-48DA-9671-CD84615A5F5D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.UserManagement", "..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj", "{2E7193B8-86B6-48DA-9671-CD84615A5F5D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -26,12 +26,14 @@ Global 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}.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}.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}.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 @@ -43,7 +45,6 @@ Global {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.Build.0 = 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 {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs index c02a6f4..5d30baa 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -1,8 +1,8 @@ -using main; -using System; +using System; using System.Data.Odbc; using TeamHobby.HobbyProjectGenerator.Archive; using TeamHobby.HobbyProjectGenerator.DataAccess; +using TeamHobby.HobbyProjectGenerator.UserManagement; namespace TeamHobby.HobbyProjectGenerator.Main @@ -24,19 +24,11 @@ namespace TeamHobby.HobbyProjectGenerator.Main } public class Controller { - public static void Main(string[] args) { - GetCredentials credentials = new GetCredentials(); - string? username = credentials.GetUserName(); - string? password = credentials.GetPassword(); - - - Console.WriteLine(value: $"username is {username}\npassword is {password}"); - - /* // Creating the Factory class + /*// Creating the Factory class string dbType = "sql"; - RelationalDataSourceFactory dbFactory = new RelationalDataSourceFactory(); + RDSFactory factory = new RDSFactory(); // Testing Data Access Layer string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" + @@ -45,9 +37,27 @@ namespace TeamHobby.HobbyProjectGenerator.Main "UID=root;" + "PASSWORD=Teamhobby;" + "OPTION=3"; - IDataSource datasource = dbFactory.getDataSource(dbType,dbInfo); + IDataSource datasource = factory.getDataSource(dbType, dbInfo);*/ - string sqlQuery = "Select * from log;"; + // 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); + + manager.CreateUserRecord(user); + + //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; @@ -73,13 +83,13 @@ namespace TeamHobby.HobbyProjectGenerator.Main // Testing archive Manager //while (true) //{ - string currentDate = DateTime.Now.ToString("dd"); + /* 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(); - } + }*/ //} @@ -129,11 +139,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main //datasource.WriteData(sqlRemove); //Console.WriteLine("Writing completed. "); - - /* ExampleDAO z = new ExampleDAO(); - z.UserData("Tomato"); - Console.Read();*/ - /*bool MainMenu = true; + /* bool MainMenu = true; // Set up menu loop while (MainMenu == true) @@ -149,7 +155,6 @@ namespace TeamHobby.HobbyProjectGenerator.Main // Create class objects UiPrint menu = new UiPrint(); - UserAccount user = new UserAccount(); // Print main menu @@ -207,8 +212,8 @@ namespace TeamHobby.HobbyProjectGenerator.Main catch { MainMenu = false; - }; - }*/ + };*/ + //} } } diff --git a/Source Code/main/main.csproj b/Source Code/main/main.csproj index 8853c02..463e46e 100644 --- a/Source Code/main/main.csproj +++ b/Source Code/main/main.csproj @@ -14,6 +14,9 @@ + + +