52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using BodyshopPartner.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BodyshopPartner.Utils
|
|
{
|
|
public static class DiskScan
|
|
{
|
|
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
|
|
|
public static async Task<List<ScanResponseItem>> ScanDiskForEstimates()
|
|
{
|
|
List<ScanResponseItem> EstimatesOnDisk = new List<ScanResponseItem>();
|
|
List<string> ad1FilePaths = new List<string>();
|
|
|
|
Properties.Settings.Default.MonitoringPaths.ForEach(mp => ad1FilePaths.AddRange(Directory.GetFiles(mp, "*.env").ToList()));
|
|
|
|
await JobProcessingQueue.GetOpCodes();
|
|
|
|
ad1FilePaths.ForEach(envfp =>
|
|
{
|
|
//Create a DTO_Queue Item to re-use the decoder.
|
|
logger.Info(envfp);
|
|
|
|
DTO_QueueItem item = new DTO_QueueItem()
|
|
{
|
|
FilePath = envfp
|
|
};
|
|
|
|
dynamic job = Utils.Decoder.EstimateDecoder.CIECAEstimateImport.DecodeEstimate(envfp);
|
|
|
|
EstimatesOnDisk.Add(new ScanResponseItem()
|
|
{
|
|
Filepath = envfp,
|
|
Cieca_Id = job.ciecaid,
|
|
Clm_No = job.clm_no,
|
|
Owner = job.ownr_fn?.Value + " " + job.ownr_ln?.Value,
|
|
Ins_Co_Nm = job.ins_co_nm?.Value,
|
|
Vehicle = job.vehicle.data.v_model_yr.Value + " " + job.vehicle.data.v_make_desc.Value + " " + job.vehicle.data.v_model_desc.Value,
|
|
|
|
});
|
|
});
|
|
logger.Info("Estimates found: " + ad1FilePaths.Count);
|
|
return EstimatesOnDisk;
|
|
}
|
|
}
|
|
}
|