diff --git a/Source Code/TeamHobby.Main/HobbyMain.cs b/Source Code/TeamHobby.Main/HobbyMain.cs index 3d20ec8..7e6146d 100644 --- a/Source Code/TeamHobby.Main/HobbyMain.cs +++ b/Source Code/TeamHobby.Main/HobbyMain.cs @@ -10,7 +10,7 @@ public class HobbyMain Console.WriteLine("Hello World!"); // Testing Compressing a file - string fileName = @"C:\Users\Chunchunmaru\Documents\csulbFall2021\HobbyProject\Source Code\TeamHobby.Main\archiving2.txt"; + string fileName = @"C:\Users\Chunchunmaru\Documents\csulbFall2021\HobbyProject\Source Code\TeamHobby.Main\rando"; //string fileName = @"arhiving2.txt"; FileInfo fileInfo = new FileInfo(fileName); diff --git a/Source Code/TeamHobby.Main/rando b/Source Code/TeamHobby.Main/rando new file mode 100644 index 0000000..a2ba694 --- /dev/null +++ b/Source Code/TeamHobby.Main/rando @@ -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 \ No newline at end of file diff --git a/src/dbCode/ExportingRows.txt b/src/dbCode/ExportingRows.txt new file mode 100644 index 0000000..f4355a1 --- /dev/null +++ b/src/dbCode/ExportingRows.txt @@ -0,0 +1,62 @@ + +select * from log; + +-- Find logs that are older than 30 days of current time. +SELECT * FROM log WHERE DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30; + +-- Output logs to a file +SELECT * FROM log +WHERE + DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30 +INTO OUTFILE 'C:/Temp/oldlogs.csv' +FIELDS ENCLOSED BY '"' +TERMINATED BY ';' +ESCAPED BY '"' +LINES TERMINATED BY '\r\n'; + +-- Output into comma separated file +SELECT * INTO OUTFILE 'C:/Temp/oldlogs2.csv' +FIELDS ENCLOSED BY '"' +TERMINATED BY ',' +ESCAPED BY '"' +LINES TERMINATED BY '\r\n' +FROM log +WHERE + DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30; + +-- Output into comma separated file +SELECT * +INTO OUTFILE 'C:/Temp/oldlogs4.csv' + FIELDS ENCLOSED BY '' + TERMINATED BY ',' + ESCAPED BY '"' + LINES TERMINATED BY '\r\n' +FROM log +WHERE DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30; + +-- Find the name of each columns +SELECT `COLUMN_NAME` +FROM `information_schema`.`COLUMNS` +WHERE `TABLE_SCHEMA` = 'hobby' AND `TABLE_NAME` = 'log'; + +-- Add the column names to the heading of the file +SELECT 'LtimeStamp', 'logID', 'LvName', 'catName', 'userOP', 'logMessage' +UNION ALL +SELECT * FROM log +WHERE + DATEDIFF(CURRENT_TIMESTAMP, log.LtimeStamp) > 30 +INTO OUTFILE 'C:/Temp/oldlogs5.csv' +FIELDS ENCLOSED BY '' +TERMINATED BY ',' +ESCAPED BY '"' +LINES TERMINATED BY '\r\n'; + + +show columns from log; + +SELECT COLUMN_NAME FROM information_schema.COLUMNS; + + +-- Remove logs from the table + +SELECT DATEDIFF('2021-08-07 23:00:00', current_timestamp); \ No newline at end of file