diff --git a/BodyshopUploader/App.config b/BodyshopUploader/App.config index 774e37c..172e943 100644 --- a/BodyshopUploader/App.config +++ b/BodyshopUploader/App.config @@ -72,6 +72,9 @@ C:\CIECA\MITCHELL\EXPORT + + c:\program files\armsbusinesssolutions\repairorderpumpagentservice\export + diff --git a/BodyshopUploader/ImEXOnlinePartner.csproj b/BodyshopUploader/ImEXOnlinePartner.csproj index fb1c7d7..84dd97c 100644 --- a/BodyshopUploader/ImEXOnlinePartner.csproj +++ b/BodyshopUploader/ImEXOnlinePartner.csproj @@ -189,7 +189,7 @@ - + @@ -255,6 +255,9 @@ PublicResXFileCodeGenerator Resources.Designer.cs + + Always + Always diff --git a/BodyshopUploader/Properties/Resources.Designer.cs b/BodyshopUploader/Properties/Resources.Designer.cs index 34499f2..4e2dd90 100644 --- a/BodyshopUploader/Properties/Resources.Designer.cs +++ b/BodyshopUploader/Properties/Resources.Designer.cs @@ -150,6 +150,15 @@ namespace BodyshopPartner.Properties { } } + /// + /// Looks up a localized string similar to ARMS Export Path. + /// + public static string Label_ArmsExportPath { + get { + return ResourceManager.GetString("Label_ArmsExportPath", resourceCulture); + } + } + /// /// Looks up a localized string similar to Auto-start Monitors. /// @@ -159,6 +168,15 @@ namespace BodyshopPartner.Properties { } } + /// + /// Looks up a localized string similar to Browse ARMS Export Path. + /// + public static string Label_BrowseArmsExportPath { + get { + return ResourceManager.GetString("Label_BrowseArmsExportPath", resourceCulture); + } + } + /// /// Looks up a localized string similar to Browse for EMS Export Path. /// @@ -186,6 +204,15 @@ namespace BodyshopPartner.Properties { } } + /// + /// Looks up a localized string similar to (Re)configure ARMS Export. + /// + public static string Label_ConfigureArmsExport { + get { + return ResourceManager.GetString("Label_ConfigureArmsExport", resourceCulture); + } + } + /// /// Looks up a localized string similar to (Re)Configure Paint Scale Task. /// diff --git a/BodyshopUploader/Properties/Resources.resx b/BodyshopUploader/Properties/Resources.resx index d2d53e5..3a3a208 100644 --- a/BodyshopUploader/Properties/Resources.resx +++ b/BodyshopUploader/Properties/Resources.resx @@ -147,9 +147,15 @@ Add Path + + ARMS Export Path + Auto-start Monitors + + Browse ARMS Export Path + Browse for EMS Export Path @@ -159,6 +165,9 @@ Browse Paint Scale Path + + (Re)configure ARMS Export + (Re)Configure Paint Scale Task diff --git a/BodyshopUploader/Properties/Settings.Designer.cs b/BodyshopUploader/Properties/Settings.Designer.cs index 4d25104..ddebeda 100644 --- a/BodyshopUploader/Properties/Settings.Designer.cs +++ b/BodyshopUploader/Properties/Settings.Designer.cs @@ -164,5 +164,17 @@ namespace BodyshopPartner.Properties { this["EmsExportPath"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("c:\\program files\\armsbusinesssolutions\\repairorderpumpagentservice\\export")] + public string ArmsExportPath { + get { + return ((string)(this["ArmsExportPath"])); + } + set { + this["ArmsExportPath"] = value; + } + } } } diff --git a/BodyshopUploader/Properties/Settings.settings b/BodyshopUploader/Properties/Settings.settings index 5a6c982..1f4fd3a 100644 --- a/BodyshopUploader/Properties/Settings.settings +++ b/BodyshopUploader/Properties/Settings.settings @@ -38,5 +38,8 @@ C:\CIECA\MITCHELL\EXPORT + + c:\program files\armsbusinesssolutions\repairorderpumpagentservice\export + \ No newline at end of file diff --git a/BodyshopUploader/Utils/ARMSRoData.cs b/BodyshopUploader/Utils/ARMSRoData.cs index d468dff..5476b9e 100644 --- a/BodyshopUploader/Utils/ARMSRoData.cs +++ b/BodyshopUploader/Utils/ARMSRoData.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; @@ -30,6 +31,7 @@ query ENTEGRAL_EXPORT($bodyshopid: uuid!, $start: timestamptz!, $end: timestampt actual_completion actual_delivery date_exported + actual_in ins_co_nm ins_addr1 ins_addr2 @@ -163,9 +165,9 @@ query ENTEGRAL_EXPORT($bodyshopid: uuid!, $start: timestamptz!, $end: timestampt logger.Debug(RoNumber); RepairOrders.Add(new ARMSRoDataModel() { - ShopShortName = int.Parse(data.bodyshops_by_pk.entegral_id?.Value), + ShopShortName = data.bodyshops_by_pk.entegral_id?.Value, RO = int.Parse(RoNumber), - TransType = "Z", //TODO*** Finish this status mapping. + TransType = job.actual_completion?.Value == null ? "Z" : "C", //TODO*** Finish this status mapping. ShopLongName = data.bodyshops_by_pk.shopname?.Value, EstimatorID = job.est_ct_ln, EstimatorName = $"{job.est_ct_fn} {job.est_ct_ln}", @@ -175,8 +177,10 @@ query ENTEGRAL_EXPORT($bodyshopid: uuid!, $start: timestamptz!, $end: timestampt CustomerStreet = job.ownr_addr1?.Value, CustomerCity = job.ownr_city?.Value, CustomerState = job.ownr_st?.Value, - CustomerZip = job.ownr_ph1?.Value, - RetWhslCustomer = "R", + CustomerZip = job.ownr_zip?.Value, + CustomerPhone1 = job.ownr_ph1?.Value, + CustomerPhone2 = job.ownr_ph2?.Value, + //RetWhslCustomer = "R", Year = int.Parse(job.v_model_yr?.Value ?? 0), //TODO STRIP TO 2 NUMBERS Make = job.v_make_desc?.Value, Model = job.v_model_desc?.Value, @@ -191,8 +195,11 @@ query ENTEGRAL_EXPORT($bodyshopid: uuid!, $start: timestamptz!, $end: timestampt ClaimType = "N/A", Claim = job.clm_no?.Value, DateOpened = job.date_open?.Value,// ? job.date_open : null, + EstComplete = job.date_open?.Value, //DateofLoss = job.loss_date?.Value,// ? job.loss_date : null, PromiseDate = job.scheduled_completion, + CarComplete = job.actual_completion, + CarinShop = job.actual_in, CustPickup = job.actual_delivery, DateClosed = job.date_invoiced, BodyRate = job.rate_lab, @@ -201,33 +208,35 @@ query ENTEGRAL_EXPORT($bodyshopid: uuid!, $start: timestamptz!, $end: timestampt StructuralRate = job.rate_las, PMRate = job.rate_mapa, BMRate = job.rate_mash, - RevisedTotalsBodyHours = job.job_totals?.rates?.lab?.hours?.Value, - RevisedTotalsRefinishHours = job.job_totals?.rates?.lar?.hours?.Value, - RevisedTotalsMechanicalHours = job.job_totals?.rates?.lam?.hours?.Value, - RevisedTotalsStructuralHours = job.job_totals?.rates?.las?.hours?.Value, - RevisedTotalsPartsTotal = job.job_totals?.pars?.parts?.total?.amount?.Value/100, - RevisedTotalsSubletTotal = job.job_totals?.pars?.sublets?.total?.amount?.Value / 100, - RevisedTotalsBodyLaborTotal = job.job_totals?.rates?.lab?.total?.amount?.Value/100, - RevisedTotalsRefinishLaborTotal = job.job_totals?.rates?.lar?.total?.amount?.Value / 100, - RevisedTotalsMechanicalLaborTotal = job.job_totals?.rates?.lam?.total?.amount?.Value / 100, - RevisedTotalsStructuralLaborTotal = job.job_totals?.rates?.las?.total?.amount?.Value / 100, - RevisedTotalsPMTotal = job.job_totals?.rates?.mapa?.total?.amount?.Value / 100, - RevisedTotalsBMTotal = job.job_totals?.rates?.mash?.total?.amount?.Value / 100, - RevisedTotalsSalesTaxTotal = (job.job_totals?.totals?.federal_tax?.amount?.Value + job.job_totals?.totals?.state_tax?.amount?.Value) /100, - RevisedTotalsGrossTotal = job.job_totals?.totals?.total_repairs?.amount?.Value /100, - RevisedTotalsDeductibleTotal = job.ded_amt?.Value, - // RevisedTotalsDepreciationTotal = job.job_totals?.rates?.lab?.hours?.Value, + RevisedTotalsBodyHours = (Decimal?)job.job_totals?.rates?.lab?.hours?.Value, + RevisedTotalsRefinishHours = (Decimal?)job.job_totals?.rates?.lar?.hours?.Value, + RevisedTotalsMechanicalHours = (Decimal?)job.job_totals?.rates?.lam?.hours?.Value, + RevisedTotalsStructuralHours = (Decimal?)job.job_totals?.rates?.las?.hours?.Value, + RevisedTotalsPartsTotal = ((Decimal?)job.job_totals?.parts?.parts?.total?.amount?.Value) / 100, + RevisedTotalsSubletTotal = ((Decimal?)job.job_totals?.parts?.sublets?.total?.amount?.Value) / 100, + RevisedTotalsBodyLaborTotal = ((Decimal?)job.job_totals?.rates?.lab?.total?.amount?.Value) / 100, + RevisedTotalsRefinishLaborTotal = ((Decimal?)job.job_totals?.rates?.lar?.total?.amount?.Value) / 100, + RevisedTotalsMechanicalLaborTotal = ((Decimal?)job.job_totals?.rates?.lam?.total?.amount?.Value) / 100, + RevisedTotalsStructuralLaborTotal = ((Decimal?)job.job_totals?.rates?.las?.total?.amount?.Value) / 100, + RevisedTotalsPMTotal = ((Decimal?)job.job_totals?.rates?.mapa?.total?.amount?.Value) / 100, + RevisedTotalsBMTotal = ((Decimal?)job.job_totals?.rates?.mash?.total?.amount?.Value) / 100, + RevisedTotalsSalesTaxTotal = ((Decimal?)(job.job_totals?.totals?.federal_tax?.amount?.Value + job.job_totals?.totals?.state_tax?.amount?.Value)) / 100, + RevisedTotalsGrossTotal = ((Decimal?)job.job_totals?.totals?.total_repairs?.amount?.Value) / 100, + RevisedTotalsDeductibleTotal = (Decimal?)job.ded_amt?.Value, + // RevisedTotalsDepreciationTotal = job.job_totals?.rates?.lab?.hours?.Value, TotalLossYN = job.tlos_ind, BodyTechName = job.employee_body_rel?.Value == null ? "" : $"{job.employee_body_rel?.first_name?.Value} {job.employee_body_rel?.last_name?.Value}", Vehiclecolor = job.v_color?.Value, PaintTechID = job.employee_refinish_rel?.Value == null ? "" : job.employee_refinish_rel?.employee_number?.Value, PaintTechName = job.employee_refinish_rel?.Value == null ? "" : $"{job.employee_refinish_rel?.first_name?.Value} {job.employee_refinish_rel?.last_name?.Value}", - ProductionStageCode = "33" //TODO ADD THE REST OF THE CODE + ProductionStageCode = (job.actual_delivery?.Value != null || job.date_invoiced != null) ? "8D" : "33", + Vehiclescheduledindate = job.scheduled_in?.Value }); } + Directory.CreateDirectory(Properties.Settings.Default.ArmsExportPath); - engine.WriteFile("Output.Txt", RepairOrders); + engine.WriteFile($"{Properties.Settings.Default.ArmsExportPath}\\{DateTime.Now.ToString("MMdd")}{data.bodyshops_by_pk.entegral_id?.Value}.txt", RepairOrders); } catch (Exception ex) { diff --git a/BodyshopUploader/Utils/ARMSRoDataModel.cs b/BodyshopUploader/Utils/ARMSRoDataModel.cs index eaa0844..d3999c1 100644 --- a/BodyshopUploader/Utils/ARMSRoDataModel.cs +++ b/BodyshopUploader/Utils/ARMSRoDataModel.cs @@ -7,24 +7,13 @@ using FileHelpers; namespace BodyshopPartner.Utils { + + [FixedLengthRecord()] public class ARMSRoDataModel { - [FieldFixedLength(5)] - public int CustId; - - [FieldFixedLength(30)] - [FieldTrim(TrimMode.Both)] - public string Name; - [FieldFixedLength(8)] - [FieldConverter(ConverterKind.Date, "ddMMyyyy")] - public DateTime? AddedDate; - - - - [FieldFixedLength(8)] - public int ShopShortName; + public string ShopShortName; [FieldFixedLength(8)] public int RO; [FieldFixedLength(1)] @@ -52,9 +41,9 @@ namespace BodyshopPartner.Utils [FieldFixedLength(11)] public String CustomerZip; [FieldFixedLength(10)] - public int CustomerPhone1; + public String CustomerPhone1; [FieldFixedLength(10)] - public int CustomerPhone2; + public String CustomerPhone2; [FieldFixedLength(35)] public String CustomerSource; [FieldFixedLength(1)] @@ -92,9 +81,9 @@ namespace BodyshopPartner.Utils [FieldFixedLength(11)] public String InsuranceZip; [FieldFixedLength(10)] - public int InsurancePhone; + public String InsurancePhone; [FieldFixedLength(10)] - public int InsuranceFax; + public String InsuranceFax; [FieldFixedLength(4)] public String ClaimType; @@ -132,7 +121,7 @@ namespace BodyshopPartner.Utils [FieldFixedLength(35)] public String InsuranceAgentFirstName; [FieldFixedLength(10)] - public int InsAgentPhone; + public String InsAgentPhone; [FieldFixedLength(8)] [FieldConverter(ConverterKind.Date, "ddMMyyyy")] @@ -183,184 +172,250 @@ namespace BodyshopPartner.Utils public DateTime? DateClosed; [FieldFixedLength(12)] - public Double? BodyRate; + public Decimal? BodyRate; [FieldFixedLength(12)] - public Double? RefinishRate; + public Decimal? RefinishRate; [FieldFixedLength(12)] - public Double? MechanicalRate; + public Decimal? MechanicalRate; [FieldFixedLength(12)] - public Double? StructuralRate; + public Decimal? StructuralRate; [FieldFixedLength(12)] - public Double? PMRate; + public Decimal? PMRate; [FieldFixedLength(12)] - public Double? BMRate; + public Decimal? BMRate; [FieldFixedLength(7)] - public Double? RetailWholesaleTaxRate; + public Decimal? RetailWholesaleTaxRate; [FieldFixedLength(12)] - public Double? StorageRateperDay; + public Decimal? StorageRateperDay; [FieldFixedLength(3)] - public Double? DaysStored; + public Decimal? DaysStored; [FieldFixedLength(5)] - public Double? BodyHours; + public Decimal? BodyHours; [FieldFixedLength(5)] - public Double? RefinishHours; + public Decimal? RefinishHours; [FieldFixedLength(5)] - public Double? MechanicalHours; + public Decimal? MechanicalHours; [FieldFixedLength(5)] - public Double? StructuralHours; + public Decimal? StructuralHours; [FieldFixedLength(12)] - public Double? PartsTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? PartsTotal; [FieldFixedLength(12)] - public Double? SubletTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SubletTotal; [FieldFixedLength(12)] - public Double? BodyLaborTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? BodyLaborTotal; [FieldFixedLength(12)] - public Double? RefinishLaborTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RefinishLaborTotal; [FieldFixedLength(12)] - public Double? MechanicalLaborTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? MechanicalLaborTotal; [FieldFixedLength(12)] - public Double? StructuralLaborTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? StructuralLaborTotal; [FieldFixedLength(12)] - public Double? MiscellaneousChargeTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? MiscellaneousChargeTotal; [FieldFixedLength(12)] - public Double? PMTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? PMTotal; [FieldFixedLength(12)] - public Double? BMTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? BMTotal; [FieldFixedLength(12)] - public Double? MiscTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? MiscTotal; [FieldFixedLength(12)] - public Double? TowingTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? TowingTotal; [FieldFixedLength(12)] - public Double? StorageTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? StorageTotal; [FieldFixedLength(12)] - public Double? DetailTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? DetailTotal; [FieldFixedLength(12)] - public Double? SalesTaxTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SalesTaxTotal; [FieldFixedLength(12)] - public Double? GrossTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? GrossTotal; [FieldFixedLength(12)] - public Double? DeductibleTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? DeductibleTotal; [FieldFixedLength(12)] - public Double? DepreciationTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? DepreciationTotal; [FieldFixedLength(12)] - public Double? Discount; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? Discount; [FieldFixedLength(12)] - public Double? CustomerPay; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? CustomerPay; [FieldFixedLength(12)] - public Double? InsurancePay; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? InsurancePay; [FieldFixedLength(12)] - public Double? Deposit; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? Deposit; [FieldFixedLength(12)] - public Double? AmountDue; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? AmountDue; [FieldFixedLength(5)] - public Double? SupplementBodyHours; + public Decimal? SupplementBodyHours; [FieldFixedLength(5)] - public Double? SupplementRefinishHours; + public Decimal? SupplementRefinishHours; [FieldFixedLength(5)] - public Double? SupplementMechanicalHours; + public Decimal? SupplementMechanicalHours; [FieldFixedLength(5)] - public Double? SupplementStructuralHours; + public Decimal? SupplementStructuralHours; [FieldFixedLength(12)] - public Double? SupplementPartsTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementPartsTotal; [FieldFixedLength(12)] - public Double? SupplementSubletTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementSubletTotal; [FieldFixedLength(12)] - public Double? SupplementBodyLaborTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementBodyLaborTotal; [FieldFixedLength(12)] - public Double? SupplementRefinishLaborTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementRefinishLaborTotal; [FieldFixedLength(12)] - public Double? SupplementMechanicalLaborTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementMechanicalLaborTotal; [FieldFixedLength(12)] - public Double? SupplementStructuralLaborTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementStructuralLaborTotal; [FieldFixedLength(12)] - public Double? SupplementMiscellaneousChargeTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementMiscellaneousChargeTotal; [FieldFixedLength(12)] - public Double? SupplementPMTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementPMTotal; [FieldFixedLength(12)] - public Double? SupplementBMTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementBMTotal; [FieldFixedLength(12)] - public Double? SupplementMiscTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementMiscTotal; [FieldFixedLength(12)] - public Double? SupplementTowingTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementTowingTotal; [FieldFixedLength(12)] - public Double? SupplementStorageTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementStorageTotal; [FieldFixedLength(12)] - public Double? SupplementDetailTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementDetailTotal; [FieldFixedLength(12)] - public Double? SupplementSalesTaxTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementSalesTaxTotal; [FieldFixedLength(12)] - public Double? SupplementGrossTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementGrossTotal; [FieldFixedLength(12)] - public Double? SupplementDeductibleTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementDeductibleTotal; [FieldFixedLength(12)] - public Double? SupplementDepreciationTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementDepreciationTotal; [FieldFixedLength(12)] - public Double? SupplementDiscount; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementDiscount; [FieldFixedLength(12)] - public Double? SupplementCustomerPay; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementCustomerPay; [FieldFixedLength(12)] - public Double? SupplementInsurancePay; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementInsurancePay; [FieldFixedLength(12)] - public Double? SupplementDeposit; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementDeposit; [FieldFixedLength(12)] - public Double? SupplementAmountDue; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? SupplementAmountDue; [FieldFixedLength(5)] - public Double? RevisedTotalsBodyHours; + public Decimal? RevisedTotalsBodyHours; [FieldFixedLength(5)] - public Double? RevisedTotalsRefinishHours; + public Decimal? RevisedTotalsRefinishHours; [FieldFixedLength(5)] - public Double? RevisedTotalsMechanicalHours; + public Decimal? RevisedTotalsMechanicalHours; [FieldFixedLength(5)] - public Double? RevisedTotalsStructuralHours; + public Decimal? RevisedTotalsStructuralHours; [FieldFixedLength(12)] - public Double? RevisedTotalsPartsTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsPartsTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsSubletTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsSubletTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsBodyLaborTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsBodyLaborTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsRefinishLaborTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsRefinishLaborTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsMechanicalLaborTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsMechanicalLaborTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsStructuralLaborTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsStructuralLaborTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsMiscellaneousChargeTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsMiscellaneousChargeTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsPMTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsPMTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsBMTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsBMTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsMiscTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsMiscTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsTowingTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsTowingTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsStorageTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsStorageTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsDetailTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsDetailTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsSalesTaxTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsSalesTaxTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsGrossTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsGrossTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsDeductibleTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsDeductibleTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsDepreciationTotal; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsDepreciationTotal; [FieldFixedLength(12)] - public Double? RevisedTotalsDiscount; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsDiscount; [FieldFixedLength(12)] - public Double? RevisedTotalsCustomerPay; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsCustomerPay; [FieldFixedLength(12)] - public Double? RevisedTotalsInsurancePay; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsInsurancePay; [FieldFixedLength(12)] - public Double? RevisedTotalsDeposit; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsDeposit; [FieldFixedLength(12)] - public Double? RevisedTotalsAmountDue; + [FieldConverter(typeof(MoneyConverter))] + public Decimal? RevisedTotalsAmountDue; [FieldFixedLength(2)] public int ProductionStatus; @@ -382,11 +437,11 @@ namespace BodyshopPartner.Utils [FieldFixedLength(50)] public String InScreenCommentsLine2; [FieldFixedLength(4)] - public int CustomerPhone2Extension; + public string CustomerPhone2Extension; [FieldFixedLength(10)] - public int CustomerPhone3; + public String CustomerPhone3; [FieldFixedLength(4)] - public int CustomerPhone3Extension; + public string CustomerPhone3Extension; [FieldFixedLength(60)] public String CustomerFileComments; [FieldFixedLength(10)] @@ -422,7 +477,7 @@ namespace BodyshopPartner.Utils [FieldFixedLength(80)] public String CustomerEmail; [FieldFixedLength(12)] - public Double? GSTTax; + public Decimal? GSTTax; [FieldFixedLength(3)] public String RepairDelayStatusCode; [FieldFixedLength(80)] @@ -443,3 +498,21 @@ namespace BodyshopPartner.Utils } + +public class MoneyConverter : ConverterBase +{ + private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); + + public override object StringToField(string from) + { + return Convert.ToDecimal(Decimal.Parse(from) / 100); + } + + public override string FieldToString(object fieldValue) + { + + if (fieldValue == null) return ""; + return ((Decimal)(fieldValue ?? 0)).ToString("#.##"); + } + +}; \ No newline at end of file diff --git a/BodyshopUploader/Utils/PaintScaleConfig.cs b/BodyshopUploader/Utils/PaintScaleConfig.cs deleted file mode 100644 index fbd354e..0000000 --- a/BodyshopUploader/Utils/PaintScaleConfig.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Win32.TaskScheduler; - - -namespace BodyshopPartner.Utils -{ - public static class PaintScaleConfig - { - private static string workingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); - private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); - - public static void RegisterScheduledTask() - { - try - { - - Microsoft.Win32.TaskScheduler.Task existingTask = TaskService.Instance.FindTask("ImEX Online Partner - Paint Scale Connection"); - if(existingTask != null) - { - TaskService.Instance.RootFolder.DeleteTask("ImEX Online Partner - Paint Scale Connection"); - } - Microsoft.Win32.TaskScheduler.Task newTask = TaskService.Instance.AddTask("ImEX Online Partner - Paint Scale Connection", QuickTriggerType.Hourly, "powershell.exe", @"-ExecutionPolicy Bypass -File " + workingDirectory + @"\Utils\Scripts\PaintScaleExport.ps1"); - newTask.Run(); - - - } - catch(Exception ex) - { - logger.Error(ex, "Error when trying to register scheduled task."); - } - - } -} -} diff --git a/BodyshopUploader/Utils/ScheduledTaskConfig.cs b/BodyshopUploader/Utils/ScheduledTaskConfig.cs new file mode 100644 index 0000000..bbd387e --- /dev/null +++ b/BodyshopUploader/Utils/ScheduledTaskConfig.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Win32.TaskScheduler; + + +namespace BodyshopPartner.Utils +{ + public static class ScheduledTaskConfig + { + private static string workingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); + + public static void RegisterPaintScale() + { + try + { + + Microsoft.Win32.TaskScheduler.Task existingTask = TaskService.Instance.FindTask("ImEX Online Partner - Paint Scale Connection"); + if (existingTask != null) + { + TaskService.Instance.RootFolder.DeleteTask("ImEX Online Partner - Paint Scale Connection"); + } + Microsoft.Win32.TaskScheduler.Task newTask = TaskService.Instance.AddTask("ImEX Online Partner - Paint Scale Connection", QuickTriggerType.Hourly, "powershell.exe", @"-ExecutionPolicy Bypass -File " + workingDirectory + @"\Utils\Scripts\PaintScaleExport.ps1"); + newTask.Run(); + + + } + catch (Exception ex) + { + logger.Error(ex, "Error when trying to register scheduled task."); + } + + } + + public static void RegisterArms() + { + try + { + + Microsoft.Win32.TaskScheduler.Task existingTask = TaskService.Instance.FindTask("ImEX Online Partner - ARMS"); + if (existingTask != null) + { + TaskService.Instance.RootFolder.DeleteTask("ImEX Online Partner - ARMS"); + } + Microsoft.Win32.TaskScheduler.Task newTask = TaskService.Instance.AddTask("ImEX Online Partner - ARMS", QuickTriggerType.Daily, "powershell.exe", @"-ExecutionPolicy Bypass -File " + workingDirectory + @"\Utils\Scripts\ArmsExport.ps1"); + newTask.Run(); + + + } + catch (Exception ex) + { + logger.Error(ex, "Error when trying to register scheduled task."); + } + + } + } +} diff --git a/BodyshopUploader/Utils/Scripts/ArmsExport.ps1 b/BodyshopUploader/Utils/Scripts/ArmsExport.ps1 new file mode 100644 index 0000000..40b9621 --- /dev/null +++ b/BodyshopUploader/Utils/Scripts/ArmsExport.ps1 @@ -0,0 +1,38 @@ +#Verify that the partner is running. If not, strat it. + +if((Get-Process -Name ImEXOnlinePartner -ErrorAction SilentlyContinue) -eq $null){ + & "$Env:USERPROFILE\AppData\Local\ImEXOnlinePartner\ImEXOnlinePartner.exe" +} + +$PSversion = $PSVersionTable.PSVersion.Major + + +function v2 { +# Post request to the partner to trigger the export. +Invoke-WebRequest -Uri http://localhost:1337/arms/rodata/ -Method POST +#Start the Arms Uploader. +#Start-Process -FilePath "C:\ImEX\Applications\ARMSUploader\ROUpload.exe" +} + +function v1 { +WebRequest = [System.Net.WebRequest]::Create("http://localhost:1337/arms/rodata/") +WebRequest.Method = "POST" +WebRequest.ContentType = "application/json" +Response = $WebRequest.GetResponse() +ResponseStream = $Response.GetResponseStream() +ReadStream = New-Object System.IO.StreamReader $ResponseStream +#Data=$ReadStream.ReadToEnd() +#Start the Arms Uploader. +Start-Process -FilePath "C:\ImEX\Applications\ARMSUploader\ROUpload.exe" +} + + +Switch ($PSversion) { + 1 {v1} + 2 {v1} + 4 {v2} + 5 {v2} + 6 {v2} + 7 {v2} +} + diff --git a/BodyshopUploader/Utils/SquirrelAwareHelper.cs b/BodyshopUploader/Utils/SquirrelAwareHelper.cs index fdfbfdc..c5b4172 100644 --- a/BodyshopUploader/Utils/SquirrelAwareHelper.cs +++ b/BodyshopUploader/Utils/SquirrelAwareHelper.cs @@ -74,7 +74,7 @@ namespace BodyshopPartner.Utils mgr.CreateShortcutForThisExe(); Utils.UpdateHandler.RestoreSettings(); Utils.UpdateHandler.ToggleStartWithWindows(Properties.Settings.Default.StartWithWindows); - Utils.PaintScaleConfig.RegisterScheduledTask(); + Utils.ScheduledTaskConfig.RegisterPaintScale(); }, onAppUninstall: v => { diff --git a/BodyshopUploader/ViewModels/MainViewModel.commands.cs b/BodyshopUploader/ViewModels/MainViewModel.commands.cs index 7126428..aaf1d8e 100644 --- a/BodyshopUploader/ViewModels/MainViewModel.commands.cs +++ b/BodyshopUploader/ViewModels/MainViewModel.commands.cs @@ -218,6 +218,38 @@ namespace BodyshopPartner.ViewModels } } + private ICommand _browseForArmsPathPathCommand; + public ICommand BrowseForArmsPathPathCommand + { + get + { + if (_browseForArmsPathPathCommand == null) + { + _browseForArmsPathPathCommand = new RelayCommand( + p => true, + p => BrowseForArmsPath() + ); + } + return _browseForArmsPathPathCommand; + } + } + + private ICommand _configureArmsExportCommand; + public ICommand ConfigureArmsExportCommand + { + get + { + if (_configureArmsExportCommand == null) + { + _configureArmsExportCommand = new RelayCommand( + p => true, + p => Utils.ScheduledTaskConfig.RegisterArms() + ); ; + } + return _configureArmsExportCommand; + } + } + private ICommand _installUpdatesCommand; public ICommand InstallUpdatesCommand { diff --git a/BodyshopUploader/ViewModels/MainViewModel.cs b/BodyshopUploader/ViewModels/MainViewModel.cs index a27ea6c..a35246f 100644 --- a/BodyshopUploader/ViewModels/MainViewModel.cs +++ b/BodyshopUploader/ViewModels/MainViewModel.cs @@ -256,6 +256,19 @@ namespace BodyshopPartner.ViewModels } + } + public void BrowseForArmsPath() + { + + var dialog = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog(); + dialog.SelectedPath = Properties.Settings.Default.ArmsExportPath; + if (dialog.ShowDialog().GetValueOrDefault()) + { + Properties.Settings.Default.ArmsExportPath = dialog.SelectedPath; + Properties.Settings.Default.Save(); + } + + } public void StopAllFolderMonitors() @@ -362,7 +375,8 @@ namespace BodyshopPartner.ViewModels public void ConfigurePaintScale() { - Utils.PaintScaleConfig.RegisterScheduledTask(); + Utils.ScheduledTaskConfig.RegisterPaintScale(); } + } } diff --git a/BodyshopUploader/Views/Main.xaml b/BodyshopUploader/Views/Main.xaml index cad3e32..6379aff 100644 --- a/BodyshopUploader/Views/Main.xaml +++ b/BodyshopUploader/Views/Main.xaml @@ -11,7 +11,7 @@ xmlns:tb="http://www.hardcodet.net/taskbar" mc:Ignorable="d" Title="{x:Static p:Resources.Title_Main}" - Height="650" + Height="800" Width="800" TextElement.Foreground="{DynamicResource MaterialDesignBody}" TextElement.FontWeight="Regular" @@ -162,9 +162,17 @@