commit
f452b599e3
2
.gitignore
vendored
2
.gitignore
vendored
@ -423,3 +423,5 @@ healthchecksdb
|
|||||||
|
|
||||||
.vscode/launch.json
|
.vscode/launch.json
|
||||||
.vscode/tasks.json
|
.vscode/tasks.json
|
||||||
|
Source Code/.vscode/tasks.json
|
||||||
|
Source Code/.vscode/launch.json
|
||||||
|
|||||||
@ -7,7 +7,7 @@ using TeamHobby.HobbyProjectGenerator.DataAccess;
|
|||||||
|
|
||||||
namespace TeamHobby.HobbyProjectGenerator.DataAccess
|
namespace TeamHobby.HobbyProjectGenerator.DataAccess
|
||||||
{
|
{
|
||||||
public class RelationalDataSourceFactory
|
public class RDSFactory
|
||||||
{
|
{
|
||||||
// Mehthod to create a specific data source suitable to the need
|
// Mehthod to create a specific data source suitable to the need
|
||||||
public IDataSource<string> getDataSource(string name, string info)
|
public IDataSource<string> getDataSource(string name, string info)
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
namespace TeamHobby.HobbyProjectGenerator.Logging
|
||||||
|
{
|
||||||
|
public class Logger
|
||||||
|
{
|
||||||
|
public static void PrintTest()
|
||||||
|
{
|
||||||
|
Console.WriteLine("testing");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -4,9 +4,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace TeamHobby.HobbyProjectGenerator.Contracts
|
namespace TeamHobby.HobbyProjectGenerator.UserManagement
|
||||||
{
|
{
|
||||||
internal interface IDataSource
|
internal class AccountService
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,11 +3,69 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
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()
|
/*public NewUserName()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -60,7 +118,7 @@ namespace main
|
|||||||
public void AccountController()
|
public void AccountController()
|
||||||
{
|
{
|
||||||
// Create objects
|
// Create objects
|
||||||
UserAccount user = new UserAccount();
|
//UserAccount user = new UserAccount();
|
||||||
UiPrint ui = new UiPrint();
|
UiPrint ui = new UiPrint();
|
||||||
|
|
||||||
bool foo = true;
|
bool foo = true;
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator\TeamHobby.HobbyProjectGenerator.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TeamHobby.HobbyProjectGenerator.UserManagement
|
||||||
|
{
|
||||||
|
public class UserAccount
|
||||||
|
{
|
||||||
|
// Admin Credentials
|
||||||
|
private string UserName;
|
||||||
|
private string Password;
|
||||||
|
private DateTime Time;
|
||||||
|
|
||||||
|
public UserAccount(string un, string pwd, DateTime 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)
|
||||||
|
{
|
||||||
|
newusername = newUN;
|
||||||
|
newpassword = newPWD;
|
||||||
|
newemail = Email;
|
||||||
|
newtime = 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;} }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<string> GetAllUsers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -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<string> GetAllUsers()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool User(string username)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace TeamHobby.HobbyProjectGenerator.Implementations
|
namespace TeamHobby.HobbyProjectGenerator.Implementations
|
||||||
{
|
{
|
||||||
public class InMemoryUserService : IUserService
|
public class InMemoryUserService
|
||||||
{
|
{
|
||||||
// Make it readonly so it can't be changed
|
// Make it readonly so it can't be changed
|
||||||
private readonly IList<string> _logstore;
|
private readonly IList<string> _logstore;
|
||||||
|
|||||||
@ -6,9 +6,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
// Print Statements used throughout the program.
|
// Print Statements used throughout the program.
|
||||||
|
|
||||||
namespace main
|
namespace TeamHobby.HobbyProjectGenerator
|
||||||
{
|
{
|
||||||
internal class UiPrint
|
public class UiPrint
|
||||||
{
|
{
|
||||||
public void InitialMenu()
|
public void InitialMenu()
|
||||||
{
|
{
|
||||||
@ -1,6 +1,6 @@
|
|||||||
namespace TeamHobby.HobbyProjectGenerator
|
namespace TeamHobby.HobbyProjectGenerator
|
||||||
{
|
{
|
||||||
public class User_Authentication : IUserService
|
public class User_Authentication
|
||||||
{
|
{
|
||||||
public IList<string> GetAllUsers()
|
public IList<string> GetAllUsers()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace TeamHobby.HobbyProjectGenerator.Implementations
|
namespace TeamHobby.HobbyProjectGenerator.Implementations
|
||||||
{
|
{
|
||||||
public class User_Manager : IUserService
|
public class User_Manager
|
||||||
{
|
{
|
||||||
public IList<string> GetAllUsers()
|
public IList<string> GetAllUsers()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,4 +6,8 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Contracts\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -15,7 +15,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGener
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.Main", "..\TeamHobby.Main\TeamHobby.Main.csproj", "{ED126EFB-B337-42F9-BE4B-65A5AE90503B}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.Main", "..\TeamHobby.Main\TeamHobby.Main.csproj", "{ED126EFB-B337-42F9-BE4B-65A5AE90503B}"
|
||||||
EndProject
|
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.Logging", "..\TeamHobby.HobbyProjectGenerator.Logging\TeamHobby.HobbyProjectGenerator.Logging.csproj", "{C0494115-838E-43A3-8896-133E5D1E874A}"
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.UserManagement", "..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj", "{2E7193B8-86B6-48DA-9671-CD84615A5F5D}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -24,12 +27,14 @@ Global
|
|||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.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
|
||||||
{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}.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
|
||||||
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
@ -41,13 +46,20 @@ Global
|
|||||||
{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
|
||||||
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.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.ActiveCfg = Release|Any CPU
|
||||||
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.Build.0 = Release|Any CPU
|
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.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}.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
|
||||||
|
{C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
using main;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Data.Odbc;
|
using System.Data.Odbc;
|
||||||
using TeamHobby.HobbyProjectGenerator.Archive;
|
using TeamHobby.HobbyProjectGenerator.Archive;
|
||||||
using TeamHobby.HobbyProjectGenerator.DataAccess;
|
using TeamHobby.HobbyProjectGenerator.DataAccess;
|
||||||
|
using TeamHobby.HobbyProjectGenerator.Logging;
|
||||||
|
using TeamHobby.HobbyProjectGenerator.UserManagement;
|
||||||
namespace TeamHobby.HobbyProjectGenerator.Main
|
namespace TeamHobby.HobbyProjectGenerator.Main
|
||||||
{
|
{
|
||||||
public class GetCredentials
|
public class GetCredentials
|
||||||
@ -17,16 +16,18 @@ namespace TeamHobby.HobbyProjectGenerator.Main
|
|||||||
}
|
}
|
||||||
public string? GetPassword()
|
public string? GetPassword()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Please enter a password:");
|
Console.WriteLine("Please enter " +
|
||||||
|
"a password:");
|
||||||
string? userPassword = Console.ReadLine();
|
string? userPassword = Console.ReadLine();
|
||||||
return userPassword;
|
return userPassword;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public class Controller
|
public class Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
// Logger log = new Logger();
|
||||||
|
//Logger.PrintTest();
|
||||||
//GetCredentials credentials = new GetCredentials();
|
//GetCredentials credentials = new GetCredentials();
|
||||||
//string? username = credentials.GetUserName();
|
//string? username = credentials.GetUserName();
|
||||||
//string? password = credentials.GetPassword();
|
//string? password = credentials.GetPassword();
|
||||||
@ -35,19 +36,43 @@ namespace TeamHobby.HobbyProjectGenerator.Main
|
|||||||
//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
|
||||||
|
// Creating the Factory class
|
||||||
|
|
||||||
string dbType = "sql";
|
string dbType = "sql";
|
||||||
RelationalDataSourceFactory dbFactory = new RelationalDataSourceFactory();
|
RDSFactory factory = new RDSFactory();
|
||||||
|
|
||||||
// Testing Data Access Layer
|
// Testing Data Access Layer
|
||||||
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
|
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
|
||||||
|
"TCPIP=1;" +
|
||||||
"SERVER=localhost;" +
|
"SERVER=localhost;" +
|
||||||
"DATABASE=hobby;" +
|
"DATABASE=hobby;" +
|
||||||
"UID=root;" +
|
"UID=root;" +
|
||||||
"PASSWORD=Teamhobby;" +
|
"PASSWORD=Teamhobby;" +
|
||||||
"OPTION=3";
|
"PORT=3306;";
|
||||||
IDataSource<string> datasource = dbFactory.getDataSource(dbType,dbInfo);
|
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
|
||||||
|
|
||||||
string sqlQuery = "Select * from log;";
|
"OPTION=3";
|
||||||
|
IDataSource<string> datasource = factory.getDataSource(dbType, dbInfo);*/
|
||||||
|
|
||||||
|
// Create manager class from UserManagement
|
||||||
|
SystemAccountManager manager = new SystemAccountManager();
|
||||||
|
|
||||||
|
// Admin Sign in
|
||||||
|
GetCredentials credentials = new GetCredentials();
|
||||||
|
string? username = credentials.GetUserName();
|
||||||
|
string? password = credentials.GetPassword();
|
||||||
|
|
||||||
|
// Get time of login attempt
|
||||||
|
DateTime TimeStamp = DateTime.UtcNow;
|
||||||
|
|
||||||
|
// Create UserAccount class
|
||||||
|
UserAccount user = new UserAccount(username, password, TimeStamp);
|
||||||
|
|
||||||
|
manager.CreateUserRecord(user);
|
||||||
|
|
||||||
|
//Console.WriteLine(value: $"Welcome {username}\n");
|
||||||
|
|
||||||
|
/* string sqlQuery = "Select * from log;";
|
||||||
Object result = datasource.ReadData(sqlQuery);
|
Object result = datasource.ReadData(sqlQuery);
|
||||||
Console.WriteLine("type of Result: " + result.GetType());
|
Console.WriteLine("type of Result: " + result.GetType());
|
||||||
OdbcDataReader reader = null;
|
OdbcDataReader reader = null;
|
||||||
@ -67,19 +92,19 @@ namespace TeamHobby.HobbyProjectGenerator.Main
|
|||||||
Console.WriteLine("");
|
Console.WriteLine("");
|
||||||
|
|
||||||
// Closing the connection
|
// Closing the connection
|
||||||
sqlDS.getConnection().Close();
|
sqlDS.getConnection().Close();*/
|
||||||
|
|
||||||
// While loop to keep this running forever with UserManagement
|
// 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();
|
||||||
}
|
}*/
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
@ -129,11 +154,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main
|
|||||||
//datasource.WriteData(sqlRemove);
|
//datasource.WriteData(sqlRemove);
|
||||||
//Console.WriteLine("Writing completed. ");
|
//Console.WriteLine("Writing completed. ");
|
||||||
|
|
||||||
|
/* bool MainMenu = true;
|
||||||
/* ExampleDAO z = new ExampleDAO();
|
|
||||||
z.UserData("Tomato");
|
|
||||||
Console.Read();*/
|
|
||||||
/*bool MainMenu = true;
|
|
||||||
|
|
||||||
// Set up menu loop
|
// Set up menu loop
|
||||||
while (MainMenu == true)
|
while (MainMenu == true)
|
||||||
@ -149,7 +170,6 @@ namespace TeamHobby.HobbyProjectGenerator.Main
|
|||||||
|
|
||||||
// Create class objects
|
// Create class objects
|
||||||
UiPrint menu = new UiPrint();
|
UiPrint menu = new UiPrint();
|
||||||
UserAccount user = new UserAccount();
|
|
||||||
|
|
||||||
|
|
||||||
// Print main menu
|
// Print main menu
|
||||||
@ -207,8 +227,8 @@ namespace TeamHobby.HobbyProjectGenerator.Main
|
|||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
MainMenu = false;
|
MainMenu = false;
|
||||||
};
|
};*/
|
||||||
}*/
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,23 +1,22 @@
|
|||||||
using Microsoft.Data.SqlClient;
|
using Microsoft.Data.SqlClient;
|
||||||
|
using TeamHobby.HobbyProjectGenerator.Models;
|
||||||
|
|
||||||
namespace TeamHobby.HobbyProjectGenerator.Main
|
namespace TeamHobby.HobbyProjectGenerator.DAL
|
||||||
{
|
{
|
||||||
public class ExampleDAO
|
public class SqlDAO
|
||||||
{
|
{
|
||||||
|
public IList<Credentials> GetUserData(string username)
|
||||||
public void UserData(string username)
|
|
||||||
{
|
{
|
||||||
// Sql server connection string, needs to be changed accordingly to connect
|
// 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
|
// 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
|
// More complex sql commands are done in this method instead
|
||||||
var sql = "Select * from roles";
|
var sql = "Select * from roles";
|
||||||
using (var command = new SqlCommand(sql, conn))
|
using (var command = new SqlCommand(sql, conn))
|
||||||
{
|
{
|
||||||
conn.Open();
|
|
||||||
// Get the results from the query
|
// Get the results from the query
|
||||||
SqlDataReader r = command.ExecuteReader();
|
SqlDataReader r = command.ExecuteReader();
|
||||||
|
|
||||||
@ -33,18 +32,18 @@ namespace TeamHobby.HobbyProjectGenerator.Main
|
|||||||
{
|
{
|
||||||
Console.WriteLine(r.ToString());
|
Console.WriteLine(r.ToString());
|
||||||
}
|
}
|
||||||
conn.Close();
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
// Console.Read();
|
|
||||||
/*
|
/*// this is meant for specific basic sql commands
|
||||||
* this is meant for specific basic sql commands
|
using (var adapter = new SqlDataAdapter())
|
||||||
using (var adapter = new SqlDataAdapter())
|
{
|
||||||
{
|
adapter.UpdateCommand
|
||||||
adapter.SelectCommand
|
adapter.DeleteCommand
|
||||||
}
|
adapter.InsertCommand
|
||||||
*/
|
adapter.SelectCommand
|
||||||
//return null;
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,34 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace main
|
|
||||||
{
|
|
||||||
public class UserAccount
|
|
||||||
{
|
|
||||||
/* private string username;
|
|
||||||
private string password;
|
|
||||||
private string role;
|
|
||||||
|
|
||||||
public UserAccount(string un,string pwd,string rol)
|
|
||||||
{
|
|
||||||
username = un;
|
|
||||||
password = pwd;
|
|
||||||
role = rol;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UserAccount()
|
|
||||||
{
|
|
||||||
password = "1234";
|
|
||||||
role = "Regular";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void newUser()
|
|
||||||
{
|
|
||||||
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -5,6 +5,7 @@
|
|||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -14,6 +15,10 @@
|
|||||||
<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\TeamHobby.HobbyProjectGenerator.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
1
doc/LowLevel/Logging/LogToFile_Sequence.svg
Normal file
1
doc/LowLevel/Logging/LogToFile_Sequence.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 32 KiB |
BIN
doc/LowLevel/Logging/Logging_LLD_V4.png
Normal file
BIN
doc/LowLevel/Logging/Logging_LLD_V4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 330 KiB |
Loading…
Reference in New Issue
Block a user