Merge branch 'compressTesting' of https://github.com/long237/HobbyProject into compressTesting

This commit is contained in:
Alatreon 2021-12-10 16:22:23 -08:00
commit 0cc7a4a7c3
61 changed files with 1493 additions and 87 deletions

View File

@ -12,15 +12,15 @@ namespace TeamHobby.HobbyProjectGenerator.Archive
{
public class SQLSource : IDataSource, IRelationArchivable
{
private SqlConnection conn;
//private SqlConnection conn;
public SQLSource(string info)
{
// Do I put using here to make sure the connection closed once the object is gone?
conn = new SqlConnection(info);
// Perhaps open the connection here?
// conn.Open();
}
//public SQLSource(string info)
//{
// // Do I put using here to make sure the connection closed once the object is gone?
// conn = new SqlConnection(info);
// // Perhaps open the connection here?
// // conn.Open();
//}
// The also Identical to update data, maybe only one method is enough
public bool DeleteData(string cmd)
@ -33,22 +33,23 @@ namespace TeamHobby.HobbyProjectGenerator.Archive
{
try
{
conn.Open();
//conn.Open();
//SqlCommand command = new SqlCommand(null, conn);
SqlCommand command = new SqlCommand(cmd, conn);
//SqlCommand command = new SqlCommand(cmd, conn);
// conn.Execute();
Console.WriteLine("Access a SQL database");
Console.WriteLine("Select * from archive");
// Execute the command to query the data
using SqlDataReader sqlReader = command.ExecuteReader();
//using SqlDataReader sqlReader = command.ExecuteReader();
// while (myReader)
// Print to console
conn.Close();
conn.Dispose();
return sqlReader;
//conn.Close();
//conn.Dispose();
//return sqlReader;
return new SqlConnection();
}
catch (Exception e)
{
@ -62,16 +63,16 @@ namespace TeamHobby.HobbyProjectGenerator.Archive
{
try
{
conn.Open();
//conn.Open();
// Create the SQL command object
SqlCommand command = new SqlCommand(cmd, conn);
//SqlCommand command = new SqlCommand(cmd, conn);
// Execute the command to change the rows in a table
command.ExecuteNonQuery();
//command.ExecuteNonQuery();
conn.Close();
conn.Dispose();
//conn.Close();
//conn.Dispose();
return true;
}
catch (Exception e)
@ -124,28 +125,28 @@ namespace TeamHobby.HobbyProjectGenerator.Archive
}
}
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);
//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);
// tableParam.Value = table;
// command.Parameters.Add(tableParam);
// conn.Execute();
Console.WriteLine("Access a SQL database");
Console.WriteLine("Select * from archive");
// // 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();
// // Make the Prepare statement and excute the query:
// command.Prepare();
// SqlDataReader sqlReader = command.ExecuteReader();
// while (myReader)
// Print to console
// conn.close();
return sqlReader;
}
// // while (myReader)
// // Print to console
// // conn.close();
// return sqlReader;
//}
}
}

View File

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

View File

@ -0,0 +1,48 @@
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());
}
}
/*
* this is meant for specific basic sql commands
using (var adapter = new SqlDataAdapter())
{
adapter.SelectCommand
}
*/
}
}
}
}

View File

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

View File

@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using TeamHobby.HobbyProjectGenerator.Main.Models;
namespace TeamHobby.HobbyProjectGenerator.Main.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
return View();
}
public IActionResult Privacy()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}

View File

@ -0,0 +1,10 @@
using TeamHobby.HobbyProjectGenerator;
using TeamHobby.HobbyProjectGenerator.DAL;
namespace TeamHobby.HobbyProjectGenerator.Main
{
public class ExampleDAO : SqlDAO
{
}
}

View File

@ -0,0 +1,9 @@
namespace TeamHobby.HobbyProjectGenerator.Main.Models
{
public class ErrorViewModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}

View File

@ -0,0 +1,29 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();

View File

@ -0,0 +1,28 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:6067",
"sslPort": 44307
}
},
"profiles": {
"TeamHobby.HobbyProjectGenerator.Main": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7023;http://localhost:5023",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.DAL\TeamHobby.HobbyProjectGenerator.DAL.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,8 @@
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Hello World!</p>
</div>

View File

@ -0,0 +1,6 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>

View File

@ -0,0 +1,25 @@
@model ErrorViewModel
@{
ViewData["Title"] = "Error";
}
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model?.ShowRequestId ?? false)
{
<p>
<strong>Request ID:</strong> <code>@Model?.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>

View File

@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - TeamHobby.HobbyProjectGenerator.Main</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/TeamHobby.HobbyProjectGenerator.Main.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">TeamHobby.HobbyProjectGenerator.Main</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2021 - TeamHobby.HobbyProjectGenerator.Main - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>

View File

@ -0,0 +1,48 @@
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}
a {
color: #0077cc;
}
.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy {
font-size: 1rem;
line-height: inherit;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}

View File

@ -0,0 +1,2 @@
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>

View File

@ -0,0 +1,3 @@
@using TeamHobby.HobbyProjectGenerator.Main
@using TeamHobby.HobbyProjectGenerator.Main.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,18 @@
html {
font-size: 14px;
}
@media (min-width: 768px) {
html {
font-size: 16px;
}
}
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 60px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -0,0 +1,4 @@
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
// for details on configuring this project to bundle and minify static web assets.
// Write your JavaScript code.

View File

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

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -1,12 +0,0 @@
using System;
namespace TeamHobby.HobbyProjectGenerator
{
public class Class1
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

View File

@ -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
{
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}
}

View File

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

View File

@ -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();
}
}
}

View File

@ -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();
}
}
}

View File

@ -1,37 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31919.166
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator", "TeamHobby.HobbyProjectGenerator.csproj", "{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Archive", "..\TeamHobby.HobbyProjectGenerator.Archive\TeamHobby.HobbyProjectGenerator.Archive.csproj", "{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.Main", "..\TeamHobby.Main\TeamHobby.Main.csproj", "{6E9DCCDB-B7E3-4530-B20D-5B86BA86A905}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.Build.0 = Release|Any CPU
{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0E39503-E55A-4EB8-AA98-98D74A79D7D6}.Release|Any CPU.Build.0 = Release|Any CPU
{6E9DCCDB-B7E3-4530-B20D-5B86BA86A905}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6E9DCCDB-B7E3-4530-B20D-5B86BA86A905}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6E9DCCDB-B7E3-4530-B20D-5B86BA86A905}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6E9DCCDB-B7E3-4530-B20D-5B86BA86A905}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B2517200-A9F9-468C-B0EB-280FF9B9FBC9}
EndGlobalSection
EndGlobal

View 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
{
}
}

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 92 KiB

View 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

Binary file not shown.

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 132 KiB

View File

@ -0,0 +1,141 @@
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
//
activate UserAccount #CBC3E3
Controller.cs->UserAccount:++ new UserAccount(string username,\n string password,\n string email,\n DateTime RegistrationTimeStamp)++
UserAccount->UserAccount: ++Constructor(string username,\n string password,\n string email,\n DateTime RegistrationTimeStamp)++
Controller.cs<--UserAccount:++New UserAccount++
deactivate UserAccount
//
Controller.cs->SystemAccountManager:++manager.CreateUserRecord(user:UserAccount)++
//check if there is an admin user
activate SystemAccountManager #ffffe0
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
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"++
deactivate SystemAccountManager
end
group #green Valid Information #white
activate SystemAccountManager #ffffe0
SystemAccountManager->AccountService:++AccountService\n.CreateUserRecord(user:UserAccount)++
activate AccountService #ff8b3d
AccountService->SqlDAO:++SqlDAO\n.CreateUserRecord(user:UserAccount)++
activate SqlDAO #D3D3D3
SqlDAO->SqlServer(MariaDB):++SqlRead \nisUser(user:UserAccount)++
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++
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"++
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,137 @@
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
//
activate UserAccount #CBC3E3
Controller.cs->UserAccount:++ new UserAccount(string username,\n string password\n DateTime RegistrationTimeStamp)++
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)++
//check if there is an admin user
activate SystemAccountManager #ffffe0
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
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"++
deactivate SystemAccountManager
end
group #green Valid Information #white
activate SystemAccountManager #ffffe0
SystemAccountManager->AccountService:++AccountService\n.DeleteUserRecord(user:UserAccount)++
activate AccountService #ff8b3d
AccountService->SqlDAO:++SqlDAO\n.DeleteUserRecord(user:UserAccount)++
activate SqlDAO #D3D3D3
SqlDAO->SqlServer(MariaDB): ++isUser(user:UserAccount)++
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 131 KiB

View File

@ -0,0 +1,138 @@
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
// Pass object
activate UserAccount #CBC3E3
Controller.cs->UserAccount:++ new UserAccount(string username,\n string password\n DateTime RegistrationTimeStamp)++
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)++
//check if there is an admin user
activate SystemAccountManager #ffffe0
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
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"++
deactivate SystemAccountManager
end
group #green Valid Information #white
activate SystemAccountManager #ffffe0
SystemAccountManager->AccountService:++AccountService\n.DisableUserRecord(user:UserAccount)++
activate AccountService #ff8b3d
AccountService->SqlDAO:++SqlDAO\n.DisableUser(user:UserAccount)++
activate SqlDAO #D3D3D3
SqlDAO->SqlServer(MariaDB): ++isUser(user:UserAccount)++
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):++Update users Set isActive = 0\nwhere UserName = @UserName++
SqlDAO<--SqlServer(MariaDB):++ return 1++
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"++
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 139 KiB

View File

@ -0,0 +1,140 @@
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 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
//
activate UserAccount #CBC3E3
Controller.cs->UserAccount:++ new UserAccount(string username,\n string password,\n string email,\n DateTime RegistrationTimeStamp)++
UserAccount->UserAccount: ++string username,\n string password,\n string email,\n DateTime RegistrationTimeStamp++
Controller.cs<--UserAccount:++New UserAccount++
deactivate UserAccount
//look over
Controller.cs->SystemAccountManager: ++manager.UpdateUserRecord(user:UserAccount,\nActiveUser:user, UpdateObj: userUpdate)++
//check if there is an admin user
activate SystemAccountManager #ffffe0
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
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"++
deactivate SystemAccountManager
end
group #green Valid Information #white
activate SystemAccountManager #ffffe0
SystemAccountManager->AccountService: ++AccountService\n.CreateUserRecord(user:UserAccount\n,ActiveUser:user, UpdateObj: userUpdate)++
activate AccountService #ff8b3d
AccountService->SqlDAO: ++SqlDAO\n.CreateUserRecord(user:UserAccount\n,ActiveUser:user, UpdateObj: userUpdate)++
activate SqlDAO #D3D3D3
SqlDAO->SqlServer(MariaDB): ++isUser(user:UserAccount)++
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):++ SQL insert\nuser 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

Binary file not shown.

Binary file not shown.