diff --git a/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs b/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs index 10df328..1452b74 100644 --- a/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs +++ b/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs @@ -37,7 +37,7 @@ namespace BodyshopUploader.Utils.Decoder ParsePfmFile(ref ret, _dir); //ParseStlFile(ref ret, _dir); //Contains information about the total amounts of the estimate. //ParseTtlFile(ref ret, _dir); - //ParseLinFile(ref ret, _dir); + ParseLinFile(ref ret, _dir); return ret; } @@ -770,6 +770,147 @@ namespace BodyshopUploader.Utils.Decoder } } + public static void ParseLinFile(ref dynamic j, string RootFilePath) + { + if (string.IsNullOrWhiteSpace(j.ciecaid.Value)) + { + return; + } + logger.Trace(@"Parsing LIN at: {0}{1}", RootFilePath, j.ciecaid.Value); + + int retryNumber = 0; + while (retryNumber < 11) + { + try + { + using (Stream fis = File.Open(RootFilePath + j.ciecaid.Value + ".lin", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + //"CAL_LBRMAX may have null values. had to be removed becauase dbf reader expects 0 and not null. + var reader = new DBFReader(fis); + reader.SetSelectFields(new string[] { "LINE_NO", + "LINE_IND", + "LINE_REF", + "TRAN_CODE", + "DB_REF", + "UNQ_SEQ", + "WHO_PAYS", + "LINE_DESC", + "PART_TYPE", + "PART_DESCJ", + "GLASS_FLAG", + "OEM_PARTNO", + "PRICE_INC", + "ALT_PART_I", + "TAX_PART", + "DB_PRICE", + "ACT_PRICE", + "PRICE_J", + "CERT_PART", + "PART_QTY", + "ALT_CO_ID", + "ALT_PARTNO", + "ALT_OVERRD", + "ALT_PARTM", + "PRT_DSMK_P", + "PRT_DSMK_M", + "MOD_LBR_TY", + "DB_HRS", + "MOD_LB_HRS", + "LBR_INC", + "LBR_OP", + "LBR_HRS_J", + "LBR_TYP_J", + "LBR_OP_J", + "PAINT_STG", + "PAINT_TONE", + "LBR_TAX", + "LBR_AMT", + "MISC_AMT", + "MISC_SUBLT", + "MISC_TAX", + "BETT_TYPE", + "BETT_PCTG", + "BETT_AMT", + "BETT_TAX", + + }); + + var allLines = new JArray(); + + for (int i = 0; i < reader.RecordCount; i++) + { + var readValues = reader.NextRecord(); + dynamic lin = new JObject(); + + //Mising est_seq + + //lin.line_no = readValues[0];//LINE_NO + lin.line_ind = readValues[1];//LINE_IND + lin.line_ref = readValues[2];//LINE_REF + //lin.tran_code = readValues[3];//TRAN_CODE + lin.db_ref = readValues[4];//DB_REF + lin.unq_seq = readValues[5];//UNQ_SEQ + //lin.who_pays = readValues[6];//WHO_PAYS + lin.line_desc = readValues[7];//LINE_DESC + lin.part_type = readValues[8];//PART_TYPE + //lin.part_descj = readValues[9];//PART_DESCJ + //lin.glass_flag = readValues[10];//GLASS_FLAG + lin.oem_partno = readValues[11];//OEM_PARTNO + //lin.price_inc = readValues[12];//PRICE_INC + //lin.alt_part_i = readValues[13];//ALT_PART_I + lin.tax_part = readValues[14];//TAX_PART + lin.db_price = readValues[15];//DB_PRICE + lin.act_price = readValues[16];//ACT_PRICE + //lin.price_j = readValues[17];//PRICE_J + //lin.cert_part = readValues[18];//CERT_PART + lin.part_qty = readValues[19];//PART_QTY + //lin.alt_co_id = readValues[20];//ALT_CO_ID + lin.alt_partno = readValues[21];//ALT_PARTNO + //lin.alt_overrd = readValues[22];//ALT_OVERRD + //lin.alt_partm = readValues[23];//ALT_PARTM + //lin.prt_dsmk_p = readValues[24];//PRT_DSMK_P + //lin.prt_dsmk_m = readValues[25];//PRT_DSMK_M + lin.mod_lbr_ty = readValues[26];//MOD_LBR_TY + lin.db_hrs = readValues[27];//DB_HRS + lin.mod_lb_hrs = readValues[28];//MOD_LB_HRS + //lin.lbr_inc = readValues[29];//LBR_INC + lin.lbr_op = readValues[30];//LBR_OP + //lin.lbr_hrs_j = readValues[31];//LBR_HRS_J + //lin.lbr_typ_j = readValues[32];//LBR_TYP_J + //lin.lbr_op_j = readValues[33];//LBR_OP_J + //lin.paint_stg = readValues[34];//PAINT_STG + //lin.paint_tone = readValues[35];//PAINT_TONE + //lin.lbr_tax = readValues[36];//LBR_TAX + lin.lbr_amt = readValues[37];//LBR_AMT + //lin.misc_amt = readValues[38];//MISC_AMT + //lin.misc_sublt = readValues[39];//MISC_SUBLT + //lin.misc_tax = readValues[40];//MISC_TAX + //lin.bett_type = readValues[41];//BETT_TYPE + //lin.bett_pctg = readValues[42];//BETT_PCTG + //lin.bett_amt = readValues[43];//BETT_AMT + //lin.bett_tax = readValues[44];//BETT_TAX + + allLines.Add(lin); + } + + j.joblines = new JObject(); + j.joblines.data = allLines; + + + reader.Dispose(); + return; + } + } + catch (IOException ex) + { + logger.Trace(ex, "Unable to open LIN file. Retrying. "); + retryNumber++; + Thread.Sleep(3000); + } + } + } + + public static void ParseTtlFile(ref dynamic j, string RootFilePath) { if (string.IsNullOrWhiteSpace(j.ciecaid.Value)) { return; } @@ -842,7 +983,7 @@ namespace BodyshopUploader.Utils.Decoder } } - public static void ParseLinFile(ref dynamic j, string RootFilePath) + public static void ParseLinFile_OLD(ref dynamic j, string RootFilePath) { if (string.IsNullOrWhiteSpace(j.ciecaid.Value)) { return; } diff --git a/BodyshopUploader/Utils/JobProcessingQueue.cs b/BodyshopUploader/Utils/JobProcessingQueue.cs index 29bfb34..c7c6c5d 100644 --- a/BodyshopUploader/Utils/JobProcessingQueue.cs +++ b/BodyshopUploader/Utils/JobProcessingQueue.cs @@ -73,7 +73,7 @@ namespace BodyshopUploader.Utils { ThreadPool.UnsafeQueueUserWorkItem(ProcessQueuedItems, null); logger.Error(ex, "Error processing job queue item. "); - throw; + //throw; } } }