Merge pull request #12 from long237/Jacobs-Branch

Jacobs branch
This commit is contained in:
Jacob Delgado 2021-12-13 20:17:19 -08:00 committed by GitHub
commit 5224841dac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 550 additions and 288 deletions

26
Source Code/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/main/bin/Debug/net6.0/main.dll",
"args": [],
"cwd": "${workspaceFolder}/main",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

42
Source Code/.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/main/main.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/main/main.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/main/main.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@ -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;

View File

@ -0,0 +1,39 @@
// Print Statements used throughout the program.
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
int menu = 0;
Console.WriteLine($"Welcome {username} to User Management.\n");
Console.WriteLine("What would you like to do?\n");
Console.WriteLine(menu + ") To exit User Management.\n");
menu += 1;
Console.WriteLine(menu + ") Create a new account.\n");
menu += 1;
Console.WriteLine(menu + ") Edit an account.\n");
menu += 1;
Console.WriteLine(menu + ") Delete an account.\n");
menu += 1;
Console.WriteLine(menu + ") Disable an account.\n");
menu += 1;
Console.WriteLine(menu + ") Enable an account.\n");
menu += 1;
Console.WriteLine(menu + ") View logs.\n");
menu += 1;
Console.WriteLine(menu + ") View archive.\n");
}
}
}

View File

@ -3,10 +3,79 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Odbc;
using TeamHobby.HobbyProjectGenerator.DataAccess;
namespace TeamHobby.HobbyProjectGenerator.UserManagement
{
internal class AccountService
public class AccountService
{
public bool CreateUserRecord(UserAccount newUser, string CreatedBy, IDataSource<string> dbSource)
{
try
{
// Insert into users table
string sqlUser = $"INSERT INTO users (UserName, Password, Role, IsActive," +
$"CreatedBy, CreatedDate, Email) VALUES ('{newUser.username}', " +
$"'{newUser.password}','{newUser.role}', 1," +
$"'{CreatedBy}', NOW(),'{newUser.email}');";
bool insertNewUser = dbSource.WriteData(sqlUser);
return insertNewUser;
}
catch (Exception ex)
{
return false;
}
}
public bool EditUserRecord(UserAccount newUser, string CreatedBy, IDataSource<string> 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))
{
reader = (OdbcDataReader)conUser;
}
// Read Sql query results
while (reader.Read())
{
Console.WriteLine(reader.GetString(0));
}
SqlDAO sqlDS = (SqlDAO)dbSource;
Console.WriteLine("");
// Closing the connection
sqlDS.getConnection().Close();*/
return true;
}
public bool DeleteUserRecord(UserAccount newUser, IDataSource<string> dbSource)
{
return true;
}
public bool DisableUser(UserAccount newUser, IDataSource<string> dbSource)
{
return true;
}
public bool EnableUser(UserAccount newUser, IDataSource<string> dbSource)
{
return true;
}
}
}

View File

@ -3,8 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Odbc;
using TeamHobby.HobbyProjectGenerator.UserManagement;
using TeamHobby.HobbyProjectGenerator.Implementations;
using TeamHobby.HobbyProjectGenerator.DataAccess;
namespace TeamHobby.HobbyProjectGenerator.UserManagement
{
@ -13,125 +14,257 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
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 == '@'
bool validUN = checkUN.All(un=>Char.IsLetterOrDigit(un) || un=='@'
|| un == '.' || un == ',' || un == '!');
bool ValidPwd = checkPWD.All(Char.IsLetterOrDigit);
bool validPwd = checkPWD.All(Char.IsLetterOrDigit);
// Check if any are empty
if (checkUN == null || checkPWD == null)
{
return "Invalid input\n";
}
// Check if username is within the restricted length
else if (checkUN.Length > 15 || checkUN.Length <= 0
|| ValidUN is false)
|| validUN is false)
{
return "Invalid Username\n";
}
// Check if password is within the restricted length
else if (checkPWD.Length > 18 || checkPWD.Length <= 0
|| ValidPwd is false)
|| validPwd is false)
{
return "Invalid Password\n";
}
// Check if username and password are valid
else if (checkUN.Length <= 15 && checkUN.Length > 0
|| ValidUN is true && checkPWD.Length <= 18
&& checkPWD.Length > 0 || ValidPwd is true)
&& validUN is true && checkPWD.Length <= 18
&& checkPWD.Length > 0 && validPwd is true)
{
return "Username and password is valid.\n";
}
// Check if username and password and email are valid
else if (checkUN.Length <= 15 && checkUN.Length > 0
|| ValidUN is true)
&& validUN is true && checkPWD.Length <= 18
&& checkPWD.Length > 0 && validPwd is true)
{
return "Username and password is valid.\n";
}
// For testing to make sure username is valid
else if (checkUN.Length <= 15 && checkUN.Length > 0
&& validUN is true)
{
return "Valid Username\n";
}
// For testing to make sure password is valid
else if (checkPWD.Length <= 18 && checkPWD.Length > 0
|| ValidPwd is true)
&& validPwd is true)
{
return "Valid Password\n";
}
else
{
return "Invalid Input\n";
return "Invalid input\n";
}
}
public bool isAdmin()
public string IsInputValid(string checkUN, string checkPWD, string email, string role)
{
return false;
}
public void CreateUserRecord(UserAccount user)
{
Console.Write(IsInputValid(user.username, user.password));
// Create bool variables to check if username and password and email are valid
bool validUN = checkUN.All(un => Char.IsLetterOrDigit(un) || un == '@'
|| un == '.' || un == ',' || un == '!');
}
bool validPwd = checkPWD.All(Char.IsLetterOrDigit);
bool validEmail = email.All(email => Char.IsLetterOrDigit(email) && email == '@'
&& email == '.');
bool validRole = role.All(role => Char.IsLetter(role));
/*public NewUserName()
{
}
public NewPassword()
{
// Create bool value for password confirm loop
bool conPsswrd = true;
// Loop until password is confirmed
while (conPsswrd == true)
// Check if any are empty
if (checkUN == null || checkPWD == null || email == null)
{
// 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();
return "Invalid input\n";
}
// Check if username is within the restricted length
else if (checkUN.Length > 15 || checkUN.Length <= 0
|| validUN is false)
{
return "Invalid Username\n";
}
// Check if password is within the restricted length
else if (checkPWD.Length > 18 || checkPWD.Length <= 0
|| validPwd is false)
{
return "Invalid Password\n";
}
// Check if email is within the restricted length
else if (email.Length > 18 || email.Length <= 0
|| validEmail is false)
{
return "Invalid Email.\n";
}
// Check if username and password are valid
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";
}
// Check if username and password and email are valid
else if (checkUN.Length <= 15 && checkUN.Length > 0
&& validUN is true && checkPWD.Length <= 18
&& checkPWD.Length > 0 && validPwd is true
&& email.Length > 18 && email.Length <= 0
&& validEmail is true)
{
return "Username and password is valid.\n";
}
// For testing to make sure username is valid
else if (checkUN.Length <= 15 && checkUN.Length > 0
&& validUN is true)
{
return "Valid Username\n";
}
// For testing to make sure password is valid
else if (checkPWD.Length <= 18 && checkPWD.Length > 0
&& validPwd is true)
{
return "Valid Password\n";
}
// For testing to make sure email is valid
else if (email.Length > 18 && email.Length <= 0
&& validEmail is true)
{
return "Valid Password\n";
}
else
{
return "Invalid input\n";
}
}
// Check with database if user is an admin
public bool isAdmin(UserAccount user, IDataSource<string> dbSource)
{
// string checkAdmin = $"Select * from users where username = {user.username} and password = {user.password};";
string checkAdmin = $"select r.Role from roles r, users u where " +
$"UserName = '{user.username}' and Password = '{user.password}' and r.Role = u.Role;";
Object confirmAdmin = dbSource.ReadData(checkAdmin);
//Console.WriteLine("type of Reesult:" + confirmAdmin.GetType());
OdbcDataReader reader = null;
// Call user manager method to create the new user
//int userCreateConfirm = new CreateUser(userName,userPassword,SecQuest,SecAnswer);
if (confirmAdmin.GetType() == typeof(OdbcDataReader))
{
reader = (OdbcDataReader)confirmAdmin;
}
// Check if user creation was successful
/*if (userCreateConfirm = 1)
// Create String to hold sql output
string checkSql = "";
// Read Sql query results
while (reader.Read())
{
checkSql = reader.GetString(0);
}
SqlDAO sqlDS = (SqlDAO)dbSource;
Console.WriteLine("");
// Closing the connection
sqlDS.getConnection().Close();
if (checkSql == "Admin")
{
return true;
}
else
{
return false;
}
}
public string CreateUserRecord(UserAccount user, IDataSource<string> dbSource)
{
// Check Login inputs
IsInputValid(user.username, user.password);
bool Admin = isAdmin(user, dbSource);
// Give access if the user is and Admin
if (Admin is false)
{
return "Access Denied: Unauthorized\n";
}
else
{
// db.users layout (UserName, Password, RoleID, IsActive, CreatedBy, CreatedDate)
// db.roles layout (RoleID(AutoGen), Role, CreatedBy, CreatedDate)
// Create UiPrint Object
UiPrint ui = new UiPrint();
// Create Account Service object
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) {
// Get user choice
int menuChoice = Convert.ToInt32(Console.ReadLine());
// Complete the appropriate action
switch (menuChoice)
{
// Confirm to user that the account has been created
Console.WriteLine("Account created succesfully with the username of" + userName);
// Exit menu
case 0:
return "Exiting UserManagement.\n";
break;
// Create account
case 1:
UserAccount newUser = new UserAccount(newCredentials.GetUserName(),
newCredentials.GetPassword(), newCredentials.GetEmail(),
newCredentials.GetRole(), DateTime.UtcNow);
accountService.CreateUserRecord(newUser,user.username, dbSource);
break;
// Edit account
case 2:
/* UserAccount newEditUser = new UserAccount(newCredentials.GetUserName(),
newCredentials.GetPassword(), DateTime.UtcNow);
accountService.EditUserRecord(newEditUser, dbSource);*/
break;
// Delete account
case 3:
UserAccount newDeleteUser = new UserAccount(newCredentials.GetUserName(),
newCredentials.GetPassword(), DateTime.UtcNow);
accountService.DeleteUserRecord(newDeleteUser, dbSource);
break;
// Disable account
case 4:
UserAccount newDisableUser = new UserAccount(newCredentials.GetUserName(),
newCredentials.GetPassword(), DateTime.UtcNow);
accountService.DisableUser(newDisableUser, dbSource);
break;
// Enable account
case 5:
UserAccount newEnableUser = new UserAccount(newCredentials.GetUserName(),
newCredentials.GetPassword(), DateTime.UtcNow);
accountService.EnableUser(newEnableUser, dbSource);
break;
// View logs
case 6:
break;
// View archive
case 7:
break;
default:
Console.WriteLine("Invalid input.\nPlease enter a valid option.\n");
break;
}
else
{
}*/
/*conPsswrd = false;
}
else
{
Console.WriteLine("Passwords did not match, please try again.");
}
}
return true;
}*/
public void AccountController()
{
// Create objects
//UserAccount user = new UserAccount();
UiPrint ui = new UiPrint();
bool foo = true;
while (foo == true)
{
// sub menu
ui.SystemAccountMenu();
//
}
string dbAction = user.username;
return dbAction;
}
}
}
}
}

View File

@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator\TeamHobby.HobbyProjectGenerator.csproj" />
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj" />
</ItemGroup>
</Project>

View File

@ -6,37 +6,70 @@ using System.Threading.Tasks;
namespace TeamHobby.HobbyProjectGenerator.UserManagement
{
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 string ConfirmPassword()
{
Console.WriteLine();
string confirmPassword = newUser.NewPassword;
}*/
public string GetEmail()
{
Console.WriteLine("Please enter an email:");
return Console.ReadLine();
}
public string GetRole()
{
Console.WriteLine("Please enter the role of the user:");
return Console.ReadLine();
}
}
public class UserAccount
{
// Admin Credentials
private string UserName;
private string Password;
private DateTime Time;
private string _userName;
private string _password;
private DateTime _Time;
// New User Credentials
private string _Email;
private string _Role;
public UserAccount(string un, string pwd, DateTime TimeStamp)
{
UserName = un;
Password = pwd;
Time = TimeStamp;
_userName = un;
_password = pwd;
_Time = TimeStamp;
}
public string username { get { return UserName; } }
public string password { get { return Password; } }
// 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)
public UserAccount(string newUN, string newPWD, string Email, string role, DateTime newTime)
{
newusername = newUN;
newpassword = newPWD;
newemail = Email;
newtime = newTime;
_userName = newUN;
_password = newPWD;
_Role = role;
_Email = Email;
_Time = newTime;
}
public string NewUserName { get { return newusername; } }
public string NewPassword { get { return newpassword; } }
public string NewEmail { get { return newemail; } }
public DateTime Newtime { get { return newtime; } }
public UserAccount()
{
_Role = "regular";
_Time= DateTime.Now;
}
public string username { get { return _userName; } }
public string password { get { return _password; } }
public string email { get { return _Email; } }
public string role { get { return _Role; } }
public DateTime Time { get { return _Time; } }
}
}

View File

@ -1,53 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TeamHobby.HobbyProjectGenerator.Implementations
{
public class InMemoryUserService
{
// Make it readonly so it can't be changed
private readonly IList<string> _logstore;
public InMemoryUserService()
{
_logstore = new List<string>();
}
public IList<string> GetAllUsers()
{
return _logstore;
}
public bool User(string username)
{
try
{
//DateTime.UtcNow.ToString() + "->" + username; old way of doing it
_logstore.Add($"{DateTime.UtcNow}->{username}"); // New way of doing it
return true;
}
catch
{
return false;
}
}
/*
public bool User(DateTime timestamp, string username)
{
try
{
//DateTime.UtcNow.ToString() + "->" + username; old way of doing it
_logstore.Add($"{timestamp.ToUniversalTime()}->{username}"); // New way of doing it
return true;
}
catch
{
return false;
}
}
*/
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TeamHobby.HobbyProjectGenerator.UserManagement;
// Print Statements used throughout the program.
@ -21,12 +22,16 @@ namespace TeamHobby.HobbyProjectGenerator
}
public void SystemAccountMenu()
{
// Create intial menu
Console.WriteLine("What would you like to do?");
int num = 1;
Console.WriteLine(num + ".Create a new account.");
num += 1;
Console.WriteLine(num + ".Access Admin Features");
UserAccount user = new UserAccount();
// Menu for all UserManagement options
int menu = 0;
Console.WriteLine($"Welcome {user.username} to User Management.\n");
Console.WriteLine("What would you like to do?\n");
Console.WriteLine((menu + 1) + ". Create a new account.");
Console.WriteLine((menu + 1) + ". Edit an account.");
Console.WriteLine((menu + 1) + ". Delete an account.");
Console.WriteLine((menu + 1) + ". Disable an account.");
Console.WriteLine((menu + 1) + ". Enable an account.");
}
}
}

View File

@ -1,17 +0,0 @@
namespace TeamHobby.HobbyProjectGenerator
{
public class User_Authentication
{
public IList<string> GetAllUsers()
{
throw new NotImplementedException();
}
public bool User(string username)
{
//Console.WriteLine("Hello World!");
//Console.WriteLine("Testing console");
throw new NotImplementedException();
}
}
}

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TeamHobby.HobbyProjectGenerator.Implementations
{
public class User_Manager
{
public IList<string> GetAllUsers()
{
throw new NotImplementedException();
}
public bool User(string username)
{
throw new NotImplementedException();
}
}
}

View File

@ -3,8 +3,6 @@ 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.HobbyProjectGenerator", "TeamHobby.HobbyProjectGenerator.csproj", "{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}"
EndProject
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}"

View File

@ -14,8 +14,4 @@
<PackageReference Include="coverlet.collector" Version="3.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator\TeamHobby.HobbyProjectGenerator.csproj" />
</ItemGroup>
</Project>

View File

@ -21,12 +21,22 @@ namespace TeamHobby.HobbyProjectGenerator.Main
"a password:");
string? userPassword = Console.ReadLine();
return userPassword;
}
public class Controller
{
public static void Main(string[] args)
{
// Console customization
// Change the look of the console
Console.Title = "HobbyProjectGenerator";
// Change console text color
Console.ForegroundColor = ConsoleColor.Green;
// Change terminal height
Console.WindowHeight = 40;
Console.WriteLine(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));
// Creating the Factory class
// Logger log = new Logger();
//Logger.PrintTest();
//GetCredentials credentials = new GetCredentials();
@ -49,6 +59,8 @@ namespace TeamHobby.HobbyProjectGenerator.Main
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = factory.getDataSource(dbType, dbInfo);
"PORT=3306;";
@ -69,11 +81,11 @@ namespace TeamHobby.HobbyProjectGenerator.Main
// Create UserAccount class
UserAccount user = new UserAccount(username, password, TimeStamp);
manager.CreateUserRecord(user);
Console.Write(manager.CreateUserRecord(user, datasource));
//Console.WriteLine(value: $"Welcome {username}\n");
/* string sqlQuery = "Select * from log;";
/* string sqlQuery = "Select * from log;";
Object result = datasource.ReadData(sqlQuery);
Console.WriteLine("type of Result: " + result.GetType());
OdbcDataReader reader = null;
@ -95,18 +107,19 @@ namespace TeamHobby.HobbyProjectGenerator.Main
// Closing the connection
sqlDS.getConnection().Close();*/
// 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();
}*/
//}
/* // 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();
}
//}*/
@ -138,7 +151,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main
//// Remove entries fromt the database
//sqlDS.RemoveEntries();
// 2.Inserting Data into the database:
@ -155,80 +168,80 @@ namespace TeamHobby.HobbyProjectGenerator.Main
//datasource.WriteData(sqlRemove);
//Console.WriteLine("Writing completed. ");
/* bool MainMenu = true;
/* 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;
// 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();
// Create class objects
UiPrint menu = new UiPrint();
// Print main menu
menu.InitialMenu();
// 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);
// 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();
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
// 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("");
// 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;
};*/
break;
default:
Console.WriteLine("Invalid choice, please enter a valid number.");
break;
};
}
// Catch invalid keys such as spamming enter
catch
{
MainMenu = false;
};*/
//}
}

View File

@ -18,7 +18,6 @@
<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\TeamHobby.HobbyProjectGenerator.csproj" />
</ItemGroup>
</Project>