Compare commits

..

210 Commits

Author SHA1 Message Date
Lunastra
271f2df7f9 Merge branch 'newMain' 2022-01-04 13:58:51 -08:00
Im_Alpha
d550ad44df Added logging with references fixed 2022-01-04 13:57:23 -08:00
colincreasman
4f8aeaead8 Added in old code for logging library 2022-01-04 13:53:20 -08:00
colincreasman
a424b6f7a2 new DBLogger file using old code
new DBLogger file using old code
2022-01-04 13:45:22 -08:00
Lunastra
27c322d759 Merge branch 'newMain' 2022-01-04 13:39:53 -08:00
Im_Alpha
8cda716487 Fixed namespace 2022-01-04 13:38:02 -08:00
Lunastra
3bf30af52f Merge branch 'newMain' 2022-01-04 13:27:09 -08:00
Im_Alpha
85c6f25721 Added Folders to match HLD 2022-01-04 13:23:18 -08:00
Im_Alpha
c139b80459 Moved logging into service layer 2022-01-04 13:20:16 -08:00
Im_Alpha
300158ec25 Renamed and moved to match HLD 2022-01-04 13:17:58 -08:00
Lunastra
f79dd88cc7 Merge branch 'newMain' 2022-01-04 12:59:32 -08:00
Lunastra
56c7725f56 Merge branch 'master' of https://github.com/long237/HobbyProject 2022-01-04 12:58:14 -08:00
Lunastra
d96d1f972b Ignore a binary folder 2022-01-04 12:57:47 -08:00
Lunastra
d8be0846fc Add missing comments 2022-01-04 12:56:54 -08:00
Im_Alpha
2c5dea12df Working Cleaned solution 2022-01-04 12:55:32 -08:00
long237
52f6a2b731
Delete binary folder in main directory 2022-01-04 12:02:13 -08:00
Lunastra
51b41fc9f7 ignore the 2 binary files 2021-12-15 20:29:29 -08:00
Lunastra
6319cc7693 Ignored binary folder for gitignore 2021-12-15 20:01:09 -08:00
Rifat Hasan
df7e6f9c5e
Add files via upload 2021-12-16 02:48:06 +00:00
Im_Alpha
19fdbc21f6 Merge branch 'master' of https://github.com/long237/HobbyProject 2021-12-15 18:40:25 -08:00
Im_Alpha
9afb9af9f6 updated text file path to new path 2021-12-15 18:40:16 -08:00
long237
7daf61c6bd
Ignore binary and debug folder 2021-12-15 18:39:26 -08:00
Im_Alpha
3c154ed8aa Merge branch 'Jacobs-Branch' 2021-12-15 18:38:02 -08:00
Im_Alpha
e7c11778ee fixed txt 2021-12-15 18:36:24 -08:00
long237
d989c5c840
Remove testingDB line 2021-12-15 18:36:23 -08:00
Im_Alpha
a87237fbf0 Revert "added text for bulk operation"
This reverts commit 1046293c9e.
2021-12-15 18:33:14 -08:00
Im_Alpha
0b182cb08c Merge branch 'Jacobs-Branch' 2021-12-15 18:29:19 -08:00
Im_Alpha
1046293c9e added text for bulk operation 2021-12-15 18:28:57 -08:00
long237
f62abbd1e5
not ignore debug 2021-12-15 18:27:18 -08:00
long237
c96b6eda56
Include binary folder 2021-12-15 18:22:47 -08:00
Im_Alpha
32be141e44 fixed solution file 2021-12-15 18:19:53 -08:00
Jacob Delgado
e1a2cb8b1b added drop database and fixed insert 2021-12-15 17:52:53 -08:00
Jacob Delgado
ff690dc836 added show tables when complete 2021-12-15 17:41:05 -08:00
Im_Alpha
f1dc060545 removed unused 2021-12-15 17:20:09 -08:00
Im_Alpha
ab2096492c removed unused 2021-12-15 17:18:49 -08:00
Im_Alpha
5dacebdffd Merge branch 'Jacobs-Branch' 2021-12-15 17:13:51 -08:00
Im_Alpha
27080ce36c fixed testing, add archive path to menu 2021-12-15 17:13:36 -08:00
DanBribi
b618041489
Add files via upload 2021-12-15 17:02:43 -08:00
DanBribi
8f364fb521
Delete Project Roadmap.drawio.png 2021-12-15 16:57:23 -08:00
DanBribi
fe4b2f891b
Delete Project Plan.pdf 2021-12-15 16:57:07 -08:00
DanBribi
699de5a7e6
Fixed test cases (#18) 2021-12-15 16:44:21 -08:00
Lunastra
8a6e4c8541 Merge branch 'Long_archivePos' 2021-12-15 16:31:08 -08:00
Lunastra
2bf0341668 Add output to print some prompt 2021-12-15 16:30:56 -08:00
Im_Alpha
f11ed7d6ad Merge branch 'Jacobs-Branch' into Rifats_tests 2021-12-15 15:37:42 -08:00
Rifat Hasan
8d49e66a90 Add operations for single and bulk 2021-12-15 15:36:47 -08:00
Lunastra
b2217dee34 Merge branch 'Long_archivePos' 2021-12-15 15:15:39 -08:00
Lunastra
c403278f9f Remove archive table and some settings.
Cleaned up DDL
2021-12-15 15:15:28 -08:00
Lunastra
6e8e2f9756 Merge branch 'Long_archivePos' 2021-12-15 14:03:00 -08:00
Lunastra
cd7f94a5e0 Add performance testing for 10k and 1 million records 2021-12-15 14:02:39 -08:00
Im_Alpha
a709675c99 Merge branch 'Jacobs-Branch' 2021-12-15 05:00:18 -08:00
Im_Alpha
1a265f8239 Bulk Operation option completed 2021-12-15 04:59:29 -08:00
Lunastra
3c4a413917 Fixed a small syntax in the controller 2021-12-15 00:21:40 -08:00
Lunastra
6689b91e70 Add testing compression method. 2021-12-14 22:24:28 -08:00
Im_Alpha
9bba0ebcc1 initial script for dummy bulk data 2021-12-14 22:24:10 -08:00
Lunastra
03cfb10c10 Translate the test case from main over
Revert back to open and close design.
Move test cases to unit test.
2021-12-14 20:37:43 -08:00
Lunastra
a2c5e0a1f9 Merge branch 'master' into Long_archivePos 2021-12-14 19:13:18 -08:00
Lunastra
66e3aed842 Merge remote-tracking branch 'origin/Danny's_branch' into Long_archivePos 2021-12-14 19:12:30 -08:00
Lunastra
2ef2d3c919 some csproj files changes 2021-12-14 19:11:12 -08:00
Im_Alpha
4cf16cce93 Merge branch 'Jacobs-Branch' 2021-12-14 15:27:10 -08:00
Im_Alpha
de8dd8a583 Merge remote-tracking branch 'origin/Rifats_tests' into Jacobs-Branch 2021-12-14 15:17:35 -08:00
Rifat Hasan
6bf376802d Add correct failure case 2021-12-14 15:15:40 -08:00
Im_Alpha
cef3c4114c Merge remote-tracking branch 'origin/Rifats_tests' into Jacobs-Branch 2021-12-14 14:44:52 -08:00
Rifat Hasan
e012dde28c Add single and bulk tests 2021-12-14 14:43:50 -08:00
DanBribi
68b8439256 Adjusted open and close connections 2021-12-14 14:41:37 -08:00
DanBribi
04f5d9856b update backup 2021-12-14 14:19:32 -08:00
DanBribi
1f84ec0a8d updates_12_14_21 2021-12-14 14:19:15 -08:00
Rifat Hasan
136505be71 Merge branch 'Jacobs-Branch' into Rifats_tests 2021-12-14 13:34:08 -08:00
Im_Alpha
97cc4369bd cleaned solution 2021-12-14 13:33:23 -08:00
Im_Alpha
20cbf225ff Merge remote-tracking branch 'origin/Rifats_tests' into Jacobs-Branch 2021-12-14 13:32:47 -08:00
Rifat Hasan
9c0472f061 Update UnitTest1.cs 2021-12-14 13:30:22 -08:00
DanBribi
14dec71367 Testing removeOutputFile 2021-12-14 12:33:06 -08:00
Im_Alpha
510ea55421 changed return strings to match design diagram 2021-12-14 02:57:01 -08:00
Im_Alpha
bca0875ec7 rechecked DDL for full DB 2021-12-14 02:54:23 -08:00
Im_Alpha
c9f60c2f76 moved archive check into menu loop
requires confirmation with the rest of the commented code
2021-12-14 02:53:20 -08:00
DanBribi
95f762552f remove_entries_testing 2021-12-14 02:50:12 -08:00
Im_Alpha
084e0de6ec changed everything so that the branch is running again 2021-12-14 02:23:11 -08:00
Jacob Delgado
89eda68a6c
Merge pull request #15 from long237/Jacobs-Branch
Jacobs branch
2021-12-14 02:20:42 -08:00
Im_Alpha
ceabdc9161 Merge branch 'master' into Jacobs-Branch 2021-12-14 02:20:10 -08:00
Im_Alpha
ba6db79f09 removed unused files 2021-12-14 02:16:21 -08:00
Im_Alpha
7575354797 Added confirmation password loop
removed commented code and unused files
2021-12-14 02:12:24 -08:00
Im_Alpha
cc71d41cca reworded for easier implementation 2021-12-14 02:02:56 -08:00
Im_Alpha
53aaf77c6b finished all UM features
create account
edit account
delete account
disable account
enable account
2021-12-14 02:01:28 -08:00
Im_Alpha
484c725ba8 Infinite menu completed
both main menu and sub menu will run forever unless user enters a specified input
2021-12-14 00:23:52 -08:00
Im_Alpha
a4a133b0cd Menu completed
Commented out database connecting lines and added successful login in instead.
2021-12-13 23:28:47 -08:00
Im_Alpha
6f9c6f0f12 removed roleID 2021-12-13 21:48:46 -08:00
Im_Alpha
487138890a adjusted files to build menu and start testing 2021-12-13 21:41:27 -08:00
Lunastra
9b2b38620b Merge branch 'Long_archivePos' 2021-12-13 20:56:16 -08:00
Lunastra
cdba27ee12 Delete a blank space 2021-12-13 20:52:58 -08:00
Lunastra
dfb32b0e26 Changed Removed Entries to throw an Error
Tested the clean up sequence for Manager
2021-12-13 20:50:24 -08:00
Jacob Delgado
7f9e278266
Merge pull request #14 from long237/Jacobs-Branch
fixed UserManagement ddl
2021-12-13 20:49:00 -08:00
Im_Alpha
ca51159bc6 fixed ddl 2021-12-13 20:48:32 -08:00
colincreasman
4ecbb14940
Merge pull request #13 from long237/Colins-Branch
Colins branch
2021-12-13 20:23:55 -08:00
colincreasman
34dac0e3b9 Merge branch 'master' into Colins-Branch 2021-12-13 20:22:30 -08:00
colincreasman
c021d5f04f Added initial Logging library 2021-12-13 20:18:42 -08:00
Jacob Delgado
5224841dac
Merge pull request #12 from long237/Jacobs-Branch
Jacobs branch
2021-12-13 20:17:19 -08:00
Im_Alpha
e3c3ef4b83 Merge branch 'master' into Jacobs-Branch 2021-12-13 20:16:58 -08:00
Im_Alpha
c100a73b39 fixed create account sql and edit account 2021-12-13 20:09:07 -08:00
Im_Alpha
80cd5c3de9 fixed sql DDL 2021-12-13 19:56:47 -08:00
Lunastra
d8bf615b02 Add method for testing if the file exist or not 2021-12-13 19:37:39 -08:00
Lunastra
5866a0a860 Merge branch 'Long_archivePos' 2021-12-13 18:32:56 -08:00
Lunastra
65d41e0faa Rename the DataSource Factory 2021-12-13 18:29:34 -08:00
Im_Alpha
3074044777 created usermanagement standalone DDL 2021-12-13 15:40:21 -08:00
Im_Alpha
9e1ef7bcab added users and roles table to ddl 2021-12-13 15:39:38 -08:00
Im_Alpha
b2a627a9c7 added create account record 2021-12-13 15:37:58 -08:00
colincreasman
c72af8ccb6
Merge pull request #11 from long237/Colins-Branch
Revised Logging LLD
2021-12-13 11:39:23 -08:00
colincreasman
4f2f4c8fce Revised Logging LLD
Fixed entry point and added LogEntry class
2021-12-13 11:36:10 -08:00
Im_Alpha
6414c9feed menu finished, requires logs and archive
menu is done and also overloaded GetCredentials and isInputValid to accomodate the new user credentials when creating an account
2021-12-13 09:12:51 -08:00
Im_Alpha
55ab7c6cf2 updated menu and uiprint
working on menu switch still and rearranged project folders
2021-12-13 07:17:44 -08:00
Im_Alpha
f67b172f8d Finished isAdmin, working on submenu 2021-12-13 06:29:13 -08:00
colincreasman
c118c908f1 Removed old svg 2021-12-12 23:49:59 -08:00
colincreasman
f452b599e3
Merge pull request #10 from long237/Colins-Branch
Colins branch
2021-12-12 23:41:18 -08:00
colincreasman
99c3a7eb4a Added Logging LLD v4 2021-12-12 23:39:58 -08:00
Lunastra
a76603f00c Rearrange Low level diagrams into a folder. 2021-12-12 22:42:20 -08:00
Lunastra
e8d42bf98f Creating test methods for archiving 2021-12-12 20:56:34 -08:00
Alatreon
4a2bd5b38f Add error handling an cleaning up for Archiving 2021-12-12 16:21:02 -08:00
colincreasman
57f6e4f9d8 Merge branch 'Jacobs-Branch' into Colins-Branch 2021-12-12 15:11:21 -08:00
colincreasman
000c3aed41 Merge branch 'master' into Colins-Branch 2021-12-12 15:03:23 -08:00
colincreasman
af21f771d0 add ignore json
add ignore json
2021-12-12 15:02:57 -08:00
colincreasman
2e4c898c89 Update Controller.cs
Added port specification to the connection string so i could connect on my machine. (Project config is still set to x86)
2021-12-12 14:55:52 -08:00
Im_Alpha
c7815d215c renamed and reorganized solution file
completed isInputValid method
2021-12-12 04:43:20 -08:00
colincreasman
ef025afe0f Changed Project config to build on x86 2021-12-12 03:27:50 -08:00
Im_Alpha
e6a751db31 Finished UserAccount Class 2021-12-12 02:26:21 -08:00
Im_Alpha
79426a2ce2 Merge branch 'master' into Jacobs-Branch 2021-12-12 02:21:21 -08:00
Lunastra
01711fe223 Merge branch 'Long_archivePos' 2021-12-12 00:25:47 -08:00
Lunastra
4e970f28b6 Rename to archiveManager
Add the while loop and if statement
2021-12-12 00:24:40 -08:00
Im_Alpha
8999a71a97 Rearranged items and removed dummy DAO 2021-12-11 23:42:27 -08:00
Lunastra
b89e4f69c4 Process flowed testing for compress sequence 2021-12-11 23:40:39 -08:00
Lunastra
421637bda7 Add a CreateOutFile method overload
Changed the file path for the archive folder
2021-12-11 22:59:17 -08:00
Lunastra
9db6ab7db7 Create copy to file method 2021-12-11 22:34:47 -08:00
Rifat Hasan
0f825ca4bd
Add files via upload 2021-12-12 04:17:44 +00:00
Lunastra
feb2c0abe5 Create function to create folder in archive 2021-12-11 18:01:02 -08:00
colincreasman
121dace628 Created Logging Library 2021-12-11 16:38:51 -08:00
colincreasman
5e24218d94 Merge branch 'master' into Colins-Branch 2021-12-11 16:01:29 -08:00
Lunastra
698aa45318 Fixed DataSourceFactory 2021-12-11 15:34:18 -08:00
Lunastra
f8bafc8b6d Add writing, deleting data to SqlDAO 2021-12-11 15:06:44 -08:00
Lunastra
d76a389b9e Rearrange some files, add SqlReadData 2021-12-11 14:32:40 -08:00
Lunastra
0b3c5df2b8 Change a print line in main 2021-12-11 13:33:36 -08:00
Lunastra
f79f0e6adc Merge branch 'compressTesting' 2021-12-11 00:58:48 -08:00
Lunastra
38a7195040 Tested for connection to MariaDB 2021-12-11 00:55:58 -08:00
Im_Alpha
567bf71720 fixed error of archiving not in solution 2021-12-10 22:11:53 -08:00
Lunastra
ace8f88ec1 Merge branch 'master' into compressTesting 2021-12-10 22:03:37 -08:00
Lunastra
a811a98b6f Add the submission pdf as record 2021-12-10 22:02:48 -08:00
Im_Alpha
ba273228ac removed web template 2021-12-10 19:48:39 -08:00
Rifat Hasan
e5ef385b18
Add files via upload 2021-12-11 03:20:02 +00:00
Jacob Delgado
9e098b064f
Merge pull request #9 from long237/Jacobs-Branch
continued updates to menu
2021-12-10 18:39:51 -08:00
Im_Alpha
a98a5fc3f6 continued updates to menu 2021-12-10 18:39:04 -08:00
Jacob Delgado
3f7597e1eb
Merge pull request #8 from long237/Jacobs-Branch
Jacobs branch
2021-12-10 18:34:33 -08:00
Im_Alpha
598197d542 readded designs to resolve merge 2021-12-10 18:34:22 -08:00
Im_Alpha
ba6ae16a05 removed for merging 2021-12-10 18:30:25 -08:00
Im_Alpha
8825a94301 fix diagrams for inputValidation
rearranged input line
2021-12-10 18:28:59 -08:00
Alatreon
cacb66ef83 Change IDataSource, Add main controller file, add functions signatures. 2021-12-10 17:27:53 -08:00
Alatreon
29a773560c Merge branch 'master' into compressTesting 2021-12-10 16:24:51 -08:00
Alatreon
0cc7a4a7c3 Merge branch 'compressTesting' of https://github.com/long237/HobbyProject into compressTesting 2021-12-10 16:22:23 -08:00
Alatreon
38549d9209 Ignore vscode folder 2021-12-10 16:21:44 -08:00
Im_Alpha
d682c463a4 removed web app template and added main controller
initial main controller added
2021-12-10 02:07:02 -08:00
Im_Alpha
a7d1679332 Renamed for readability
added a period to separate the text
2021-12-09 01:57:09 -08:00
Jacob Delgado
c759799c20
Merge pull request #7 from long237/Jacobs-Branch
Jacobs branch
2021-12-09 01:54:14 -08:00
Im_Alpha
122db1cf47 Fixed title of enable user
was left unchanged before
2021-12-09 00:44:02 -08:00
Im_Alpha
0cbb43fd97 Fixed sql and added enable user
altered sql query to match the correct parameters available
2021-12-09 00:20:35 -08:00
Im_Alpha
93b8e9a327 removed svg, updated final diagrams
Need to create one more for enabling an account
2021-12-09 00:08:52 -08:00
long237
74be5c5c9b
Merge pull request #6 from long237/compressTesting
Compress testing
2021-12-08 23:08:15 -08:00
Lunastra
a695bd5cac Merge branch 'master' into compressTesting 2021-12-08 23:04:50 -08:00
Lunastra
79bd9f0e64 Add error handling for connection 2021-12-08 23:04:20 -08:00
Lunastra
3f4d78dae3 Add Sql command 2021-12-08 18:51:24 -08:00
Lunastra
916ddc888f Add Exception handling when failed
Remove any files created if any of the process failed during compression.
2021-12-08 18:37:17 -08:00
Lunastra
3d37a31072 Redesign Archiving
Change archiving so that it will now work with a master main
2021-12-08 17:34:00 -08:00
Im_Alpha
639d738dba Merge branch 'master' into Jacobs-Branch 2021-12-08 02:54:43 -08:00
Im_Alpha
5887f4d06d Updated All diagrams for User Management
added factory within the designs for final inspections from group
2021-12-08 02:50:49 -08:00
Im_Alpha
3797701563 updated create account
need to update rest, text file added
2021-12-08 00:56:57 -08:00
Im_Alpha
27dc15577e moved designs
svgs
2021-12-08 00:53:21 -08:00
Im_Alpha
aafad06ecf never again 2021-12-07 21:34:09 -08:00
Im_Alpha
90b97ea98d renamed
removed numbering
2021-12-07 19:46:09 -08:00
colincreasman
e94e772970 Logging LLD
first draft
2021-12-07 19:43:59 -08:00
Im_Alpha
a392265a42 pre-final diagrams
still need to add in factory
2021-12-07 19:42:05 -08:00
colincreasman
91bae8f8fc Logging LLD
First draft of logging LLD
2021-12-07 19:41:09 -08:00
Im_Alpha
fa5282b074 initial batch
setting up sql configuration
2021-12-05 23:41:27 -08:00
Alatreon
ae0d3db59c Add update method for data access 2021-12-05 16:17:05 -08:00
Alatreon
012af8f5d7 Add read method for data access 2021-12-05 16:09:23 -08:00
Lunastra
13204721b2 Add statement to remove 30 days old logs 2021-12-04 23:30:30 -08:00
Lunastra
05a58ee907 Add some code to export old logs to file 2021-12-04 23:23:47 -08:00
Lunastra
78c31ad6c5 Change the result value of Compress( ) and delete some comments 2021-12-04 18:40:19 -08:00
Lunastra
1828f5acbb Added a main to test stuffs
Change return type for Datasource interface.
Add file compression method.
2021-12-04 18:23:15 -08:00
Lunastra
e0af27a177 Change the design to suit with CSV file 2021-12-04 00:33:53 -08:00
Lunastra
92ad047db2 Added some file for Archiving and Dataaccess 2021-12-04 00:30:24 -08:00
long237
82047e09e3
Merge pull request #5 from long237/compressTesting
Adding Data source factory pattern. Fix some conflict in ignore file.
2021-12-03 20:23:04 -08:00
long237
034336fbf2
Merge branch 'master' into compressTesting 2021-12-03 20:22:29 -08:00
Lunastra
96224ef96f Add Factory Design pattern
Factory design patter is added
Some print line for place holder
Need to imiplement Private instances
2021-12-03 20:16:05 -08:00
Lunastra
bcfedfec60 Add VisualStudio ignore files 2021-12-03 20:12:17 -08:00
Lunastra
2dabab9b53 Update gitignore file to ignore vsCode files 2021-12-03 20:07:48 -08:00
Im_Alpha
9f5cd80d0c corrections
sln file
2021-12-03 15:01:29 -08:00
Im_Alpha
ec8634cd16 empty class
testing upload
2021-12-03 14:47:48 -08:00
Im_Alpha
4efa5bc585 ignore vs studio
.
2021-12-03 14:44:23 -08:00
Im_Alpha
77790110bd Revert "source code folder"
This reverts commit a78b0b8f10.
2021-12-03 14:40:44 -08:00
Lunastra
296f7756ce Add display statement to file 2021-12-03 14:28:12 -08:00
Im_Alpha
5be774e5ab Merge branch 'master' of https://github.com/long237/HobbyProject 2021-12-03 14:25:57 -08:00
Im_Alpha
a78b0b8f10 source code folder
added sln file so everyone can just add their cs file to it
2021-12-03 14:25:53 -08:00
Lunastra
641e43030e Add sql code for different sizes 2021-11-30 23:59:59 -08:00
Lunastra
179083fc80 Add perfomance test case for different block size 2021-11-30 23:59:10 -08:00
Lunastra
50bc3aab5f Add tables for testing
Create a tables with 3 million rows to test performance.
2021-11-30 23:20:50 -08:00
Lunastra
a29ac2a030 Add some DML to the file 2021-11-28 22:34:39 -08:00
Lunastra
c321a5f89e add DDL for testing Archiving 2021-11-28 20:48:44 -08:00
Lunastra
d859998c9d Add Singleton class to the diagram 2021-11-27 22:10:39 -08:00
Lunastra
61189d8377 Add archiving with Error Handling 2021-11-24 22:18:18 -08:00
Lunastra
3e17663bf7 Add database resources and low level for archiving
Low level Archiving without connection to database.
2021-11-24 21:14:27 -08:00
Lunastra
6bd4cbb8ab Remove "Relational database" metric 2021-11-14 23:57:22 -08:00
Lunastra
95c0da0cc0 Add amazon RDS approval request 2021-11-11 23:54:35 -08:00
DanBribi
62aa383032
Add files via upload 2021-10-27 18:55:11 -07:00
DanBribi
1e1c379930
Delete Project Roadmap.drawio.png 2021-10-27 18:55:02 -07:00
DanBribi
4815fb669b
Add files via upload 2021-10-27 18:49:28 -07:00
DanBribi
d9f626b24b
Delete Project Roadmap.drawio.png 2021-10-27 18:49:16 -07:00
111 changed files with 6115 additions and 1 deletions

427
.gitignore vendored
View File

@ -2,3 +2,430 @@
venv/ venv/
HaskellCode/.vscode/tasks.json HaskellCode/.vscode/tasks.json
Notes/ Notes/
.vscode/*
!.vscode/launch.json
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Nuget personal access tokens and Credentials
# nuget.config
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true
**/wwwroot/lib/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
.idea/
*.sln.iml
# BeatPulse healthcheck temp database
healthchecksdb
.vscode/launch.json
.vscode/tasks.json
Source Code/.vscode/tasks.json
Source Code/.vscode/launch.json
Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.Archiving.xTests/bin/Debug/net6.0/CoverletSourceRootsMapping
Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/bin/Debug/net6.0/CoverletSourceRootsMapping
Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.Archiving.xTests/bin/Debug/net6.0/CoverletSourceRootsMapping
Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/bin/Debug/net6.0/CoverletSourceRootsMapping

View File

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TeamHobby.HobbyProjectGenerator.DataAccess;
using TeamHobby.HobbyProjectGenerator.UserManagement;
namespace main
{
internal class FileExtract
{
public static void Main(string[] args)
{
string[] lines = { "First line", "Second line", "Third line" };
using StreamWriter file = new ("BulkRequest.txt");
var serviceTest = new AccountService();
string dbType = "sql";
RDSFactory dbFactory = new RDSFactory();
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=hobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Create a file
for (int i = 0; i < 10000; i++)
{
var TestAcc = new UserAccount("newUser" + $"{i}", "4567", $"email{i}@a.com", "regular", DateTime.Now);
file.Write(serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource));
}
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TeamHobby.HobbyProjectGenerator.DataAccessLayer
{
public interface IDataSource<T>
{
// Method for reading data, return 0 for sucessful operation
Object ReadData(T model);
// Method for Writing data to a data source
bool WriteData(T model);
//Method for deleteing data from a data source, 0 for successful
bool DeleteData(T model);
// Method for updating data from a data source, 0 for sucessful
bool UpdateData(T model);
}
}

View File

@ -0,0 +1,275 @@
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.DataAccessLayer
{
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;
}
// TODO: 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)
{
var compFileName = Path.ChangeExtension(fileName, ".gz");
//using FileStream outputFile = File.Create(fileName + ".gz");
using FileStream outputFile = File.Create(compFileName);
using GZipStream compressor = new GZipStream(outputFile, CompressionMode.Compress);
origFile.CopyTo(compressor);
return true;
}
return false;
}
catch (Exception ex)
{
Console.WriteLine("Error when compressing a file !!, will be handled higher up the call stack");
Console.WriteLine(ex.Message);
throw;
}
}
// Copy the Sql data to the a text file
public bool CopyToFile(string filePath){
try
{
_conn.Open();
// Conver backward slash in to forward slash
filePath = filePath.Replace("\\", "/");
string sqlQuery = "SELECT 'LtimeStamp', 'logID', 'LvName', 'catName', 'userOP', 'logMessage' " +
"UNION ALL " +
"SELECT* FROM log " +
"WHERE DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30 " +
"INTO OUTFILE '" + filePath + "'" +
"FIELDS ENCLOSED BY ''" +
"TERMINATED BY ',' " +
"LINES TERMINATED BY '\r\n';";
Console.WriteLine(sqlQuery);
OdbcCommand command = new OdbcCommand(sqlQuery, _conn);
//command.Parameters.AddWithValue("@filePath", filePath);
//command.Prepare();
Console.WriteLine("Output to a file started. ");
command.ExecuteNonQuery();
Console.WriteLine("Output to a file completed. ");
_conn.Close();
return true;
}
catch (Exception ex)
{
_conn.Close();
Console.WriteLine("Error when copying query to a file !!, will be handled higher up the call stack");
throw;
}
finally
{
_conn.Close();
}
}
public bool RemoveOutputFile(string filePath){
try
{
if (File.Exists(filePath))
{
Console.WriteLine("File at: {0} exist, proceed to remove.", filePath);
File.Delete(filePath);
return true;
}
return false;
}
catch {
Console.WriteLine("Removing file failed!!");
throw;
}
}
// Remove data from the database, if failed, let the controller handle it.
public bool RemoveEntries() {
string sqlCmd = "DELETE FROM log WHERE DATEDIFF(current_timestamp, log.LtimeStamp) > 30";
if (DeleteData(sqlCmd) == false)
{
throw new Exception("Error in removing entries,not to worry, will be handled higher up the call stack");
};
return true;
}
//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;
//}
}
}

View File

@ -0,0 +1,36 @@
// Print Statements used throughout the program.
namespace TeamHobby.HobbyProjectGenerator.DataAccessLayer
{
public class UiPrint
{
public void UserManagementMenu(string username)
{
// File must be within the main folder path
// Get the current directory.
string path = Directory.GetCurrentDirectory();
// Menu for all UserManagement options
int menu = 0;
Console.WriteLine("-------------------------------------\n");
Console.WriteLine($"\nWelcome {username} to User Management.\n");
Console.WriteLine("What would you like to do?\n");
Console.WriteLine(menu + ") To exit User Management.\n");
menu += 1;
Console.WriteLine(menu + ") Create a new account.\n");
menu += 1;
Console.WriteLine(menu + ") Edit an account.\n");
menu += 1;
Console.WriteLine(menu + ") Delete an account.\n");
menu += 1;
Console.WriteLine(menu + ") Disable an account.\n");
menu += 1;
Console.WriteLine(menu + ") Enable an account.\n");
menu += 1;
Console.WriteLine(menu + $") Bulk operation from file within the directory.\n{path}\\BulkOps\n");
menu += 1;
Console.WriteLine(menu + ") View log path.\n");
menu += 1;
Console.WriteLine(menu + ") View archive path.\n");
}
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TeamHobby.HobbyProjectGenerator.DataAccessLayer;
namespace TeamHobby.HobbyProjectGenerator.DataAccessLayer
{
public class RDSFactory
{
// Mehthod to create a specific data source suitable to the need
public IDataSource<string> getDataSource(string name, string info)
{
try
{
if (String.Equals(name, "SQL", StringComparison.OrdinalIgnoreCase))
{
return new SqlDAO(info);
}
return null;
}
catch (Exception ex)
{
Console.WriteLine("RelationDataFactory: Data Access object creation failed!");
Console.WriteLine(ex.Message);
return null;
}
}
}
}

View File

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

View File

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

View File

@ -0,0 +1,378 @@
using System;
using System.Data.Odbc;
using System.Diagnostics;
using System.IO;
using System.Threading;
using TeamHobby.HobbyProjectGenerator.Archive;
using TeamHobby.HobbyProjectGenerator.DataAccess;
using Xunit;
using Xunit.Abstractions;
namespace TeamHobby.Archiving.xTests
{
public class ArchivingXUnitTest
{
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
ITestOutputHelper output;
public ArchivingXUnitTest(ITestOutputHelper output)
{
this.output = output;
}
[Fact]
public void IsArchiveFolderCreated()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
string folderPath = @"C:/HobbyArchive";
bool expectedVal = true;
// Act
archiveManager.CreateArchiveFolder();
// Assert
bool actualVal = Directory.Exists(folderPath);
output.WriteLine("Actual value: {0}, Expected value: {1}", actualVal, expectedVal);
Assert.Equal(expectedVal, actualVal);
// Cleaning up directory after test
output.WriteLine("Cleaning up Folder and File used for testing... ");
try
{
Directory.Delete(folderPath, true);
}
catch
{
Console.WriteLine("Folder failed to be deleted");
}
output.WriteLine("Cleaning up completed. ");
}
[Fact]
public void IsFileNameCreated()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
string foldPath = @"C:\HobbyArchive";
string fileName = DateTime.Now.ToString("M_d_yyyy") + "_archive.csv";
string expectedFilePath = System.IO.Path.Combine(foldPath, fileName);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
// Act
string actualFilePath = archiveManager.CreateOutFileName();
// Assert
Assert.Equal(expectedFilePath, actualFilePath);
}
[Fact]
public void IsCSVFileExist()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
SqlDAO sqlDS = null;
string folderPath = @"C:/HobbyArchive";
try
{
bool folderRes = archiveManager.CreateArchiveFolder();
}
catch (Exception ex)
{
Console.WriteLine("Folder creation for copying failed");
}
string filePath = archiveManager.CreateOutFileName();
bool expectedVal = true;
if (sqlDAO.GetType() == typeof(SqlDAO))
{
sqlDS = (SqlDAO)sqlDAO;
}
// Act
if (sqlDS != null)
{
try
{
sqlDS.CopyToFile(filePath);
}
catch (Exception ex)
{
Console.WriteLine("Copying to a file failed !!");
Console.WriteLine(ex.Message);
}
}
// Assert
bool actualVal = File.Exists(filePath);
output.WriteLine("Actual value: {0}, Expected value: {1}", actualVal, expectedVal);
Assert.Equal(expectedVal, actualVal);
output.WriteLine("Cleaning up Folder and File used for testing... ");
try
{
Directory.Delete(folderPath, true);
}
catch
{
Console.WriteLine("Folder failed to be deleted");
}
output.WriteLine("Cleaning up completed. ");
}
[Fact]
public void IsEntriesRemoved()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
OdbcDataReader odbcObj = null;
Object resultData = null;
bool expectedVal = false;
sqlDAO.WriteData("INSERT into log(LtimeStamp, LvName, catname, userop, logmessage) values" +
"('2021-08-07 23:00:00', 'Info', 'View', 'create some projects', 'new account created')," +
"('2021-06-04 23:00:00', 'Info', 'Business', 'create some projects', 'new projects made')," +
"('2021-07-02 23:00:00', 'Info', 'View', 'log out', 'log out successful')," +
"('2021-09-03 23:00:00', 'Info', 'Business', 'log in', 'log in successfully')," +
"('2021-10-20 23:00:00', 'Info', 'View', 'search for projects', 'result return');");
// Act
sqlDAO.RemoveEntries();
// Assert
bool actualVal;
resultData = sqlDAO.ReadData("SELECT * FROM log WHERE DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30;");
if ((resultData != null) && (resultData.GetType() == typeof(OdbcDataReader)))
{
odbcObj = (OdbcDataReader)resultData;
}
OdbcConnection conn = sqlDAO.GetConnection();
actualVal = odbcObj.HasRows;
conn.Close();
output.WriteLine("Actual value: {0}, Expected value: {1}", actualVal, expectedVal);
Assert.Equal(expectedVal, actualVal);
}
[Fact]
public void IsOutputFileRemoved()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
bool expectedVal = false;
//Thread.Sleep(5000);
// Create the folder and the csv file for compressing
archiveManager.CreateArchiveFolder();
string filepath = archiveManager.CreateOutFileName();
sqlDAO.CopyToFile(filepath);
// Act
if (sqlDAO != null)
{
sqlDAO.RemoveOutputFile(filepath);
}
// Assert
bool actualVal = File.Exists(filepath);
Assert.Equal(expectedVal, actualVal);
}
[Fact]
public void IsFileCompressed()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
// Create the folder and the csv file to be compressed.
archiveManager.CreateArchiveFolder();
string filePath = archiveManager.CreateOutFileName();
sqlDAO.CopyToFile(filePath);
FileAttributes expectedAttribute = FileAttributes.Archive;
string compFilePath = Path.ChangeExtension(filePath, ".gz");
// Act
sqlDAO.CompressFile(filePath);
// Assert
FileAttributes actualAttribute = File.GetAttributes(compFilePath);
output.WriteLine("Actual value: {0}, Expected value: {1}", actualAttribute, expectedAttribute);
Assert.Equal(expectedAttribute, actualAttribute);
}
[Fact]
public void IsArchive_Under_60s_10kRecords()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
var timer = new Stopwatch();
double expectedVal = 60;
string folderPath = @"C:/HobbyArchive";
sqlDAO.WriteData("INSERT into log(LtimeStamp, LvName, catname, userop, logmessage) values" +
"('2021-08-07 23:00:00', 'Info', 'View', 'create some projects', 'new account created')," +
"('2021-06-04 23:00:00', 'Info', 'Business', 'create some projects', 'new projects made')," +
"('2021-07-02 23:00:00', 'Info', 'View', 'log out', 'log out successful')," +
"('2021-09-03 23:00:00', 'Info', 'Business', 'log in', 'log in successfully')," +
"('2021-10-20 23:00:00', 'Info', 'View', 'search for projects', 'result return');");
for (int i = 0; i <= 11; i++)
{
sqlDAO.WriteData("INSERT INTO log(LtimeStamp, LvName, catName, userOP, logMessage) " +
"SELECT LtimeStamp, LvName, catName, userOP, logMessage FROM log WHERE DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30;");
}
// Act
timer.Start();
archiveManager.Controller();
timer.Stop();
// Assert
var actualVal = timer.Elapsed.Seconds;
output.WriteLine("Actual value: {0}s, Expected value: {1}s", actualVal, expectedVal);
Assert.True(actualVal < expectedVal);
// Clean up resources after testing
output.WriteLine("Cleaning up Folder and File used for testing... ");
try
{
Directory.Delete(folderPath, true);
}
catch
{
Console.WriteLine("Folder failed to be deleted");
}
output.WriteLine("Cleaning up completed... ");
}
[Fact]
public void IsArchive_Under_60s_1mRecords()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
var timer = new Stopwatch();
double expectedVal = 60;
string folderPath = @"C:/HobbyArchive";
sqlDAO.WriteData("INSERT into log(LtimeStamp, LvName, catname, userop, logmessage) values" +
"('2021-08-07 23:00:00', 'Info', 'View', 'create some projects', 'new account created')," +
"('2021-06-04 23:00:00', 'Info', 'Business', 'create some projects', 'new projects made')," +
"('2021-07-02 23:00:00', 'Info', 'View', 'log out', 'log out successful')," +
"('2021-09-03 23:00:00', 'Info', 'Business', 'log in', 'log in successfully')," +
"('2021-10-20 23:00:00', 'Info', 'View', 'search for projects', 'result return');");
for (int i = 0; i <= 18; i++)
{
sqlDAO.WriteData("INSERT INTO log(LtimeStamp, LvName, catName, userOP, logMessage) " +
"SELECT LtimeStamp, LvName, catName, userOP, logMessage FROM log WHERE DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30;");
}
// Act
timer.Start();
archiveManager.Controller();
timer.Stop();
// Arrange
double actualVal = timer.Elapsed.Seconds;
output.WriteLine("Actual value: {0}s, Expected value: {1}s", actualVal, expectedVal);
Assert.True(actualVal < expectedVal);
output.WriteLine("Cleaning up Folder and File used for testing... ");
//Clean up resources after testing
try
{
Directory.Delete(folderPath, true);
}
catch
{
Console.WriteLine("Folder failed to be deleted");
}
output.WriteLine("Cleaning up completed... ");
}
[Fact]
// [Test Method]
public void IsProcessFlowCompleted()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archive = new ArchiveManager(sqlDAO);
bool expectedVal = true;
bool actualVal = false;
string folderPath = @"C:/HobbyArchive";
// Adding 10000 records to database for testing
sqlDAO.WriteData("INSERT into log(LtimeStamp, LvName, catname, userop, logmessage) values" +
"('2021-08-07 23:00:00', 'Info', 'View', 'create some projects', 'new account created')," +
"('2021-06-04 23:00:00', 'Info', 'Business', 'create some projects', 'new projects made')," +
"('2021-07-02 23:00:00', 'Info', 'View', 'log out', 'log out successful')," +
"('2021-09-03 23:00:00', 'Info', 'Business', 'log in', 'log in successfully')," +
"('2021-10-20 23:00:00', 'Info', 'View', 'search for projects', 'result return');");
for (int j = 0; j <= 11; j++)
{
sqlDAO.WriteData("INSERT INTO log(LtimeStamp, LvName, catName, userOP, logMessage) " +
"SELECT LtimeStamp, LvName, catName, userOP, logMessage FROM log WHERE DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30;");
}
// Act
// Testing archive Manager
int i = -10;
while (i < 20)
{
DateTime date1 = new DateTime(2021, 12, 1, 0, 0, 0);
string currentTime = "00:00:00 AM";
string currentDate = i.ToString();
if (i == 1)
{
currentDate = date1.ToString("dd");
}
//Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime);
Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime);
if (String.Equals(currentDate, "01") && String.Equals(currentTime, "00:00:00 AM"))
{
Console.WriteLine("Archiving process Start");
actualVal = archive.Controller();
}
i++;
}
// Assert
output.WriteLine("Actual value: {0}, Expected value: {1}", actualVal, expectedVal);
Assert.Equal(expectedVal, actualVal);
output.WriteLine("Cleaning up Folder and File used for testing... ");
try
{
Directory.Delete(folderPath, true);
}
catch
{
Console.WriteLine("Folder failed to be deleted");
}
output.WriteLine("Cleaning up completed... ");
}
}
}

View File

@ -0,0 +1,27 @@
<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="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\TeamHobby.HobbyProjectGenerator.Archive\TeamHobby.HobbyProjectGenerator.Archive.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TeamHobby.HobbyProjectGenerator.ServiceLayer
{
public interface IRelationArchivable
{
bool CreateArchived(string fileName);
}
}

View File

@ -0,0 +1,170 @@

using TeamHobby.HobbyProjectGenerator.DataAccessLayer;
namespace TeamHobby.HobbyProjectGenerator.ServiceLayer
{
public class ArchiveManager
{
private IDataSource<string> _conn;
// Constructor to take in the connection.
public ArchiveManager(IDataSource<string> dataSource) {
_conn = dataSource;
}
//public IDataSource<string> GetConnection()
//{
// return _conn;
//}
// Create the folder where the compress file will be stored
public bool CreateArchiveFolder(){
//string curPath = Directory.GetCurrentDirectory();
string curPath = @"C:\";
string folderName = "\\HobbyArchive";
// Find the root drive of the program
string drive = Path.GetPathRoot(path: curPath);
// Check if Drive exists or not
try {
if (!Directory.Exists(drive))
{
Console.WriteLine("Drive {0} not found", drive);
return false;
}
string archiveFolder = curPath + folderName;
//Console.WriteLine("Creating a new folder at: {0}", archiveFolder);
if (!Directory.Exists(archiveFolder))
{
Console.WriteLine("Creating a new folder at: {0}", archiveFolder);
Directory.CreateDirectory(archiveFolder);
//return true;
}
}
catch (Exception ex){
// If the creating a folder failed, return false
return false;
}
return true;
}
// Return the name of the new output file with Path
public string CreateOutFileName() {
try {
// Creating a file name:
string path = @"C:\HobbyArchive";
//string path = Directory.GetCurrentDirectory() + "\\HobbyArchive";
Console.WriteLine("The current directory is {0}", path);
string date = DateTime.Now.ToString("M_d_yyyy");
string fileName = date + "_archive.csv";
string filePath = System.IO.Path.Combine(path, fileName);
Console.WriteLine("Date: {0}", date);
Console.WriteLine("Filepath: {0}", filePath);
return filePath;
}
catch
{
Console.WriteLine("ArchiveCon: Creating a file name failed. ");
return "";
}
}
// put everything toget here
public bool Controller(){
SqlDAO sqlDS = null;
if (_conn.GetType() == typeof(SqlDAO))
{
sqlDS = (SqlDAO)_conn;
}
// Check to make sure that Sql Data source connection is not null
if (sqlDS == null){
return false;
}
// TODO: Remember to add try catch block here to make sure it is completed.
//Creating the folder Archive
Console.WriteLine("Creating a new folder ...");
CreateArchiveFolder();
Console.WriteLine("Creating a new folder completed ...");
Console.WriteLine("----------------");
Console.WriteLine("");
// Creating a file name:
//string filePath = @"C:\HobbyArchive";
//Console.WriteLine("Creating file name ... ");
//string curPath = archive.CreateOutFileName();
Console.WriteLine("Creating Output file name ...");
string outPath = CreateOutFileName();
Console.WriteLine("Output file name created ...");
Console.WriteLine("----------------");
Console.WriteLine("");
//string pathForward = @"C:\Users\Chunchunmaru\Documents\csulbFall2021\HobbyProject\Source Code\main\bin\Debug\net6.0\HobbyArchive";
//string pathTemp = "C:/Temp/oldlogs10.txt";
//string pathTempBack = @"C:\Temp\oldlogs10.txt";
// Try catch block to delete abort the compressing process
try{
//Output SQL to a text file
Console.WriteLine("Copying to a text file ...");
sqlDS.CopyToFile(outPath);
Console.WriteLine("Copying completed ...");
Console.WriteLine("----------------");
Console.WriteLine("");
// Compress the file
Console.WriteLine("Copressing the text file ...");
sqlDS.CompressFile(outPath);
Console.WriteLine("Copression completed ...");
Console.WriteLine("----------------");
Console.WriteLine("");
//Remove output file
Console.WriteLine("Removing the text file ...");
sqlDS.RemoveOutputFile(outPath);
Console.WriteLine("Text File removal completed ...");
Console.WriteLine("----------------");
Console.WriteLine("");
// Remove entries fromt the database
Console.WriteLine("Removing the text file ...");
sqlDS.RemoveEntries();
Console.WriteLine("Entries removal completed ...");
Console.WriteLine("----------------");
Console.WriteLine("");
// Return true if compressing sequence is successful
return true;
}
catch (Exception e){
// Abort the compressing sequence and clean up uneccesary files.
Console.WriteLine("Archiving Sequenced failed. Cleaning up resources.");
// Delete the text output file if any of the process failed
if (File.Exists(outPath)){
File.Delete(outPath);
}
// Delete the compressed file if Removing entries and removing text file output failed
string compFile = outPath + ".gz";
if (File.Exists(compFile)){
File.Delete(compFile);
}
return false;
}
// Testing date time patters
//string date = DateTime.Now.ToString("d");
//Console.WriteLine(date);
//Console.WriteLine(DateTime.Now.ToString("M_d_yyyy_H:mm:ss"));
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TeamHobby.HobbyProjectGenerator.Logging.Contracts;
namespace TeamHobby.HobbyProjectGenerator.ServiceLayer
{
public interface ILogger
{
// private IDataSource<string> _datasource = T;
// attempts to connect to the data source provided by the type T
// returns true if the connection is successful
// public bool Connect();
public bool Log(LogEntry Log);
// IList<string> GetAllLogs();
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TeamHobby.HobbyProjectGenerator.ServiceLayer.Contracts
{
public interface ILoggerFactory
{
ILogger CreateLogger();
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TeamHobby.HobbyProjectGenerator.Logging.Contracts;
namespace TeamHobby.HobbyProjectGenerator.ServiceLayer
{
public class ConsoleLogger : ILogger
{
public bool Log(LogEntry log)
{
return true;
}
}
}

View File

@ -0,0 +1,200 @@
using System;
using System.Data.Odbc;
using TeamHobby.HobbyProjectGenerator.DataAccessLayer;
using TeamHobby.HobbyProjectGenerator.Logging.Contracts;
namespace TeamHobby.HobbyProjectGenerator.ServiceLayer
{
public class DBLogger : ILogger
{
private SqlDAO _datasource;
public DBLogger()
{
}
// SELECT * FROM log
// public IList<LogEntry> GetAllLogs()
// {
// throw new NotImplementedException();
// }
//INSERT INTO log(LvName, catName, userOP, logMessage) VALUES ('Debug','Data', 'SYSTEM', 'testing insert method')
// public bool Connect(SqlDAO logDatabase) {
//
// }
public bool IsActive() {
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=ocalhost;" +
"DATABASE=hbby;" +
"UID=ot;" + // omit password to force SQLException for incorrect passeword
"PASSWORD=wrong" +
"OPTION=3";
// bool isActive = true;
OdbcConnection active = new OdbcConnection(dbInfo);
try {
active.Open();
return false;
}
catch (OdbcException ex) {
// Console.WriteLine(ex.Message);
if (ex.ErrorCode == -2146232009 ) {
//Console.WriteLine(ex.ErrorCode);
Console.WriteLine("Database is active");
return true;
}
else {
Console.WriteLine("Database is inactive");
return false;
}
}
finally {
// Console.WriteLine("closed1");
active.Close();
}
// return false;
}
public bool IsAccessible() {
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
OdbcConnection access = new OdbcConnection(dbInfo);
try {
access.Open();
Console.WriteLine("Database is active and accessible by the system");
return true;
}
catch {
Console.WriteLine("Database is active but inaccessible to the system at this time.");
return false;
}
finally {
access.Close();
}
}
public bool HasCapacity() {
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
OdbcConnection conn = new OdbcConnection(dbInfo);
// get the current capacity of the database in MB using the query:
// SELECT SUM(storage.MB) as CURRENT_CAPACITY_MB FROM (SELECT table_schema as name, ROUND(SUM(data_length + index_length)/1024/1024,1) as MB FROM information_schema.tables GROUP BY table_schema) as storage;
string sqlCurrentCap = $"SELECT SUM(storage.mb) as currentCap FROM (SELECT table_schema as name, ROUND(SUM(data_length + index_length)/1024/1024,1) as mb FROM information_schema.tables GROUP BY table_schema) as storage;";
// get the max capacity in GB; too big to be shown as MB
string sqlMaxCap = $"SELECT SUM(storage.mb) as maxCap FROM (SELECT table_schema as name, ROUND(SUM(max_data_length + max_index_length)/1024,1) as mb FROM information_schema.tables GROUP BY table_schema) as storage;";
// query the data base to get currentCap; the current storage capacity of the system's database (in megabytes)
conn.Open();
OdbcCommand command1 = new OdbcCommand(sqlCurrentCap, conn);
OdbcDataReader result1 = command1.ExecuteReader();
double currentCap = 0;
while (result1.Read()) {
//Console.WriteLine(result1[0].GetType());
//Console.WriteLine("currentCap = {0}", result1[0]);
currentCap = result1.GetDouble(0);
}
// Console.WriteLine(currentCap);
//float currentCap1 = (float) currentCap;
result1.Close();
command1.Dispose();
conn.Close();
// Console.WriteLine("close conn");
// query the data base again to get maxCap; the maximum possible storage capacity of the system's database (in megabytes)
conn.Open();
// Console.WriteLine("open conn");
OdbcCommand command2 = new OdbcCommand(sqlMaxCap, conn);
OdbcDataReader result2 = command2.ExecuteReader();
// Console.WriteLine("open reader 1");
double maxCap = 0;
try {
while (result2.Read()) {
//Console.WriteLine(result2[0].GetType());
maxCap = result2.GetDouble(0);
// Console.WriteLine("maxCap = {0}", result2[0]);
}
// compare currentCap to maxCap
// return true if there is at least 1MB of free space available
// decrement max by 1 MB to allow for any required space from new logs
if ( (currentCap * 1024) < (maxCap - 1024) ) {
// Console.WriteLine(maxCap);
Console.WriteLine("Database has sufficient storage capacity to be written to at this time.\n Current Capacity: {0} MB\n Max Capacity: {1} MB\n", currentCap, maxCap);
}
}
catch {
Console.WriteLine("Insufficient Storage Capacity to log entry to database.\n Current Capacity: {0} MB \n Max Capacity: {1} MB \n", currentCap, maxCap);
return false;
}
finally {
result2.Close();
command2.Dispose();
conn.Close();
}
return false;
}
//Console.WriteLine("close conn 2");
//Console.WriteLine(maxCap);
public bool Log(LogEntry log)
{
log.ShowLog();
//bool status = HasCapacity();
if ( (IsActive() == false || IsAccessible() == false) || (HasCapacity() == false) ) {
return false;
}
else {
// SqlDAO sqlDS = (SqlDAO)_datasource;
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
_datasource = new SqlDAO(dbInfo);
//bool storage = HasCapacity();
try
{
// once connection is confirmed, try inserting the log via SQL statements
string sqlLog = $"INSERT INTO log (Lvname, catName, userOP, logMessage) VALUES ('{log.GetLevel()}','{log.GetCategory()}', " + $"'{log.GetUser()}', '{log.GetDescription()}');";
bool insertNewLog = _datasource.WriteData(sqlLog);
//Console.WriteLine($"Logging Succeeded: The following entry was written to the database: {log}");
// Console.WriteLine(_datasource.ReadData($"SELECT * FROM log;"));
return insertNewLog;
}
// if failed, that means the connection was a sucess but actually writing to the database failed
catch
{
Console.WriteLine("Failed to write log to database; likely due to error in SQL syntax");
return false;
}
}
}
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TeamHobby.HobbyProjectGenerator.ServiceLayer.Contracts;
namespace TeamHobby.HobbyProjectGenerator.ServiceLayer.Implementations
{
public class DBLoggerFactory : ILoggerFactory
{
public DBLoggerFactory()
{
//this._logDatabase = logDatabase;
}
public ILogger CreateLogger() {
return new DBLogger();
}
}
}

View File

@ -0,0 +1,25 @@
using System;
using TeamHobby.HobbyProjectGenerator.Logging.Contracts;
using TeamHobby.HobbyProjectGenerator.ServiceLayer.Contracts;
namespace TeamHobby.HobbyProjectGenerator.ServiceLayer
{
public class FileLogger : ILogger
{
public FileLogger()
{
}
public IList<string> GetAllLogs()
{
throw new NotImplementedException();
}
public bool Log(LogEntry log)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public enum LogLevel
{
Info, Debug, Warning, Error
}
public enum LogCategory
{
View, Business, Server, Data, Datastore
}
namespace TeamHobby.HobbyProjectGenerator.Logging.Contracts
{
// LogEntry is a record type with init properties for each field
// ensures that log entries are immutable after initialization
// LogEntry is a record type with init properties for each field
// ensures that log entries are immutable after initialization
public record LogEntry
{
private LogLevel _level { get; init; }
private LogCategory _category { get; init; }
private string _user { get; init; }
private string _description { get; init; }
// Constructor with args for all fields except timestamp
// timestamp is always set to the UTC time at the time of initialization
public LogEntry(LogLevel level, LogCategory category, string user, string description)
{
this._level = level;
this._category = category;
this._user = user;
this._description = description;
}
// Constructor requiring only the description as an arg
// Assigns default values for LogLevel (Info), LogCategory (Server), user ("System"), and the UTC time at initialization for timestamp
// public LogEntry(string description)
// {
// this._level = LogLevel.Debug;
// this._category = LogCategory.Server;
// this._user = "SYSTEM";
// this._description = description;
// }
public LogLevel GetLevel() {
return this._level;
}
public LogCategory GetCategory() {
return this._category;
}
public string GetUser() {
return this._user;
}
public string GetDescription() {
return this._description;
}
public void ShowLog() {
Console.WriteLine("Timestamp: {0} | Level: {1}, | Category: {2}, | User: {3}, | Description: '{4}' ", DateTime.Now, this._level.ToString(),this._category.ToString(), this._user, this._description);
}
}
}

View File

@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TeamHobby.HobbyProjectGenerator.DataAccessLayer;
using TeamHobby.HobbyProjectGenerator.Logging.Contracts;
using TeamHobby.HobbyProjectGenerator.ServiceLayer.Contracts;
using TeamHobby.HobbyProjectGenerator.ServiceLayer.Implementations;
namespace TeamHobby.HobbyProjectGenerator.ServiceLayer
{
public class LoggingManager
{
// private static IDataSource<string> _datasource;
private ILogger _logger;
private ILoggerFactory _factory;
private LogEntry _logEntry;
// assign default values for LogEntry fields
// these are not readonly because they can be overwritten to specify logging at specific field(s) from the main controller by using the public setters for each field
private LogLevel _level = LogLevel.Debug;
private LogCategory _category = LogCategory.Server;
private string _user = "System";
// Both Constructors take an IDataSource arg to make logging extensible to future data sources
// first constructor has no additional args - defaults to using a DBLoggerFactory to log to database
public LoggingManager()
{
// _datasource = datasource;
_logEntry = new LogEntry(_level, _category, _user, "Logging Manager instantiated");
_factory = new DBLoggerFactory();
_logger = _factory.CreateLogger();
}
// second constructor takes an additional ILoggerFactory arg - allows for extensible logger types
public LoggingManager(ILoggerFactory factory)
{
//_datasource = datasource;
_logEntry = new LogEntry(_level, _category, _user, "Logging Manager instantiated");
_factory = factory;
_logger = _factory.CreateLogger();
}
// // used to create a template entry with the desired fields to write entries at
// public void CreateLog(LogLevel level, LogCategory category, string user, string description) {
// _logEntry = new LogEntry(level,
// category, user, description);
// _logger.Log(_logEntry);
// }
// creates a LogEntry object using a description arg
// uses whateever the current assignments for the other fields ares
public bool CreateLog(string description) {
// creates a LogEntry using the passed in description and current assignements from the necessary fields
_logEntry = new LogEntry(_level, _category, _user, description);
// attempt to log the LogEntry by calling the _logger's Log() method
try {
_logger.Log(_logEntry);
return true;
}
catch {
return false;
}
}
public void Level(LogLevel level) {
this._level = level;
}
public void Category(LogCategory category) {
this._category = category;
}
public void User(string user) {
this._user = user;
}
// public static void Source(IDataSource<string> datasource) {
// _datasource = datasource;
// }
// public static IDataSource<string> GetDataSource() {
// return _datasource;
// }
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="UserManagement\Contracts\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\TeamHobby.HobbyProjectGenerator.DataAccessLayer\TeamHobby.HobbyProjectGenerator.DataAccessLayer.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,301 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Odbc;
using TeamHobby.HobbyProjectGenerator.DataAccessLayer;
namespace TeamHobby.HobbyProjectGenerator.ServiceLayer
{
public class AccountService
{
public bool CreateUserRecord(UserAccount newUser, string CreatedBy, IDataSource<string> dbSource)
{
try
{
// Insert into users table
if (newUser.email == null || newUser.email == "NULL")
{
string sqlUser = $"INSERT INTO users (UserName, Password, Role, IsActive," +
$"CreatedBy, CreatedDate, Email) VALUES ('{newUser.username}', " +
$"'{newUser.password}','{newUser.role}', 1," +
$"'{CreatedBy}', NOW(),{newUser.email});";
bool insertNewUser = dbSource.WriteData(sqlUser);
return insertNewUser;
}
else
{
string sqlUser = $"INSERT INTO users (UserName, Password, Role, IsActive," +
$"CreatedBy, CreatedDate, Email) VALUES ('{newUser.username}', " +
$"'{newUser.password}','{newUser.role}', 1," +
$"'{CreatedBy}', NOW(),'{newUser.email}');";
bool insertNewUser = dbSource.WriteData(sqlUser);
return insertNewUser;
}
}
catch (Exception ex)
{
return false;
}
}
public bool EditUserRecord(UserAccount editUser, string CreatedBy, IDataSource<string> dbSource)
{
try
{
// Insert into users table
if (editUser.email == null || editUser.email == "NULL")
{
string sqlUser = $"UPDATE users t SET t.Password = '{editUser.password}', " +
$"t.Role = '{editUser.role}',t.Email = '{editUser.email}' " +
$"WHERE t.UserName = {editUser.username};";
bool updateNewUser = dbSource.UpdateData(sqlUser);
return updateNewUser;
}
else
{
string sqlUser = $"UPDATE users t SET t.Password = '{editUser.password}', " +
$"t.Role = '{editUser.role}',t.Email = '{editUser.email}' " +
$"WHERE t.UserName = '{editUser.username}';";
bool updateNewUser = dbSource.UpdateData(sqlUser);
return updateNewUser;
}
}
catch (Exception ex)
{
return false;
}
}
public bool DeleteUserRecord(UserAccount deleteUser, string CreatedBy, IDataSource<string> dbSource)
{
try
{
// Insert into users table
string sqlUser = $"DELETE from users WHERE UserName = '{deleteUser.username}' " +
$"and Password = '{deleteUser.password}';";
bool deleteNewUser = dbSource.DeleteData(sqlUser);
return deleteNewUser;
}
catch (Exception ex)
{
return false;
}
}
public bool DisableUser(UserAccount disableUser, string CreatedBy, IDataSource<string> dbSource)
{
try
{
// Insert into users table
string sqlUser = $"UPDATE users u SET u.IsActive = 0 WHERE u.UserName = '{disableUser.username}'" +
$"and u.Role = '{disableUser.role}';";
bool disableNewUser = dbSource.UpdateData(sqlUser);
return disableNewUser;
}
catch (Exception ex)
{
return false;
}
}
public bool EnableUser(UserAccount enableUser, string CreatedBy, IDataSource<string> dbSource)
{
try
{
// Insert into users table
string sqlUser = $"UPDATE users u SET u.IsActive = 1 WHERE u.UserName = '{enableUser.username}'" +
$"and u.Role = '{enableUser.role}';";
bool disableNewUser = dbSource.UpdateData(sqlUser);
return disableNewUser;
}
catch (Exception ex)
{
return false;
}
}
public bool BulkOperation(string signedUser, string path, IDataSource<string> dbSource)
{
try
{
// Get the current directory.
//string path = Directory.GetCurrentDirectory();
// Open file reader stream
using StreamReader fileRead = new(path); // path + + "\\BulkOps\\Bulk.txt"
// Show location of the file being written
//Console.WriteLine(path);
// List choices of operations
List<string> ops = new List<string> {"Create Account", "Edit Account",
"Delete Account", "Disable Account", "Enable Account"};
// List to hold file operation and credentials
List<string> fileList = new List<string>();
string operation = "";
string UN = "";
string PWD = "";
string Role = "";
string Email = "";
// Loop through file rows
while (!fileRead.EndOfStream)
{
// Create variable to hold current line
string line = fileRead.ReadLine();
// Check if line is not empty and contains the separator
if (line != null && line.Contains(":"))
{
// Assign value to hold current line parameter
string value = line.Split(':')[1].Trim();
// Check what operation is being called
if (ops.Contains(value))
{
// Add operation into temp
//Console.WriteLine("Found operation");
//Console.WriteLine(value);
operation = value;
}
else
{
string checkCredential = line.Split(':')[0].Trim();
//Console.WriteLine("Found credential");
switch (checkCredential)
{
case "Username":
UN = value;
break;
case "Password":
PWD = value;
break;
case "Role":
Role = value;
break;
case "Email":
Email = value;
break;
default:
break;
}
}
}
else if(line != null)
{
switch (operation)
{
case "Create Account":
//Console.WriteLine(operation);
if (!String.IsNullOrEmpty(UN))
{
// Create UserAccount object
UserAccount user = new UserAccount(UN, PWD, Email, DateTime.UtcNow);
// Create Account service object
AccountService serviceTest = new AccountService();
serviceTest.CreateUserRecord(user, signedUser, dbSource);
}
break;
case "Edit Account":
//Console.WriteLine(operation);
//Console.WriteLine(operation);
if (String.IsNullOrEmpty(UN))
{
// Create UserAccount object
UserAccount user = new UserAccount(UN, PWD, Email, DateTime.UtcNow);
// Create Account service object
AccountService serviceTest = new AccountService();
serviceTest.CreateUserRecord(user, signedUser, dbSource);
}
break;
case "Delete Account":
//Console.WriteLine(operation);
//Console.WriteLine(operation);
if (String.IsNullOrEmpty(UN))
{
// Create UserAccount object
UserAccount user = new UserAccount(UN, PWD, Email, DateTime.UtcNow);
// Create Account service object
AccountService serviceTest = new AccountService();
serviceTest.CreateUserRecord(user, signedUser, dbSource);
}
break;
case "Disable Account":
//Console.WriteLine(operation);
//Console.WriteLine(operation);
if (String.IsNullOrEmpty(Role) && UN != null)
{
// Create UserAccount object
UserAccount user = new UserAccount(UN, PWD, Email, DateTime.UtcNow);
// Create Account service object
AccountService serviceTest = new AccountService();
serviceTest.CreateUserRecord(user, signedUser, dbSource);
}
else if (String.IsNullOrEmpty(Email) && UN != null)
{
// Create UserAccount object
UserAccount user = new UserAccount(UN, PWD, Role);
// Create Account service object
AccountService serviceTest = new AccountService();
serviceTest.CreateUserRecord(user, signedUser, dbSource);
}
else if (String.IsNullOrEmpty(Role) && String.IsNullOrEmpty(Email) && UN != null)
{
// Create UserAccount object
UserAccount user = new UserAccount(UN, PWD, DateTime.UtcNow);
// Create Account service object
AccountService serviceTest = new AccountService();
serviceTest.CreateUserRecord(user, signedUser, dbSource);
}
break;
case "Enable Account":
//Console.WriteLine(operation);
//Console.WriteLine(operation);
if (String.IsNullOrEmpty(Role) && UN != null)
{
// Create UserAccount object
UserAccount user = new UserAccount(UN, PWD, Email, DateTime.UtcNow);
// Create Account service object
AccountService serviceTest = new AccountService();
serviceTest.CreateUserRecord(user, signedUser, dbSource);
}
else if (String.IsNullOrEmpty(Email) && UN != null)
{
// Create UserAccount object
UserAccount user = new UserAccount(UN, PWD, Role);
// Create Account service object
AccountService serviceTest = new AccountService();
serviceTest.CreateUserRecord(user, signedUser, dbSource);
}
else if (String.IsNullOrEmpty(Role) && String.IsNullOrEmpty(Email) && UN != null)
{
// Create UserAccount object
UserAccount user = new UserAccount(UN, PWD, DateTime.UtcNow);
// Create Account service object
AccountService serviceTest = new AccountService();
serviceTest.CreateUserRecord(user, signedUser, dbSource);
}
break;
default:
break;
}
}
}
fileRead.Close();
return true;
}
catch (Exception e)
{
Console.WriteLine("Error reading file");
Console.WriteLine(e.Message);
return false;
}
}
}
}

View File

@ -0,0 +1,366 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Odbc;
using TeamHobby.HobbyProjectGenerator.DataAccessLayer;
namespace TeamHobby.HobbyProjectGenerator.ServiceLayer
{
public class SystemAccountManager
{
public string IsInputValid(string checkUN, string checkPWD)
{
// Create bool variables to check if username and password are valid
bool validUN = checkUN.All(un=>Char.IsLetterOrDigit(un) || un=='@'
|| un == '.' || un == ',' || un == '!');
bool validPwd = checkPWD.All(Char.IsLetterOrDigit);
// Check if any are empty
if (checkUN == null || checkPWD == null)
{
return "Invalid input\n";
}
// Check if username is within the restricted length
else if (checkUN.Length > 15 || checkUN.Length <= 0
|| validUN is false)
{
return "Invalid Username\n";
}
// Check if password is within the restricted length
else if (checkPWD.Length > 18 || checkPWD.Length <= 0
|| validPwd is false)
{
return "Invalid Password\n";
}
// Check if username and password are valid
else if (checkUN.Length <= 15 && checkUN.Length > 0
&& validUN is true && checkPWD.Length <= 18
&& checkPWD.Length > 0 && validPwd is true)
{
return "Username and password is valid.\n";
}
// Check if username and password and email are valid
else if (checkUN.Length <= 15 && checkUN.Length > 0
&& validUN is true && checkPWD.Length <= 18
&& checkPWD.Length > 0 && validPwd is true)
{
return "Username and password is valid.\n";
}
// For testing to make sure username is valid
else if (checkUN.Length <= 15 && checkUN.Length > 0
&& validUN is true)
{
return "Valid Username\n";
}
// For testing to make sure password is valid
else if (checkPWD.Length <= 18 && checkPWD.Length > 0
&& validPwd is true)
{
return "Valid Password\n";
}
else
{
return "Invalid input\n";
}
}
public string IsInputValid(string checkUN, string checkPWD, string email, string role)
{
// Create bool variables to check if username and password and email are valid
bool validUN = checkUN.All(un => Char.IsLetterOrDigit(un) || un == '@'
|| un == '.' || un == ',' || un == '!');
bool validPwd = checkPWD.All(Char.IsLetterOrDigit);
bool validEmail = email.All(email => Char.IsLetterOrDigit(email) && email == '@'
&& email == '.');
bool validRole = role.All(role => Char.IsLetter(role));
// Check if any are empty
if (checkUN == null || checkPWD == null || email == null)
{
return "Invalid input\n";
}
// Check if username is within the restricted length
else if (checkUN.Length > 15 || checkUN.Length <= 0
|| validUN is false)
{
return "Invalid Username\n";
}
// Check if password is within the restricted length
else if (checkPWD.Length > 18 || checkPWD.Length <= 0
|| validPwd is false)
{
return "Invalid Password\n";
}
// Check if email is within the restricted length
else if (email.Length > 18 || email.Length <= 0
|| validEmail is false)
{
return "Invalid Email.\n";
}
// Check if username and password are valid
else if (checkUN.Length <= 15 && checkUN.Length > 0
&& validUN is true && checkPWD.Length <= 18
&& checkPWD.Length > 0 && validPwd is true)
{
return "Username and password is valid.\n";
}
// Check if username and password and email are valid
else if (checkUN.Length <= 15 && checkUN.Length > 0
&& validUN is true && checkPWD.Length <= 18
&& checkPWD.Length > 0 && validPwd is true
&& email.Length > 18 && email.Length <= 0
&& validEmail is true)
{
return "Username and password is valid.\n";
}
// For testing to make sure username is valid
else if (checkUN.Length <= 15 && checkUN.Length > 0
&& validUN is true)
{
return "Valid Username\n";
}
// For testing to make sure password is valid
else if (checkPWD.Length <= 18 && checkPWD.Length > 0
&& validPwd is true)
{
return "Valid Password\n";
}
// For testing to make sure email is valid
else if (email.Length > 18 && email.Length <= 0
&& validEmail is true)
{
return "Valid Password\n";
}
else
{
return "Invalid input\n";
}
}
// Check with database if user is an admin
public bool isAdmin(UserAccount user, IDataSource<string> dbSource)
{
// string checkAdmin = $"Select * from users where username = {user.username} and password = {user.password};";
string checkAdmin = $"select r.Role from roles r, users u where " +
$"UserName = '{user.username}' and Password = '{user.password}' and r.Role = u.Role;";
Object confirmAdmin = dbSource.ReadData(checkAdmin);
//Console.WriteLine("type of Reesult:" + confirmAdmin.GetType());
OdbcDataReader reader = null;
if (confirmAdmin.GetType() == typeof(OdbcDataReader))
{
reader = (OdbcDataReader)confirmAdmin;
}
// Create String to hold sql output
string checkSql = "";
// Read Sql query results
while (reader.Read())
{
checkSql = reader.GetString(0);
}
SqlDAO sqlDS = (SqlDAO)dbSource;
Console.WriteLine("");
// Closing the connection
sqlDS.GetConnection().Close();
if (checkSql == "Admin")
{
Console.WriteLine("-- Logged in successfully.");
return true;
}
else
{
return false;
}
}
public string CreateUserRecord(UserAccount user, IDataSource<string> dbSource)
{
// Check Login inputs
IsInputValid(user.username, user.password);
bool Admin = isAdmin(user, dbSource);
// Give access if the user is and Admin
if (Admin is false)
{
return "Access Denied: Unauthorized\n";
}
else
{
// db.users layout (UserName, Password, RoleID, IsActive, CreatedBy, CreatedDate)
// db.roles layout (RoleID(AutoGen), Role, CreatedBy, CreatedDate)
// Create UiPrint Object
UiPrint ui = new UiPrint();
// Create Account Service object
AccountService accountService = new AccountService();
// Create credentials object for new inptus
GetCredentials newCredentials = new GetCredentials();
// Create bool object for menu loop
bool menuLoop = true;
// Create loop for menu
while (menuLoop is true) {
// Print User Management menu
ui.UserManagementMenu(user.username);
// Get user choice
int menuChoice = Convert.ToInt32(Console.ReadLine());
// Complete the appropriate action
switch (menuChoice)
{
// Exit menu
case 0:
return "Back to Login";
// Create account
case 1:
// Get all credentials and create newUser
UserAccount newUser = new UserAccount(newCredentials.GetUserName(),
newCredentials.ConfirmPassword(), newCredentials.GetEmail(),
newCredentials.GetRole(), DateTime.UtcNow);
bool accountValid = accountService.CreateUserRecord(newUser, user.username, dbSource);
if (accountValid is true)
{
Console.WriteLine("\nAccount created Successfully");
break;
}
else
{
return "Database Timed out";
}
// Edit account
case 2:
// State what account is being edited
string userName = newCredentials.GetUserName();
// Notify the user of what can be edited
Console.WriteLine($"\n****The following information will be used to update {userName}");
// Get updated parameters
UserAccount newEditUser = new UserAccount(userName,
newCredentials.GetPassword(), newCredentials.GetEmail(),
newCredentials.GetRole(), DateTime.UtcNow);
bool editValid = accountService.EditUserRecord(newEditUser, user.username, dbSource);
if (editValid is true)
{
Console.WriteLine("\nAccount updated Successfully");
break;
}
else
{
return "Database Timed out";
}
break;
// Delete account
case 3:
UserAccount newDeleteUser = new UserAccount(newCredentials.GetUserName(),
newCredentials.GetPassword(), DateTime.UtcNow);
bool deleteValid = accountService.DeleteUserRecord(newDeleteUser, user.username , dbSource);
if (deleteValid is true)
{
Console.WriteLine("\nAccount deleted Successfully");
break;
}
else
{
return "User does not exist";
}
break;
// Disable account
case 4:
UserAccount newDisableUser = new UserAccount(newCredentials.GetUserName(),
newCredentials.GetRole());
bool disableValid = accountService.DisableUser(newDisableUser, user.username , dbSource);
if (disableValid is true)
{
Console.WriteLine("\nAccount disabled Successfully");
break;
}
else
{
return "User does not exist";
}
break;
// Enable account
case 5:
UserAccount newEnableUser = new UserAccount(newCredentials.GetUserName(),
newCredentials.GetRole());
bool enableValid = accountService.EnableUser(newEnableUser, user.username , dbSource);
if (enableValid is true)
{
Console.WriteLine("\nAccount enabled Successfully");
break;
}
else
{
return "User does not exist";
}
break;
// Bulk operation through file
case 6:
AccountService bulkOP = new AccountService();
// Get path to defualt bin location
string path = Directory.GetCurrentDirectory();
while (true)
{
// Get name of file and update path to correct folder
Console.WriteLine("Please input the name of the file:(Example.txt)");
string filename = $"{path}\\{Console.ReadLine()}";
//Console.WriteLine(filename)
// Get filesize
long fileSize = filename.Length;
long fileSizeGB = fileSize / (1024 * 1024);
//Console.WriteLine($"File size is {fileSize}kb");
// Check if input is empty
if (filename == null)
{
Console.WriteLine("Invalid file name.\n");
}
// Check if file is over 2GB
else if (fileSizeGB > 2)
{
Console.WriteLine($"File size is {fileSizeGB}GB\n");
Console.WriteLine("File is too large, please enter a smaller file.\n");
}
else
{
// Begin bulk operation
Console.WriteLine("Running bulk operation...");
bool bulkReq = bulkOP.BulkOperation(user.username, filename, dbSource);
if (bulkReq is true)
{
Console.WriteLine("\nBulk operation complete");
break;
}
else
{
return "Bulk operation failed";
}
}
}
break;
// View logs
case 7:
break;
// View archive
case 8:
Console.WriteLine("C:/HobbyArchive");
break;
default:
Console.WriteLine("Invalid input.\nPlease enter a valid option.\n");
break;
}
}
return "Back to Login";
}
}
}
}

View File

@ -0,0 +1,150 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TeamHobby.HobbyProjectGenerator.ServiceLayer
{ // Class for getting user credentials
public class GetCredentials
{
public string? GetUserName()
{
Console.WriteLine("Please enter a username:");
string? userName = Console.ReadLine();
return userName;
}
public string? GetPassword()
{
Console.WriteLine("Please enter a password:");
string? userPassword = Console.ReadLine();
return userPassword;
}
public string ConfirmPassword()
{
while (true)
{
Console.WriteLine("Please enter a password:");
string? userPassword = Console.ReadLine();
// Confirm Password
Console.WriteLine("Please re-enter the password:");
string checkPsswd = Console.ReadLine();
// Check if passwords match
if (userPassword == checkPsswd)
{
return userPassword;
}
else
{
Console.WriteLine("Passwords do not match.\n");
}
}
}
public string GetEmail()
{
Console.WriteLine("Please enter an email:");
return Console.ReadLine();
}
public string GetRole()
{
while (true)
{
// List of possible roles
List<string> roles = new List<string> {"Admin", "regular" };
// Get role
Console.WriteLine("Please enter the role of the user:(Admin or regular)");
string? userRole = Console.ReadLine();
// Check if passwords match
if (roles.Contains(userRole))
{
return userRole;
}
else
{
Console.WriteLine("Not an available role.\n");
}
}
return Console.ReadLine();
}
}
public class UserAccount
{
// Admin Credentials
private string _userName;
private string _password;
private DateTime _Time;
// New User Credentials
private string _Email;
private string _Role;
public UserAccount(string un, string pwd, DateTime TimeStamp)
{
_userName = un;
_password = pwd;
_Role = "regular";
_Email = "NULL";
_Time = TimeStamp;
}
public UserAccount(string un, string pwd, string role)
{
if (String.IsNullOrEmpty(role))
{
_Role = "regular";
}
else { _Role = role; }
_userName = un;
_password = pwd;
_Email = "NULL";
_Time = DateTime.UtcNow;
}
public UserAccount(string un, string role)
{
_userName = un;
_Role = role;
_Email = "NULL";
_Time = DateTime.UtcNow;
}
public UserAccount(string un, string pwd, string Email, DateTime TimeStamp)
{
if (String.IsNullOrEmpty(Email))
{
_Email = "NULL";
}
else { _Email = Email; }
_userName = un;
_password = pwd;
_Role = "regular";
_Time = TimeStamp;
}
public UserAccount(string newUN, string newPWD, string Email, string role, DateTime newTime)
{
if (String.IsNullOrEmpty(role))
{
_Role = "regular";
}
else { _Role = role; }
if (String.IsNullOrEmpty(Email))
{
_Email = "NULL";
}
else { _Email = Email; }
_userName = newUN;
_password = newPWD;
_Time = newTime;
}
public UserAccount()
{
_Role = "regular";
_Email = "NULL";
_Time = DateTime.Now;
}
public string username { get { return _userName; } }
public string password { get { return _password; } }
public string email { get { return _Email; } }
public string role { get { return _Role; } }
public DateTime Time { get { return _Time; } }
}
}

View File

@ -0,0 +1,378 @@
using System;
using System.Data.Odbc;
using System.Diagnostics;
using System.IO;
using System.Threading;
using TeamHobby.HobbyProjectGenerator.ServiceLayer;
using TeamHobby.HobbyProjectGenerator.DataAccessLayer;
using Xunit;
using Xunit.Abstractions;
namespace TeamHobby.Archiving.xTests
{
public class ArchivingXUnitTest
{
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
ITestOutputHelper output;
public ArchivingXUnitTest(ITestOutputHelper output)
{
this.output = output;
}
[Fact]
public void IsArchiveFolderCreated()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
string folderPath = @"C:/HobbyArchive";
bool expectedVal = true;
// Act
archiveManager.CreateArchiveFolder();
// Assert
bool actualVal = Directory.Exists(folderPath);
output.WriteLine("Actual value: {0}, Expected value: {1}", actualVal, expectedVal);
Assert.Equal(expectedVal, actualVal);
// Cleaning up directory after test
output.WriteLine("Cleaning up Folder and File used for testing... ");
try
{
Directory.Delete(folderPath, true);
}
catch
{
Console.WriteLine("Folder failed to be deleted");
}
output.WriteLine("Cleaning up completed. ");
}
[Fact]
public void IsFileNameCreated()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
string foldPath = @"C:\HobbyArchive";
string fileName = DateTime.Now.ToString("M_d_yyyy") + "_archive.csv";
string expectedFilePath = System.IO.Path.Combine(foldPath, fileName);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
// Act
string actualFilePath = archiveManager.CreateOutFileName();
// Assert
Assert.Equal(expectedFilePath, actualFilePath);
}
[Fact]
public void IsCSVFileExist()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
SqlDAO sqlDS = null;
string folderPath = @"C:/HobbyArchive";
try
{
bool folderRes = archiveManager.CreateArchiveFolder();
}
catch (Exception ex)
{
Console.WriteLine("Folder creation for copying failed");
}
string filePath = archiveManager.CreateOutFileName();
bool expectedVal = true;
if (sqlDAO.GetType() == typeof(SqlDAO))
{
sqlDS = (SqlDAO)sqlDAO;
}
// Act
if (sqlDS != null)
{
try
{
sqlDS.CopyToFile(filePath);
}
catch (Exception ex)
{
Console.WriteLine("Copying to a file failed !!");
Console.WriteLine(ex.Message);
}
}
// Assert
bool actualVal = File.Exists(filePath);
output.WriteLine("Actual value: {0}, Expected value: {1}", actualVal, expectedVal);
Assert.Equal(expectedVal, actualVal);
output.WriteLine("Cleaning up Folder and File used for testing... ");
try
{
Directory.Delete(folderPath, true);
}
catch
{
Console.WriteLine("Folder failed to be deleted");
}
output.WriteLine("Cleaning up completed. ");
}
[Fact]
public void IsEntriesRemoved()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
OdbcDataReader odbcObj = null;
Object resultData = null;
bool expectedVal = false;
sqlDAO.WriteData("INSERT into log(LtimeStamp, LvName, catname, userop, logmessage) values" +
"('2021-08-07 23:00:00', 'Info', 'View', 'create some projects', 'new account created')," +
"('2021-06-04 23:00:00', 'Info', 'Business', 'create some projects', 'new projects made')," +
"('2021-07-02 23:00:00', 'Info', 'View', 'log out', 'log out successful')," +
"('2021-09-03 23:00:00', 'Info', 'Business', 'log in', 'log in successfully')," +
"('2021-10-20 23:00:00', 'Info', 'View', 'search for projects', 'result return');");
// Act
sqlDAO.RemoveEntries();
// Assert
bool actualVal;
resultData = sqlDAO.ReadData("SELECT * FROM log WHERE DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30;");
if ((resultData != null) && (resultData.GetType() == typeof(OdbcDataReader)))
{
odbcObj = (OdbcDataReader)resultData;
}
OdbcConnection conn = sqlDAO.GetConnection();
actualVal = odbcObj.HasRows;
conn.Close();
output.WriteLine("Actual value: {0}, Expected value: {1}", actualVal, expectedVal);
Assert.Equal(expectedVal, actualVal);
}
[Fact]
public void IsOutputFileRemoved()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
bool expectedVal = false;
//Thread.Sleep(5000);
// Create the folder and the csv file for compressing
archiveManager.CreateArchiveFolder();
string filepath = archiveManager.CreateOutFileName();
sqlDAO.CopyToFile(filepath);
// Act
if (sqlDAO != null)
{
sqlDAO.RemoveOutputFile(filepath);
}
// Assert
bool actualVal = File.Exists(filepath);
Assert.Equal(expectedVal, actualVal);
}
[Fact]
public void IsFileCompressed()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
// Create the folder and the csv file to be compressed.
archiveManager.CreateArchiveFolder();
string filePath = archiveManager.CreateOutFileName();
sqlDAO.CopyToFile(filePath);
FileAttributes expectedAttribute = FileAttributes.Archive;
string compFilePath = Path.ChangeExtension(filePath, ".gz");
// Act
sqlDAO.CompressFile(filePath);
// Assert
FileAttributes actualAttribute = File.GetAttributes(compFilePath);
output.WriteLine("Actual value: {0}, Expected value: {1}", actualAttribute, expectedAttribute);
Assert.Equal(expectedAttribute, actualAttribute);
}
[Fact]
public void IsArchive_Under_60s_10kRecords()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
var timer = new Stopwatch();
double expectedVal = 60;
string folderPath = @"C:/HobbyArchive";
sqlDAO.WriteData("INSERT into log(LtimeStamp, LvName, catname, userop, logmessage) values" +
"('2021-08-07 23:00:00', 'Info', 'View', 'create some projects', 'new account created')," +
"('2021-06-04 23:00:00', 'Info', 'Business', 'create some projects', 'new projects made')," +
"('2021-07-02 23:00:00', 'Info', 'View', 'log out', 'log out successful')," +
"('2021-09-03 23:00:00', 'Info', 'Business', 'log in', 'log in successfully')," +
"('2021-10-20 23:00:00', 'Info', 'View', 'search for projects', 'result return');");
for (int i = 0; i <= 11; i++)
{
sqlDAO.WriteData("INSERT INTO log(LtimeStamp, LvName, catName, userOP, logMessage) " +
"SELECT LtimeStamp, LvName, catName, userOP, logMessage FROM log WHERE DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30;");
}
// Act
timer.Start();
archiveManager.Controller();
timer.Stop();
// Assert
var actualVal = timer.Elapsed.Seconds;
output.WriteLine("Actual value: {0}s, Expected value: {1}s", actualVal, expectedVal);
Assert.True(actualVal < expectedVal);
// Clean up resources after testing
output.WriteLine("Cleaning up Folder and File used for testing... ");
try
{
Directory.Delete(folderPath, true);
}
catch
{
Console.WriteLine("Folder failed to be deleted");
}
output.WriteLine("Cleaning up completed... ");
}
[Fact]
public void IsArchive_Under_60s_1mRecords()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archiveManager = new ArchiveManager(sqlDAO);
var timer = new Stopwatch();
double expectedVal = 60;
string folderPath = @"C:/HobbyArchive";
sqlDAO.WriteData("INSERT into log(LtimeStamp, LvName, catname, userop, logmessage) values" +
"('2021-08-07 23:00:00', 'Info', 'View', 'create some projects', 'new account created')," +
"('2021-06-04 23:00:00', 'Info', 'Business', 'create some projects', 'new projects made')," +
"('2021-07-02 23:00:00', 'Info', 'View', 'log out', 'log out successful')," +
"('2021-09-03 23:00:00', 'Info', 'Business', 'log in', 'log in successfully')," +
"('2021-10-20 23:00:00', 'Info', 'View', 'search for projects', 'result return');");
for (int i = 0; i <= 18; i++)
{
sqlDAO.WriteData("INSERT INTO log(LtimeStamp, LvName, catName, userOP, logMessage) " +
"SELECT LtimeStamp, LvName, catName, userOP, logMessage FROM log WHERE DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30;");
}
// Act
timer.Start();
archiveManager.Controller();
timer.Stop();
// Arrange
double actualVal = timer.Elapsed.Seconds;
output.WriteLine("Actual value: {0}s, Expected value: {1}s", actualVal, expectedVal);
Assert.True(actualVal < expectedVal);
output.WriteLine("Cleaning up Folder and File used for testing... ");
//Clean up resources after testing
try
{
Directory.Delete(folderPath, true);
}
catch
{
Console.WriteLine("Folder failed to be deleted");
}
output.WriteLine("Cleaning up completed... ");
}
[Fact]
// [Test Method]
public void IsProcessFlowCompleted()
{
// Arrange
SqlDAO sqlDAO = new SqlDAO(dbInfo);
ArchiveManager archive = new ArchiveManager(sqlDAO);
bool expectedVal = true;
bool actualVal = false;
string folderPath = @"C:/HobbyArchive";
// Adding 10000 records to database for testing
sqlDAO.WriteData("INSERT into log(LtimeStamp, LvName, catname, userop, logmessage) values" +
"('2021-08-07 23:00:00', 'Info', 'View', 'create some projects', 'new account created')," +
"('2021-06-04 23:00:00', 'Info', 'Business', 'create some projects', 'new projects made')," +
"('2021-07-02 23:00:00', 'Info', 'View', 'log out', 'log out successful')," +
"('2021-09-03 23:00:00', 'Info', 'Business', 'log in', 'log in successfully')," +
"('2021-10-20 23:00:00', 'Info', 'View', 'search for projects', 'result return');");
for (int j = 0; j <= 11; j++)
{
sqlDAO.WriteData("INSERT INTO log(LtimeStamp, LvName, catName, userOP, logMessage) " +
"SELECT LtimeStamp, LvName, catName, userOP, logMessage FROM log WHERE DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30;");
}
// Act
// Testing archive Manager
int i = -10;
while (i < 20)
{
DateTime date1 = new DateTime(2021, 12, 1, 0, 0, 0);
string currentTime = "00:00:00 AM";
string currentDate = i.ToString();
if (i == 1)
{
currentDate = date1.ToString("dd");
}
//Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime);
Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime);
if (String.Equals(currentDate, "01") && String.Equals(currentTime, "00:00:00 AM"))
{
Console.WriteLine("Archiving process Start");
actualVal = archive.Controller();
}
i++;
}
// Assert
output.WriteLine("Actual value: {0}, Expected value: {1}", actualVal, expectedVal);
Assert.Equal(expectedVal, actualVal);
output.WriteLine("Cleaning up Folder and File used for testing... ");
try
{
Directory.Delete(folderPath, true);
}
catch
{
Console.WriteLine("Folder failed to be deleted");
}
output.WriteLine("Cleaning up completed... ");
}
}
}

View File

@ -0,0 +1,27 @@
<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="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\main\TeamHobby.HobbyProjectGenerator.Main.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,264 @@
using System;
using Xunit;
using Xunit.Abstractions;
using System.Threading;
using TeamHobby.HobbyProjectGenerator.ServiceLayer;
using TeamHobby.HobbyProjectGenerator.DataAccessLayer;
using System.IO;
namespace TeamHobby.UserManagement.xTests
{
public class UseerManagementTests
{
ITestOutputHelper output;
public UseerManagementTests(ITestOutputHelper output)
{
this.output = output;
}
// User is able to perform any single UM operation within 5 seconds upon invocation.A system message displays “UM operation was successful”
[Fact]
public void SingleOperationinFiveSec()
{
// Arrange
DateTime sTime = DateTime.Now;
var TestAcc = new UserAccount("newUser", "4567", "email@a.com", "regular", sTime);
var serviceTest = new AccountService();
string dbType = "sql";
RDSFactory dbFactory = new RDSFactory();
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Act
// Create a file
serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource);
DateTime eTime = DateTime.Now;
TimeSpan timeDiff = (eTime - sTime);
var sec = timeDiff.TotalSeconds;
// Assert
if (sec > 5)
{
output.WriteLine("Single Operation was unsuccessful");
Assert.True(false);
}
else
{
Assert.True(true);
output.WriteLine("Single Operation was successful");
}
}
// Single UM operation takes longer than 5 seconds
[Fact]
public void FailSingleOperationinFiveSec()
{
// Arrange
DateTime sTime = DateTime.Now;
var TestAcc = new UserAccount("newUser", "4567", "email@a.com", "regular", sTime);
var serviceTest = new AccountService();
string dbType = "sql";
RDSFactory dbFactory = new RDSFactory();
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Act
// Create a file
serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource);
Thread.Sleep(6000);
DateTime eTime = DateTime.Now;
TimeSpan timeDiff = (eTime - sTime);
var sec = timeDiff.TotalSeconds;
// Assert
if (sec > 5)
{
output.WriteLine("Single Operation was unsuccessful");
Assert.False(false);
}
else
{
Assert.True(false);
output.WriteLine("Single Operation was successful");
}
}
// Single UM operation completes within 5 seconds, but no system message is shown or inaccurate system message is shown
[Fact]
public void SingleOperationwithMessage()
{
// Arrange
DateTime sTime = DateTime.Now;
var TestAcc = new UserAccount("newUserMessage", "4567", "email@a.com", "regular", sTime);
var serviceTest = new AccountService();
string dbType = "sql";
RDSFactory dbFactory = new RDSFactory();
var checkMess = false;
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Act
// Create a file
serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource);
DateTime eTime = DateTime.Now;
TimeSpan timeDiff = (eTime - sTime);
var sec = timeDiff.TotalSeconds;
// Assert
if (sec > 5)
{
var message = "Single Operation was unsuccessful";
Assert.False(true);
output.WriteLine(message);
if (checkMess)
{
Assert.False(true);
throw new Exception("Message was not printed");
}
}
else
{
Assert.True(true);
var message2 = "Single Operation was successful";
output.WriteLine(message2);
if (!checkMess)
{
output.WriteLine("Message was printed");
Assert.True(true);
}
}
}
// Bulk UM operations completes within 60 seconds, but no system message is shown or inaccurate system message is shown
[Fact]
public void BulkOperationwithMessage()
{
// Arrange
DateTime sTime = DateTime.Now;
var checkMess = false;
var serviceTest = new AccountService();
string dbType = "sql";
RDSFactory dbFactory = new RDSFactory();
string path = Directory.GetCurrentDirectory();
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Act
// Create a file
//for (int i = 0; i < 10000; i++)
//{
//var TestAcc = new UserAccount("newUser" + $"{i}", "4567", $"email{i}@a.com", "regular", sTime);
serviceTest.BulkOperation("Rifat", path + "\\Bulk.txt", datasource);
//}
DateTime eTime = DateTime.Now;
TimeSpan timeDiff = (eTime - sTime);
var sec = timeDiff.TotalSeconds;
// Assert
if (sec > 60)
{
var message = "Bulk Operation was unsuccessful";
Assert.True(false);
output.WriteLine(message);
if (checkMess)
{
Assert.True(false);
throw new Exception("Message was not printed");
}
}
else
{
Assert.True(true);
var message2 = "Bulk Operation was successful";
output.WriteLine(message2);
if (!checkMess)
{
output.WriteLine("Message was printed");
Assert.True(true);
}
}
}
// User is able to perform less than 10K UM operations in bulk within 60 seconds. A system message displays “Bulk UM operation was successful”
[Fact]
public void BulkOperationforSixty()
{
// Arrange
DateTime sTime = DateTime.Now;
var serviceTest = new AccountService();
string dbType = "sql";
RDSFactory dbFactory = new RDSFactory();
string dir = Directory.GetCurrentDirectory();
string path = dir + "\\Bulk.txt";
output.WriteLine(path);
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Act
// Create a file
//for (int i = 0; i < 10000; i++)
//{
//var TestAcc = new UserAccount("newUser" + $"{i}", "4567", $"email{i}@a.com", "regular", sTime);
serviceTest.BulkOperation("Rifat", path, datasource);
//}
DateTime eTime = DateTime.Now;
TimeSpan timeDiff = (eTime - sTime);
var sec = timeDiff.TotalSeconds;
// Assert
if (sec > 60)
{
output.WriteLine("Bulk Operation was unsuccessful");
Assert.True(false);
}
else
{
Assert.True(true);
output.WriteLine("Bulk Operation was successful");
}
}
}
}

View File

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

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

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

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

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="Contracts\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,86 @@

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.Main", "..\main\TeamHobby.HobbyProjectGenerator.Main.csproj", "{30C7EBF3-3957-46E5-86C1-C13356841ECA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D29D9225-3748-4067-AF07-E677A525EF39}"
ProjectSection(SolutionItems) = preProject
TeamHobby.HobbyProjectGenerator.csproj = TeamHobby.HobbyProjectGenerator.csproj
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Tests", "TeamHobby.HobbyProjectGenerator.Tests\TeamHobby.HobbyProjectGenerator.Tests.csproj", "{2E9DC0A0-D9A1-40A5-9684-ECC8EDCD8DAD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.ServiceLayer", "TeamHobby.HobbyProjectGenerator.ServiceLayer\TeamHobby.HobbyProjectGenerator.ServiceLayer.csproj", "{EF90CC6C-0C44-4E39-AAB6-96F9F34F0784}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.DataAccessLayer", "..\TeamHobby.HobbyProjectGenerator.DataAccessLayer\TeamHobby.HobbyProjectGenerator.DataAccessLayer.csproj", "{6DBAC411-AC0E-4129-AE57-C8D1DA1DF9B2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator.ViewModel", "TeamHobby.HobbyProjectGenerator.ViewModel\TeamHobby.HobbyProjectGenerator.ViewModel.csproj", "{092F7372-3CBA-49A2-A7A8-EC3FF97E3082}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator.View", "TeamHobby.HobbyProjectGenerator.View\TeamHobby.HobbyProjectGenerator.View.csproj", "{2E401E9D-731B-425D-B0BD-FF1E72D5D23C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|x86.ActiveCfg = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|x86.Build.0 = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.Build.0 = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|x86.ActiveCfg = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|x86.Build.0 = Release|Any CPU
{2E9DC0A0-D9A1-40A5-9684-ECC8EDCD8DAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E9DC0A0-D9A1-40A5-9684-ECC8EDCD8DAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E9DC0A0-D9A1-40A5-9684-ECC8EDCD8DAD}.Debug|x86.ActiveCfg = Debug|Any CPU
{2E9DC0A0-D9A1-40A5-9684-ECC8EDCD8DAD}.Debug|x86.Build.0 = Debug|Any CPU
{2E9DC0A0-D9A1-40A5-9684-ECC8EDCD8DAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E9DC0A0-D9A1-40A5-9684-ECC8EDCD8DAD}.Release|Any CPU.Build.0 = Release|Any CPU
{2E9DC0A0-D9A1-40A5-9684-ECC8EDCD8DAD}.Release|x86.ActiveCfg = Release|Any CPU
{2E9DC0A0-D9A1-40A5-9684-ECC8EDCD8DAD}.Release|x86.Build.0 = Release|Any CPU
{EF90CC6C-0C44-4E39-AAB6-96F9F34F0784}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF90CC6C-0C44-4E39-AAB6-96F9F34F0784}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF90CC6C-0C44-4E39-AAB6-96F9F34F0784}.Debug|x86.ActiveCfg = Debug|Any CPU
{EF90CC6C-0C44-4E39-AAB6-96F9F34F0784}.Debug|x86.Build.0 = Debug|Any CPU
{EF90CC6C-0C44-4E39-AAB6-96F9F34F0784}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF90CC6C-0C44-4E39-AAB6-96F9F34F0784}.Release|Any CPU.Build.0 = Release|Any CPU
{EF90CC6C-0C44-4E39-AAB6-96F9F34F0784}.Release|x86.ActiveCfg = Release|Any CPU
{EF90CC6C-0C44-4E39-AAB6-96F9F34F0784}.Release|x86.Build.0 = Release|Any CPU
{6DBAC411-AC0E-4129-AE57-C8D1DA1DF9B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6DBAC411-AC0E-4129-AE57-C8D1DA1DF9B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6DBAC411-AC0E-4129-AE57-C8D1DA1DF9B2}.Debug|x86.ActiveCfg = Debug|Any CPU
{6DBAC411-AC0E-4129-AE57-C8D1DA1DF9B2}.Debug|x86.Build.0 = Debug|Any CPU
{6DBAC411-AC0E-4129-AE57-C8D1DA1DF9B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6DBAC411-AC0E-4129-AE57-C8D1DA1DF9B2}.Release|Any CPU.Build.0 = Release|Any CPU
{6DBAC411-AC0E-4129-AE57-C8D1DA1DF9B2}.Release|x86.ActiveCfg = Release|Any CPU
{6DBAC411-AC0E-4129-AE57-C8D1DA1DF9B2}.Release|x86.Build.0 = Release|Any CPU
{092F7372-3CBA-49A2-A7A8-EC3FF97E3082}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{092F7372-3CBA-49A2-A7A8-EC3FF97E3082}.Debug|Any CPU.Build.0 = Debug|Any CPU
{092F7372-3CBA-49A2-A7A8-EC3FF97E3082}.Debug|x86.ActiveCfg = Debug|Any CPU
{092F7372-3CBA-49A2-A7A8-EC3FF97E3082}.Debug|x86.Build.0 = Debug|Any CPU
{092F7372-3CBA-49A2-A7A8-EC3FF97E3082}.Release|Any CPU.ActiveCfg = Release|Any CPU
{092F7372-3CBA-49A2-A7A8-EC3FF97E3082}.Release|Any CPU.Build.0 = Release|Any CPU
{092F7372-3CBA-49A2-A7A8-EC3FF97E3082}.Release|x86.ActiveCfg = Release|Any CPU
{092F7372-3CBA-49A2-A7A8-EC3FF97E3082}.Release|x86.Build.0 = Release|Any CPU
{2E401E9D-731B-425D-B0BD-FF1E72D5D23C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E401E9D-731B-425D-B0BD-FF1E72D5D23C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E401E9D-731B-425D-B0BD-FF1E72D5D23C}.Debug|x86.ActiveCfg = Debug|Any CPU
{2E401E9D-731B-425D-B0BD-FF1E72D5D23C}.Debug|x86.Build.0 = Debug|Any CPU
{2E401E9D-731B-425D-B0BD-FF1E72D5D23C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E401E9D-731B-425D-B0BD-FF1E72D5D23C}.Release|Any CPU.Build.0 = Release|Any CPU
{2E401E9D-731B-425D-B0BD-FF1E72D5D23C}.Release|x86.ActiveCfg = Release|Any CPU
{2E401E9D-731B-425D-B0BD-FF1E72D5D23C}.Release|x86.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,28 @@
<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="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj" />
<ProjectReference Include="..\..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,264 @@
using System;
using Xunit;
using Xunit.Abstractions;
using System.Threading;
using TeamHobby.HobbyProjectGenerator.UserManagement;
using TeamHobby.HobbyProjectGenerator.DataAccess;
using System.IO;
namespace TeamHobby.UserManagement.xTests
{
public class UseerManagementTests
{
ITestOutputHelper output;
public UseerManagementTests(ITestOutputHelper output)
{
this.output = output;
}
// User is able to perform any single UM operation within 5 seconds upon invocation.A system message displays “UM operation was successful”
[Fact]
public void SingleOperationinFiveSec()
{
// Arrange
DateTime sTime = DateTime.Now;
var TestAcc = new UserAccount("newUser", "4567", "email@a.com", "regular", sTime);
var serviceTest = new AccountService();
string dbType = "sql";
RDSFactory dbFactory = new RDSFactory();
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Act
// Create a file
serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource);
DateTime eTime = DateTime.Now;
TimeSpan timeDiff = (eTime - sTime);
var sec = timeDiff.TotalSeconds;
// Assert
if (sec > 5)
{
output.WriteLine("Single Operation was unsuccessful");
Assert.True(false);
}
else
{
Assert.True(true);
output.WriteLine("Single Operation was successful");
}
}
// Single UM operation takes longer than 5 seconds
[Fact]
public void FailSingleOperationinFiveSec()
{
// Arrange
DateTime sTime = DateTime.Now;
var TestAcc = new UserAccount("newUser", "4567", "email@a.com", "regular", sTime);
var serviceTest = new AccountService();
string dbType = "sql";
RDSFactory dbFactory = new RDSFactory();
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Act
// Create a file
serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource);
Thread.Sleep(6000);
DateTime eTime = DateTime.Now;
TimeSpan timeDiff = (eTime - sTime);
var sec = timeDiff.TotalSeconds;
// Assert
if (sec > 5)
{
output.WriteLine("Single Operation was unsuccessful");
Assert.False(false);
}
else
{
Assert.True(false);
output.WriteLine("Single Operation was successful");
}
}
// Single UM operation completes within 5 seconds, but no system message is shown or inaccurate system message is shown
[Fact]
public void SingleOperationwithMessage()
{
// Arrange
DateTime sTime = DateTime.Now;
var TestAcc = new UserAccount("newUserMessage", "4567", "email@a.com", "regular", sTime);
var serviceTest = new AccountService();
string dbType = "sql";
RDSFactory dbFactory = new RDSFactory();
var checkMess = false;
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Act
// Create a file
serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource);
DateTime eTime = DateTime.Now;
TimeSpan timeDiff = (eTime - sTime);
var sec = timeDiff.TotalSeconds;
// Assert
if (sec > 5)
{
var message = "Single Operation was unsuccessful";
Assert.False(true);
output.WriteLine(message);
if (checkMess)
{
Assert.False(true);
throw new Exception("Message was not printed");
}
}
else
{
Assert.True(true);
var message2 = "Single Operation was successful";
output.WriteLine(message2);
if (!checkMess)
{
output.WriteLine("Message was printed");
Assert.True(true);
}
}
}
// Bulk UM operations completes within 60 seconds, but no system message is shown or inaccurate system message is shown
[Fact]
public void BulkOperationwithMessage()
{
// Arrange
DateTime sTime = DateTime.Now;
var checkMess = false;
var serviceTest = new AccountService();
string dbType = "sql";
RDSFactory dbFactory = new RDSFactory();
string path = Directory.GetCurrentDirectory();
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Act
// Create a file
//for (int i = 0; i < 10000; i++)
//{
//var TestAcc = new UserAccount("newUser" + $"{i}", "4567", $"email{i}@a.com", "regular", sTime);
serviceTest.BulkOperation("Rifat", path + "\\Bulk.txt", datasource);
//}
DateTime eTime = DateTime.Now;
TimeSpan timeDiff = (eTime - sTime);
var sec = timeDiff.TotalSeconds;
// Assert
if (sec > 60)
{
var message = "Bulk Operation was unsuccessful";
Assert.True(false);
output.WriteLine(message);
if (checkMess)
{
Assert.True(false);
throw new Exception("Message was not printed");
}
}
else
{
Assert.True(true);
var message2 = "Bulk Operation was successful";
output.WriteLine(message2);
if (!checkMess)
{
output.WriteLine("Message was printed");
Assert.True(true);
}
}
}
// User is able to perform less than 10K UM operations in bulk within 60 seconds. A system message displays “Bulk UM operation was successful”
[Fact]
public void BulkOperationforSixty()
{
// Arrange
DateTime sTime = DateTime.Now;
var serviceTest = new AccountService();
string dbType = "sql";
RDSFactory dbFactory = new RDSFactory();
string dir = Directory.GetCurrentDirectory();
string path = dir + "\\Bulk.txt";
output.WriteLine(path);
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Act
// Create a file
//for (int i = 0; i < 10000; i++)
//{
//var TestAcc = new UserAccount("newUser" + $"{i}", "4567", $"email{i}@a.com", "regular", sTime);
serviceTest.BulkOperation("Rifat", path, datasource);
//}
DateTime eTime = DateTime.Now;
TimeSpan timeDiff = (eTime - sTime);
var sec = timeDiff.TotalSeconds;
// Assert
if (sec > 60)
{
output.WriteLine("Bulk Operation was unsuccessful");
Assert.True(false);
}
else
{
Assert.True(true);
output.WriteLine("Bulk Operation was successful");
}
}
}
}

View File

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

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

@ -0,0 +1,108 @@
using System;
using System.Data.Odbc;
using TeamHobby.HobbyProjectGenerator.ServiceLayer;
using TeamHobby.HobbyProjectGenerator.DataAccessLayer;
namespace TeamHobby.HobbyProjectGenerator.Main
{
public class Controller
{
public static void Main(string[] args)
{
// Console customization
// Change the look of the console
Console.Title = "HobbyProjectGenerator";
// Change console text color
Console.ForegroundColor = ConsoleColor.Green;
// Change terminal height
Console.WindowHeight = 40;
// Creating the Factory class
// Logger log = new Logger();
//Logger.PrintTest();
// Loop login terminal
bool mainMenu = true;
// Loop Admin login
while (mainMenu is true)
{
// Create credentials object
GetCredentials credentials = new GetCredentials();
// Get DB credentials ***Both values currently hard coded, will update to user input later on.***
string dbUserName = "root";
string dbPassword = "Teamhobby";
// Admin Sign in
Console.WriteLine("\nPlease Enter Admin Credentials " +
"or enter 0 to exit the machine\n");
string? username = credentials.GetUserName();
//int menuExit = Convert.ToInt32(username);
// Exit Infinite Menu
if (username == "0")
{
break;
}
string? password = credentials.GetPassword();
// Get time of login attempt
DateTime TimeStamp = DateTime.UtcNow;
// String for checking query return type
string dbType = "sql";
// Creating the Factory class
RDSFactory dbFactory = new RDSFactory();
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
$"UID={dbUserName};" +
$"PASSWORD={dbPassword};" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// While loop to keep this running forever with UserManagement
// Testing archive Manager
//while (true)
//{
string currentDate = DateTime.Now.ToString("dd");
string currentTime = DateTime.Now.ToString("T");
//Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime);
if (String.Equals(currentDate, "01") && String.Equals(currentTime, "00:00:00 AM"))
{
ArchiveManager archive = new ArchiveManager(datasource);
archive.Controller();
}
//}
// Create manager class from UserManagement
SystemAccountManager manager = new SystemAccountManager();
// Create UserAccount class
UserAccount user = new UserAccount(username, password, TimeStamp);
// Call user object and wait for return string
string isLogin = manager.CreateUserRecord(user, datasource);
// If login is not incorrect and user is returning to login menu
if (isLogin != "Access Denied: Unauthorized\n")
{
Console.WriteLine("Returning to login...\n");
Console.WriteLine("-------------------------------------\n");
}
// If login is incorrect
else
{
Console.WriteLine("******Access Denied: Unauthorized******");
}
}
}
}
}

View File

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TeamHobby.HobbyProjectGenerator.DataAccessLayer;
using TeamHobby.HobbyProjectGenerator.ServiceLayer;
namespace main
{
public class GenerateOpFile
{
public void GenerateOPFile()
//public static void Main(string[] args)
{
try
{
// Get the current directory.
string path = Directory.GetCurrentDirectory();
// Open file stream
using StreamWriter file = new(path + "\\BulkOps\\Bulk.txt", append: true);
// Show location of the file being written
Console.WriteLine(path + "\\BulkOps\\Bulk.txt");
// List choices of operations
List<string> ops = new List<string> {"Create Account", "Edit Account",
"Delete Account", "Disable Account", "Enable Account"};
// Create Account service object
AccountService serviceTest = new AccountService();
// Find database and connect to it
string dbType = "sql";
RDSFactory dbFactory = new RDSFactory();
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Create a file
// Initialize value for random operation
Random random = new Random();
int index = 0;
for (int i = 0; i < 10000; i++)
{
// Choose random operation
index = random.Next(ops.Count);
// Create next dummy data
UserAccount testAcc = new UserAccount("newUser" + $"{i}", "4567", $"email{i}@aol.com", "regular", DateTime.Now);
// Write to file
// Write Operation: for now it is only create accounts to avoid errors
file.WriteLine($"Operation: {ops[0]}");
// Write credentials in the format of: (UserName, Password, Role, IsActive, CreatedBy, CreatedDate, Email)
file.WriteLine($"Username: {testAcc.username}\nPassword: {testAcc.password}\nRole: {testAcc.role}\nEmail: {testAcc.email}\n");
}
file.Close();
}
catch (Exception e)
{
Console.WriteLine("Error reading file");
Console.WriteLine(e.Message);
}
}
}
}

View File

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PlatformTarget>AnyCPU</PlatformTarget>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.DataAccessLayer\TeamHobby.HobbyProjectGenerator.DataAccessLayer.csproj" />
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator\TeamHobby.HobbyProjectGenerator.ServiceLayer\TeamHobby.HobbyProjectGenerator.ServiceLayer.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PlatformTarget>AnyCPU</PlatformTarget>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.Archive\TeamHobby.HobbyProjectGenerator.Archive.csproj" />
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj" />
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.Logging\TeamHobby.HobbyProjectGenerator.Logging.csproj" />
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj" />
</ItemGroup>
</Project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 KiB

After

Width:  |  Height:  |  Size: 314 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

23
doc/Images/references.txt Normal file
View File

@ -0,0 +1,23 @@
https://aws.amazon.com/rds/
https://aws.amazon.com/rds/features/#administration
https://docs.microsoft.com/en-us/azure/mariadb/concepts-supported-versions
https://cloud.google.com/sql/pricing
https://calculator.aws/#/createCalculator/RDSMariaDB
https://azure.microsoft.com/en-us/pricing/calculator/
https://aws.amazon.com/about-aws/whats-new/2019/06/rds-storage-auto-scaling/
https://aws.amazon.com/blogs/database/scaling-your-amazon-rds-instance-vertically-and-horizontally/
https://cloud.google.com/architecture/elastically-scaling-your-mysql-environment
https://techcommunity.microsoft.com/t5/azure-database-support-blog/how-to-auto-scale-azure-sql-databases/ba-p/2235441
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Storage.html
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.MultiAZ.html
https://docs.microsoft.com/en-us/azure/security/fundamentals/encryption-overview
https://cloud.google.com/security/encryption/default-encryption
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.Encryption.html
https://cloud.google.com/compute/docs/regions-zones
https://docs.microsoft.com/en-us/azure/availability-zones/az-overview
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html
https://azure.microsoft.com/en-us/pricing/details/bandwidth/
https://aws.amazon.com/ec2/pricing/on-demand/
https://cloud.google.com/vpc/network-pricing
https://azure.microsoft.com/en-us/pricing/details/azure-sql-database/single/
https://azure.microsoft.com/en-us/pricing/details/azure-sql-managed-instance/single/

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.

View File

@ -0,0 +1,49 @@
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
DataSourceFactory ->DataSourceFactory:DataSourceFactory()\nconstructor
ArchiveController.cs <-- DataSourceFactory:return DataSourceFactory
deactivate DataSourceFactory
activate SQLSource
ArchiveController.cs->SQLSource: IDataSource DataSourceFact.GetDataSource(String sourceName)
SQLSource->SQLSource: SQLSource()\nconstructor
SQLSource --> ArchiveController.cs :return SQLSource
loop #lightblue while true
alt #lightgreen date == 1
ArchiveController.cs -> SQLSource: int Compress(DataConnection conn, IDataSource ds, String logList[])
activate MariaDB
alt #lightgreen archive == 0
SQLSource -> MariaDB: int createArchive(DataConnection conn, String SQLcmd)
MariaDB -->SQLSource:return 0
end
SQLSource ->SQLSource: int updateArchive(DataConnection conn, String logList[])
SQLSource ->MariaDB: int CopremovyEntries(DataConnection conn, String logList[])
MariaDB --> SQLSource: return 0
SQLSource ->MariaDB: int RemoveEntries(DataConnection conn, String logList[])
MariaDB-->SQLSource:return 0
end
deactivate MariaDB
SQLSource-->ArchiveController.cs:return 0
end
deactivate ArchiveController.cs
deactivate SQLSource

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

View 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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,44 @@
title Use Case: Archiving
participant ArchiveController.cs
participant DataSourceFactory
participant SQLSource
participant MariaDB
activate ArchiveController.cs
ArchiveController.cs->DataSourceFactory:new DataSourceFactory()
activate DataSourceFactory
DataSourceFactory ->DataSourceFactory:DataSourceFactory()\nconstructor
ArchiveController.cs <-- DataSourceFactory:return DataSourceFactory
deactivate DataSourceFactory
activate SQLSource
ArchiveController.cs->SQLSource: IDataSource DataSourceFact.GetDataSource(String sourceName)
SQLSource->SQLSource: SQLSource()\nconstructor
SQLSource --> ArchiveController.cs :return SQLSource
loop #lightblue while true
alt #lightgreen date == 1
ArchiveController.cs -> SQLSource: int Compress(DataConnection conn, IDataSource ds, String logList[])
activate MariaDB
alt #lightgreen archive == 0
SQLSource -> MariaDB: int createArchive(DataConnection conn, String SQLcmd)
MariaDB -->SQLSource:return 0
end
SQLSource ->SQLSource: int updateArchive(DataConnection conn, String logList[])
SQLSource ->MariaDB: int CopremovyEntries(DataConnection conn, String logList[])
MariaDB --> SQLSource: return 0
SQLSource ->MariaDB: int RemoveEntries(DataConnection conn, String logList[])
MariaDB-->SQLSource:return 0
end
deactivate MariaDB
SQLSource-->ArchiveController.cs:return 0
end
deactivate ArchiveController.cs
deactivate SQLSource

View File

@ -0,0 +1,63 @@
title Use Case: Archiving
participant ArchiveController.cs
participant DataConnection
participant DataSourceFactory
participant SQLSource
participant MariaDB
activate ArchiveController.cs
ArchiveController.cs ->DataConnection:static DataConnection getDataConnection()
DataConnection -->ArchiveController.cs:return DataConnection
ArchiveController.cs->DataSourceFactory:new DataSourceFactory()
activate DataSourceFactory
DataSourceFactory ->DataSourceFactory:DataSourceFactory()\nconstructor
ArchiveController.cs <-- DataSourceFactory:return DataSourceFactory
deactivate DataSourceFactory
activate SQLSource
ArchiveController.cs->SQLSource: IDataSource DataSourceFact.GetDataSource(String sourceName)
SQLSource->SQLSource: SQLSource()\nconstructor
SQLSource --> ArchiveController.cs :return SQLSource
loop #lightblue while true
alt #lightgreen date == 1
ArchiveController.cs -> SQLSource: int Compress(DataConnection conn, IDataSource ds, String logList[])
activate MariaDB
alt #lightgreen archive == 0 (If Archive have not exist already
SQLSource -> MariaDB: int createArchive(DataConnection conn, String SQLcmd)
SQLSource <-- MariaDB:return 0
end
alt #red No error when doing executing copy SQL command
SQLSource ->SQLSource: int updateArchive(DataConnection conn, String logList[])
SQLSource ->MariaDB: int CopremovyEntries(DataConnection conn, String logList[])
MariaDB --> SQLSource: return 0
SQLSource -->ArchiveController.cs: return 0
else Error occur when executing copy SQL command on Database
MariaDB -->SQLSource: throw SQLException
SQLSource -->ArchiveController.cs: throw SQLException
ArchiveController.cs ->ArchiveController.cs: Console.WriteLine(SQLException.Message) \n (As a form of handling error)
end
alt #red No error when doing executing remove SQL command
SQLSource ->MariaDB: int RemoveEntries(DataConnection conn, String logList[])
MariaDB-->SQLSource:return 0
SQLSource -->ArchiveController.cs: return 0
else Error occur when executing removing SQL command on Database
MariaDB -->SQLSource: throw SQLException
SQLSource -->ArchiveController.cs: throw SQLException
ArchiveController.cs ->ArchiveController.cs: Console.WriteLine(SQLException.Message) \n (As a form of handling error)
end
end
deactivate MariaDB
SQLSource-->ArchiveController.cs:return 0
end
deactivate ArchiveController.cs
deactivate SQLSource

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 KiB

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 KiB

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 KiB

View 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

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
doc/Resources/IJ0350020.pdf Normal file

Binary file not shown.

View File

@ -0,0 +1,2 @@
https://csu-lb.primo.exlibrisgroup.com/permalink/01CALS_ULB/dfriqe/cdi_proquest_journals_2512916339
https://csu-lb.primo.exlibrisgroup.com/permalink/01CALS_ULB/dfriqe/cdi_nrf_kci_oai_kci_go_kr_ARTI_4401754

26
src/Archive/.vscode/launch.json vendored Normal file
View File

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

42
src/Archive/.vscode/tasks.json vendored Normal file
View File

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

View File

@ -0,0 +1,51 @@
using System;
namespace app
{
class ArchiveController{
static void Main(string[] args)
{
string dsName = "SQL";
string cmd = "";
Console.WriteLine("Hello World!");
//SQLConnection myconnection = new SQLConnection();
// Creating a DataSource Factory to make Data sources
DataSourceFactory dsFactory = new DataSourceFactory();
// Creating a SQL data source objects to gain access to the SQL database
IDataSource dataSource = dsFactory.getDataSource("SQL");
// Read from the database
dataSource.ReadData("a");
// Write to the database
dataSource.WriteData("Insert newName");
// Update the datasource
dataSource.UpdateData();
// Delete from the datasource
dataSource.DeleteData();
Console.WriteLine("-----------------");
// Creating a Data Source for text files
IDataSource txtSource = dsFactory.getDataSource("txt");
// Read from the database
txtSource.ReadData("a");
// Write to the database
txtSource.WriteData("a");
// Update the datasource
txtSource.UpdateData();
// Delete from the datasource
txtSource.DeleteData();
}
}
}

View File

@ -0,0 +1,18 @@
class DataSourceFactory{
public IDataSource getDataSource(string name){
if (name == "SQL"){
return new SQLSource();
}
else if (String.Equals(name, "TXT", StringComparison.OrdinalIgnoreCase)){
return new TxtSource();
}
else if(name == "XML"){
return null;
}
else {
return null;
}
}
}

View File

@ -0,0 +1,6 @@
abstract class Factory{
//Method to make a datasource object
public abstract IDataSource getDataSource(string name);
}

View File

@ -0,0 +1,15 @@
interface IDataSource{
// Method for reading data, return 0 for sucessful operation
int ReadData(string cmd);
// Method for Writing data to a data source
int WriteData(string cmd);
//Method for deleteing data from a data source, 0 for successful
int DeleteData();
// Method for updating data from a data source, 0 for sucessful
int UpdateData();
}

View File

Some files were not shown because too many files have changed in this diff Show More