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

@@ -23,11 +23,9 @@ namespace BodyshopUploader.Utils.Decoder
/// <returns></returns>
public static dynamic DecodeEstimate(string FilePath)
{
//Sleep the thread so that all files can finish writing.
Thread.Sleep(1000);
dynamic ret = new JObject();
ret.CiecaId = Path.GetFileNameWithoutExtension(FilePath);
ret.ciecaid = Path.GetFileNameWithoutExtension(FilePath);
string _dir = Path.GetDirectoryName(FilePath) + @"\";
@@ -42,18 +40,18 @@ namespace BodyshopUploader.Utils.Decoder
public static void ParseAd1File(ref dynamic j, string RootFilePath)
{
if (string.IsNullOrWhiteSpace(j.CiecaId.Value))
if (string.IsNullOrWhiteSpace(j.ciecaid.Value))
{
return;
}
logger.Trace(@"Parsing AD1 at: {0}{1}", RootFilePath, j.CiecaId.Value);
logger.Trace(@"Parsing AD1 at: {0}{1}", RootFilePath, j.ciecaid.Value);
int retryNumber = 0;
while (retryNumber < 11)
{
try
{
using (Stream fis = File.Open(RootFilePath + j.CiecaId.Value + "A.ad1", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (Stream fis = File.Open(RootFilePath + j.ciecaid.Value + "A.ad1", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
var reader = new DBFReader(fis);
reader.SetSelectFields(new string[] { "INS_CO_NM", "CLM_NO", "OWNR_LN", "OWNR_FN", "OWNR_EA", "OWNR_PH1" });
@@ -80,16 +78,16 @@ namespace BodyshopUploader.Utils.Decoder
public static void ParseVehFile(ref dynamic j, string RootFilePath)
{
if (string.IsNullOrWhiteSpace(j.CiecaId.Value)) { return; }
if (string.IsNullOrWhiteSpace(j.ciecaid.Value)) { return; }
logger.Trace(@"Parsing Veh at: {0}{1}", RootFilePath, j.CiecaId.Value);
logger.Trace(@"Parsing Veh at: {0}{1}", RootFilePath, j.ciecaid.Value);
int retryNumber = 0;
while (retryNumber < 11)
{
try
{
using (Stream fis = File.Open(RootFilePath + j.CiecaId.Value + "v.veh", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (Stream fis = File.Open(RootFilePath + j.ciecaid.Value + "v.veh", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
var reader = new DBFReader(fis);
reader.SetSelectFields(new string[] { "V_MODEL_YR", "V_MAKEDESC", "V_MODEL", "V_COLOR", "PLATE_NO", "V_VIN" });
@@ -115,9 +113,9 @@ namespace BodyshopUploader.Utils.Decoder
public static void ParseTtlFile(ref dynamic j, string RootFilePath)
{
if (string.IsNullOrWhiteSpace(j.CiecaId.Value)) { return; }
if (string.IsNullOrWhiteSpace(j.ciecaid.Value)) { return; }
logger.Trace(@"Parsing Ttl at: {0}{1}", RootFilePath, j.CiecaId.Value);
logger.Trace(@"Parsing Ttl at: {0}{1}", RootFilePath, j.ciecaid.Value);
@@ -126,7 +124,7 @@ namespace BodyshopUploader.Utils.Decoder
{
try
{
using (Stream fis = File.Open(RootFilePath + j.CiecaId.Value + ".ttl", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (Stream fis = File.Open(RootFilePath + j.ciecaid.Value + ".ttl", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
var reader = new DBFReader(fis);
reader.SetSelectFields(new string[] { "G_TTL_AMT" });
@@ -146,9 +144,9 @@ namespace BodyshopUploader.Utils.Decoder
public static void ParseStlFile(ref dynamic j, string RootFilePath)
{
if (string.IsNullOrWhiteSpace(j.CiecaId.Value)) { return; }
if (string.IsNullOrWhiteSpace(j.ciecaid.Value)) { return; }
logger.Trace(@"Parsing Ttl at: {0}{1}", RootFilePath, j.CiecaId.Value);
logger.Trace(@"Parsing Ttl at: {0}{1}", RootFilePath, j.ciecaid.Value);
@@ -157,7 +155,7 @@ namespace BodyshopUploader.Utils.Decoder
{
try
{
using (Stream fis = File.Open(RootFilePath + j.CiecaId.Value + ".stl", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (Stream fis = File.Open(RootFilePath + j.ciecaid.Value + ".stl", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
var reader = new DBFReader(fis);
reader.SetSelectFields(new string[] { "TTL_TYPECD", "T_HRS" });
@@ -192,9 +190,9 @@ namespace BodyshopUploader.Utils.Decoder
public static void ParseLinFile(ref dynamic j, string RootFilePath)
{
if (string.IsNullOrWhiteSpace(j.CiecaId.Value)) { return; }
if (string.IsNullOrWhiteSpace(j.ciecaid.Value)) { return; }
logger.Trace(@"Parsing Ttl at: {0}{1}", RootFilePath, j.CiecaId.Value);
logger.Trace(@"Parsing Ttl at: {0}{1}", RootFilePath, j.ciecaid.Value);
//j.JobSublets = new List<JobSublet>();
string _maxSupp = "";
@@ -204,7 +202,7 @@ namespace BodyshopUploader.Utils.Decoder
{
try
{
using (Stream fis = File.Open(RootFilePath + j.CiecaId.Value + ".lin", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (Stream fis = File.Open(RootFilePath + j.ciecaid.Value + ".lin", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
var reader = new DBFReader(fis);
reader.SetSelectFields(new string[] { "PART_TYPE", "LINE_DESC", "UNQ_SEQ", "LINE_IND" });