feat(FinalizeDocument): aus CommonJobs kopiert, mit einfachen Fehlerbehebungen unter Verwendung von Copilot
- Programmiersprache von VSC zu C# geändert - Framework von .NET Framework zu .NET geändert
This commit is contained in:
72
EnvelopeGenerator.ServiceHost/Jobs/TempFiles.cs
Normal file
72
EnvelopeGenerator.ServiceHost/Jobs/TempFiles.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System.IO;
|
||||
using DigitalData.Modules.Base;
|
||||
using DigitalData.Modules.Logging;
|
||||
|
||||
namespace EnvelopeGenerator.ServiceHost.Jobs;
|
||||
|
||||
public class TempFiles : BaseClass
|
||||
{
|
||||
public string TempPath { get; }
|
||||
|
||||
public TempFiles(LogConfig logConfig) : base(logConfig)
|
||||
{
|
||||
var tempDirectoryPath = Path.GetTempPath();
|
||||
TempPath = Path.Combine(tempDirectoryPath, "EnvelopeGenerator");
|
||||
}
|
||||
|
||||
public bool Create()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(TempPath))
|
||||
{
|
||||
Directory.CreateDirectory(TempPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
CleanUpFiles();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool CleanUpFiles()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var fileItem in Directory.GetFiles(TempPath))
|
||||
{
|
||||
Logger.Debug("Deleting tempPath-file: {0} ...", fileItem);
|
||||
File.Delete(fileItem);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CleanUp()
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.Debug("Deleting tempPath-Data: {0} ...", TempPath);
|
||||
Directory.Delete(TempPath, true);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user