Created monitoring object and refactored code accordingly.

This commit is contained in:
Patrick Fic
2020-01-17 14:19:49 -08:00
parent 3357a8a564
commit b7218b6771
16 changed files with 217 additions and 76 deletions

View File

@@ -4,6 +4,16 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BodyshopUploader
{
public enum SourceSystem
{
Mitchell = 0,
Audatex = 1,
CCC = 2
}
}
namespace BodyshopUploader.Models
{
public class DTO_QueueItem : DTO_Base
@@ -13,6 +23,13 @@ namespace BodyshopUploader.Models
}
private SourceSystem _source;
public SourceSystem Source
{
get { return _source; }
set { SetProperty(ref _source, value); }
}
private dynamic _job;
public dynamic Job
{

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BodyshopUploader.Models
{
public class Monitor : DTO_Base
{
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
public Monitor()
{
}
private SourceSystem _source;
public SourceSystem Source
{
get { return _source; }
set { SetProperty(ref _source, value); }
}
private string _filePath;
public string FilePath
{
get { return _filePath; }
set { SetProperty(ref _filePath, value); }
}
private string _status;
public string Status
{
get { return _status; }
set { SetProperty(ref _status, value); }
}
private Utils.CIECAMonitor _folderMonitor;
public Utils.CIECAMonitor FolderMonitor
{
get { return _folderMonitor; }
set { SetProperty(ref _folderMonitor, value); }
}
public void StartMonitor()
{
logger.Debug("Starting folder monitor for path {0}", FilePath);
System.IO.Directory.CreateDirectory(FilePath);
FolderMonitor = new Utils.CIECAMonitor(FilePath);
}
public void StopMonitor()
{
logger.Debug("Stopping folder monitor for path {0}", FilePath);
FolderMonitor?.Dispose();
}
}
}