Merge branch 'master' into Colins-Branch
2
.gitignore
vendored
@ -421,3 +421,5 @@ FodyWeavers.xsd
|
|||||||
# BeatPulse healthcheck temp database
|
# BeatPulse healthcheck temp database
|
||||||
healthchecksdb
|
healthchecksdb
|
||||||
|
|
||||||
|
.vscode/launch.json
|
||||||
|
.vscode/tasks.json
|
||||||
|
|||||||
@ -1,7 +1,39 @@
|
|||||||
namespace TeamHobby.HobbyProjectGenerator.Archive
|
|
||||||
|
using TeamHobby.HobbyProjectGenerator.DataAccess;
|
||||||
|
|
||||||
|
namespace TeamHobby.HobbyProjectGenerator.Archive
|
||||||
{
|
{
|
||||||
public class ArchiveController
|
public class ArchiveController
|
||||||
{
|
{
|
||||||
|
private IDataSource<string> _conn;
|
||||||
|
|
||||||
|
// Constructor to take in the connection.
|
||||||
|
public ArchiveController(IDataSource<string> dataSource) {
|
||||||
|
_conn = dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IDataSource<string> GetDataSource(){
|
||||||
|
return _conn;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the folder where the compress file will be stored
|
||||||
|
public bool CreateArchiveFolder(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the name of the new output file with Path
|
||||||
|
public string CreateOutFileName(){
|
||||||
|
return "hello";
|
||||||
|
}
|
||||||
|
|
||||||
|
// put everything toget here
|
||||||
|
public bool Controller(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,96 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.IO.Compression;
|
|
||||||
|
|
||||||
|
|
||||||
namespace TeamHobby.HobbyProjectGenerator.Archive
|
|
||||||
{
|
|
||||||
public class SQLSource : IDataSource, IRelationArchivable
|
|
||||||
{
|
|
||||||
//private SqlConnection conn;
|
|
||||||
|
|
||||||
//public SQLSource(string info)
|
|
||||||
//{
|
|
||||||
// conn = new SqlConnection(info);
|
|
||||||
//}
|
|
||||||
|
|
||||||
public bool DeleteData()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object ReadData(string cmd)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// conn.open();
|
|
||||||
// conn.Execute();
|
|
||||||
Console.WriteLine("Access a SQL database");
|
|
||||||
Console.WriteLine("Select * from archive");
|
|
||||||
|
|
||||||
// while (myReader)
|
|
||||||
// Print to console
|
|
||||||
// conn.close();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Console.WriteLine(e.Message);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool UpdateData()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool WriteData(string cmd)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Method to archive data
|
|
||||||
public bool CreateArchived(string fileName)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CompressFile(string fileName)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Get the stream of the original file
|
|
||||||
using FileStream origFile = File.Open(fileName, FileMode.Open);
|
|
||||||
|
|
||||||
|
|
||||||
// Get the attribute of the file
|
|
||||||
FileAttributes atrribute = File.GetAttributes(fileName);
|
|
||||||
|
|
||||||
// Check to see if the file is hidden or already compressed before compressing the file.
|
|
||||||
if (atrribute != FileAttributes.Hidden && atrribute != FileAttributes.Compressed)
|
|
||||||
{
|
|
||||||
using FileStream outputFile = File.Create(fileName + ".gz");
|
|
||||||
|
|
||||||
using GZipStream compressor = new GZipStream(outputFile, CompressionMode.Compress);
|
|
||||||
origFile.CopyTo(compressor);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine(ex.Message);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -7,7 +7,18 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.0" />
|
||||||
|
<PackageReference Include="MySql.Data" Version="8.0.27" />
|
||||||
|
<PackageReference Include="System.Data.Odbc" Version="6.0.0" />
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
|
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Implementations\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TeamHobby.HobbyProjectGenerator.DAL
|
||||||
|
{
|
||||||
|
public interface IRepository<T>
|
||||||
|
{
|
||||||
|
bool Create(T model);
|
||||||
|
|
||||||
|
T Read();
|
||||||
|
|
||||||
|
bool Update(T model);
|
||||||
|
|
||||||
|
bool Delete(T model);
|
||||||
|
}
|
||||||
|
}
|
||||||
50
Source Code/TeamHobby.HobbyProjectGenerator.DAL/SqlDAO.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
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
|
||||||
|
}*/
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.Models\TeamHobby.HobbyProjectGenerator.Models.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
namespace TeamHobby.HobbyProjectGenerator.DataAccess
|
||||||
|
{
|
||||||
|
public class Class1
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,21 +4,21 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
//namespace TeamHobby.HobbyProjectGenerator.Archive.Contracts
|
|
||||||
namespace TeamHobby.HobbyProjectGenerator.Archive
|
namespace TeamHobby.HobbyProjectGenerator.DataAccess
|
||||||
{
|
{
|
||||||
public interface IDataSource
|
public interface IDataSource<T>
|
||||||
{
|
{
|
||||||
// Method for reading data, return 0 for sucessful operation
|
// Method for reading data, return 0 for sucessful operation
|
||||||
Object ReadData(string cmd);
|
Object ReadData(T model);
|
||||||
|
|
||||||
// Method for Writing data to a data source
|
// Method for Writing data to a data source
|
||||||
bool WriteData(string cmd);
|
bool WriteData(T model);
|
||||||
|
|
||||||
//Method for deleteing data from a data source, 0 for successful
|
//Method for deleteing data from a data source, 0 for successful
|
||||||
bool DeleteData();
|
bool DeleteData(T model);
|
||||||
|
|
||||||
// Method for updating data from a data source, 0 for sucessful
|
// Method for updating data from a data source, 0 for sucessful
|
||||||
bool UpdateData();
|
bool UpdateData(T model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,224 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Data.Odbc;
|
||||||
|
|
||||||
|
namespace TeamHobby.HobbyProjectGenerator.DataAccess
|
||||||
|
{
|
||||||
|
public class SqlDAO : IDataSource<string>
|
||||||
|
{
|
||||||
|
private OdbcConnection _conn;
|
||||||
|
|
||||||
|
public SqlDAO(string info)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Console.WriteLine("Establising Connection");
|
||||||
|
_conn = new OdbcConnection(info);
|
||||||
|
Console.WriteLine("Connection established");
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
//_conn = null;
|
||||||
|
Console.WriteLine("Error when creating a connection");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getter and setter for Odbc
|
||||||
|
public OdbcConnection Connection { get; set; }
|
||||||
|
|
||||||
|
public OdbcConnection getConnection()
|
||||||
|
{
|
||||||
|
return _conn;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Closing a connection here will cause a problem
|
||||||
|
// Make sure whoever called this need to close the connection until we can fixed it.
|
||||||
|
public Object? ReadData(string cmd)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_conn.Open();
|
||||||
|
OdbcCommand command = new OdbcCommand(cmd, _conn);
|
||||||
|
OdbcDataReader reader = command.ExecuteReader();
|
||||||
|
|
||||||
|
//_conn.Close();
|
||||||
|
return reader;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error when Reading data from databse.");
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
//finally
|
||||||
|
//{
|
||||||
|
// _conn.Close();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The also Identical to update data, maybe only one method is enough
|
||||||
|
public bool DeleteData(string cmd)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_conn.Open();
|
||||||
|
|
||||||
|
OdbcCommand command = new OdbcCommand(cmd, _conn);
|
||||||
|
command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
_conn.Close();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error when deleting data from database!!");
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_conn.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: No idea how to check if the command is valid or where to check it
|
||||||
|
public bool UpdateData(string cmd)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_conn.Open();
|
||||||
|
|
||||||
|
OdbcCommand command = new OdbcCommand(cmd, _conn);
|
||||||
|
command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
_conn.Close();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error when updating data from database!!");
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_conn.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Very similar to UpdataData if not identical
|
||||||
|
public bool WriteData(string cmd)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_conn.Open();
|
||||||
|
|
||||||
|
OdbcCommand command = new OdbcCommand(cmd, _conn);
|
||||||
|
command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
_conn.Close();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error when Writing data from database!!");
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_conn.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool CompressFile(string fileName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Get the stream of the original file
|
||||||
|
using FileStream origFile = File.Open(fileName, FileMode.Open);
|
||||||
|
|
||||||
|
|
||||||
|
// Get the attribute of the file
|
||||||
|
FileAttributes atrribute = File.GetAttributes(fileName);
|
||||||
|
|
||||||
|
// Check to see if the file is hidden or already compressed before compressing the file.
|
||||||
|
if (atrribute != FileAttributes.Hidden && atrribute != FileAttributes.Compressed)
|
||||||
|
{
|
||||||
|
using FileStream outputFile = File.Create(fileName + ".gz");
|
||||||
|
|
||||||
|
using GZipStream compressor = new GZipStream(outputFile, CompressionMode.Compress);
|
||||||
|
origFile.CopyTo(compressor);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy the Sql data to the a text file
|
||||||
|
public bool CopyToFile(string filePath){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RemoveOutputFile(string filePath){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove data from the database, if failed, let the controller handle it.
|
||||||
|
public bool RemoveEntries() {
|
||||||
|
|
||||||
|
string sqlCmd = "DELETE FROM log WHERE DATE_DIFF(current_timestamp, log.LtimeStamp) > 30";
|
||||||
|
|
||||||
|
try{
|
||||||
|
DeleteData(sqlCmd);
|
||||||
|
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){
|
||||||
|
// //conn.Open();
|
||||||
|
// //SqlCommand command = new SqlCommand(null, conn);
|
||||||
|
// SqlCommand command = new SqlCommand("SELECT * from @table;", conn);
|
||||||
|
// SqlParameter tableParam = new SqlParameter("@table", System.Data.SqlDbType.Text, 50);
|
||||||
|
|
||||||
|
// tableParam.Value = table;
|
||||||
|
// command.Parameters.Add(tableParam);
|
||||||
|
|
||||||
|
// // conn.Execute();
|
||||||
|
// Console.WriteLine("Access a SQL database");
|
||||||
|
// Console.WriteLine("Select * from archive");
|
||||||
|
|
||||||
|
// // Make the Prepare statement and excute the query:
|
||||||
|
// command.Prepare();
|
||||||
|
// SqlDataReader sqlReader = command.ExecuteReader();
|
||||||
|
|
||||||
|
// // while (myReader)
|
||||||
|
// // Print to console
|
||||||
|
// // conn.close();
|
||||||
|
// return sqlReader;
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,28 +3,26 @@ 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.Archive;
|
using TeamHobby.HobbyProjectGenerator.DataAccess;
|
||||||
|
|
||||||
namespace TeamHobby.HobbyProjectGenerator.Archive
|
namespace TeamHobby.HobbyProjectGenerator.DataAccess
|
||||||
{
|
{
|
||||||
public class RelationalDataSourceFactory
|
public class RelationalDataSourceFactory
|
||||||
{
|
{
|
||||||
// Mehthod to create a specific data source suitable to the need
|
// Mehthod to create a specific data source suitable to the need
|
||||||
public IDataSource? getDataSource(string name)
|
public IDataSource<string> getDataSource(string name, string info)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (String.Equals(name, "SQL", StringComparison.OrdinalIgnoreCase))
|
if (String.Equals(name, "SQL", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return new SQLSource();
|
return new SqlDAO(info);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("RelationDataFactory: Data Access object creation failed!");
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.Data.Odbc" Version="6.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
namespace TeamHobby.HobbyProjectGenerator.Models
|
||||||
|
{
|
||||||
|
public class Credentials
|
||||||
|
{
|
||||||
|
public string userName { get; set; }
|
||||||
|
|
||||||
|
// Syntactic sugar
|
||||||
|
public string Password { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace TeamHobby.HobbyProjectGenerator
|
|
||||||
{
|
|
||||||
public class Class1
|
|
||||||
{
|
|
||||||
static void Main(string[] args)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Hello World!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TeamHobby.HobbyProjectGenerator.Contracts
|
||||||
|
{
|
||||||
|
internal interface IDataSource
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TeamHobby.HobbyProjectGenerator.Implementations
|
||||||
|
{
|
||||||
|
public class InMemoryUserService : IUserService
|
||||||
|
{
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
namespace TeamHobby.HobbyProjectGenerator
|
||||||
|
{
|
||||||
|
public class User_Authentication : IUserService
|
||||||
|
{
|
||||||
|
public IList<string> GetAllUsers()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool User(string username)
|
||||||
|
{
|
||||||
|
//Console.WriteLine("Hello World!");
|
||||||
|
//Console.WriteLine("Testing console");
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TeamHobby.HobbyProjectGenerator.Implementations
|
||||||
|
{
|
||||||
|
public class User_Manager : IUserService
|
||||||
|
{
|
||||||
|
public IList<string> GetAllUsers()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool User(string username)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,9 +5,17 @@ VisualStudioVersion = 17.0.31919.166
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator", "TeamHobby.HobbyProjectGenerator.csproj", "{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator", "TeamHobby.HobbyProjectGenerator.csproj", "{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Archive", "..\TeamHobby.HobbyProjectGenerator.Archive\TeamHobby.HobbyProjectGenerator.Archive.csproj", "{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.UserManagement.Tests", "..\TeamHobby.UserManagement.Tests\TeamHobby.UserManagement.Tests.csproj", "{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.Main", "..\TeamHobby.Main\TeamHobby.Main.csproj", "{6E9DCCDB-B7E3-4530-B20D-5B86BA86A905}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Models", "..\TeamHobby.HobbyProjectGenerator.Models\TeamHobby.HobbyProjectGenerator.Models.csproj", "{75DED6C2-D404-4E71-A58B-0F616DB5C062}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "main", "..\main\main.csproj", "{30C7EBF3-3957-46E5-86C1-C13356841ECA}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Archive", "..\TeamHobby.HobbyProjectGenerator.Archive\TeamHobby.HobbyProjectGenerator.Archive.csproj", "{B88ED0D9-72E2-4245-BD8F-856FF42E500C}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.Main", "..\TeamHobby.Main\TeamHobby.Main.csproj", "{ED126EFB-B337-42F9-BE4B-65A5AE90503B}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator.DataAccess", "..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj", "{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -16,17 +24,30 @@ 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
|
||||||
{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}.Release|Any CPU.Build.0 = Release|Any CPU
|
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{6E9DCCDB-B7E3-4530-B20D-5B86BA86A905}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{6E9DCCDB-B7E3-4530-B20D-5B86BA86A905}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{6E9DCCDB-B7E3-4530-B20D-5B86BA86A905}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{6E9DCCDB-B7E3-4530-B20D-5B86BA86A905}.Release|Any CPU.Build.0 = Release|Any CPU
|
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{ED126EFB-B337-42F9-BE4B-65A5AE90503B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@ -1,62 +1,148 @@
|
|||||||
// See https://aka.ms/new-console-template for more information
|
// See https://aka.ms/new-console-template for more information
|
||||||
using System.Data.SqlClient;
|
//using System.Data.SqlClient;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using TeamHobby.HobbyProjectGenerator.Archive;
|
using TeamHobby.HobbyProjectGenerator.Archive;
|
||||||
|
//using MySql.Data.MySqlClient;
|
||||||
|
using System.Data.Odbc;
|
||||||
|
|
||||||
public class HobbyMain
|
public class HobbyMain
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Hello World!");
|
// Testing file compression Start
|
||||||
|
//Console.WriteLine("Hello World!");
|
||||||
|
|
||||||
// Testing Compressing a file
|
//// Testing Compressing a file
|
||||||
string fileName = @"C:\Users\Chunchunmaru\Documents\csulbFall2021\HobbyProject\Source Code\TeamHobby.Main\archiving2.txt";
|
//string fileName = @"C:\Users\Chunchunmaru\Documents\csulbFall2021\HobbyProject\Source Code\TeamHobby.Main\rando";
|
||||||
//string fileName = @"arhiving2.txt";
|
////string fileName = @"arhiving2.txt";
|
||||||
FileInfo fileInfo = new FileInfo(fileName);
|
//FileInfo fileInfo = new FileInfo(fileName);
|
||||||
|
|
||||||
Console.WriteLine("File Name: {0}", fileInfo.FullName);
|
//Console.WriteLine("File Name: {0}", fileInfo.FullName);
|
||||||
|
|
||||||
//Console.WriteLine("Starting file compression: ");
|
//SQLSource sqlSource = new SQLSource();
|
||||||
//Compress(fileInfo);
|
//bool res = sqlSource.CompressFile(fileName);
|
||||||
//Console.WriteLine("Ending compression");
|
////bool res = CompressFile(fileName);
|
||||||
//SqlConnection myconn = new SqlConnection();
|
//Console.WriteLine(res);
|
||||||
|
|
||||||
|
//Console.WriteLine(CreateFileName());
|
||||||
|
|
||||||
|
// Testing File compression end
|
||||||
|
|
||||||
|
// testing end
|
||||||
|
|
||||||
|
// Testing connection to MariaDB
|
||||||
|
|
||||||
|
string connString = "user id=root;" + "password=Teamhobby;server=localhost;" + "Trusted_Connection=yes;" + "database=Alatreon; " + "connection timeout=5";
|
||||||
|
string connMariaDB = "server=localhost;port=3306;uid=root;pwd=Teamhobby;connection timeout=5";
|
||||||
|
//var conn = new SqlConnection(connString);
|
||||||
|
|
||||||
|
|
||||||
//IDataSource dataSource = new SQLSource();
|
|
||||||
|
|
||||||
SQLSource sqlSource = new SQLSource();
|
|
||||||
bool res = sqlSource.CompressFile(fileName);
|
|
||||||
//bool res = CompressFile(fileName);
|
|
||||||
Console.WriteLine(res);
|
|
||||||
|
|
||||||
|
//// SqlConnection conn = new SqlConnection(connString);
|
||||||
|
string sqlQ = "Select * from log;";
|
||||||
|
|
||||||
|
//MySql.Data.MySqlClient.MySqlConnection connect;
|
||||||
|
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// Console.WriteLine("Open connection: ");
|
||||||
|
// //connect = new MySql.Data.MySqlClient.MySqlConnection();
|
||||||
|
// //connect.ConnectionString = connMariaDB;
|
||||||
|
// //connect.Open();
|
||||||
|
// conn.Open();
|
||||||
|
|
||||||
|
// SqlCommand cmd = new SqlCommand(sqlQ, conn);
|
||||||
|
|
||||||
|
// SqlDataReader myReader = cmd.ExecuteReader();
|
||||||
|
// while (myReader.Read())
|
||||||
|
// {
|
||||||
|
// Console.WriteLine(myReader["Column1"].ToString());
|
||||||
|
// Console.WriteLine(myReader["Column2"].ToString());
|
||||||
|
// }
|
||||||
|
// conn.Close();
|
||||||
|
|
||||||
|
// //if (connect.State == System.Data.ConnectionState.Open)
|
||||||
|
// //{
|
||||||
|
// // Console.WriteLine("Connection established");
|
||||||
|
// //}
|
||||||
|
// //connect.Close();
|
||||||
|
|
||||||
|
//}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.WriteLine("Opening connection: ");
|
||||||
|
//Connection string for Connector/ODBC 3.51
|
||||||
|
string MyConString = "DRIVER={MariaDB ODBC 3.1 Driver};" +
|
||||||
|
"SERVER=localhost;" +
|
||||||
|
"DATABASE=hobby;" +
|
||||||
|
"UID=root;" +
|
||||||
|
"PASSWORD=Teamhobby;" +
|
||||||
|
"OPTION=3";
|
||||||
|
|
||||||
|
//Connect to MySQL using Connector/ODBC
|
||||||
|
//OdbcConnection MyConnection = new OdbcConnection(MyConString);
|
||||||
|
//MyConnection.Open();
|
||||||
|
|
||||||
|
//Console.WriteLine("\n !!! success, connected successfully !!!\n");
|
||||||
|
|
||||||
|
////Display connection information
|
||||||
|
//Console.WriteLine("Connection Information:");
|
||||||
|
//Console.WriteLine("\tConnection String:" +
|
||||||
|
// MyConnection.ConnectionString);
|
||||||
|
//Console.WriteLine("\tConnection Timeout:" +
|
||||||
|
// MyConnection.ConnectionTimeout);
|
||||||
|
//Console.WriteLine("\tDatabase:" +
|
||||||
|
// MyConnection.Database);
|
||||||
|
//Console.WriteLine("\tDataSource:" +
|
||||||
|
// MyConnection.DataSource);
|
||||||
|
//Console.WriteLine("\tDriver:" +
|
||||||
|
// MyConnection.Driver);
|
||||||
|
//Console.WriteLine("\tServerVersion:" +
|
||||||
|
// MyConnection.ServerVersion);
|
||||||
|
|
||||||
|
//Console.WriteLine("Connection Successful");
|
||||||
|
|
||||||
|
ReadData(MyConString);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
Console.WriteLine("COnnection failed");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ReadData(string connectionString)
|
||||||
|
{
|
||||||
|
string queryString = "SELECT * from log;";
|
||||||
|
|
||||||
|
using (OdbcConnection connection = new OdbcConnection(connectionString))
|
||||||
|
{
|
||||||
|
OdbcCommand command = new OdbcCommand(queryString, connection);
|
||||||
|
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
// Execute the DataReader and access the data.
|
||||||
|
OdbcDataReader reader = command.ExecuteReader();
|
||||||
|
Console.WriteLine("Read 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]);
|
||||||
|
//Console.WriteLine("Col A: {0} ", reader[0]);
|
||||||
|
//Console.WriteLine("Column: " + reader.FieldCount);
|
||||||
|
//Console.WriteLine("Column={1}", reader[1]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call Close when done reading.
|
||||||
|
reader.Close();
|
||||||
|
connection.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void Compress(FileInfo fi)
|
public static string CreateFileName()
|
||||||
{
|
{
|
||||||
// Get the stream of the source file.
|
return DateTime.Now.ToString() + "archive.txt";
|
||||||
using (FileStream inFile = fi.OpenRead())
|
|
||||||
{
|
|
||||||
// Prevent compressing hidden and
|
|
||||||
// already compressed files.
|
|
||||||
if ((File.GetAttributes(fi.FullName) & FileAttributes.Hidden) != FileAttributes.Hidden & fi.Extension != ".gz")
|
|
||||||
{
|
|
||||||
// Create the compressed file.
|
|
||||||
using (FileStream outFile =
|
|
||||||
File.Create(fi.FullName + ".gz"))
|
|
||||||
{
|
|
||||||
using (GZipStream Compress = new GZipStream(outFile, CompressionMode.Compress))
|
|
||||||
{
|
|
||||||
// Copy the source file into
|
|
||||||
// the compression stream.
|
|
||||||
inFile.CopyTo(Compress);
|
|
||||||
|
|
||||||
Console.WriteLine("Compressed {0} from {1} to {2} bytes.",
|
|
||||||
fi.Name, fi.Length.ToString(), outFile.Length.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
33
Source Code/TeamHobby.Main/MasterController.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
public class MasterController{
|
||||||
|
|
||||||
|
public static void main(string[] args){
|
||||||
|
|
||||||
|
//The main Controller of the program, It will run all services here
|
||||||
|
|
||||||
|
// While loop to run everything
|
||||||
|
|
||||||
|
// 1. Initialize the Data Factory here
|
||||||
|
|
||||||
|
// 2. Create the SqlConnection object
|
||||||
|
|
||||||
|
int userInput = 0;
|
||||||
|
|
||||||
|
while (userInput != -1) {
|
||||||
|
|
||||||
|
// Print the menu
|
||||||
|
|
||||||
|
//
|
||||||
|
if (userInput == 1){
|
||||||
|
// 1. User Managment goes here
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trigger Archiving automatically
|
||||||
|
// Create new ArchiveManager object
|
||||||
|
// if (currentDate == 1){
|
||||||
|
// ArchiveManager.Controller()
|
||||||
|
|
||||||
|
// Logging also automatic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,6 +9,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.Data.Odbc" Version="6.0.0" />
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
|
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
46
Source Code/TeamHobby.Main/rando
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
title Use Case: Archiving
|
||||||
|
|
||||||
|
participant ArchiveController.cs
|
||||||
|
participant DataConnection
|
||||||
|
participant DataSourceFactory
|
||||||
|
participant SQLSource
|
||||||
|
participant MariaDB
|
||||||
|
|
||||||
|
activate ArchiveController.cs
|
||||||
|
activate DataConnection
|
||||||
|
ArchiveController.cs ->DataConnection:static DataConnection getDataConnection()
|
||||||
|
DataConnection -->ArchiveController.cs:return DataConnection
|
||||||
|
deactivate DataConnection
|
||||||
|
|
||||||
|
activate DataSourceFactory
|
||||||
|
ArchiveController.cs ->DataSourceFactory: new DataSourceFactory()
|
||||||
|
DataSourceFactory ->DataSourceFactory:DataSourceFactory()\nconstructor
|
||||||
|
ArchiveController.cs <-- DataSourceFactory:return DataSourceFactory
|
||||||
|
deactivate DataSourceFactory
|
||||||
|
|
||||||
|
activate SQLSource
|
||||||
|
ArchiveController.cs->SQLSource: IDataSource DataSourceFact.GetDataSource(String sourceName, string info)
|
||||||
|
SQLSource->SQLSource: SQLSource(string info)\nconstructor
|
||||||
|
SQLSource --> ArchiveController.cs :return SQLSource
|
||||||
|
|
||||||
|
loop #lightblue while true
|
||||||
|
alt #lightgreen date == 1
|
||||||
|
ArchiveController.cs ->ArchiveController.cs: string fileName = string CreateFileName( )
|
||||||
|
ArchiveController.cs -> SQLSource: int Compress(string fileName)
|
||||||
|
activate MariaDB
|
||||||
|
|
||||||
|
SQLSource -> MariaDB: int createArchive(string fileLocation)
|
||||||
|
MariaDB -->SQLSource:return 0
|
||||||
|
|
||||||
|
SQLSource ->MariaDB: int RemoveEntries()
|
||||||
|
MariaDB-->SQLSource:return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
deactivate MariaDB
|
||||||
|
|
||||||
|
SQLSource-->ArchiveController.cs:return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
deactivate ArchiveController.cs
|
||||||
|
deactivate SQLSource
|
||||||
12
Source Code/TeamHobby.Main/text.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TeamHobby.Main
|
||||||
|
{
|
||||||
|
internal class text
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,69 @@
|
|||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using TeamHobby.HobbyProjectGenerator;
|
||||||
|
using TeamHobby.HobbyProjectGenerator.Implementations;
|
||||||
|
|
||||||
|
namespace TeamHobby.UserManagement.Tests
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class InMemeoryUserServiceShould
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void GetNoLogs()
|
||||||
|
{
|
||||||
|
// Triple A Format
|
||||||
|
// Arrange
|
||||||
|
var userService = new InMemoryUserService();
|
||||||
|
var expectedCount = 0;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var actualFetch = userService.GetAllUsers();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
// This is the best format
|
||||||
|
Assert.IsTrue(actualFetch.Count == expectedCount);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void AllowValidUserInput()
|
||||||
|
{
|
||||||
|
// Triple A Format
|
||||||
|
// Arrange
|
||||||
|
var userService = new InMemoryUserService();
|
||||||
|
var expectedCount = 1;
|
||||||
|
var expectedUserMessage = "Test log entry";
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var actual = userService.User("Test log entry");
|
||||||
|
var actualFetch = userService.GetAllUsers();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
// This is the best format
|
||||||
|
Assert.IsTrue(actualFetch.Count == expectedCount);
|
||||||
|
Assert.IsTrue(actualFetch[0].Contains(expectedUserMessage));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
[TestMethod]
|
||||||
|
public void Users()
|
||||||
|
{
|
||||||
|
// Triple A Format
|
||||||
|
// Arrange
|
||||||
|
var inMemoryUserService = new InMemoryUserService();
|
||||||
|
var expected = true;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var actual = inMemoryUserService.User("Potato");
|
||||||
|
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
// This is the best format
|
||||||
|
Assert.IsTrue(expected == actual);
|
||||||
|
// Alternate is
|
||||||
|
//Assert.AreEqual(expected, actual);
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||||
|
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
|
||||||
|
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
|
||||||
|
<PackageReference Include="coverlet.collector" Version="3.1.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator\TeamHobby.HobbyProjectGenerator.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
7
Source Code/TeamHobby/Class1.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace TeamHobby
|
||||||
|
{
|
||||||
|
public class Class1
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
9
Source Code/TeamHobby/TeamHobby.csproj
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
170
Source Code/main/Controller.cs
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
using main;
|
||||||
|
using System;
|
||||||
|
using System.Data.Odbc;
|
||||||
|
using TeamHobby.HobbyProjectGenerator.DataAccess;
|
||||||
|
|
||||||
|
|
||||||
|
namespace TeamHobby.HobbyProjectGenerator.Main
|
||||||
|
{
|
||||||
|
public class GetCredentials
|
||||||
|
{
|
||||||
|
public string? GetUserName()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Please enter a username:");
|
||||||
|
string? userName = Console.ReadLine();
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
public string? GetPassword()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Please enter a password:");
|
||||||
|
string? userPassword = Console.ReadLine();
|
||||||
|
return userPassword;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
//GetCredentials credentials = new GetCredentials();
|
||||||
|
//string? username = credentials.GetUserName();
|
||||||
|
//string? password = credentials.GetPassword();
|
||||||
|
|
||||||
|
|
||||||
|
//Console.WriteLine(value: $"username is {username}\npassword is {password}");
|
||||||
|
|
||||||
|
// Creating the Factory class
|
||||||
|
string dbType = "sql";
|
||||||
|
RelationalDataSourceFactory dbFactory = new RelationalDataSourceFactory();
|
||||||
|
|
||||||
|
// Testing Data Access Layer
|
||||||
|
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
|
||||||
|
"SERVER=localhost;" +
|
||||||
|
"DATABASE=hobby;" +
|
||||||
|
"UID=root;" +
|
||||||
|
"PASSWORD=Teamhobby;" +
|
||||||
|
"OPTION=3";
|
||||||
|
IDataSource<string> datasource = dbFactory.getDataSource(dbType,dbInfo);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
// Closing the connection
|
||||||
|
sqlDS.getConnection().Close();
|
||||||
|
|
||||||
|
// 2.Inserting Data into the database:
|
||||||
|
//string sqlWrite = "INSERT into log(lvname, catname, userop, logmessage) values " +
|
||||||
|
// "('Info', 'View', 'Testing DAL stuffs', 'new DAL method tested');";
|
||||||
|
|
||||||
|
//Console.WriteLine("Writing to the database... ");
|
||||||
|
//datasource.WriteData(sqlWrite);
|
||||||
|
//Console.WriteLine("Writing completed. ");
|
||||||
|
|
||||||
|
// 3. Removing from a database
|
||||||
|
//string sqlRemove = "DELETE from log where logID = 28;";
|
||||||
|
//Console.WriteLine("Writing to the database... ");
|
||||||
|
//datasource.WriteData(sqlRemove);
|
||||||
|
//Console.WriteLine("Writing completed. ");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ExampleDAO z = new ExampleDAO();
|
||||||
|
z.UserData("Tomato");
|
||||||
|
Console.Read();*/
|
||||||
|
/*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();
|
||||||
|
UserAccount user = new UserAccount();
|
||||||
|
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
};
|
||||||
|
}*/
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
51
Source Code/main/ExampleDAO.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
using Microsoft.Data.SqlClient;
|
||||||
|
|
||||||
|
namespace TeamHobby.HobbyProjectGenerator.Main
|
||||||
|
{
|
||||||
|
public class ExampleDAO
|
||||||
|
{
|
||||||
|
|
||||||
|
public void UserData(string username)
|
||||||
|
{
|
||||||
|
// Sql server connection string, needs to be changed accordingly to connect
|
||||||
|
var connString = "server=localhost,3316;user=root;database=users;password=Plop20"; // Using @" " makes the string literal
|
||||||
|
|
||||||
|
// 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))
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
// 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());
|
||||||
|
}
|
||||||
|
conn.Close();
|
||||||
|
|
||||||
|
}
|
||||||
|
// Console.Read();
|
||||||
|
/*
|
||||||
|
* this is meant for specific basic sql commands
|
||||||
|
using (var adapter = new SqlDataAdapter())
|
||||||
|
{
|
||||||
|
adapter.SelectCommand
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
//return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
134
Source Code/main/MainMenu.cs
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
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;
|
||||||
|
};
|
||||||
|
}*/
|
||||||
|
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
79
Source Code/main/SystemAccountManager.cs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace main
|
||||||
|
{
|
||||||
|
internal class SystemAccountManager
|
||||||
|
{
|
||||||
|
/*public NewUserName()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public NewPassword()
|
||||||
|
{
|
||||||
|
// 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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
//
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
32
Source Code/main/UiPrint.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
// Print Statements used throughout the program.
|
||||||
|
|
||||||
|
namespace main
|
||||||
|
{
|
||||||
|
internal 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 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
Source Code/main/UserAccount.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
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()
|
||||||
|
{
|
||||||
|
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
18
Source Code/main/main.csproj
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
BIN
doc/Business Docs/Testing_Library_Tech_Approval.pdf
Normal file
BIN
doc/LowLevel/ArchivingWithError.png
Normal file
|
After Width: | Height: | Size: 544 KiB |
1
doc/LowLevel/ArchivingWithError.svg
Normal file
|
After Width: | Height: | Size: 92 KiB |
146
doc/LowLevel/ArchivingWithError.txt
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
|
||||||
|
title Use Case: Archiving
|
||||||
|
|
||||||
|
participant Controller.cs #90EE90
|
||||||
|
participant RDSFactory #26abff
|
||||||
|
participant ArchiveManager #ffffe0
|
||||||
|
participant SqlDAO #D3D3D3
|
||||||
|
participant MariaDB #00FFFF
|
||||||
|
|
||||||
|
activate Controller.cs #90EE90
|
||||||
|
// Create a new factory
|
||||||
|
Controller.cs->RDSFactory:factory = new RDSFactory()
|
||||||
|
activate RDSFactory #26abff
|
||||||
|
RDSFactory->RDSFactory:Constructor()
|
||||||
|
Controller.cs<--RDSFactory:return RDSFactory
|
||||||
|
deactivate RDSFactory
|
||||||
|
Controller.cs->SqlDAO: ++IDataSource factory.GetDataSource(string name, string connInfo)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlDAO:++Constructor(string connInfo)++
|
||||||
|
Controller.cs<--SqlDAO: ++return SqlDAO++
|
||||||
|
|
||||||
|
|
||||||
|
alt #red
|
||||||
|
SqlDAO ->SqlDAO: Catch Exception
|
||||||
|
SqlDAO -->Controller.cs:return "DataSourceTimeOut"
|
||||||
|
end
|
||||||
|
deactivate SqlDAO
|
||||||
|
|
||||||
|
// Create Archive Manager
|
||||||
|
|
||||||
|
activate ArchiveManager #ffffe0
|
||||||
|
group #lightblue Connection to DataSource successful
|
||||||
|
Controller.cs ->ArchiveManager:new ArchiveManager(IDataSource conn)
|
||||||
|
ArchiveManager ->ArchiveManager: ArchiveManager(IDatasSource conn)
|
||||||
|
|
||||||
|
// Calling the main:
|
||||||
|
ArchiveManager -->Controller.cs: return ArchiveManager
|
||||||
|
loop #lightblue while true
|
||||||
|
alt #lightgreen The First Day of the month at 00:00:00 AM
|
||||||
|
Controller.cs ->ArchiveManager: bool ArchiveManager.Controller( )
|
||||||
|
|
||||||
|
// Keep looping
|
||||||
|
|
||||||
|
// Check if the directory exist or not
|
||||||
|
alt #lightgreen Archive folder does not exist already in the current directory
|
||||||
|
ArchiveManager -> ArchiveManager:bool CreateArchiveFolder(string path)
|
||||||
|
|
||||||
|
end
|
||||||
|
// Create the file name
|
||||||
|
ArchiveManager ->ArchiveManager:string filePath = string CreateOutFileName( )
|
||||||
|
ArchiveManager ->SqlDAO:bool Compress(string filePath)
|
||||||
|
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
activate MariaDB #00FFFF
|
||||||
|
SqlDAO ->MariaDB: bool CopyToArchive(string filePath)
|
||||||
|
// Sql Command to add data to the table
|
||||||
|
MariaDB ->MariaDB: SELECT 'LtimeStamp', 'logID', 'LvName', 'catName', 'userOP', 'logMessage' \nUNION ALL\nSELECT * FROM log\nWHERE DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30\nINTO OUTFILE @filePath\nFIELDS ENCLOSED BY ''\nTERMINATED BY ','\nESCAPED BY '"'\nLINES TERMINATED BY '\r\\n';
|
||||||
|
alt #lightgreen No error when doing executing copy SQL command
|
||||||
|
MariaDB --> SqlDAO: return True
|
||||||
|
SqlDAO -->ArchiveManager: return True
|
||||||
|
end
|
||||||
|
|
||||||
|
alt #red Error occur when executing copy SQL command on Database
|
||||||
|
MariaDB -->SqlDAO: throw SQLException
|
||||||
|
deactivate MariaDB
|
||||||
|
SqlDAO -->ArchiveManager: throw SqlException
|
||||||
|
deactivate SqlDAO
|
||||||
|
|
||||||
|
|
||||||
|
ArchiveManager ->ArchiveManager: Catch Exception
|
||||||
|
// Removing created files if the process failed
|
||||||
|
alt #red Log output text file exist
|
||||||
|
ArchiveManager ->ArchiveManager: File.Delete(string filePath)
|
||||||
|
end
|
||||||
|
alt #red Compressed file exist
|
||||||
|
ArchiveManager ->ArchiveManager: File.Delete(string comFilePath)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
// Compress the file
|
||||||
|
SqlDAO ->SqlDAO: bool CompressArchive(string filePath)
|
||||||
|
alt #lightgreen File Compression was successful
|
||||||
|
SqlDAO -->ArchiveManager: return True
|
||||||
|
end
|
||||||
|
alt #red File Compresssion failed
|
||||||
|
SqlDAO -->ArchiveManager: throw FileException
|
||||||
|
ArchiveManager ->ArchiveManager: Catch Exception
|
||||||
|
alt #red Log output text file exist
|
||||||
|
ArchiveManager ->ArchiveManager: File.Delete(filePath)
|
||||||
|
end
|
||||||
|
alt #red Compressed file exist
|
||||||
|
ArchiveManager ->ArchiveManager: File.Delete(string comFilePath)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
// Remove output file
|
||||||
|
SqlDAO ->SqlDAO:bool RemoveOutputFile(string filePath)
|
||||||
|
alt #lightgreen UncompressFile was removed successfully
|
||||||
|
SqlDAO -->ArchiveManager: return true
|
||||||
|
end
|
||||||
|
|
||||||
|
alt #red Uncompressfile failed to be removed
|
||||||
|
SqlDAO -->ArchiveManager: throw FileException
|
||||||
|
deactivate SqlDAO
|
||||||
|
ArchiveManager ->ArchiveManager: catch Exception
|
||||||
|
|
||||||
|
alt #red Log output text file exist
|
||||||
|
ArchiveManager ->ArchiveManager: File.Delete(string filePath)
|
||||||
|
end
|
||||||
|
alt #red Compressed file exist
|
||||||
|
ArchiveManager ->ArchiveManager: File.Delete(string comFilePath)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
activate MariaDB #00FFFF
|
||||||
|
SqlDAO ->MariaDB: bool RemoveEntries( )
|
||||||
|
MariaDB ->MariaDB: DELETE from log \nWHERE \nDATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30;
|
||||||
|
|
||||||
|
alt #lightgreen No error when doing executing remove old logs SQL command
|
||||||
|
MariaDB-->SqlDAO:return True
|
||||||
|
SqlDAO -->ArchiveManager: return True
|
||||||
|
end
|
||||||
|
|
||||||
|
alt #red Error occur when executing removing SQL command on Database
|
||||||
|
MariaDB -->SqlDAO: throw SQLException
|
||||||
|
deactivate MariaDB
|
||||||
|
SqlDAO-->ArchiveManager: throw SQLException
|
||||||
|
deactivate SqlDAO
|
||||||
|
ArchiveManager ->ArchiveManager:Catch Exception
|
||||||
|
alt #red Log output text file exist
|
||||||
|
ArchiveManager ->ArchiveManager: File.Delete(string filePath)
|
||||||
|
end
|
||||||
|
alt #red Compressed file exist
|
||||||
|
ArchiveManager ->ArchiveManager: File.Delete(string comFilePath)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
ArchiveManager --> Controller.cs:return True
|
||||||
|
deactivate ArchiveManager
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
BIN
doc/LowLevel/ArchivingWithSingleton.pdf
Normal file
99
doc/LowLevel/ArchvingMasterCon.txt
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
|
||||||
|
title Use Case: Archiving
|
||||||
|
|
||||||
|
participant Controller.cs #90EE90
|
||||||
|
participant RDSFactory #26abff
|
||||||
|
participant ArchiveManager #ffffe0
|
||||||
|
participant SqlDAO #D3D3D3
|
||||||
|
participant MariaDB
|
||||||
|
|
||||||
|
activate Controller.cs
|
||||||
|
// Create a new factory
|
||||||
|
Controller.cs->RDSFactory:factory = new RDSFactory()
|
||||||
|
activate RDSFactory #26abff
|
||||||
|
RDSFactory->RDSFactory:Constructor()
|
||||||
|
Controller.cs<--RDSFactory:return RDSFactory
|
||||||
|
deactivate RDSFactory
|
||||||
|
Controller.cs->SqlDAO: ++IDataSource factory.GetDataSource(string name, string connInfo)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlDAO:++Constructor(string connInfo)++
|
||||||
|
Controller.cs<--SqlDAO: ++return SqlDAO++
|
||||||
|
deactivate SqlDAO
|
||||||
|
|
||||||
|
// Create Archive Manager
|
||||||
|
activate ArchiveManager
|
||||||
|
Controller.cs ->ArchiveManager:new ArchiveManager(IDataSource conn)
|
||||||
|
ArchiveManager ->ArchiveManager: ArchiveManager(IDatasSource conn)
|
||||||
|
|
||||||
|
// Calling the main:
|
||||||
|
ArchiveManager -->Controller.cs: return ArchiveManager
|
||||||
|
Controller.cs ->ArchiveManager: bool ArchiveManager.Controller( )
|
||||||
|
|
||||||
|
// Keep looping
|
||||||
|
|
||||||
|
loop #lightblue while true
|
||||||
|
alt #lightgreen The First Day of the month at 00:00:00 AM
|
||||||
|
// Check if the directory exist or not
|
||||||
|
alt #lightgreen Archive folder does not exist already in the current directory
|
||||||
|
ArchiveManager -> ArchiveManager:int CreateArchiveFolder(string path)
|
||||||
|
|
||||||
|
end
|
||||||
|
// Create the file name
|
||||||
|
ArchiveManager ->ArchiveManager: string filePath = string CreateFileName( )
|
||||||
|
ArchiveManager ->SqlDAO:bool Compress(string filePath)
|
||||||
|
|
||||||
|
activate SqlDAO
|
||||||
|
activate MariaDB
|
||||||
|
SqlDAO ->MariaDB: bool CopyToArchive(string filePath)
|
||||||
|
alt #red No error when doing executing copy SQL command
|
||||||
|
MariaDB --> SqlDAO: return True
|
||||||
|
|
||||||
|
else #red Error occur when executing copy SQL command on Database
|
||||||
|
MariaDB -->SqlDAO: throw SQLException
|
||||||
|
deactivate MariaDB
|
||||||
|
SqlDAO -->ArchiveManager: throw SqlException
|
||||||
|
deactivate SqlDAO
|
||||||
|
|
||||||
|
ArchiveManager ->ArchiveManager: Catch SqlException
|
||||||
|
end
|
||||||
|
|
||||||
|
activate SqlDAO
|
||||||
|
// Compress the file
|
||||||
|
SqlDAO ->SqlDAO: bool CompressArchive(string filePath)
|
||||||
|
// Remove output file
|
||||||
|
SqlDAO ->SqlDAO:bool RemoveOutputFile(string filePath)
|
||||||
|
alt #red File was created succesffuly
|
||||||
|
SqlDAO -->SqlDAO: new file
|
||||||
|
else File Exception
|
||||||
|
SqlDAO ->SqlDAO: Catch FileException
|
||||||
|
SqlDAO -->ArchiveManager: throw FileException
|
||||||
|
deactivate SqlDAO
|
||||||
|
ArchiveManager ->ArchiveManager: catch FileException
|
||||||
|
end
|
||||||
|
|
||||||
|
activate SqlDAO
|
||||||
|
|
||||||
|
SqlDAO ->MariaDB: bool RemoveEntries( )
|
||||||
|
activate MariaDB
|
||||||
|
alt #red No error when doing executing remove old logs SQL command
|
||||||
|
MariaDB-->SqlDAO:return True
|
||||||
|
|
||||||
|
|
||||||
|
else Error occur when executing removing SQL command on Database
|
||||||
|
MariaDB -->SqlDAO: throw SQLException
|
||||||
|
deactivate MariaDB
|
||||||
|
SqlDAO-->ArchiveManager: throw SQLException
|
||||||
|
deactivate SqlDAO
|
||||||
|
ArchiveManager ->ArchiveManager:Catch SqlException
|
||||||
|
end
|
||||||
|
activate SqlDAO
|
||||||
|
SqlDAO-->ArchiveManager:return True
|
||||||
|
deactivate SqlDAO
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
deactivate MariaDB
|
||||||
|
|
||||||
|
end
|
||||||
|
deactivate ArchiveManager
|
||||||
|
deactivate SqlDAO
|
||||||
BIN
doc/LowLevel/UMLforArchving.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
doc/LowLevel/UserManagement/UserManagementCreateAccount.png
Normal file
|
After Width: | Height: | Size: 474 KiB |
172
doc/LowLevel/UserManagement/UserManagementCreateAccount.txt
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
title Create User Record
|
||||||
|
actor User
|
||||||
|
participant Controller.cs #90EE90
|
||||||
|
participant RDSFactory #26abff
|
||||||
|
participant UserAccount #CBC3E3
|
||||||
|
participant SystemAccountManager #ffffe0
|
||||||
|
participant AccountService #ff8b3d
|
||||||
|
participant SqlDAO #D3D3D3
|
||||||
|
//SqlDAO
|
||||||
|
database SqlServer(MariaDB) #00FFFF
|
||||||
|
|
||||||
|
//activate User
|
||||||
|
activate Controller.cs #90EE90
|
||||||
|
User->Controller.cs: ++Create new User++
|
||||||
|
|
||||||
|
//RelatDSFactory
|
||||||
|
Controller.cs->RDSFactory:++factory = new RDSFactory()++
|
||||||
|
activate RDSFactory #26abff
|
||||||
|
RDSFactory->RDSFactory:++Constructor()++
|
||||||
|
Controller.cs<--RDSFactory:++return RDSFactory++
|
||||||
|
deactivate RDSFactory
|
||||||
|
Controller.cs->SqlDAO:++IDataSource factory.GetDataSource(string DbName, string connInfo)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlDAO:++Constructor(string connInfo)++
|
||||||
|
group #red Data Store Timed Out #white
|
||||||
|
SqlDAO->SqlDAO: ++Catch SqlException++
|
||||||
|
Controller.cs<--SqlDAO:++return "Data Source Timed Out"++
|
||||||
|
end
|
||||||
|
group #blue Data Store Online #white
|
||||||
|
Controller.cs<--SqlDAO: ++return SqlDAO++
|
||||||
|
deactivate SqlDAO
|
||||||
|
|
||||||
|
|
||||||
|
// Create new Admin
|
||||||
|
Controller.cs->SystemAccountManager:++ manager = new SystemAccountManager(IDataSource conn)++
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
SystemAccountManager->SystemAccountManager:++Constructor(IDataSource conn)++
|
||||||
|
Controller.cs<--SystemAccountManager:++ New SystemAccountManager++
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
|
||||||
|
// GetUserName
|
||||||
|
Controller.cs->Controller.cs:++string GetUserName()++
|
||||||
|
|
||||||
|
// GetPassword
|
||||||
|
Controller.cs->Controller.cs:++string GetPassword()++
|
||||||
|
//
|
||||||
|
Controller.cs->UserAccount:++ new UserAccount(string username,\n string password,\n DateTime TimeStamp)++
|
||||||
|
activate UserAccount #CBC3E3
|
||||||
|
UserAccount->UserAccount:++Constructor(string username,\n string password,\n DateTime TimeStamp)++
|
||||||
|
Controller.cs<--UserAccount:++New UserAccount++
|
||||||
|
deactivate UserAccount
|
||||||
|
//
|
||||||
|
Controller.cs->SystemAccountManager:++manager.CreateUserRecord(user:UserAccount)++
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
SystemAccountManager->SystemAccountManager:++isInputValid(user: UserAccount)++
|
||||||
|
|
||||||
|
group #red Invalid Information #white
|
||||||
|
Controller.cs<--SystemAccountManager:++return "Invalid input"++
|
||||||
|
User<--Controller.cs:++ return "Invalid input"++
|
||||||
|
end
|
||||||
|
group #green Information Valid #white
|
||||||
|
|
||||||
|
//check if there is an admin user
|
||||||
|
SystemAccountManager->SqlDAO:++bool isAdmin(user:UserAccount)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlServer(MariaDB):++SqlRead confirmAdmin()++
|
||||||
|
activate SqlServer(MariaDB)#00FFFF
|
||||||
|
//authorized
|
||||||
|
SqlServer(MariaDB)->SqlServer(MariaDB):++Select * from Admins\n where Username = @UserName \nand Password = @Pwd++
|
||||||
|
//Unauthorized role section
|
||||||
|
group #red Unauthorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++SqlException++
|
||||||
|
SqlDAO->SqlDAO: ++Catch\nSqlException++
|
||||||
|
SystemAccountManager<--SqlDAO:++return false++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Access Denied: \nUnauthorized"++
|
||||||
|
User<--Controller.cs:++return "Access Denied: \nUnauthorized"++
|
||||||
|
end
|
||||||
|
//Unauthorized role section
|
||||||
|
group #red Unauthorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++return false++
|
||||||
|
SystemAccountManager<--SqlDAO:++return false++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Access Denied: \nUnauthorized"++
|
||||||
|
User<--Controller.cs:++return "Access Denied: \nUnauthorized"++
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
//Authorized role section
|
||||||
|
group #blue Authorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++return true++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
SystemAccountManager<--SqlDAO:++return true++
|
||||||
|
deactivate SqlDAO
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
|
||||||
|
group #green Valid Information #white
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
// GetUserName
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewUserName()++
|
||||||
|
// Enter UserName
|
||||||
|
User->SystemAccountManager:++string NewUserName++
|
||||||
|
// GetPassword
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewPassword()++
|
||||||
|
// Enter Password
|
||||||
|
User->SystemAccountManager:++string NewPassword++
|
||||||
|
// GetEmail
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewEmail()++
|
||||||
|
// Enter Email
|
||||||
|
User->SystemAccountManager:++string NewEmail++
|
||||||
|
// GetRole
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewRole()++
|
||||||
|
// Enter Role
|
||||||
|
User->SystemAccountManager:++string NewRole++
|
||||||
|
// Create NewUser object
|
||||||
|
UserAccount<-SystemAccountManager:++new NewUser(\nstring NewUserName,\nstring NewPassword,\nstring New Email,\nDateTime TimeStamp)++
|
||||||
|
activate UserAccount #CBC3E3
|
||||||
|
UserAccount->UserAccount:++Constructor(string NewUserName,\nstring NewPassword,\nstring New Email,\nDateTime TimeStamp)++
|
||||||
|
UserAccount-->SystemAccountManager:++return NewUser++
|
||||||
|
deactivate UserAccount
|
||||||
|
//Create User Record
|
||||||
|
SystemAccountManager->AccountService:++AccountService\n.CreateUserRecord(user:NewUser)++
|
||||||
|
activate AccountService #ff8b3d
|
||||||
|
AccountService->SqlDAO:++SqlDAO\n.CreateUserRecord(user:NewUser)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlServer(MariaDB):++SqlRead \nisUser(user:NewUser)++
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlServer(MariaDB)->SqlServer(MariaDB):++ Select *\nFrom Users\nwhere Username\n= @UserName OR\nemail = @Email++
|
||||||
|
group #red data store timed out #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++SqlException++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
SqlDAO->SqlDAO: ++Catch\nSqlException++
|
||||||
|
AccountService<--SqlDAO:++return "Database timed out"++
|
||||||
|
|
||||||
|
SystemAccountManager<--AccountService:++ return "Database timed out"++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Database timed out"++
|
||||||
|
User<--Controller.cs:++ return "Database timed out"++
|
||||||
|
end
|
||||||
|
group #blue data store is online #white
|
||||||
|
// User exists
|
||||||
|
group #green User does exist #white
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return True++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
AccountService<--SqlDAO:++return "User is already registered"++
|
||||||
|
SystemAccountManager<--AccountService:++return "User is already registered"++
|
||||||
|
Controller.cs<--SystemAccountManager:++return "User is already registered"++
|
||||||
|
User<--Controller.cs:++ return \n"User is already registered"++
|
||||||
|
|
||||||
|
end
|
||||||
|
// User doesn't exist
|
||||||
|
group #green User does not exist #white
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return False++
|
||||||
|
SqlDAO->SqlServer(MariaDB):++ SQL insert\nuser credentials++
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return 1++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
AccountService<--SqlDAO:++return "User is now registered"++
|
||||||
|
deactivate SqlDAO
|
||||||
|
SystemAccountManager<--AccountService:++return "User is now registered"++
|
||||||
|
deactivate AccountService
|
||||||
|
Controller.cs<--SystemAccountManager:++return "User is now registered"++
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
User<--Controller.cs:++ return \n"User is now registered"++
|
||||||
|
|
||||||
|
deactivate Controller.cs
|
||||||
|
end
|
||||||
|
//deactivate User
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
BIN
doc/LowLevel/UserManagement/UserManagementDeleteUser.png
Normal file
|
After Width: | Height: | Size: 477 KiB |
161
doc/LowLevel/UserManagement/UserManagementDeleteUser.txt
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
title Delete User Record
|
||||||
|
actor User
|
||||||
|
participant Controller.cs #90EE90
|
||||||
|
participant RDSFactory #26abff
|
||||||
|
participant UserAccount #CBC3E3
|
||||||
|
participant SystemAccountManager #ffffe0
|
||||||
|
participant AccountService #ff8b3d
|
||||||
|
participant SqlDAO #D3D3D3
|
||||||
|
//SqlDAO
|
||||||
|
database SqlServer(MariaDB) #00FFFF
|
||||||
|
|
||||||
|
//activate User
|
||||||
|
activate Controller.cs #90EE90
|
||||||
|
User->Controller.cs: ++Request to delete user++
|
||||||
|
|
||||||
|
//RelatDSFactory
|
||||||
|
Controller.cs->RDSFactory:++factory = new RDSFactory()++
|
||||||
|
activate RDSFactory #26abff
|
||||||
|
RDSFactory->RDSFactory:++Constructor()++
|
||||||
|
Controller.cs<--RDSFactory:++return RDSFactory++
|
||||||
|
deactivate RDSFactory
|
||||||
|
Controller.cs->SqlDAO:++IDataSource factory.GetDataSource(string DbName, string connInfo)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlDAO:++Constructor(string connInfo)++
|
||||||
|
group #red Data Store Timed Out #white
|
||||||
|
SqlDAO->SqlDAO: ++Catch SqlException++
|
||||||
|
Controller.cs<--SqlDAO:++return "Data Source Timed Out"++
|
||||||
|
end
|
||||||
|
group #blue Data Store Online #white
|
||||||
|
Controller.cs<--SqlDAO: ++return SqlDAO++
|
||||||
|
deactivate SqlDAO
|
||||||
|
|
||||||
|
// Create new Admin
|
||||||
|
Controller.cs->SystemAccountManager:++ manager = new SystemAccountManager(IDataSource conn)++
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
SystemAccountManager->SystemAccountManager:++Constructor(IDataSource conn)++
|
||||||
|
Controller.cs<--SystemAccountManager:++ New SystemAccountManager++
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
|
||||||
|
// GetUserName
|
||||||
|
Controller.cs->Controller.cs:++string GetUserName()++
|
||||||
|
|
||||||
|
// GetPassword
|
||||||
|
Controller.cs->Controller.cs:++string GetPassword()++
|
||||||
|
|
||||||
|
//
|
||||||
|
Controller.cs->UserAccount:++ new UserAccount(string username,\n string password\n DateTime RegistrationTimeStamp)++
|
||||||
|
activate UserAccount #CBC3E3
|
||||||
|
UserAccount->UserAccount: ++Constructor(string username,\n string password,\n DateTime RegistrationTimeStamp)++
|
||||||
|
Controller.cs<--UserAccount:++New UserAccount++
|
||||||
|
deactivate UserAccount
|
||||||
|
Controller.cs->SystemAccountManager: ++manager.DeleteUserRecord(user:UserAccount)++
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
SystemAccountManager->SystemAccountManager:++isInputValid(user: UserAccount)++
|
||||||
|
group #red Invalid Information #white
|
||||||
|
Controller.cs<--SystemAccountManager:++return "Invalid input"++
|
||||||
|
User<--Controller.cs:++ return "Invalid input"++
|
||||||
|
end
|
||||||
|
|
||||||
|
//
|
||||||
|
group #green Information Valid #white
|
||||||
|
//check if there is an admin user
|
||||||
|
SystemAccountManager->SqlDAO:++isAdmin(user:UserAccount)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlServer(MariaDB):++SqlRead confirmAdmin()++
|
||||||
|
activate SqlServer(MariaDB)#00FFFF
|
||||||
|
SqlServer(MariaDB)->SqlServer(MariaDB):++Select * from Admins\n where Username = @UserName \nand Password = @Pwd++
|
||||||
|
//Unauthorized role section
|
||||||
|
group #red Unauthorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++SqlException++
|
||||||
|
SqlDAO->SqlDAO: ++Catch\nSqlException++
|
||||||
|
SystemAccountManager<--SqlDAO:++return false++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Access Denied: \nUnauthorized"++
|
||||||
|
User<--Controller.cs:++return "Access Denied: \nUnauthorized"++
|
||||||
|
end
|
||||||
|
//Unauthorized role section
|
||||||
|
group #red Unauthorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++return false++
|
||||||
|
SystemAccountManager<--SqlDAO:++return false++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Access Denied: \nUnauthorized"++
|
||||||
|
User<--Controller.cs:++return "Access Denied: \nUnauthorized"++
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
//Authorized role section
|
||||||
|
group #blue Authorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++return true++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
SystemAccountManager<--SqlDAO:++return true++
|
||||||
|
deactivate SqlDAO
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
group #green Valid Information #white
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
// GetUserName
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewUserName()++
|
||||||
|
// Enter UserName
|
||||||
|
User->SystemAccountManager:++string NewUserName++
|
||||||
|
// GetPassword
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewPassword()++
|
||||||
|
// Enter Password
|
||||||
|
User->SystemAccountManager:++string NewPassword++
|
||||||
|
// GetRole
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewRole()++
|
||||||
|
// Enter Role
|
||||||
|
User->SystemAccountManager:++string NewRole++
|
||||||
|
// Create NewUser object
|
||||||
|
UserAccount<-SystemAccountManager:++new NewUser(\nstring NewUserName,\nstring NewPassword,\nstring role,\nDateTime TimeStamp)++
|
||||||
|
activate UserAccount #CBC3E3
|
||||||
|
UserAccount->UserAccount:++Constructor(\nstring NewUserName,\nstring NewPassword,\nstring role,\nDateTime TimeStamp)++
|
||||||
|
UserAccount-->SystemAccountManager:++return NewUser++
|
||||||
|
deactivate UserAccount
|
||||||
|
SystemAccountManager->AccountService:++AccountService\n.DeleteUserRecord(user:NewUser,\nUpdateType: userDelete)++
|
||||||
|
activate AccountService #ff8b3d
|
||||||
|
AccountService->SqlDAO:++SqlDAO\n.DeleteUserRecord(user:NewUser,\nUpdateType: userDelete)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlServer(MariaDB):++isUser(user:NewUser)++
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlServer(MariaDB)->SqlServer(MariaDB):++ Select *\nFrom Users\nwhere Username\n= @UserName OR\nemail = @Email++
|
||||||
|
group #red data store timed out #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++SqlException++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
SqlDAO->SqlDAO: ++Catch\nSqlException++
|
||||||
|
AccountService<--SqlDAO:++return "Database timed out"++
|
||||||
|
|
||||||
|
SystemAccountManager<--AccountService:++ return "Database timed out"++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Database timed out"++
|
||||||
|
User<--Controller.cs:++ return "Database timed out"++
|
||||||
|
end
|
||||||
|
group #blue data store is online #white
|
||||||
|
// User exists
|
||||||
|
group #green User does exist #white
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return True++
|
||||||
|
SqlDAO->SqlServer(MariaDB):++Delete from users\nwhere Username = @UserName \nand Password = @PWD++
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return 1++
|
||||||
|
AccountService<--SqlDAO:++return "User deleted successfully"++
|
||||||
|
SystemAccountManager<--AccountService:++return "User deleted successfully"++
|
||||||
|
Controller.cs<--SystemAccountManager:++return "User deleted successfully"++
|
||||||
|
User<--Controller.cs:++ return \n"User deleted successfully"++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
end
|
||||||
|
// User doesn't exist
|
||||||
|
group #red User does not exist #white
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return False++
|
||||||
|
AccountService<--SqlDAO:++return "User does not exist"++
|
||||||
|
SystemAccountManager<--AccountService:++return "User does not exist"++
|
||||||
|
Controller.cs<--SystemAccountManager:++return "User does not exist"++
|
||||||
|
User<--Controller.cs:++ return \n"User does not exist"++
|
||||||
|
deactivate AccountService
|
||||||
|
deactivate SqlDAO
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
deactivate Controller.cs
|
||||||
|
end
|
||||||
|
//deactivate User
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
BIN
doc/LowLevel/UserManagement/UserManagementDisableUser.png
Normal file
|
After Width: | Height: | Size: 462 KiB |
160
doc/LowLevel/UserManagement/UserManagementDisableUser.txt
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
title Disable Specfied User
|
||||||
|
actor User
|
||||||
|
participant Controller.cs #90EE90
|
||||||
|
participant RDSFactory #26abff
|
||||||
|
participant UserAccount #CBC3E3
|
||||||
|
participant SystemAccountManager #ffffe0
|
||||||
|
participant AccountService #ff8b3d
|
||||||
|
participant SqlDAO #D3D3D3
|
||||||
|
//SqlDAO
|
||||||
|
database SqlServer(MariaDB) #00FFFF
|
||||||
|
|
||||||
|
//activate User
|
||||||
|
activate Controller.cs #90EE90
|
||||||
|
User->Controller.cs: ++Request to disable user\n by a different user++
|
||||||
|
|
||||||
|
//RelatDSFactory
|
||||||
|
Controller.cs->RDSFactory:++factory = new RDSFactory()++
|
||||||
|
activate RDSFactory #26abff
|
||||||
|
RDSFactory->RDSFactory:++Constructor()++
|
||||||
|
Controller.cs<--RDSFactory:++return RDSFactory++
|
||||||
|
deactivate RDSFactory
|
||||||
|
Controller.cs->SqlDAO:++IDataSource factory.GetDataSource(string DbName, string connInfo)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlDAO:++Constructor(string connInfo)++
|
||||||
|
group #red Data Store Timed Out #white
|
||||||
|
SqlDAO->SqlDAO: ++Catch SqlException++
|
||||||
|
Controller.cs<--SqlDAO:++return "Data Source Timed Out"++
|
||||||
|
end
|
||||||
|
group #blue Data Store Online #white
|
||||||
|
Controller.cs<--SqlDAO: ++return SqlDAO++
|
||||||
|
deactivate SqlDAO
|
||||||
|
|
||||||
|
// Create new Admin
|
||||||
|
Controller.cs->SystemAccountManager:++ manager = new SystemAccountManager(IDataSource conn)++
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
SystemAccountManager->SystemAccountManager:++Constructor(IDataSource conn)++
|
||||||
|
Controller.cs<--SystemAccountManager:++ New SystemAccountManager++
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
|
||||||
|
// GetUserName
|
||||||
|
Controller.cs->Controller.cs:++string GetUserName()++
|
||||||
|
|
||||||
|
// GetPassword
|
||||||
|
Controller.cs->Controller.cs:++string GetPassword()++
|
||||||
|
|
||||||
|
// Pass object
|
||||||
|
Controller.cs->UserAccount:++ new UserAccount(string username,\n string password\n DateTime RegistrationTimeStamp)++
|
||||||
|
activate UserAccount #CBC3E3
|
||||||
|
UserAccount->UserAccount: ++Constructor(string username,\n string password,\n DateTime RegistrationTimeStamp)++
|
||||||
|
Controller.cs<--UserAccount:++New UserAccount++
|
||||||
|
deactivate UserAccount
|
||||||
|
Controller.cs->SystemAccountManager: ++manager.DisableUserRecord(user:UserAccount)++
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
SystemAccountManager->SystemAccountManager:++isInputValid(user: UserAccount)++
|
||||||
|
group #red Invalid Information #white
|
||||||
|
Controller.cs<--SystemAccountManager:++return "Invalid input"++
|
||||||
|
User<--Controller.cs:++ return "Invalid input"++
|
||||||
|
end
|
||||||
|
group #green Information Valid #white
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//check if there is an admin user
|
||||||
|
|
||||||
|
SystemAccountManager->SqlDAO:++isAdmin(user:UserAccount)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlServer(MariaDB):++SqlRead confirmAdmin()++
|
||||||
|
activate SqlServer(MariaDB)#00FFFF
|
||||||
|
SqlServer(MariaDB)->SqlServer(MariaDB):++Select * from Admins\n where Username = @UserName \nand Password = @Pwd++
|
||||||
|
//Unauthorized role section
|
||||||
|
group #red Unauthorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++SqlException++
|
||||||
|
SqlDAO->SqlDAO: ++Catch\nSqlException++
|
||||||
|
SystemAccountManager<--SqlDAO:++return false++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Access Denied: \nUnauthorized"++
|
||||||
|
User<--Controller.cs:++return "Access Denied: \nUnauthorized"++
|
||||||
|
//Unauthorized role section
|
||||||
|
end
|
||||||
|
group #red Unauthorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++return false++
|
||||||
|
SystemAccountManager<--SqlDAO:++return false++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Access Denied: \nUnauthorized"++
|
||||||
|
User<--Controller.cs:++return "Access Denied: \nUnauthorized"++
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
//Authorized role section
|
||||||
|
group #blue Authorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++return true++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
SystemAccountManager<--SqlDAO:++return true++
|
||||||
|
deactivate SqlDAO
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
|
||||||
|
group #green Valid Information #white
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
// GetUserName
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewUserName()++
|
||||||
|
// Enter UserName
|
||||||
|
User->SystemAccountManager:++string NewUserName++
|
||||||
|
// GetRole
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewRole()++
|
||||||
|
// Enter Role
|
||||||
|
User->SystemAccountManager:++string NewRole++
|
||||||
|
// Create NewUser object
|
||||||
|
UserAccount<-SystemAccountManager:++new NewUser(\nstring NewUserName,\nstring role,\nDateTime TimeStamp)++
|
||||||
|
activate UserAccount #CBC3E3
|
||||||
|
UserAccount->UserAccount:++Constructor(\nstring NewUserName,\nstring role,\nDateTime TimeStamp)++
|
||||||
|
UserAccount-->SystemAccountManager:++return NewUser++
|
||||||
|
deactivate UserAccount
|
||||||
|
SystemAccountManager->AccountService:++AccountService\n.DisableUserRecord(user:NewUser,\nUpdateType:userDisable)++
|
||||||
|
activate AccountService #ff8b3d
|
||||||
|
AccountService->SqlDAO:++SqlDAO\n.DisableUser(user:NewUser,\nUpdateType:userDisable)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlServer(MariaDB):++isUser(user:NewUser)++
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlServer(MariaDB)->SqlServer(MariaDB):++ Select *\nFrom Users\nwhere Username\n= @UserName and\nRole = @UserRole\n
|
||||||
|
group #red data store timed out #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++SqlException++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
SqlDAO->SqlDAO: ++Catch\nSqlException++
|
||||||
|
AccountService<--SqlDAO:++return "Database timed out"++
|
||||||
|
|
||||||
|
SystemAccountManager<--AccountService:++ return "Database timed out"++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Database timed out"++
|
||||||
|
User<--Controller.cs:++ return "Database timed out"++
|
||||||
|
end
|
||||||
|
group #blue data store is online #white
|
||||||
|
// User exists
|
||||||
|
group #green User does exist #white
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return True++
|
||||||
|
SqlDAO->SqlServer(MariaDB):++Update users Set isActive = 0\nwhere UserName = @UserName++
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return 1++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
AccountService<--SqlDAO:++return "User is now disabled"++
|
||||||
|
SystemAccountManager<--AccountService:++return "User is now disabled"++
|
||||||
|
Controller.cs<--SystemAccountManager:++return "User is now disabled"++
|
||||||
|
User<--Controller.cs:++ return \n"User is now disabled"++
|
||||||
|
end
|
||||||
|
// User doesn't exist
|
||||||
|
group #red User does not exist #white
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return False++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
AccountService<--SqlDAO:++return "User does not exist"++
|
||||||
|
deactivate SqlDAO
|
||||||
|
SystemAccountManager<--AccountService:++return "User does not exist"++
|
||||||
|
deactivate AccountService
|
||||||
|
Controller.cs<--SystemAccountManager:++return "User does not exist"++
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
User<--Controller.cs:++ return \n"User does not exist"++
|
||||||
|
deactivate Controller.cs
|
||||||
|
end
|
||||||
|
//deactivate User
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
BIN
doc/LowLevel/UserManagement/UserManagementEditUserRecords.png
Normal file
|
After Width: | Height: | Size: 441 KiB |
170
doc/LowLevel/UserManagement/UserManagementEditUserRecords.txt
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
title Edit User Record
|
||||||
|
actor User
|
||||||
|
participant Controller.cs #90EE90
|
||||||
|
participant RDSFactory #26abff
|
||||||
|
participant UserAccount #CBC3E3
|
||||||
|
participant SystemAccountManager #ffffe0
|
||||||
|
participant AccountService #ff8b3d
|
||||||
|
participant SqlDAO #D3D3D3
|
||||||
|
//SqlDAO
|
||||||
|
database SqlServer(MariaDB) #00FFFF
|
||||||
|
|
||||||
|
//activate User
|
||||||
|
activate Controller.cs #90EE90
|
||||||
|
User->Controller.cs: ++Request to edit user\nby a different user++
|
||||||
|
|
||||||
|
//RelatDSFactory
|
||||||
|
Controller.cs->RDSFactory:++factory = new RDSFactory()++
|
||||||
|
activate RDSFactory #26abff
|
||||||
|
RDSFactory->RDSFactory:++Constructor()++
|
||||||
|
Controller.cs<--RDSFactory:++return RDSFactory++
|
||||||
|
deactivate RDSFactory
|
||||||
|
Controller.cs->SqlDAO:++IDataSource factory.GetDataSource(string DbName, string connInfo)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlDAO:++Constructor(string connInfo)++
|
||||||
|
group #red Data Store Timed Out #white
|
||||||
|
SqlDAO->SqlDAO: ++Catch Exception++
|
||||||
|
Controller.cs<--SqlDAO:++return "Data Source Timed Out"++
|
||||||
|
end
|
||||||
|
group #blue Data Store Online #white
|
||||||
|
Controller.cs<--SqlDAO: ++return SqlDAO++
|
||||||
|
deactivate SqlDAO
|
||||||
|
|
||||||
|
// Create new Admin
|
||||||
|
Controller.cs->SystemAccountManager:++ manager = new SystemAccountManager(IDataSource conn)++
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
SystemAccountManager->SystemAccountManager:++Constructor(IDataSource conn)++
|
||||||
|
Controller.cs<--SystemAccountManager:++ New SystemAccountManager++
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
|
||||||
|
// GetUserName
|
||||||
|
Controller.cs->Controller.cs:++string GetUserName()++
|
||||||
|
|
||||||
|
// GetPassword
|
||||||
|
Controller.cs->Controller.cs:++string GetPassword()++
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
Controller.cs->UserAccount:++ new UserAccount(string username,\n string password,\n DateTime RegistrationTimeStamp)++
|
||||||
|
activate UserAccount #CBC3E3
|
||||||
|
UserAccount->UserAccount: ++string username,\n string password,\n DateTime RegistrationTimeStamp++
|
||||||
|
Controller.cs<--UserAccount:++New UserAccount++
|
||||||
|
deactivate UserAccount
|
||||||
|
Controller.cs->SystemAccountManager:++manager.UpdateUserRecord(user:UserAccount)++
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
SystemAccountManager->SystemAccountManager:++isInputValid(user: UserAccount)++
|
||||||
|
group #red Invalid Information #white
|
||||||
|
Controller.cs<--SystemAccountManager:++return "Invalid input"++
|
||||||
|
User<--Controller.cs:++ return "Invalid input"++
|
||||||
|
end
|
||||||
|
group #green Information Valid #white
|
||||||
|
|
||||||
|
//look over
|
||||||
|
|
||||||
|
//check if there is an admin user
|
||||||
|
SystemAccountManager->SqlDAO:++bool isAdmin(user:UserAccount)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlServer(MariaDB):++SqlRead confirmAdmin()++
|
||||||
|
activate SqlServer(MariaDB)#00FFFF
|
||||||
|
//authorized
|
||||||
|
SqlServer(MariaDB)->SqlServer(MariaDB):++Select * from Admins\n where Username = @UserName \nand Password = @Pwd++
|
||||||
|
//Unauthorized role section
|
||||||
|
group #red Unauthorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++SqlException++
|
||||||
|
SqlDAO->SqlDAO: ++Catch\nSqlException++
|
||||||
|
SystemAccountManager<--SqlDAO:++return false++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Access Denied: \nUnauthorized"++
|
||||||
|
User<--Controller.cs:++return "Access Denied: \nUnauthorized"++
|
||||||
|
end
|
||||||
|
//Unauthorized role section
|
||||||
|
group #red Unauthorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++return false++
|
||||||
|
SystemAccountManager<--SqlDAO:++return false++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Access Denied: \nUnauthorized"++
|
||||||
|
User<--Controller.cs:++return "Access Denied: \nUnauthorized"++
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
//Authorized role section
|
||||||
|
group #blue Authorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++return true++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
SystemAccountManager<--SqlDAO:++return true++
|
||||||
|
deactivate SqlDAO
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
group #green Valid Information #white
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
// GetUserName
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewUserName()++
|
||||||
|
// Enter UserName
|
||||||
|
User->SystemAccountManager:++string NewUserName++
|
||||||
|
// GetPassword
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewPassword()++
|
||||||
|
// Enter Password
|
||||||
|
User->SystemAccountManager:++string NewPassword++
|
||||||
|
// GetEmail
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewEmail()++
|
||||||
|
// Enter Email
|
||||||
|
User->SystemAccountManager:++string NewEmail++
|
||||||
|
// GetRole
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewRole()++
|
||||||
|
// Enter Role
|
||||||
|
User->SystemAccountManager:++string NewRole++
|
||||||
|
// Create NewUser object
|
||||||
|
UserAccount<-SystemAccountManager:++new NewUser(\nstring NewUserName,\nstring NewPassword,\nstring New Email,\nstring NewRole\nDateTime TimeStamp)++
|
||||||
|
activate UserAccount #CBC3E3
|
||||||
|
UserAccount->UserAccount:++Constructor(\nstring NewUserName,\nstring NewPassword,\nstring New Email,\nstring NewRole\nDateTime TimeStamp)++
|
||||||
|
UserAccount-->SystemAccountManager:++return NewUser++
|
||||||
|
deactivate UserAccount
|
||||||
|
SystemAccountManager->AccountService:++AccountService\n.UpdateUserRecord(user:NewUser,\nUpdateType: userUpdate)++
|
||||||
|
activate AccountService #ff8b3d
|
||||||
|
AccountService->SqlDAO:++SqlDAO\n.UpdateUserRecord(user:NewUser,\nUpdateType: userUpdate)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlServer(MariaDB):++isUser(user:NewUser)++
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlServer(MariaDB)->SqlServer(MariaDB):++Update *\nFrom Users\nwhere Username\n= @UserName OR\nemail = @Email++
|
||||||
|
group #red data store timed out #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++SqlException++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
SqlDAO->SqlDAO: ++Catch\nSqlException++
|
||||||
|
AccountService<--SqlDAO:++return "Database timed out"++
|
||||||
|
|
||||||
|
SystemAccountManager<--AccountService:++ return "Database timed out"++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Database timed out"++
|
||||||
|
User<--Controller.cs:++ return "Database timed out"++
|
||||||
|
end
|
||||||
|
group #blue data store is online #white
|
||||||
|
// User exists
|
||||||
|
group #green User does exist #white
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return True++
|
||||||
|
SqlDAO->SqlServer(MariaDB):++ SQL insert\nupdate credentials++
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return 1++
|
||||||
|
AccountService<--SqlDAO:++return "User information updated successfully"++
|
||||||
|
SystemAccountManager<--AccountService:++return "User information updated successfully"++
|
||||||
|
Controller.cs<--SystemAccountManager:++return "User information updated successfully"++
|
||||||
|
User<--Controller.cs:++ return "User information\n updated successfully"++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
end
|
||||||
|
// User doesn't exist
|
||||||
|
group #green User does not exist #white
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return False++
|
||||||
|
SqlDAO->SqlServer(MariaDB):++ SQL insert\nuser credentials++
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return 1++
|
||||||
|
AccountService<--SqlDAO:++return "User is now registered"++
|
||||||
|
SystemAccountManager<--AccountService:++return "User is now registered"++
|
||||||
|
Controller.cs<--SystemAccountManager:++return "User is now registered"++
|
||||||
|
User<--Controller.cs:++ return \n"User is now registered"++
|
||||||
|
deactivate AccountService
|
||||||
|
deactivate SqlDAO
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
deactivate Controller.cs
|
||||||
|
end
|
||||||
|
//deactivate User
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
BIN
doc/LowLevel/UserManagement/UserManagementEnableUser.png
Normal file
|
After Width: | Height: | Size: 464 KiB |
158
doc/LowLevel/UserManagement/UserManagementEnableUser.txt
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
title Disable Specfied User
|
||||||
|
actor User
|
||||||
|
participant Controller.cs #90EE90
|
||||||
|
participant RDSFactory #26abff
|
||||||
|
participant UserAccount #CBC3E3
|
||||||
|
participant SystemAccountManager #ffffe0
|
||||||
|
participant AccountService #ff8b3d
|
||||||
|
participant SqlDAO #D3D3D3
|
||||||
|
//SqlDAO
|
||||||
|
database SqlServer(MariaDB) #00FFFF
|
||||||
|
|
||||||
|
//activate User
|
||||||
|
activate Controller.cs #90EE90
|
||||||
|
User->Controller.cs: ++Request to enable user\n by a different user++
|
||||||
|
|
||||||
|
//RelatDSFactory
|
||||||
|
Controller.cs->RDSFactory:++factory = new RDSFactory()++
|
||||||
|
activate RDSFactory #26abff
|
||||||
|
RDSFactory->RDSFactory:++Constructor()++
|
||||||
|
Controller.cs<--RDSFactory:++return RDSFactory++
|
||||||
|
deactivate RDSFactory
|
||||||
|
Controller.cs->SqlDAO:++IDataSource factory.GetDataSource(string DbName, string connInfo)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlDAO:++Constructor(string connInfo)++
|
||||||
|
group #red Data Store Timed Out #white
|
||||||
|
SqlDAO->SqlDAO: ++Catch SqlException++
|
||||||
|
Controller.cs<--SqlDAO:++return "Data Source Timed Out"++
|
||||||
|
end
|
||||||
|
group #blue Data Store Online #white
|
||||||
|
Controller.cs<--SqlDAO: ++return SqlDAO++
|
||||||
|
deactivate SqlDAO
|
||||||
|
// Create new Admin
|
||||||
|
Controller.cs->SystemAccountManager:++ manager = new SystemAccountManager(IDataSource conn)++
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
SystemAccountManager->SystemAccountManager:++Constructor(IDataSource conn)++
|
||||||
|
Controller.cs<--SystemAccountManager:++ New SystemAccountManager++
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
|
||||||
|
// GetUserName
|
||||||
|
Controller.cs->Controller.cs:++string GetUserName()++
|
||||||
|
|
||||||
|
// GetPassword
|
||||||
|
Controller.cs->Controller.cs:++string GetPassword()++
|
||||||
|
|
||||||
|
// Pass object
|
||||||
|
Controller.cs->UserAccount:++ new UserAccount(string username,\n string password\n DateTime RegistrationTimeStamp)++
|
||||||
|
activate UserAccount #CBC3E3
|
||||||
|
UserAccount->UserAccount: ++Constructor(string username,\n string password,\n DateTime RegistrationTimeStamp)++
|
||||||
|
Controller.cs<--UserAccount:++New UserAccount++
|
||||||
|
deactivate UserAccount
|
||||||
|
Controller.cs->SystemAccountManager:++manager.EnableUserRecord(user:UserAccount)++
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
SystemAccountManager->SystemAccountManager:++isInputValid(user: UserAccount)++
|
||||||
|
group #red Invalid Information #white
|
||||||
|
Controller.cs<--SystemAccountManager:++return "Invalid input"++
|
||||||
|
User<--Controller.cs:++ return "Invalid input"++
|
||||||
|
end
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
group #green Information Valid #white
|
||||||
|
//check if there is an admin user
|
||||||
|
SystemAccountManager->SqlDAO:++isAdmin(user:UserAccount)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlServer(MariaDB):++SqlRead confirmAdmin()++
|
||||||
|
activate SqlServer(MariaDB)#00FFFF
|
||||||
|
SqlServer(MariaDB)->SqlServer(MariaDB):++Select * from Admins\n where Username = @UserName \nand Password = @Pwd++
|
||||||
|
//Unauthorized role section
|
||||||
|
group #red Unauthorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++SqlException++
|
||||||
|
SqlDAO->SqlDAO: ++Catch\nSqlException++
|
||||||
|
SystemAccountManager<--SqlDAO:++return false++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Access Denied: \nUnauthorized"++
|
||||||
|
User<--Controller.cs:++return "Access Denied: \nUnauthorized"++
|
||||||
|
//Unauthorized role section
|
||||||
|
end
|
||||||
|
group #red Unauthorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++return false++
|
||||||
|
SystemAccountManager<--SqlDAO:++return false++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Access Denied: \nUnauthorized"++
|
||||||
|
User<--Controller.cs:++return "Access Denied: \nUnauthorized"++
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
//Authorized role section
|
||||||
|
group #blue Authorized User #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++return true++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
SystemAccountManager<--SqlDAO:++return true++
|
||||||
|
deactivate SqlDAO
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
|
||||||
|
group #green Valid Information #white
|
||||||
|
activate SystemAccountManager #ffffe0
|
||||||
|
// GetUserName
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewUserName()++
|
||||||
|
// Enter UserName
|
||||||
|
User->SystemAccountManager:++string NewUserName++
|
||||||
|
// GetRole
|
||||||
|
SystemAccountManager->SystemAccountManager:++string NewRole()++
|
||||||
|
// Enter Role
|
||||||
|
User->SystemAccountManager:++string NewRole++
|
||||||
|
// Create NewUser object
|
||||||
|
UserAccount<-SystemAccountManager:++new NewUser(\nstring NewUserName,\nstring role,\nDateTime TimeStamp)++
|
||||||
|
activate UserAccount #CBC3E3
|
||||||
|
UserAccount->UserAccount:++Constructor(\nstring NewUserName,\nstring role,\nDateTime TimeStamp)++
|
||||||
|
UserAccount-->SystemAccountManager:++return NewUser++
|
||||||
|
deactivate UserAccount
|
||||||
|
SystemAccountManager->AccountService:++AccountService\n.EnableUserRecord(user:NewUser,\nUpdateType:userEnable)++
|
||||||
|
activate AccountService #ff8b3d
|
||||||
|
AccountService->SqlDAO:++SqlDAO\n.EnableUser(user:NewUser,\nUpdateType:userEnable)++
|
||||||
|
activate SqlDAO #D3D3D3
|
||||||
|
SqlDAO->SqlServer(MariaDB):++isUser(user:NewUser)++
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlServer(MariaDB)->SqlServer(MariaDB):++ Select *\nFrom Users\nwhere Username\n= @UserName and\nRole = @UserRole
|
||||||
|
group #red data store timed out #white
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++SqlException++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
SqlDAO->SqlDAO: ++Catch\nSqlException++
|
||||||
|
AccountService<--SqlDAO:++return "Database timed out"++
|
||||||
|
|
||||||
|
SystemAccountManager<--AccountService:++ return "Database timed out"++
|
||||||
|
Controller.cs<--SystemAccountManager:++ return "Database timed out"++
|
||||||
|
User<--Controller.cs:++ return "Database timed out"++
|
||||||
|
end
|
||||||
|
group #blue data store is online #white
|
||||||
|
// User exists
|
||||||
|
group #green User does exist #white
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return True++
|
||||||
|
SqlDAO->SqlServer(MariaDB):++Update users Set isActive = 1\nwhere UserName = @UserName++
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return 1++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
AccountService<--SqlDAO:++return "User is now enabled"++
|
||||||
|
SystemAccountManager<--AccountService:++return "User is now enabled"++
|
||||||
|
Controller.cs<--SystemAccountManager:++return "User is now enabled"++
|
||||||
|
User<--Controller.cs:++ return \n"User is now enabled"++
|
||||||
|
end
|
||||||
|
// User doesn't exist
|
||||||
|
group #red User does not exist #white
|
||||||
|
activate SqlServer(MariaDB) #00FFFF
|
||||||
|
SqlDAO<--SqlServer(MariaDB):++ return False++
|
||||||
|
deactivate SqlServer(MariaDB)
|
||||||
|
AccountService<--SqlDAO:++return "User does not exist"++
|
||||||
|
deactivate SqlDAO
|
||||||
|
SystemAccountManager<--AccountService:++return "User does not exist"++
|
||||||
|
deactivate AccountService
|
||||||
|
Controller.cs<--SystemAccountManager:++return "User does not exist"++
|
||||||
|
deactivate SystemAccountManager
|
||||||
|
User<--Controller.cs:++ return \n"User does not exist"++
|
||||||
|
deactivate Controller.cs
|
||||||
|
end
|
||||||
|
//deactivate User
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
BIN
doc/LowLevel/archivingMasterCon.pdf
Normal file
BIN
doc/LowLevel/archivingSubmission.pdf
Normal file
BIN
doc/LowLevel/arcvhingMasterCon.pdf
Normal file
64
src/dbCode/ExportingRows.txt
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
|
||||||
|
select * from log;
|
||||||
|
|
||||||
|
-- Find logs that are older than 30 days of current time.
|
||||||
|
SELECT * FROM log WHERE DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30;
|
||||||
|
|
||||||
|
-- Output logs to a file
|
||||||
|
SELECT * FROM log
|
||||||
|
WHERE
|
||||||
|
DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30
|
||||||
|
INTO OUTFILE 'C:/Temp/oldlogs.csv'
|
||||||
|
FIELDS ENCLOSED BY '"'
|
||||||
|
TERMINATED BY ';'
|
||||||
|
ESCAPED BY '"'
|
||||||
|
LINES TERMINATED BY '\r\n';
|
||||||
|
|
||||||
|
-- Output into comma separated file
|
||||||
|
SELECT * INTO OUTFILE 'C:/Temp/oldlogs2.csv'
|
||||||
|
FIELDS ENCLOSED BY '"'
|
||||||
|
TERMINATED BY ','
|
||||||
|
ESCAPED BY '"'
|
||||||
|
LINES TERMINATED BY '\r\n'
|
||||||
|
FROM log
|
||||||
|
WHERE
|
||||||
|
DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30;
|
||||||
|
|
||||||
|
-- Output into comma separated file
|
||||||
|
SELECT *
|
||||||
|
INTO OUTFILE 'C:/Temp/oldlogs4.csv'
|
||||||
|
FIELDS ENCLOSED BY ''
|
||||||
|
TERMINATED BY ','
|
||||||
|
ESCAPED BY '"'
|
||||||
|
LINES TERMINATED BY '\r\n'
|
||||||
|
FROM log
|
||||||
|
WHERE DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30;
|
||||||
|
|
||||||
|
-- Find the name of each columns
|
||||||
|
SELECT `COLUMN_NAME`
|
||||||
|
FROM `information_schema`.`COLUMNS`
|
||||||
|
WHERE `TABLE_SCHEMA` = 'hobby' AND `TABLE_NAME` = 'log';
|
||||||
|
|
||||||
|
-- Add the column names to the heading of the file
|
||||||
|
SELECT 'LtimeStamp', 'logID', 'LvName', 'catName', 'userOP', 'logMessage'
|
||||||
|
UNION ALL
|
||||||
|
SELECT * FROM log
|
||||||
|
WHERE
|
||||||
|
DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30
|
||||||
|
INTO OUTFILE 'C:/Temp/oldlogs5.csv'
|
||||||
|
FIELDS ENCLOSED BY ''
|
||||||
|
TERMINATED BY ','
|
||||||
|
ESCAPED BY '"'
|
||||||
|
LINES TERMINATED BY '\r\n';
|
||||||
|
|
||||||
|
-- Remove old logs from the log table
|
||||||
|
DELETE from log where DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30;
|
||||||
|
|
||||||
|
show columns from log;
|
||||||
|
|
||||||
|
SELECT COLUMN_NAME FROM information_schema.COLUMNS;
|
||||||
|
|
||||||
|
|
||||||
|
-- Remove logs from the table
|
||||||
|
|
||||||
|
SELECT DATEDIFF('2021-08-07 23:00:00', current_timestamp);
|
||||||