Merge branch 'Jacobs-Branch' into Rifats_tests

This commit is contained in:
Rifat Hasan 2021-12-14 13:34:08 -08:00
commit 136505be71
24 changed files with 515 additions and 639 deletions

View File

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -75,11 +75,24 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests
} }
public void CopyingToAFileTest(IDataSource<string> sqlDAO) // [Test Method]
public void IsCSVFileExist(IDataSource<string> sqlDAO)
{ {
// Arrange // Arrange
ArchiveManager archiveManager = new ArchiveManager(sqlDAO); ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
SqlDAO sqlDS = null; SqlDAO sqlDS = null;
string folderPath = @"C:/HobbyArchive";
try
{
bool folderRes = archiveManager.CreateArchiveFolder();
}
catch (Exception ex)
{
Console.WriteLine("Folder creation for copying failed");
}
string filePath = archiveManager.CreateOutFileName();
bool expectedVal = true;
if (sqlDAO.GetType() == typeof(SqlDAO)) if (sqlDAO.GetType() == typeof(SqlDAO))
{ {
@ -87,9 +100,100 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests
} }
// Act // Act
bool actualVal = false;
if (sqlDS != null)
{
try
{
actualVal = sqlDS.CopyToFile(filePath);
}
catch (Exception ex)
{
Console.WriteLine("Copying to a file failed !!");
Console.WriteLine(ex.Message);
}
}
// Assert
bool result = File.Exists(filePath);
if (result)
{
Console.WriteLine("Expected: {0}, Actual: {1}. CSV file created correctly", expectedVal, actualVal);
// Clean up the folder use to test.
try
{
Directory.Delete(folderPath, true);
}
catch
{
Console.WriteLine("Folder failed to be deleted");
}
}
else
{
Console.WriteLine("Expected: {0}, Actual: {1}. CSV file created incorrectly", expectedVal, actualVal);
}
}
// [Test Method]
public void IsProcessFlowCompleted(IDataSource<string> sqlDAO)
{
// Arrange
ArchiveManager archive = new ArchiveManager(sqlDAO);
// Act
// Testing archive Manager
int i = -10;
while (i < 20)
{
DateTime date1 = new DateTime(2021, 12, 1, 0, 0, 0);
//Console.WriteLine("Testing first of month: {0}", date1.ToString("dd"));
//string currentDate = DateTime.Now.ToString("dd");
//string currentTime = DateTime.Now.ToString("T");
string currentTime = "00:00:00 AM";
string currentDate = i.ToString();
if (i == 1)
{
currentDate = date1.ToString("dd");
//ArchiveManager archive = new ArchiveManager(sqlDAO);
//archive.Controller();
}
//Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime);
Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime);
if (String.Equals(currentDate, "01") && String.Equals(currentTime, "00:00:00 AM"))
{
Console.WriteLine("Archiving process Start");
//ArchiveManager archive = new ArchiveManager(sqlDAO);
archive.Controller();
}
i++;
}
}
public void IsCleaningUpCompleted(IDataSource<string> sqlDAO)
{
//Arrange
ArchiveManager archive = new ArchiveManager(sqlDAO);
bool actualVal = false;
bool expectedVal = false;
// Act
actualVal = archive.Controller();
// Assert // Assert
//bool result = !(actualVal && expectedVal);
if (expectedVal == actualVal)
{
Console.WriteLine("Expected: {0}, Actual: {1}. Error handle correctly", expectedVal, actualVal);
}
else
{
Console.WriteLine("Expected: {0}, Actual: {1}. Error handle incorrectly", expectedVal, actualVal);
}
} }
@ -116,6 +220,18 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests
Console.WriteLine(""); Console.WriteLine("");
// Testing file creation
test.IsCSVFileExist(sqlDAO);
Console.WriteLine("-----------------");
Console.WriteLine("");
// Testing clean up sequence
//test.IsCleaningUpCompleted(sqlDAO);
//Console.WriteLine("-----------------");
//Console.WriteLine("");
} }
} }

View File

@ -1,7 +0,0 @@
namespace TeamHobby.HobbyProjectGenerator.DataAccess
{
public class Class1
{
}
}

View File

@ -17,9 +17,9 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess
public SqlDAO(string info) public SqlDAO(string info)
{ {
try { try {
Console.WriteLine("Establising Connection..."); //Console.WriteLine("Establising Connection...");
_conn = new OdbcConnection(info); _conn = new OdbcConnection(info);
Console.WriteLine("Connection established."); //Console.WriteLine("Connection established.");
} }
catch { catch {
//_conn = null; //_conn = null;
@ -238,15 +238,13 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess
string sqlCmd = "DELETE FROM log WHERE DATEDIFF(current_timestamp, log.LtimeStamp) > 30"; string sqlCmd = "DELETE FROM log WHERE DATEDIFF(current_timestamp, log.LtimeStamp) > 30";
try{ if (DeleteData(sqlCmd) == false)
DeleteData(sqlCmd); {
throw new Exception("Error in removing entries,not to worry, will be handled higher up the call stack");
};
return true; return true;
} }
catch {
Console.WriteLine("Eeep! an error in Remove Entries, not to worry, will be handled higher up the call stack");
throw;
}
}
//public Object ReadPreparedStmt(string table){ //public Object ReadPreparedStmt(string table){
// //conn.Open(); // //conn.Open();

View File

@ -4,20 +4,12 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess
{ {
public class UiPrint 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) public void UserManagementMenu(string username)
{ {
// Menu for all UserManagement options // Menu for all UserManagement options
int menu = 0; 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("What would you like to do?\n");
Console.WriteLine(menu + ") To exit User Management.\n"); Console.WriteLine(menu + ") To exit User Management.\n");
menu += 1; menu += 1;
@ -31,9 +23,9 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess
menu += 1; menu += 1;
Console.WriteLine(menu + ") Enable an account.\n"); Console.WriteLine(menu + ") Enable an account.\n");
menu += 1; menu += 1;
Console.WriteLine(menu + ") View logs.\n"); Console.WriteLine(menu + ") View log path.\n");
menu += 1; menu += 1;
Console.WriteLine(menu + ") View archive.\n"); Console.WriteLine(menu + ") View archive path.\n");
} }
} }
} }

View File

@ -10,7 +10,7 @@ namespace TeamHobby.HobbyProjectGenerator.Logging
{ {
bool Log(LogEntry log); bool Log(LogEntry log);
IList<string> GetAllLogs(); // IList<string> GetAllLogs();
} }
} }

View File

@ -10,6 +10,7 @@ namespace TeamHobby.HobbyProjectGenerator.Logging.Contracts
{ {
ILogger CreateLogger() ILogger CreateLogger()
{ {
return new DBLogger();
} }
} }
} }

View File

@ -1,22 +1,16 @@
/*using System; // using System;
using System.Collections.Generic; // using System.Collections.Generic;
using System.Linq; // using System.Linq;
using System.Text; // using System.Text;
using System.Threading.Tasks; // using System.Threading.Tasks;
namespace TeamHobby.HobbyProjectGenerator.Logging // namespace TeamHobby.HobbyProjectGenerator.Logging
{ // {
public class ConsoleLogger : ILogger // public class ConsoleLogger : ILogger
{ // {
public IList<string> GetAllLogs() // public bool Log(LogEntry log)
{ // {
throw new NotImplementedException(); // return true;
} // }
// }
public bool Log(string description) // }
{
throw new NotImplementedException();
}
}
}
*/

View File

@ -1,18 +1,23 @@
/*using System; // using System;
namespace TeamHobby.HobbyProjectGenerator.Logging // namespace TeamHobby.HobbyProjectGenerator.Logging
{ // {
public class FileLogger : ILogger // public class FileLogger : Ilogger
{ // {
public IList<string> GetAllLogs() // public FileLogger()
{ // {
throw new NotImplementedException(); // }
}
public bool Log(string description) // public IList<string> GetAllLogs()
{ // {
throw new NotImplementedException(); // throw new NotImplementedException();
} // }
}
}*/ // public bool Log(LogEntry log)
// {
// throw new NotImplementedException();
// }
// }
// }

View File

@ -1,38 +1,58 @@
/*using System; // using System;
using System.Collections.Generic; // using System.Collections.Generic;
namespace TeamHobby.HobbyProjectGenerator.Logging // namespace TeamHobby.HobbyProjectGenerator.Logging
{ // {
// implementation of ILogger that stores logs as they initialize // // implementation of ILogger that stores logs as they initialize
public class InMemoryLogger : ILogger // public class InMemoryLogger : ILogger
{ // {
// make readonly to prevent it from being changed somewhere other than in the constructor // // make readonly to prevent it from being changed somewhere other than in the constructor
private readonly IList<string> _logStore; // private readonly IList<string> _logStore;
public InMemoryLogger() // public InMemoryLogger()
{ // {
// list of current logs // // list of current logs
_logStore = new List<string>(); // _logStore = new List<string>();
} // }
// public InMemoryLogger(IList<string> logStore)
// {
// _logStore = logStore;
// }
// public bool Log(LogEntry entry)
// {
// if (entry is null)
// {
// throw new ArgumentNullException(nameof(entry));
// }
// try
// {
// // string interpolation to add UTC timestamp to log description
// //_logStore.Add($"{DateTime.UtcNow}-> {description}");
// return true;
// }
// catch
// {
// return false;
// }
// }
// public IList<string> GetAllLogs()
// {
// return _logStore;
// }
// public override bool Equals(object? obj)
// {
// return obj is InMemoryLogger logger &&
// EqualityComparer<IList<string>>.Default.Equals(_logStore, logger._logStore);
// }
public bool Log(string description) // public override int GetHashCode()
{ // {
try // return HashCode.Combine(_logStore);
{ // }
// string interpolation to add UTC timestamp to log description // }
_logStore.Add($"{DateTime.UtcNow}-> {description}");
return true;
}
catch
{
return false;
}
}
public IList<string> GetAllLogs()
{
return _logStore;
}
}
}*/ // }

View File

@ -26,6 +26,28 @@ namespace TeamHobby.HobbyProjectGenerator.Logging
public string description { get; init; } public string description { get; init; }
public DateTime timestamp { get; init; } public DateTime timestamp { get; init; }
// Constructor requireing only the description as an arg
// Assigns default values for LogLevel (Info), LogCategory (Server), user ("System"), and the UTC time at initialization for timestamp
public LogEntry(string description)
{
this.level = LogLevel.Info;
this.category = LogCategory.Server;
this.user = "System";
this.description = description;
this.timestamp = DateTime.UtcNow;
}
// Constructor with args for all fields except timestamp
// timestamp is always set to the UTC time at the time of initialization
public LogEntry(LogLevel level, string user, LogCategory category, string description)
{
this.level = level;
this.category = category;
this.user = user;
this.description = description;
this.timestamp = DateTime.UtcNow;
}
} }
} }
*/

View File

@ -9,23 +9,23 @@ using TeamHobby.HobbyProjectGenerator.Logging.Implementations;
namespace TeamHobby.HobbyProjectGenerator.Logging namespace TeamHobby.HobbyProjectGenerator.Logging
{ {
internal class LoggingController internal class LoggingManager
{ {
private readonly IDataSource<string> _conn; private readonly IDataSource<string> _conn;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly ILoggerFactory _factory; private readonly ILoggerFactory _factory;
// private readonly LogEntry _logEntry; private readonly LogEntry _logEntry;
// Both Constructors take an IDataSource arg to make logging extensible to future data sources // Both Constructors take an IDataSource arg to make logging extensible to future data sources
// first constructor has no additional args - defaults to using the DBFactiry implementation // first constructor has no additional args - defaults to using the DBFactiry implementation
public LoggingController(IDataSource<string> dataSource) public LoggingManager(IDataSource<string> dataSource)
{ {
_conn = dataSource; _conn = dataSource;
_factory = new DBLoggerFactory(); _factory = new DBLoggerFactory();
_logger = _factory.CreateLogger(); _logger = _factory.CreateLogger();
} }
// second constructor takes an additional ILoggerFactory arg - allows for extensible logger types // second constructor takes an additional ILoggerFactory arg - allows for extensible logger types
public LoggingController(IDataSource<string> dataSource, ILoggerFactory factory) public LoggingManager(IDataSource<string> dataSource, ILoggerFactory factory)
{ {
_conn = dataSource; _conn = dataSource;
_factory = factory; _factory = factory;
@ -35,7 +35,7 @@ namespace TeamHobby.HobbyProjectGenerator.Logging
public void Process() public void Process()
{ {
_logger.Log(); _logger.Log(_logEntry);
} }

View File

@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,10 +0,0 @@
namespace TeamHobby.HobbyProjectGenerator.Models
{
public class Credentials
{
public string userName { get; set; }
// Syntactic sugar
public string Password { get; set; }
}
}

View File

@ -29,53 +29,74 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
return false; return false;
} }
} }
public bool EditUserRecord(UserAccount newUser, string CreatedBy, IDataSource<string> dbSource) public bool EditUserRecord(UserAccount editUser, string CreatedBy, IDataSource<string> dbSource)
{
try
{ {
/* // 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 // Insert into users table
string sqlRoles = $"INSERT INTO roles (Role, CreatedBy, CreatedDate) " + string sqlUser = $"UPDATE users t SET t.Password = '{editUser.password}', " +
$"VALUES ('{newUser.NewRole}', '{CreatedBy}', NOW());"; $"t.Role = '{editUser.role}',t.Email = '{editUser.email}' " +
Object insertNewRole = dbSource.WriteData(sqlUser); $"WHERE t.UserName = '{editUser.username}';";
// 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()); bool updateNewUser = dbSource.UpdateData(sqlUser);
OdbcDataReader reader = null; return updateNewUser;
if (conUser.GetType() == typeof(OdbcDataReader))
{
reader = (OdbcDataReader)conUser;
} }
catch (Exception ex)
{
return false;
}
}
public bool DeleteUserRecord(UserAccount deleteUser, string CreatedBy, IDataSource<string> dbSource)
{
try
{
// Insert into users table
string sqlUser = $"DELETE from users WHERE UserName = '{deleteUser.username}' " +
$"and Password = '{deleteUser.password}';";
// Read Sql query results bool deleteNewUser = dbSource.DeleteData(sqlUser);
while (reader.Read()) return deleteNewUser;
{
Console.WriteLine(reader.GetString(0));
}
SqlDAO sqlDS = (SqlDAO)dbSource; }
Console.WriteLine(""); catch (Exception ex)
{
return false;
}
}
public bool DisableUser(UserAccount disableUser, string CreatedBy, IDataSource<string> dbSource)
{
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;
// Closing the connection
sqlDS.getConnection().Close();*/
return true;
} }
public bool DeleteUserRecord(UserAccount newUser, IDataSource<string> dbSource) catch (Exception ex)
{ {
return true; return false;
} }
public bool DisableUser(UserAccount newUser, IDataSource<string> dbSource) }
public bool EnableUser(UserAccount enableUser, string CreatedBy, IDataSource<string> dbSource)
{ {
return true; try
}
public bool EnableUser(UserAccount newUser, IDataSource<string> dbSource)
{ {
return true; // 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;
}
} }
} }
} }

View File

@ -175,6 +175,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
if (checkSql == "Admin") if (checkSql == "Admin")
{ {
Console.WriteLine("-- Logged in successfully.");
return true; return true;
} }
else else
@ -217,47 +218,91 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
{ {
// Exit menu // Exit menu
case 0: case 0:
return "Exiting UserManagement.\n"; return "Back to Login";
break;
// Create account // Create account
case 1: case 1:
// Get all credentials and create newUser
UserAccount newUser = new UserAccount(newCredentials.GetUserName(), UserAccount newUser = new UserAccount(newCredentials.GetUserName(),
newCredentials.GetPassword(), newCredentials.GetEmail(), newCredentials.ConfirmPassword(), newCredentials.GetEmail(),
newCredentials.GetRole(), DateTime.UtcNow); newCredentials.GetRole(), DateTime.UtcNow);
bool accountValid = accountService.CreateUserRecord(newUser, user.username, dbSource); bool accountValid = accountService.CreateUserRecord(newUser, user.username, dbSource);
if (accountValid is true) if (accountValid is true)
{ {
Console.WriteLine("Account created Successfully"); Console.WriteLine("\nAccount created Successfully");
break; break;
} }
else else
{ {
return "Database Timed out"; return "Database Timed out";
} }
//break;
// Edit account // Edit account
case 2: case 2:
/* UserAccount newEditUser = new UserAccount(newCredentials.GetUserName(), // State what account is being edited
newCredentials.GetPassword(), DateTime.UtcNow); string userName = newCredentials.GetUserName();
accountService.EditUserRecord(newEditUser, dbSource);*/ 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; break;
// Delete account // Delete account
case 3: case 3:
UserAccount newDeleteUser = new UserAccount(newCredentials.GetUserName(), UserAccount newDeleteUser = new UserAccount(newCredentials.GetUserName(),
newCredentials.GetPassword(), DateTime.UtcNow); 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; break;
// Disable account // Disable account
case 4: case 4:
UserAccount newDisableUser = new UserAccount(newCredentials.GetUserName(), UserAccount newDisableUser = new UserAccount(newCredentials.GetUserName(),
newCredentials.GetPassword(), DateTime.UtcNow); newCredentials.GetRole());
accountService.DisableUser(newDisableUser, dbSource); bool disableValid = accountService.DisableUser(newDisableUser, user.username , dbSource);
if (disableValid is true)
{
Console.WriteLine("\nAccount disabled Successfully");
break;
}
else
{
return "User does not exist";
}
break; break;
// Enable account // Enable account
case 5: case 5:
UserAccount newEnableUser = new UserAccount(newCredentials.GetUserName(), UserAccount newEnableUser = new UserAccount(newCredentials.GetUserName(),
newCredentials.GetPassword(), DateTime.UtcNow); newCredentials.GetRole());
accountService.EnableUser(newEnableUser, dbSource); bool enableValid = accountService.EnableUser(newEnableUser, user.username , dbSource);
if (enableValid is true)
{
Console.WriteLine("\nAccount enabled Successfully");
break;
}
else
{
return "User does not exist";
}
break; break;
// View logs // View logs
case 6: case 6:
@ -266,14 +311,11 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
case 7: case 7:
break; break;
default: default:
Console.WriteLine("Invalid input.\nPlease enter a valid option.\n" + Console.WriteLine("Invalid input.\nPlease enter a valid option.\n");
"------------------------------------\n\n");
break; break;
} }
} }
return "Back to Login";
string dbAction = user.username;
return dbAction;
} }
} }
} }

View File

@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace TeamHobby.HobbyProjectGenerator.UserManagement namespace TeamHobby.HobbyProjectGenerator.UserManagement
{ { // Class for getting user credentials
public class GetCredentials public class GetCredentials
{ {
public string? GetUserName() public string? GetUserName()
@ -20,11 +20,26 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
string? userPassword = Console.ReadLine(); string? userPassword = Console.ReadLine();
return userPassword; return userPassword;
} }
/*public string ConfirmPassword() public string ConfirmPassword()
{ {
Console.WriteLine(); while (true)
string confirmPassword = newUser.NewPassword; {
}*/ 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() public string GetEmail()
{ {
Console.WriteLine("Please enter an email:"); Console.WriteLine("Please enter an email:");
@ -52,6 +67,12 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
_password = pwd; _password = pwd;
_Time = TimeStamp; _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) public UserAccount(string newUN, string newPWD, string Email, string role, DateTime newTime)
{ {
_userName = newUN; _userName = newUN;

View File

@ -4,6 +4,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.0.31919.166 VisualStudioVersion = 17.0.31919.166
MinimumVisualStudioVersion = 10.0.40219.1 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}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.UserManagement.Tests", "..\TeamHobby.UserManagement.Tests\TeamHobby.UserManagement.Tests.csproj", "{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}"
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 EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Models", "..\TeamHobby.HobbyProjectGenerator.Models\TeamHobby.HobbyProjectGenerator.Models.csproj", "{75DED6C2-D404-4E71-A58B-0F616DB5C062}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Models", "..\TeamHobby.HobbyProjectGenerator.Models\TeamHobby.HobbyProjectGenerator.Models.csproj", "{75DED6C2-D404-4E71-A58B-0F616DB5C062}"
EndProject EndProject
@ -11,109 +15,53 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "main", "..\main\main.csproj
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Archive", "..\TeamHobby.HobbyProjectGenerator.Archive\TeamHobby.HobbyProjectGenerator.Archive.csproj", "{B88ED0D9-72E2-4245-BD8F-856FF42E500C}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Archive", "..\TeamHobby.HobbyProjectGenerator.Archive\TeamHobby.HobbyProjectGenerator.Archive.csproj", "{B88ED0D9-72E2-4245-BD8F-856FF42E500C}"
EndProject 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}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.DataAccess", "..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj", "{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}"
EndProject 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}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.UserManagement", "..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj", "{2E7193B8-86B6-48DA-9671-CD84615A5F5D}"
EndProject 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}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.ArchiveTests", "..\TeamHobby.HobbyProjectGenerator.ArchiveTests\TeamHobby.HobbyProjectGenerator.ArchiveTests.csproj", "{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}"
EndProject 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 EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{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}.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.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.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.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.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.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.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.Build.0 = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|x86.ActiveCfg = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|x86.Build.0 = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.ActiveCfg = Release|Any CPU {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.Build.0 = Release|Any CPU {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.Build.0 = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|x86.ActiveCfg = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|x86.Build.0 = Release|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.Build.0 = Release|Any CPU {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.Build.0 = Release|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|x86.ActiveCfg = Release|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|x86.Build.0 = Release|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Debug|x86.ActiveCfg = Debug|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.Build.0 = Release|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|x86.ActiveCfg = Release|Any CPU
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|x86.Build.0 = Release|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.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.Build.0 = Debug|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|x86.ActiveCfg = Debug|x86
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|x86.Build.0 = Debug|x86
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.ActiveCfg = Release|Any CPU {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.Build.0 = Release|Any CPU {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.Build.0 = Release|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|x86.ActiveCfg = Release|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|x86.Build.0 = Release|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Debug|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
{C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.Build.0 = Release|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Release|x86.ActiveCfg = Release|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Release|x86.Build.0 = Release|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|Any CPU.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.Build.0 = Debug|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|x86.ActiveCfg = Debug|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|x86.Build.0 = Debug|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|Any CPU.Build.0 = Release|Any CPU {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|Any CPU.Build.0 = Release|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|x86.ActiveCfg = Release|Any CPU
{2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|x86.Build.0 = Release|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|x86.ActiveCfg = Debug|x86
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Debug|x86.Build.0 = Debug|x86
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|Any CPU.Build.0 = Release|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|x86.ActiveCfg = Release|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|x86.Build.0 = Release|Any CPU
{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|Any CPU.ActiveCfg = Debug|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.ActiveCfg = Release|Any CPU
{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|Any CPU.Build.0 = 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.ActiveCfg = Debug|Any CPU
{6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|Any CPU.Build.0 = 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.ActiveCfg = Release|Any CPU
{6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -6,23 +6,9 @@ using TeamHobby.HobbyProjectGenerator.UserManagement;
namespace TeamHobby.HobbyProjectGenerator.Main 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 class Controller
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
// Console customization // Console customization
@ -33,24 +19,38 @@ namespace TeamHobby.HobbyProjectGenerator.Main
// Change terminal height // Change terminal height
Console.WindowHeight = 40; Console.WindowHeight = 40;
Console.WriteLine(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));
// Creating the Factory class // Creating the Factory class
// Logger log = new Logger(); // Logger log = new Logger();
//Logger.PrintTest(); //Logger.PrintTest();
// Admin login // Loop login terminal
bool mainMenu = true;
// Loop Admin login
while (mainMenu is true)
{
// Admin Sign in
GetCredentials credentials = new GetCredentials(); GetCredentials credentials = new GetCredentials();
Console.WriteLine("\nPlease Enter Admin Credentials " +
"or enter 0 to exit the machine\n");
string? username = credentials.GetUserName(); string? username = credentials.GetUserName();
//int menuExit = Convert.ToInt32(username);
// Exit Infinite Menu
if (username == "0")
{
break;
}
string? password = credentials.GetPassword(); string? password = credentials.GetPassword();
// Get time of login attempt
DateTime TimeStamp = DateTime.UtcNow;
//Console.WriteLine(value: $"username is {username}\npassword is {password}");
// Creating the Factory class
// Creating the Factory class
// String for checking query return type
string dbType = "sql"; string dbType = "sql";
// Creating the Factory class
RDSFactory dbFactory = new RDSFactory(); RDSFactory dbFactory = new RDSFactory();
// Testing Data Access Layer // Testing Data Access Layer
@ -62,61 +62,41 @@ namespace TeamHobby.HobbyProjectGenerator.Main
"PASSWORD=Teamhobby;" + "PASSWORD=Teamhobby;" +
"OPTION=3"; "OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo); IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Create manager class from UserManagement
SystemAccountManager manager = new SystemAccountManager();
/* // Admin Sign in // While loop to keep this running forever with UserManagement
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));
//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 // Testing archive Manager
//while (true) //while (true)
//{ //{
string currentDate = DateTime.Now.ToString("dd"); string currentDate = DateTime.Now.ToString("dd");
string currentTime = DateTime.Now.ToString("T"); string currentTime = DateTime.Now.ToString("T");
Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime); //Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime);
if (String.Equals(currentDate, "1") && String.Equals(currentTime, "00:00:00 AM")) if (String.Equals(currentDate, "1") && String.Equals(currentTime, "00:00:00 AM"))
{ {
ArchiveManager archive = new ArchiveManager(datasource); ArchiveManager archive = new ArchiveManager(datasource);
archive.Controller(); archive.Controller();
} }
//}*/ //}
// 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);
if (isLogin != "Access Denied: Unauthorized\n")
{
Console.WriteLine("Returning to login...\n");
Console.WriteLine("-------------------------------------\n");
}
else
{
Console.WriteLine("******Access Denied: Unauthorized******");
}
}
//Creating the folder Archive //Creating the folder Archive
//Console.WriteLine("Creating a new folder ..."); //Console.WriteLine("Creating a new folder ...");
@ -147,8 +127,6 @@ namespace TeamHobby.HobbyProjectGenerator.Main
//sqlDS.RemoveEntries(); //sqlDS.RemoveEntries();
// 2.Inserting Data into the database: // 2.Inserting Data into the database:
//string sqlWrite = "INSERT into log(lvname, catname, userop, logmessage) values " + //string sqlWrite = "INSERT into log(lvname, catname, userop, logmessage) values " +
// "('Info', 'View', 'Testing DAL stuffs', 'new DAL method tested');"; // "('Info', 'View', 'Testing DAL stuffs', 'new DAL method tested');";
@ -162,82 +140,9 @@ namespace TeamHobby.HobbyProjectGenerator.Main
//Console.WriteLine("Writing to the database... "); //Console.WriteLine("Writing to the database... ");
//datasource.WriteData(sqlRemove); //datasource.WriteData(sqlRemove);
//Console.WriteLine("Writing completed. "); //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;
};*/
}
} }
} }
} }

View File

@ -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;
};
}*/
//}
}
}

View File

@ -1,50 +0,0 @@
using Microsoft.Data.SqlClient;
using TeamHobby.HobbyProjectGenerator.Models;
namespace TeamHobby.HobbyProjectGenerator.DAL
{
public class SqlDAO
{
public IList<Credentials> 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
}*/
}
}
}
}

View File

@ -5,7 +5,8 @@
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<Platforms>AnyCPU</Platforms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -15,8 +16,6 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.Archive\TeamHobby.HobbyProjectGenerator.Archive.csproj" /> <ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.Archive\TeamHobby.HobbyProjectGenerator.Archive.csproj" />
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj" /> <ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj" />
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.Logging\TeamHobby.HobbyProjectGenerator.Logging.csproj" />
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.Models\TeamHobby.HobbyProjectGenerator.Models.csproj" />
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj" /> <ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -1,6 +1,5 @@
create table roles create table roles
( (
RoleID int not null,
Role varchar(50) charset utf8mb3 not null, Role varchar(50) charset utf8mb3 not null,
CreatedBy varchar(200) charset utf8mb3 not null, CreatedBy varchar(200) charset utf8mb3 not null,
CreatedDate datetime not null, CreatedDate datetime not null,
@ -35,4 +34,4 @@ INSERT INTO hobby.users (UserName, Password, Role, IsActive, CreatedBy, CreatedD
INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES
('Admin', 'Jacob', '2021-12-13 03:25:14'), ('Admin', 'Jacob', '2021-12-13 03:25:14'),
('regular', 'Colin', '2021-12-13 03:25:14'); ('regular', 'Jacob', '2021-12-13 03:25:14');

View File

@ -2,52 +2,44 @@ create database Hobby;
use 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 create table users
( (
UserName varchar(50) charset utf8mb3 not null UserName varchar(50) charset utf8mb3 not null
primary key, primary key,
Password varchar(50) charset utf8mb3 null, Password varchar(50) charset utf8mb3 not null,
RoleID int auto_increment, Role varchar(50) charset utf8mb3 not null,
IsActive int default 1 null, IsActive int default 1 not null,
CreatedBy varchar(50) charset utf8mb3 null, CreatedBy varchar(50) charset utf8mb3 not null,
CreatedDate datetime null, CreatedDate datetime not null,
constraint users_UserName_uindex Email varchar(50) null,
unique (UserName), constraint users_Email_uindex
constraint users_roles_RoleID_fk unique (Email),
foreign key (RoleID) references roles (RoleID) 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, Role, IsActive, CreatedBy, CreatedDate, Email) VALUES
INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Jacob', 'Teamhobby1234', 'SystemCreator', '2021-12-13 03:25:14'); ('Colin ', 'Waffle', 'Admin', 1, 'Jacob', '2021-12-13 04:27:42', null),
INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Long', 'Joystick', 'Jacob', '2021-12-13 04:29:57'); ('Danny', 'Spartan', 'Admin', 1, 'Jacob', '2021-12-13 04:29:54', null),
INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Rifat', 'ApproveDar', 'Jacob', '2021-12-13 04:29:55'); ('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 INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES
( ('Admin', 'Jacob', '2021-12-13 03:25:14'),
RoleID int auto_increment ('regular', 'Jacob', '2021-12-13 03:25:14');
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', '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_per_table=ON;
-- SET GLOBAL innodb_file_format='Barracuda'; -- SET GLOBAL innodb_file_format='Barracuda';