Files
bodyshop-uploader/BodyshopUploader/Utils/DiskScan.cs
2023-02-24 15:51:37 -08:00

57 lines
2.0 KiB
C#

using RomeOnlinePartner.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace RomeOnlinePartner.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);
if (!(job is Boolean))
{
EstimatesOnDisk.Add(new ScanResponseItem()
{
Id = job.ciecaid,
Filepath = envfp,
Cieca_Id = job.ciecaid,
Clm_No = job.clm_no,
Owner = job.ownr_fn?.Value + " " + job.ownr_ln?.Value + " " + job.ownr_co_nm?.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;
}
}
}