Process flowed testing for compress sequence

This commit is contained in:
Lunastra 2021-12-11 23:40:39 -08:00
parent 421637bda7
commit b89e4f69c4
3 changed files with 33 additions and 5 deletions

View File

@ -65,9 +65,10 @@ namespace TeamHobby.HobbyProjectGenerator.Archive
{
//string path = archivePath + "\\HobbyArchive";
Console.WriteLine("The current directory is {0}", archivePath);
//string date = DateTime.Now.ToString("M_d_yyyy_H:mm:ss");
string date = DateTime.Now.ToString("M_d_yyyy");
string fileName = date + "_archive.csv";
string filePath = System.IO.Path.Combine(archivePath, fileName);
string filePath = Path.Combine(archivePath, fileName);
Console.WriteLine("Date: {0}", date);
Console.WriteLine("Filepath: {0}", filePath);

View File

@ -217,13 +217,26 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess
}
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!!");
return false;
}
}
// Remove data from the database, if failed, let the controller handle it.
public bool RemoveEntries() {
string sqlCmd = "DELETE FROM log WHERE DATE_DIFF(current_timestamp, log.LtimeStamp) > 30";
string sqlCmd = "DELETE FROM log WHERE DATEDIFF(current_timestamp, log.LtimeStamp) > 30";
try{
DeleteData(sqlCmd);

View File

@ -78,18 +78,32 @@ namespace TeamHobby.HobbyProjectGenerator.Main
// Creating a file name:
string filePath = @"C:\HobbyArchive";
Console.WriteLine("Creating file name ... ");
//Console.WriteLine("Creating file name ... ");
//string curPath = archive.CreateOutFileName();
string curPath = archive.CreateOutFileName(filePath);
//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";
//Console.WriteLine("----------------");
Console.WriteLine("----------------");
//Output SQL to a text file
sqlDS.CopyToFile(curPath);
// Compress the file
sqlDS.CompressFile(curPath);
//Remove output file
sqlDS.RemoveOutputFile(curPath);
// Remove entries fromt the database
sqlDS.RemoveEntries();
// Testing date time patters
//string date = DateTime.Now.ToString("d");
//Console.WriteLine(date);
//Console.WriteLine(DateTime.Now.ToString("M_d_yyyy_H:mm:ss"));
// 2.Inserting Data into the database:
//string sqlWrite = "INSERT into log(lvname, catname, userop, logmessage) values " +