diff --git a/BodyshopUploader/ImEXOnlinePartner.csproj b/BodyshopUploader/ImEXOnlinePartner.csproj index 27b6772..54b960f 100644 --- a/BodyshopUploader/ImEXOnlinePartner.csproj +++ b/BodyshopUploader/ImEXOnlinePartner.csproj @@ -361,16 +361,16 @@ 3.7.2 - 4.0.1 + 5.1.0 - 4.0.1 + 5.1.0 1.1.0 - 4.2.1 + 4.5.0 4.7.0 @@ -405,7 +405,7 @@ 3.1.0 - 107.3.0 + 108.0.1 1.0.6 diff --git a/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs b/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs index 5a6ecb5..19dc2c0 100644 --- a/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs +++ b/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs @@ -100,13 +100,27 @@ namespace BodyshopPartner.Utils.Decoder { try { - using (Stream fis = File.Open(RootFilePath + j.ciecaid.Value + "A.ad1", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + Stream fis = null; + try { - var reader = new DBFReader(fis); + fis = File.Open(RootFilePath + j.ciecaid.Value + "A.ad1", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); - var type = reader.GetType(); - logger.Trace(reader.Fields.ToString()); - reader.SetSelectFields(new string[] { "INS_CO_ID","INS_CO_NM","INS_ADDR1","INS_ADDR2","INS_CITY","INS_ST","INS_ZIP","INS_CTRY", + } + catch (Exception ex) + { + logger.Warn("*A.ad1 could not be opened."); + } + if (fis == null) + { + fis = File.Open(RootFilePath + j.ciecaid.Value + ".ad1", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + + } + + var reader = new DBFReader(fis); + + var type = reader.GetType(); + logger.Trace(reader.Fields.ToString()); + reader.SetSelectFields(new string[] { "INS_CO_ID","INS_CO_NM","INS_ADDR1","INS_ADDR2","INS_CITY","INS_ST","INS_ZIP","INS_CTRY", "INS_EA","POLICY_NO","DED_AMT","DED_STATUS","ASGN_NO","ASGN_DATE","ASGN_TYPE","CLM_NO","CLM_OFC_ID","CLM_OFC_NM","CLM_ADDR1", "CLM_ADDR2","CLM_CITY","CLM_ST","CLM_ZIP","CLM_CTRY","CLM_PH1","CLM_PH1X","CLM_PH2","CLM_PH2X","CLM_FAX","CLM_FAXX","CLM_CT_LN", @@ -119,207 +133,208 @@ namespace BodyshopPartner.Utils.Decoder "OWNR_ADDR1","OWNR_ADDR2","OWNR_CITY","OWNR_ST","OWNR_ZIP","OWNR_CTRY","OWNR_PH1","OWNR_PH1X","OWNR_PH2","OWNR_PH2X","OWNR_FAX","OWNR_FAXX", "OWNR_EA", "INS_PH1","INS_PH1X","INS_PH2","INS_PH2X","INS_FAX","INS_FAXX","INS_CT_LN","INS_CT_FN","INS_TITLE","INS_CT_PH","INS_CT_PHX", "LOSS_CAT", }); - var readValues = reader.NextRecord(); + var readValues = reader.NextRecord(); - dynamic ownerRoot = new JObject(); + dynamic ownerRoot = new JObject(); - j.ins_co_id = readValues[0]; - j.ins_co_nm = readValues[1]; - j.ins_addr1 = readValues[2]; - j.ins_addr2 = readValues[3]; - j.ins_city = readValues[4]; - j.ins_st = readValues[5]; - j.ins_zip = readValues[6]; - j.ins_ctry = readValues[7]; - j.ins_ea = readValues[8]; - j.policy_no = readValues[9]; - j.ded_amt = readValues[10]; - j.ded_status = readValues[11]; - j.asgn_no = readValues[12]; - j.asgn_date = readValues[13]; - j.asgn_type = readValues[14]; - j.clm_no = readValues[15]; - j.clm_ofc_id = readValues[16]; - j.clm_ofc_nm = readValues[17]; - j.clm_addr1 = readValues[18]; - j.clm_addr2 = readValues[19]; - j.clm_city = readValues[20]; - j.clm_st = readValues[21]; - j.clm_zip = readValues[22]; - j.clm_ctry = readValues[23]; - j.clm_ph1 = readValues[24]; - j.clm_ph1x = readValues[25]; - j.clm_ph2 = readValues[26]; - j.clm_ph2x = readValues[27]; - j.clm_fax = readValues[28]; - j.clm_faxx = readValues[29]; - j.clm_ct_ln = readValues[30]; - j.clm_ct_fn = readValues[31]; - j.clm_title = readValues[32]; - j.clm_ct_ph = readValues[33]; - j.clm_ct_phx = readValues[34]; - j.clm_ea = readValues[35]; - j.payee_nms = readValues[36]; - j.pay_type = readValues[37]; - j.pay_date = readValues[38]; - j.pay_chknm = readValues[39]; - j.pay_amt = readValues[40]; - j.agt_co_id = readValues[41]; - j.agt_co_nm = readValues[42]; - j.agt_addr1 = readValues[43]; - j.agt_addr2 = readValues[44]; - j.agt_city = readValues[45]; - j.agt_st = readValues[46]; - j.agt_zip = readValues[47]; - j.agt_ctry = readValues[48]; - j.agt_ph1 = readValues[49]; - j.agt_ph1x = readValues[50]; - j.agt_ph2 = readValues[51]; - j.agt_ph2x = readValues[52]; - j.agt_fax = readValues[53]; - j.agt_faxx = readValues[54]; - j.agt_ct_ln = readValues[55]; - j.agt_ct_fn = readValues[56]; - j.agt_ct_ph = readValues[57]; - j.agt_ct_phx = readValues[58]; - j.agt_ea = readValues[59]; - j.agt_lic_no = readValues[60]; - j.loss_date = readValues[61]; - j.loss_type = readValues[62]; - j.loss_desc = readValues[63]; - j.theft_ind = readValues[64]; //BOOL - j.cat_no = readValues[65]; - j.tlos_ind = readValues[66]; - j.cust_pr = readValues[67]; - j.insd_ln = readValues[68]; - j.insd_fn = readValues[69]; - j.insd_title = readValues[70]; - j.insd_co_nm = readValues[71]; - j.insd_addr1 = readValues[72]; - j.insd_addr2 = readValues[73]; - j.insd_city = readValues[74]; - j.insd_st = readValues[75]; - j.insd_zip = readValues[76]; - j.insd_ctry = readValues[77]; - j.insd_ph1 = readValues[78]; - j.insd_ph1x = readValues[79]; - j.insd_ph2 = readValues[80]; - j.insd_ph2x = readValues[81]; - j.insd_fax = readValues[82]; - j.insd_faxx = readValues[83]; - j.insd_ea = readValues[84]; - j.ownr_ln = readValues[85]; - j.ownr_fn = readValues[86]; - j.ownr_title = readValues[87]; - j.ownr_co_nm = readValues[88]; - j.ownr_addr1 = readValues[89]; - j.ownr_addr2 = readValues[90]; - j.ownr_city = readValues[91]; - j.ownr_st = readValues[92]; - j.ownr_zip = readValues[93]; - j.ownr_ctry = readValues[94]; - j.ownr_ph1 = readValues[95]; + j.ins_co_id = readValues[0]; + j.ins_co_nm = readValues[1]; + j.ins_addr1 = readValues[2]; + j.ins_addr2 = readValues[3]; + j.ins_city = readValues[4]; + j.ins_st = readValues[5]; + j.ins_zip = readValues[6]; + j.ins_ctry = readValues[7]; + j.ins_ea = readValues[8]; + j.policy_no = readValues[9]; + j.ded_amt = readValues[10]; + j.ded_status = readValues[11]; + j.asgn_no = readValues[12]; + j.asgn_date = readValues[13]; + j.asgn_type = readValues[14]; + j.clm_no = readValues[15]; + j.clm_ofc_id = readValues[16]; + j.clm_ofc_nm = readValues[17]; + j.clm_addr1 = readValues[18]; + j.clm_addr2 = readValues[19]; + j.clm_city = readValues[20]; + j.clm_st = readValues[21]; + j.clm_zip = readValues[22]; + j.clm_ctry = readValues[23]; + j.clm_ph1 = readValues[24]; + j.clm_ph1x = readValues[25]; + j.clm_ph2 = readValues[26]; + j.clm_ph2x = readValues[27]; + j.clm_fax = readValues[28]; + j.clm_faxx = readValues[29]; + j.clm_ct_ln = readValues[30]; + j.clm_ct_fn = readValues[31]; + j.clm_title = readValues[32]; + j.clm_ct_ph = readValues[33]; + j.clm_ct_phx = readValues[34]; + j.clm_ea = readValues[35]; + j.payee_nms = readValues[36]; + j.pay_type = readValues[37]; + j.pay_date = readValues[38]; + j.pay_chknm = readValues[39]; + j.pay_amt = readValues[40]; + j.agt_co_id = readValues[41]; + j.agt_co_nm = readValues[42]; + j.agt_addr1 = readValues[43]; + j.agt_addr2 = readValues[44]; + j.agt_city = readValues[45]; + j.agt_st = readValues[46]; + j.agt_zip = readValues[47]; + j.agt_ctry = readValues[48]; + j.agt_ph1 = readValues[49]; + j.agt_ph1x = readValues[50]; + j.agt_ph2 = readValues[51]; + j.agt_ph2x = readValues[52]; + j.agt_fax = readValues[53]; + j.agt_faxx = readValues[54]; + j.agt_ct_ln = readValues[55]; + j.agt_ct_fn = readValues[56]; + j.agt_ct_ph = readValues[57]; + j.agt_ct_phx = readValues[58]; + j.agt_ea = readValues[59]; + j.agt_lic_no = readValues[60]; + j.loss_date = readValues[61]; + j.loss_type = readValues[62]; + j.loss_desc = readValues[63]; + j.theft_ind = readValues[64]; //BOOL + j.cat_no = readValues[65]; + j.tlos_ind = readValues[66]; + j.cust_pr = readValues[67]; + j.insd_ln = readValues[68]; + j.insd_fn = readValues[69]; + j.insd_title = readValues[70]; + j.insd_co_nm = readValues[71]; + j.insd_addr1 = readValues[72]; + j.insd_addr2 = readValues[73]; + j.insd_city = readValues[74]; + j.insd_st = readValues[75]; + j.insd_zip = readValues[76]; + j.insd_ctry = readValues[77]; + j.insd_ph1 = readValues[78]; + j.insd_ph1x = readValues[79]; + j.insd_ph2 = readValues[80]; + j.insd_ph2x = readValues[81]; + j.insd_fax = readValues[82]; + j.insd_faxx = readValues[83]; + j.insd_ea = readValues[84]; + j.ownr_ln = readValues[85]; + j.ownr_fn = readValues[86]; + j.ownr_title = readValues[87]; + j.ownr_co_nm = readValues[88]; + j.ownr_addr1 = readValues[89]; + j.ownr_addr2 = readValues[90]; + j.ownr_city = readValues[91]; + j.ownr_st = readValues[92]; + j.ownr_zip = readValues[93]; + j.ownr_ctry = readValues[94]; + j.ownr_ph1 = readValues[95]; + if (String.IsNullOrWhiteSpace(j.ownr_ph1.Value)) + { + j.ownr_ph1 = readValues[97]; + } + //j.ownr_ph1x = readValues[96]; + j.ownr_ph2 = readValues[97]; + // j.ownr_ph2x = readValues[98]; + //j.ownr_fax = readValues[99]; + //j.ownr_faxx = readValues[100]; + j.ownr_ea = readValues[101]; + j.ins_ph1 = readValues[102]; + j.ins_ph1x = readValues[103]; + j.ins_ph2 = readValues[104]; + j.ins_ph2x = readValues[105]; + j.ins_fax = readValues[106]; + j.ins_faxx = readValues[107]; + j.ins_ct_ln = readValues[108]; + j.ins_ct_fn = readValues[109]; + j.ins_title = readValues[110]; + j.ins_ct_ph = readValues[111]; + j.ins_ct_phx = readValues[112]; + j.loss_cat = readValues[113]; + j.shopid = AppMetaData.ActiveShopId; + + //Set Owner Record + //Owner record will be removed by the application if required. + ownerRoot.ownr_ln = readValues[85]; + ownerRoot.ownr_fn = readValues[86]; + ownerRoot.ownr_title = readValues[87]; + ownerRoot.ownr_co_nm = readValues[88]; + ownerRoot.ownr_addr1 = readValues[89]; + ownerRoot.ownr_addr2 = readValues[90]; + ownerRoot.ownr_city = readValues[91]; + ownerRoot.ownr_st = readValues[92]; + ownerRoot.ownr_zip = readValues[93]; + ownerRoot.ownr_ctry = readValues[94]; + ownerRoot.ownr_ph1 = readValues[95]; + if (String.IsNullOrWhiteSpace(ownerRoot.ownr_ph1.Value)) + { + ownerRoot.ownr_ph1 = readValues[97]; + } + ownerRoot.ownr_ph2 = readValues[97]; + ownerRoot.ownr_ea = readValues[101]; + ownerRoot.shopid = AppMetaData.ActiveShopId; + + + //Validate that the owner is not empty. If it is, use the insured. + if (String.IsNullOrEmpty(ownerRoot.ownr_ln?.Value) && String.IsNullOrEmpty(ownerRoot.ownr_fn?.Value) && String.IsNullOrEmpty(ownerRoot.ownr_co_nm?.Value)) + { + logger.Debug("Owner FN/LN/CO NM were all empty. Using insured information instead."); + j.ownr_ln = readValues[68]; + j.ownr_fn = readValues[69]; + j.ownr_title = readValues[70]; + j.ownr_co_nm = readValues[71]; + j.ownr_addr1 = readValues[72]; + j.ownr_addr2 = readValues[73]; + j.ownr_city = readValues[74]; + j.ownr_st = readValues[75]; + j.ownr_zip = readValues[76]; + j.ownr_ctry = readValues[77]; + j.ownr_ph1 = readValues[78]; if (String.IsNullOrWhiteSpace(j.ownr_ph1.Value)) { - j.ownr_ph1 = readValues[97]; + j.ownr_ph1 = readValues[80]; } - //j.ownr_ph1x = readValues[96]; - j.ownr_ph2 = readValues[97]; - // j.ownr_ph2x = readValues[98]; - //j.ownr_fax = readValues[99]; - //j.ownr_faxx = readValues[100]; - j.ownr_ea = readValues[101]; - j.ins_ph1 = readValues[102]; - j.ins_ph1x = readValues[103]; - j.ins_ph2 = readValues[104]; - j.ins_ph2x = readValues[105]; - j.ins_fax = readValues[106]; - j.ins_faxx = readValues[107]; - j.ins_ct_ln = readValues[108]; - j.ins_ct_fn = readValues[109]; - j.ins_title = readValues[110]; - j.ins_ct_ph = readValues[111]; - j.ins_ct_phx = readValues[112]; - j.loss_cat = readValues[113]; - j.shopid = AppMetaData.ActiveShopId; + //j.insd_ph1x = readValues[79]; + j.ownr_ph2 = readValues[80]; + // j.insd_ph2x = readValues[81]; - //Set Owner Record - //Owner record will be removed by the application if required. - ownerRoot.ownr_ln = readValues[85]; - ownerRoot.ownr_fn = readValues[86]; - ownerRoot.ownr_title = readValues[87]; - ownerRoot.ownr_co_nm = readValues[88]; - ownerRoot.ownr_addr1 = readValues[89]; - ownerRoot.ownr_addr2 = readValues[90]; - ownerRoot.ownr_city = readValues[91]; - ownerRoot.ownr_st = readValues[92]; - ownerRoot.ownr_zip = readValues[93]; - ownerRoot.ownr_ctry = readValues[94]; - ownerRoot.ownr_ph1 = readValues[95]; + j.ownr_ea = readValues[84]; + + ownerRoot.ownr_ln = readValues[68]; + ownerRoot.ownr_fn = readValues[69]; + ownerRoot.ownr_title = readValues[70]; + ownerRoot.ownr_co_nm = readValues[71]; + ownerRoot.ownr_addr1 = readValues[72]; + ownerRoot.ownr_addr2 = readValues[73]; + ownerRoot.ownr_city = readValues[74]; + ownerRoot.ownr_st = readValues[75]; + ownerRoot.ownr_zip = readValues[76]; + ownerRoot.ownr_ctry = readValues[77]; + ownerRoot.ownr_ph1 = readValues[78]; if (String.IsNullOrWhiteSpace(ownerRoot.ownr_ph1.Value)) { - ownerRoot.ownr_ph1 = readValues[97]; + ownerRoot.ownr_ph1 = readValues[80]; } - ownerRoot.ownr_ph2 = readValues[97]; - ownerRoot.ownr_ea = readValues[101]; - ownerRoot.shopid = AppMetaData.ActiveShopId; + //ownerRoot.insd_ph1x = readValues[79]; + ownerRoot.ownr_ph2 = readValues[80]; + // ownerRoot.insd_ph2x = readValues[81]; + ownerRoot.ownr_ea = readValues[84]; - //Validate that the owner is not empty. If it is, use the insured. - if (String.IsNullOrEmpty(ownerRoot.ownr_ln?.Value) && String.IsNullOrEmpty(ownerRoot.ownr_fn?.Value) && String.IsNullOrEmpty(ownerRoot.ownr_co_nm?.Value)) - { - logger.Debug("Owner FN/LN/CO NM were all empty. Using insured information instead."); - j.ownr_ln = readValues[68]; - j.ownr_fn = readValues[69]; - j.ownr_title = readValues[70]; - j.ownr_co_nm = readValues[71]; - j.ownr_addr1 = readValues[72]; - j.ownr_addr2 = readValues[73]; - j.ownr_city = readValues[74]; - j.ownr_st = readValues[75]; - j.ownr_zip = readValues[76]; - j.ownr_ctry = readValues[77]; - j.ownr_ph1 = readValues[78]; - if (String.IsNullOrWhiteSpace(j.ownr_ph1.Value)) - { - j.ownr_ph1 = readValues[80]; - } - //j.insd_ph1x = readValues[79]; - j.ownr_ph2 = readValues[80]; - // j.insd_ph2x = readValues[81]; - - j.ownr_ea = readValues[84]; - - ownerRoot.ownr_ln = readValues[68]; - ownerRoot.ownr_fn = readValues[69]; - ownerRoot.ownr_title = readValues[70]; - ownerRoot.ownr_co_nm = readValues[71]; - ownerRoot.ownr_addr1 = readValues[72]; - ownerRoot.ownr_addr2 = readValues[73]; - ownerRoot.ownr_city = readValues[74]; - ownerRoot.ownr_st = readValues[75]; - ownerRoot.ownr_zip = readValues[76]; - ownerRoot.ownr_ctry = readValues[77]; - ownerRoot.ownr_ph1 = readValues[78]; - if (String.IsNullOrWhiteSpace(ownerRoot.ownr_ph1.Value)) - { - ownerRoot.ownr_ph1 = readValues[80]; - } - //ownerRoot.insd_ph1x = readValues[79]; - ownerRoot.ownr_ph2 = readValues[80]; - // ownerRoot.insd_ph2x = readValues[81]; - - ownerRoot.ownr_ea = readValues[84]; - - } - - - j.owner = new JObject(); - j.owner.data = ownerRoot; - reader.Dispose(); - - return true; } + + + j.owner = new JObject(); + j.owner.data = ownerRoot; + reader.Dispose(); + + fis.Dispose(); + return true; + } catch (IOException ex) { @@ -346,8 +361,23 @@ namespace BodyshopPartner.Utils.Decoder { try { - using (Stream fis = File.Open(RootFilePath + j.ciecaid.Value + "B.ad2", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + Stream fis = null; + try { + fis = File.Open(RootFilePath + j.ciecaid.Value + "B.ad2", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + + } + catch (Exception ex) + { + logger.Warn("*B.ad2 could not be opened."); + } + if (fis == null) + { + fis = File.Open(RootFilePath + j.ciecaid.Value + ".ad2", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + + } + + var reader = new DBFReader(fis); //RO_AUTH references a memo file and had to be reemoved. reader.SetSelectFields(new string[] { "CLMT_LN","CLMT_FN","CLMT_TITLE","CLMT_CO_NM","CLMT_ADDR1","CLMT_ADDR2","CLMT_CITY","CLMT_ST","CLMT_ZIP","CLMT_CTRY","CLMT_PH1", @@ -521,8 +551,9 @@ namespace BodyshopPartner.Utils.Decoder reader.Dispose(); + fis.Dispose(); return true; - } + } catch (IOException ex) { @@ -779,7 +810,7 @@ namespace BodyshopPartner.Utils.Decoder j.rate_mapa = float.Parse(readValues[11].ToString()) != 0 ? readValues[11] : readValues[7]; //Use CAL_LBRRTE if exists, otherwise us the pre threshold amt.? j.tax_paint_mat_rt = float.Parse(readValues[14].ToString()) / 100; - o.cal_maxdlr = float.Parse(readValues[3].ToString()) ; + o.cal_maxdlr = float.Parse(readValues[3].ToString()); d.mapa = o; break; case "MASH": @@ -870,7 +901,22 @@ namespace BodyshopPartner.Utils.Decoder { try { - using (Stream fis = File.Open(RootFilePath + j.ciecaid.Value + "v.veh", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + Stream fis = null; + try + { + fis = File.Open(RootFilePath + j.ciecaid.Value + "v.veh", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + + } + catch (Exception ex) + { + logger.Warn("*v.veh could not be opened."); + } + if (fis == null) + { + fis = File.Open(RootFilePath + j.ciecaid.Value + ".veh", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + + } + { dynamic v = new JObject(); //V_Options references a memo file and had to be removed @@ -949,6 +995,9 @@ namespace BodyshopPartner.Utils.Decoder j.v_color = readValues[19]?.ToString(); j.kmin = readValues[18]; v.shopid = AppMetaData.ActiveShopId; + + reader.Dispose(); + fis.Dispose(); } return true; } @@ -1203,7 +1252,8 @@ namespace BodyshopPartner.Utils.Decoder { var reader = new DBFReader(fis); reader.SetSelectFields(new string[] { "G_TTL_AMT","G_BETT_AMT","G_RPD_AMT","G_DED_AMT","G_CUST_AMT","G_AA_AMT","N_TTL_AMT","PREV_NET", - "SUPP_AMT","N_SUPP_AMT","G_UPD_AMT","G_TTL_DISC","G_TAX","GST_AMT", }); + "SUPP_AMT",//"N_SUPP_AMT", + "G_UPD_AMT","G_TTL_DISC","G_TAX","GST_AMT", }); var readValues = reader.NextRecord(); dynamic ttl_x = new JObject(); @@ -1217,11 +1267,11 @@ namespace BodyshopPartner.Utils.Decoder ttl_x.n_ttl_amt = readValues[6];//N_TTL_AMT ttl_x.prev_net = readValues[7];//PREV_NET ttl_x.supp_amt = readValues[8];//SUPP_AMT - ttl_x.n_supp_amt = readValues[9];//N_SUPP_AMT - ttl_x.g_upd_amt = readValues[10];//G_UPD_AMT - ttl_x.g_ttl_disc = readValues[11];//G_TTL_DISC - ttl_x.g_tax = readValues[12];//G_TAX - ttl_x.gst_amt = readValues[13];//GST_AMT + // ttl_x.n_supp_amt = readValues[9];//N_SUPP_AMT + ttl_x.g_upd_amt = readValues[9];//G_UPD_AMT + ttl_x.g_ttl_disc = readValues[10];//G_TTL_DISC + ttl_x.g_tax = readValues[11];//G_TAX + ttl_x.gst_amt = readValues[12];//GST_AMT j.clm_total = Convert.ToDecimal(readValues[0].ToString()); diff --git a/BodyshopUploader/Utils/DiskScan.cs b/BodyshopUploader/Utils/DiskScan.cs index 536fe97..61bff68 100644 --- a/BodyshopUploader/Utils/DiskScan.cs +++ b/BodyshopUploader/Utils/DiskScan.cs @@ -42,7 +42,7 @@ namespace BodyshopPartner.Utils Filepath = envfp, Cieca_Id = job.ciecaid, Clm_No = job.clm_no, - Owner = job.ownr_fn?.Value + " " + job.ownr_ln?.Value, + 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, diff --git a/BodyshopUploader/Utils/GraphQL.cs b/BodyshopUploader/Utils/GraphQL.cs index a53d378..ed5e6b7 100644 --- a/BodyshopUploader/Utils/GraphQL.cs +++ b/BodyshopUploader/Utils/GraphQL.cs @@ -45,48 +45,59 @@ namespace BodyshopPartner.Utils try { - // httpClient.PostAsync("https://api.imex.online/ioevent", content); + // httpClient.PostAsync("https://api.imex.online/ioevent", content); } catch (Exception ex) { - logger.Error(ex,"Unable to post to IOEVENT."); + logger.Error(ex, "Unable to post to IOEVENT."); } - - var graphQLResponse = await g.SendQueryAsync(r); - - if (graphQLResponse.Errors == null) + try { - - //logger.Trace("GQL Response: {0}", graphQLResponse.Data); - return graphQLResponse.Data; - } - else - { - string exceptionString = ""; - bool jwtExpired = false; - logger.Error("Error executing query."); - Array.ForEach(graphQLResponse.Errors, x => - { - logger.Error("Graphql Error: " + x.Message); - if (x.Message.Contains("JWTExpired")) - { - jwtExpired = true; - }; - exceptionString = exceptionString + x + ";"; - }); - if (jwtExpired && !lastTry) + var graphQLResponse = await g.SendQueryAsync(r); + logger.Debug("Graphql response:"); + logger.Debug("Data: " + graphQLResponse.Data); + logger.Debug("Error: " + graphQLResponse.Errors); + if (graphQLResponse.Errors == null) { - await Utils.Auth.Refresh(); - return (ExecuteQuery(r, true)); + + //logger.Trace("GQL Response: {0}", graphQLResponse.Data); + return graphQLResponse.Data; } else { - logger.Error("---------------------"); - throw new Exception(exceptionString); - } + string exceptionString = ""; + bool jwtExpired = false; + logger.Error("Error executing query."); + Array.ForEach(graphQLResponse.Errors, x => + { + logger.Error("Graphql Error: " + x.Message); + if (x.Message.Contains("JWTExpired")) + { + jwtExpired = true; + }; + exceptionString = exceptionString + x + ";"; + }); + if (jwtExpired && !lastTry) + { + await Utils.Auth.Refresh(); + return (ExecuteQuery(r, true)); + } + else + { + logger.Error("---------------------"); + throw new Exception(exceptionString); + } + } } + catch (Exception ex) + { + logger.Error("Error firing GQL query."); + logger.Error(ex); + throw ex; + } + } } } diff --git a/BodyshopUploader/Utils/OEConnection.cs b/BodyshopUploader/Utils/OEConnection.cs index 634bcd8..69454e2 100644 --- a/BodyshopUploader/Utils/OEConnection.cs +++ b/BodyshopUploader/Utils/OEConnection.cs @@ -525,6 +525,8 @@ partsOrderLine.jobline?.bett_tax?.Value writer.Fields[20] = new DBFField("V_OPTIONS", NativeDbType.Char, 20); writer.Fields[27] = new DBFField("V_MEMO", NativeDbType.Char, 20); + + writer.AddRecord( Job.area_of_impact?.impact_1?.Value,//IMPACT_1, Job.area_of_impact?.impact_2?.Value,//IMPACT_2, @@ -546,14 +548,14 @@ partsOrderLine.jobline?.bett_tax?.Value Job.vehicle?.v_mldgcode?.Value,//V_MLDGCODE, Job.vehicle?.v_engine?.Value,//V_ENGINE, Job.vehicle?.v_mileage?.Value,//V_MILEAGE, - Job.vehicle?.v_options?.Value,//V_OPTIONS, + null,//V_OPTIONS, Job.vehicle?.v_color?.Value,//V_COLOR, Job.vehicle?.v_tone?.Value,//V_TONE, - Job.vehicle?.v_stage?.Value,//V_STAGE, - Job.vehicle?.v_paint_codes?.paint_cd1?.Value,//PAINT_CD1, - Job.vehicle?.v_paint_codes?.paint_cd2?.Value,//PAINT_CD2, - Job.vehicle?.v_paint_codes?.paint_cd3?.Value,//PAINT_CD3, - Job.vehicle?.v_memo?.Value//V_MEMO, + null,//V_STAGE, +Job.vehicle?.v_paint_codes != null && Job.vehicle?.v_paint_codes?.paint_cd1 != null ? Job.vehicle?.v_paint_codes?.paint_cd1.Value : "", +Job.vehicle?.v_paint_codes != null && Job.vehicle?.v_paint_codes?.paint_cd2 != null ? Job.vehicle?.v_paint_codes?.paint_cd2.Value : "", +Job.vehicle?.v_paint_codes != null && Job.vehicle?.v_paint_codes?.paint_cd3 != null ? Job.vehicle?.v_paint_codes?.paint_cd3.Value : "", + null//V_MEMO, ); ; writer.Write(fileStream); diff --git a/BodyshopUploader/ViewModels/MainViewModel.cs b/BodyshopUploader/ViewModels/MainViewModel.cs index f4ce3dc..41d6391 100644 --- a/BodyshopUploader/ViewModels/MainViewModel.cs +++ b/BodyshopUploader/ViewModels/MainViewModel.cs @@ -322,7 +322,12 @@ namespace BodyshopPartner.ViewModels }" }; - var Data = await Utils.GraphQL.ExecuteQuery(r); + try + { + + var Data = await Utils.GraphQL.ExecuteQuery(r); + logger.Debug("Bodyshop Query Data"); + logger.Debug(JsonConvert.SerializeObject(Data)); if (Data != null) { ShopData = Data.bodyshops.ToObject>(); @@ -334,6 +339,14 @@ namespace BodyshopPartner.ViewModels Utils.AppMetaData.ShopRegion = ActiveShop?.RegionConfig; Properties.Settings.Default.LastSelectedShop = ActiveShop.Id ?? null; Properties.Settings.Default.Save(); + } + catch(Exception ex) + { + logger.Error("Error initializing shop."); + logger.Error(ex); + } + + }