44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using Microsoft.Extensions.Logging;
|
|
using AyaNova.Util;
|
|
using AyaNova.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
namespace AyaNova.Biz
|
|
{
|
|
/// <summary>
|
|
/// called by Generator to keep temp folder squeaky clean
|
|
/// </summary>
|
|
internal static class CoreJobTempFolderCleanup
|
|
{
|
|
private static ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("CoreJobTempFolderCleanup");
|
|
|
|
private static DateTime _lastRun = DateTime.UtcNow;
|
|
private static TimeSpan tsRunEvery = new TimeSpan(0, 0, 1);//every this minutes run the cleanup task
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
//
|
|
public static void DoWork()
|
|
{
|
|
if (DateUtil.IsAfterDuration(_lastRun, tsRunEvery))
|
|
{
|
|
log.LogTrace("Temp cleanup now");
|
|
FileUtil.CleanTemporaryFilesFolder(new TimeSpan(0,5,0));//erase any files found to be older than 5 minutes
|
|
var now = DateTime.UtcNow;
|
|
_lastRun = now;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
}//eoc
|
|
}//eons
|
|
|