Create function to create folder in archive

This commit is contained in:
Lunastra 2021-12-11 18:01:02 -08:00
parent 698aa45318
commit feb2c0abe5
3 changed files with 32 additions and 5 deletions

View File

@ -12,18 +12,33 @@ namespace TeamHobby.HobbyProjectGenerator.Archive
_conn = dataSource; _conn = dataSource;
} }
public IDataSource<string> GetDataSource(){
return _conn;
}
// Create the folder where the compress file will be stored // Create the folder where the compress file will be stored
public bool CreateArchiveFolder(){ public bool CreateArchiveFolder(){
string curPath = Directory.GetCurrentDirectory();
//string temp = @
string archiveFolder = curPath + "\\HobbyArhive";
//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; return true;
} }
// Return the name of the new output file with Path // Return the name of the new output file with Path
public string CreateOutFileName() { public string CreateOutFileName() {
return "hello"; try {
string path = Directory.GetCurrentDirectory();
Console.WriteLine("The current directory is {0}", path);
return path;
}
catch
{
Console.WriteLine("ArchiveCon: Creating a file name failed. ");
return "";
}
} }
// put everything toget here // put everything toget here

View File

@ -1,6 +1,7 @@
using main; using main;
using System; using System;
using System.Data.Odbc; using System.Data.Odbc;
using TeamHobby.HobbyProjectGenerator.Archive;
using TeamHobby.HobbyProjectGenerator.DataAccess; using TeamHobby.HobbyProjectGenerator.DataAccess;
@ -67,6 +68,16 @@ namespace TeamHobby.HobbyProjectGenerator.Main
// Closing the connection // Closing the connection
sqlDS.getConnection().Close(); sqlDS.getConnection().Close();
// Testing archive Manager
ArchiveController archive = new ArchiveController(datasource);
string curPath = archive.CreateOutFileName();
//Creating the folder Archive
Console.WriteLine("Creating a new folder ...");
archive.CreateArchiveFolder();
// 2.Inserting Data into the database: // 2.Inserting Data into the database:
//string sqlWrite = "INSERT into log(lvname, catname, userop, logmessage) values " + //string sqlWrite = "INSERT into log(lvname, catname, userop, logmessage) values " +
// "('Info', 'View', 'Testing DAL stuffs', 'new DAL method tested');"; // "('Info', 'View', 'Testing DAL stuffs', 'new DAL method tested');";

View File

@ -12,6 +12,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.Archive\TeamHobby.HobbyProjectGenerator.Archive.csproj" />
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj" /> <ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj" />
</ItemGroup> </ItemGroup>