diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/Implementations/SQLSource.cs b/Source Code/TeamHobby.HobbyProjectGenerator.Archive/Implementations/SQLSource.cs index cc6890e..f9c22e4 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.Archive/Implementations/SQLSource.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.Archive/Implementations/SQLSource.cs @@ -12,15 +12,15 @@ namespace TeamHobby.HobbyProjectGenerator.Archive { public class SQLSource : IDataSource, IRelationArchivable { - private SqlConnection conn; + //private SqlConnection conn; - public SQLSource(string info) - { - // Do I put using here to make sure the connection closed once the object is gone? - conn = new SqlConnection(info); - // Perhaps open the connection here? - // conn.Open(); - } + //public SQLSource(string info) + //{ + // // Do I put using here to make sure the connection closed once the object is gone? + // conn = new SqlConnection(info); + // // Perhaps open the connection here? + // // conn.Open(); + //} // The also Identical to update data, maybe only one method is enough public bool DeleteData(string cmd) @@ -33,22 +33,23 @@ namespace TeamHobby.HobbyProjectGenerator.Archive { try { - conn.Open(); + //conn.Open(); //SqlCommand command = new SqlCommand(null, conn); - SqlCommand command = new SqlCommand(cmd, conn); + //SqlCommand command = new SqlCommand(cmd, conn); // conn.Execute(); Console.WriteLine("Access a SQL database"); Console.WriteLine("Select * from archive"); // Execute the command to query the data - using SqlDataReader sqlReader = command.ExecuteReader(); + //using SqlDataReader sqlReader = command.ExecuteReader(); // while (myReader) // Print to console - conn.Close(); - conn.Dispose(); - return sqlReader; + //conn.Close(); + //conn.Dispose(); + //return sqlReader; + return new SqlConnection(); } catch (Exception e) { @@ -62,16 +63,16 @@ namespace TeamHobby.HobbyProjectGenerator.Archive { try { - conn.Open(); - + //conn.Open(); + // Create the SQL command object - SqlCommand command = new SqlCommand(cmd, conn); + //SqlCommand command = new SqlCommand(cmd, conn); // Execute the command to change the rows in a table - command.ExecuteNonQuery(); + //command.ExecuteNonQuery(); - conn.Close(); - conn.Dispose(); + //conn.Close(); + //conn.Dispose(); return true; } catch (Exception e) @@ -124,28 +125,28 @@ namespace TeamHobby.HobbyProjectGenerator.Archive } } - public Object ReadPreparedStmt(string table){ - conn.Open(); - //SqlCommand command = new SqlCommand(null, conn); - SqlCommand command = new SqlCommand("SELECT * from @table;", conn); - SqlParameter tableParam = new SqlParameter("@table", System.Data.SqlDbType.Text, 50); + //public Object ReadPreparedStmt(string table){ + // //conn.Open(); + // //SqlCommand command = new SqlCommand(null, conn); + // SqlCommand command = new SqlCommand("SELECT * from @table;", conn); + // SqlParameter tableParam = new SqlParameter("@table", System.Data.SqlDbType.Text, 50); - tableParam.Value = table; - command.Parameters.Add(tableParam); + // tableParam.Value = table; + // command.Parameters.Add(tableParam); - // conn.Execute(); - Console.WriteLine("Access a SQL database"); - Console.WriteLine("Select * from archive"); + // // conn.Execute(); + // Console.WriteLine("Access a SQL database"); + // Console.WriteLine("Select * from archive"); - // Make the Prepare statement and excute the query: - command.Prepare(); - SqlDataReader sqlReader = command.ExecuteReader(); + // // Make the Prepare statement and excute the query: + // command.Prepare(); + // SqlDataReader sqlReader = command.ExecuteReader(); - // while (myReader) - // Print to console - // conn.close(); - return sqlReader; - } + // // while (myReader) + // // Print to console + // // conn.close(); + // return sqlReader; + //} } } diff --git a/Source Code/TeamHobby.Main/archiving2.txt.gz b/Source Code/TeamHobby.Main/archiving2.txt.gz deleted file mode 100644 index d79034a..0000000 Binary files a/Source Code/TeamHobby.Main/archiving2.txt.gz and /dev/null differ diff --git a/Source Code/TeamHobby.Main/text.cs b/Source Code/TeamHobby.Main/text.cs new file mode 100644 index 0000000..85362c8 --- /dev/null +++ b/Source Code/TeamHobby.Main/text.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TeamHobby.Main +{ + internal class text + { + } +} diff --git a/doc/LowLevel/ArchivingWithSingleton.pdf b/doc/LowLevel/ArchivingWithSingleton.pdf new file mode 100644 index 0000000..bcc6af0 Binary files /dev/null and b/doc/LowLevel/ArchivingWithSingleton.pdf differ diff --git a/doc/LowLevel/ArchvingMasterCon.txt b/doc/LowLevel/ArchvingMasterCon.txt new file mode 100644 index 0000000..008c1e9 --- /dev/null +++ b/doc/LowLevel/ArchvingMasterCon.txt @@ -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 \ No newline at end of file diff --git a/doc/LowLevel/UMLforArchving.png b/doc/LowLevel/UMLforArchving.png new file mode 100644 index 0000000..1017095 Binary files /dev/null and b/doc/LowLevel/UMLforArchving.png differ diff --git a/doc/LowLevel/arcvhingMasterCon.pdf b/doc/LowLevel/arcvhingMasterCon.pdf new file mode 100644 index 0000000..b5e4564 Binary files /dev/null and b/doc/LowLevel/arcvhingMasterCon.pdf differ