diff --git a/BodyshopUploader/App.config b/BodyshopUploader/App.config
index 032e16f..774e37c 100644
--- a/BodyshopUploader/App.config
+++ b/BodyshopUploader/App.config
@@ -67,7 +67,7 @@
True
-
+ C:\Color\PPGExport
C:\CIECA\MITCHELL\EXPORT
diff --git a/BodyshopUploader/ImEXOnlinePartner.csproj b/BodyshopUploader/ImEXOnlinePartner.csproj
index c2d8475..7298cf8 100644
--- a/BodyshopUploader/ImEXOnlinePartner.csproj
+++ b/BodyshopUploader/ImEXOnlinePartner.csproj
@@ -188,6 +188,7 @@
+
@@ -252,6 +253,9 @@
PublicResXFileCodeGenerator
Resources.Designer.cs
+
+ Always
+
@@ -518,6 +522,9 @@
4.3.0
+
+ 2.9.3
+
2.5.1
diff --git a/BodyshopUploader/Properties/AssemblyInfo.cs b/BodyshopUploader/Properties/AssemblyInfo.cs
index b8672fc..c6cf421 100644
--- a/BodyshopUploader/Properties/AssemblyInfo.cs
+++ b/BodyshopUploader/Properties/AssemblyInfo.cs
@@ -51,7 +51,7 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.25.0")]
+[assembly: AssemblyVersion("1.0.26.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//Setting Squirrel Aware Version.
[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]
\ No newline at end of file
diff --git a/BodyshopUploader/Properties/Resources.Designer.cs b/BodyshopUploader/Properties/Resources.Designer.cs
index bdfeeb3..34499f2 100644
--- a/BodyshopUploader/Properties/Resources.Designer.cs
+++ b/BodyshopUploader/Properties/Resources.Designer.cs
@@ -186,6 +186,15 @@ namespace BodyshopPartner.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to (Re)Configure Paint Scale Task.
+ ///
+ public static string Label_ConfigurePaintScale {
+ get {
+ return ResourceManager.GetString("Label_ConfigurePaintScale", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to EMS Export Path.
///
@@ -222,6 +231,15 @@ namespace BodyshopPartner.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Paint Scale Path.
+ ///
+ public static string Label_PaintScalePath {
+ get {
+ return ResourceManager.GetString("Label_PaintScalePath", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to QuickBooks File Path.
///
diff --git a/BodyshopUploader/Properties/Resources.resx b/BodyshopUploader/Properties/Resources.resx
index 41750af..d2d53e5 100644
--- a/BodyshopUploader/Properties/Resources.resx
+++ b/BodyshopUploader/Properties/Resources.resx
@@ -159,6 +159,9 @@
Browse Paint Scale Path
+
+ (Re)Configure Paint Scale Task
+
EMS Export Path
@@ -171,6 +174,9 @@
Monitor Status
+
+ Paint Scale Path
+
QuickBooks File Path
diff --git a/BodyshopUploader/Properties/Settings.Designer.cs b/BodyshopUploader/Properties/Settings.Designer.cs
index 9e7ebe5..4d25104 100644
--- a/BodyshopUploader/Properties/Settings.Designer.cs
+++ b/BodyshopUploader/Properties/Settings.Designer.cs
@@ -143,7 +143,7 @@ namespace BodyshopPartner.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("")]
+ [global::System.Configuration.DefaultSettingValueAttribute("C:\\Color\\PPGExport")]
public string PaintScalePath {
get {
return ((string)(this["PaintScalePath"]));
diff --git a/BodyshopUploader/Properties/Settings.settings b/BodyshopUploader/Properties/Settings.settings
index c47a4ab..5a6c982 100644
--- a/BodyshopUploader/Properties/Settings.settings
+++ b/BodyshopUploader/Properties/Settings.settings
@@ -33,7 +33,7 @@
True
-
+ C:\Color\PPGExport
C:\CIECA\MITCHELL\EXPORT
diff --git a/BodyshopUploader/Releases/RELEASES b/BodyshopUploader/Releases/RELEASES
index ba856fc..299c7db 100644
--- a/BodyshopUploader/Releases/RELEASES
+++ b/BodyshopUploader/Releases/RELEASES
@@ -46,4 +46,6 @@ C15C0B6EE335E383F2CEF0EFA32027B7210AA312 ImEXOnlinePartner-1.0.22-full.nupkg 518
4ACCFC490941BDDE71896FE47E5E4B8ACA293CD8 ImEXOnlinePartner-1.0.24-delta.nupkg 31450
187BA94ACAE7FBF770D1D2894FF3A2F13831E7B3 ImEXOnlinePartner-1.0.24-full.nupkg 5303976
8E9C189C1D8D768FEA5E3E4B6726C1591F50026D ImEXOnlinePartner-1.0.25-delta.nupkg 58605
-F502E648C6A0C95ED82247B106CC2D6CBF14BFA6 ImEXOnlinePartner-1.0.25-full.nupkg 5303888
\ No newline at end of file
+F502E648C6A0C95ED82247B106CC2D6CBF14BFA6 ImEXOnlinePartner-1.0.25-full.nupkg 5303888
+3E5481B1FFA814BF5BAE995F1CF54A7B9C57AAF7 ImEXOnlinePartner-1.0.26-delta.nupkg 246927
+83CF6EBEB7A28CCA28633494874C9F3C19ABEF64 ImEXOnlinePartner-1.0.26-full.nupkg 5474941
\ No newline at end of file
diff --git a/BodyshopUploader/Utils/HTTPServer.cs b/BodyshopUploader/Utils/HTTPServer.cs
index 2b92a7e..d111c8d 100644
--- a/BodyshopUploader/Utils/HTTPServer.cs
+++ b/BodyshopUploader/Utils/HTTPServer.cs
@@ -79,6 +79,17 @@ namespace BodyshopPartner.Utils
(req, res, props) => { HandleOec(req, res); }
, "POST");
+ Route.Add("/paintscale/export/", (req, res, props) =>
+ {
+ hlog("Received a Paint Scale Export Request");
+ res.WithCORS();
+ res.Close();
+ }, "OPTIONS");
+ Route.Add("/paintscale/export/",
+ (req, res, props) => {
+ hlog("Received a Paint Scale Export Request");
+ HandlePaintScaleExport(req, res); }
+ , "POST");
logger.Trace("Starting HTTP server...");
hlog = HttpLogger;
@@ -223,14 +234,14 @@ namespace BodyshopPartner.Utils
{
//Do the scan
//Add the items to the response list.
- await JobProcessingQueue.UploadJob(new DTO_QueueItem() { FilePath = requestBody.filepath });
+ await JobProcessingQueue.UploadJob(new DTO_QueueItem() { FilePath = requestBody.filepath });
HttpResponse.Add("success", true);
}
catch (Exception Ex)
{
logger.Error(Ex, "Error encountered while handling import requests.");
hlog("Error encountered while handling import requests.");
- HttpResponse.Add("success" , false);
+ HttpResponse.Add("success", false);
HttpResponse.Add("error", Ex.ToString());
}
res.WithCORS().AsText(JsonConvert.SerializeObject(HttpResponse));
@@ -256,7 +267,7 @@ namespace BodyshopPartner.Utils
body.Close();
reader.Close();
- return JsonConvert.DeserializeObject(s);
+ return JsonConvert.DeserializeObject(s);
}
public static List ParseRequest(System.Net.HttpListenerRequest req)
@@ -298,6 +309,10 @@ namespace BodyshopPartner.Utils
return XDocument.Parse(input);
}
-
+ private static async void HandlePaintScaleExport(System.Net.HttpListenerRequest req, System.Net.HttpListenerResponse res)
+ {
+ await Utils.PPGMixData.PushDataToPPG();
+ res.WithCORS().AsText("OK");
+ }
}
}
diff --git a/BodyshopUploader/Utils/PPGMixData.cs b/BodyshopUploader/Utils/PPGMixData.cs
index 12d7954..a793b6c 100644
--- a/BodyshopUploader/Utils/PPGMixData.cs
+++ b/BodyshopUploader/Utils/PPGMixData.cs
@@ -6,7 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
-
+using System.IO;
namespace BodyshopPartner.Utils
{
@@ -17,6 +17,7 @@ namespace BodyshopPartner.Utils
bodyshops_by_pk(id:$shopid) {
id
shopname
+ imexshopid
}
jobs(where: {_or: [{_and: [{scheduled_in: {_lte: $todayplus5}}, {scheduled_in: {_gte: $today}}]}, {inproduction: {_eq: true}}]}) {
id
@@ -37,6 +38,9 @@ namespace BodyshopPartner.Utils
rate_mapa
rate_lab
job_totals
+vehicle{
+v_paint_codes
+}
labhrs: joblines_aggregate(where: {mod_lbr_ty: {_neq: ""LAR""}, removed: {_eq: false}}) {
aggregate {
sum {
@@ -81,15 +85,21 @@ namespace BodyshopPartner.Utils
new XElement("PPG",
new XElement("Header",
new XElement("Protocol", new XElement("Message", "PaintShopInterface"), new XElement("Name", "PPG"), new XElement("Version", "1.5.0")),
- new XElement("Transaction", new XElement("TransactionDate", new DateTime().ToString("yyyy-MM-DDTHH:MM:SS"))),
- new XElement("Product", new XElement("Name", data?.bodyshop_by_pk?.paintshopid))
+ new XElement("Transaction",
+ new XElement("TransactionID", null),
+ new XElement("TransactionDate", DateTime.Now.ToString("yyyy-MM-hh:mm:ss"))
+ ),
+ new XElement("Product",
+ new XElement("Name", "ImEX Online"),
+ new XElement("Version", null)
+ )
),
new XElement("DataInterface",
new XElement("ROData",
new XElement("ShopInfo",
- new XElement("ShopID", data?.bodyshop_by_pk?.shopname),
- new XElement("ShopName", data?.bodyshop_by_pk?.shopname)
+ new XElement("ShopID", data?.bodyshops_by_pk?.imexshopid?.Value),
+ new XElement("ShopName", data?.bodyshops_by_pk?.shopname?.Value)
),
new XElement("RepairOrders",
new XElement("ROCount", data?.jobs?.Count)
@@ -99,11 +109,12 @@ namespace BodyshopPartner.Utils
)
);
- foreach(dynamic job in data.jobs)
+ foreach (dynamic job in data.jobs)
{
- doc.Element("PPG").Element("DataInterface").Element("ROData").Element("RepairOrders").Add(new XElement("RO",
+
+ doc.Element("PPG").Element("DataInterface").Element("ROData").Element("RepairOrders").Add(new XElement("RO",
new XElement("RONumber", job.ro_number?.Value),
- new XElement("ROStatus", job.status?.Value),
+ new XElement("ROStatus", "Open"),
new XElement("Customer", $"{job.ownr_ln}, {job.ownr_fn}"),
new XElement("ROPainterNotes", ""),
new XElement("LicensePlateNum", job.plate_no?.Value),
@@ -111,33 +122,31 @@ namespace BodyshopPartner.Utils
new XElement("ModelYear", job.v_model_yr?.Value),
new XElement("MakeDesc", job.v_make_desc?.Value),
new XElement("ModelName", job.v_model_desc?.Value),
- // new XElement("OEMColorCode", job.vehicle?.colorcode),
+ new XElement("OEMColorCode", job.vehicle?.v_paint_codes?.paint_cd1?.Value),
new XElement("RefinishLaborHours", job.larhrs?.aggregate?.sum.mod_lb_hrs?.Value),
new XElement("InsuranceCompanyName", job.ins_co_nm?.Value),
new XElement("EstimatorName", $"{job.est_ct_ln}, {job.est_ct_fn}"),
- new XElement("PaintMaterialsRevenue", 0),
+ new XElement("PaintMaterialsRevenue", ((float)(job.job_totals?.rates?.mapa?.total?.amount?.Value ?? 0)) / 100),
new XElement("PaintMaterialsRate", job.rate_mapa?.Value),
new XElement("BodyHours", job.labhrs?.aggregate.sum?.mod_lb_hrs?.Value),
- new XElement("BodyLaborRate", job.rate_lab?.Value)
- //new XElement("TotalCostOfRepairs", job.job_total.totals.subtotal.amount?.Value / 100)
+ new XElement("BodyLaborRate", job.rate_lab?.Value),
+ new XElement("TotalCostOfRepairs", ((float)(job.job_totals?.totals?.subtotal?.amount?.Value ?? 0)) / 100)
));
}
+ Directory.CreateDirectory(Properties.Settings.Default.PaintScalePath);
- doc.Save(@"C:\\VPS\\doc.xml");
- // doc.Save(Properties.Settings.Default.PaintScalePath);
- //Ensure all values for strings are escaped.
+ doc.Save(Properties.Settings.Default.PaintScalePath + @"\PPGPaint.xml");
- //Write the file to the disk and start the timer again.
}
catch (Exception ex)
{
- logger.Error(ex);
+ logger.Error(ex, "Error while pushing data to PPG paint scale.");
}
-
+
}
diff --git a/BodyshopUploader/Utils/PaintScaleConfig.cs b/BodyshopUploader/Utils/PaintScaleConfig.cs
new file mode 100644
index 0000000..fbd354e
--- /dev/null
+++ b/BodyshopUploader/Utils/PaintScaleConfig.cs
@@ -0,0 +1,39 @@
+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/Scripts/PaintScaleExport.ps1 b/BodyshopUploader/Utils/Scripts/PaintScaleExport.ps1
new file mode 100644
index 0000000..1eb19ff
--- /dev/null
+++ b/BodyshopUploader/Utils/Scripts/PaintScaleExport.ps1
@@ -0,0 +1,32 @@
+#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/paintscale/export/ -Method POST
+}
+
+function v1 {
+WebRequest = [System.Net.WebRequest]::Create("http://localhost:1337/paintscale/export/")
+WebRequest.Method = "POST"
+WebRequest.ContentType = "application/json"
+Response = $WebRequest.GetResponse()
+ResponseStream = $Response.GetResponseStream()
+ReadStream = New-Object System.IO.StreamReader $ResponseStream
+#Data=$ReadStream.ReadToEnd()
+}
+
+
+Switch ($PSversion) {
+ 1 {v1}
+ 2 {v1}
+ 4 {v2}
+ 5 {v2}
+ 6 {v2}
+}
\ No newline at end of file
diff --git a/BodyshopUploader/Utils/SquirrelAwareHelper.cs b/BodyshopUploader/Utils/SquirrelAwareHelper.cs
index 3aa1651..fdfbfdc 100644
--- a/BodyshopUploader/Utils/SquirrelAwareHelper.cs
+++ b/BodyshopUploader/Utils/SquirrelAwareHelper.cs
@@ -5,6 +5,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Squirrel;
+using Microsoft.Win32.TaskScheduler;
+
+
namespace BodyshopPartner.Utils
{
public static class SquirrelAwareHelper
@@ -66,13 +69,30 @@ namespace BodyshopPartner.Utils
Utils.UpdateHandler.ToggleStartWithWindows(true);
mgr.CreateShortcutForThisExe();
},
- onAppUpdate: v => {
+ onAppUpdate: v =>
+ {
mgr.CreateShortcutForThisExe();
Utils.UpdateHandler.RestoreSettings();
Utils.UpdateHandler.ToggleStartWithWindows(Properties.Settings.Default.StartWithWindows);
+ Utils.PaintScaleConfig.RegisterScheduledTask();
},
- onAppUninstall: v => mgr.RemoveShortcutForThisExe(),
-
+ onAppUninstall: v =>
+ {
+ mgr.RemoveShortcutForThisExe();
+ 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");
+ }
+ }
+ catch (Exception ex)
+ {
+ logger.Error(ex, "Error removing task while uninstalling.");
+ }
+ },
+
onFirstRun: () =>
{
logger.Info("We've run for the first time.");
diff --git a/BodyshopUploader/ViewModels/MainViewModel.commands.cs b/BodyshopUploader/ViewModels/MainViewModel.commands.cs
index 05cd541..7126428 100644
--- a/BodyshopUploader/ViewModels/MainViewModel.commands.cs
+++ b/BodyshopUploader/ViewModels/MainViewModel.commands.cs
@@ -202,6 +202,22 @@ namespace BodyshopPartner.ViewModels
}
}
+ private ICommand _configurePaintScaleCommand;
+ public ICommand ConfigurePaintScaleCommand
+ {
+ get
+ {
+ if (_configurePaintScaleCommand == null)
+ {
+ _configurePaintScaleCommand = new RelayCommand(
+ p => true,
+ p => ConfigurePaintScale()
+ );
+ }
+ return _configurePaintScaleCommand;
+ }
+ }
+
private ICommand _installUpdatesCommand;
public ICommand InstallUpdatesCommand
{
diff --git a/BodyshopUploader/ViewModels/MainViewModel.cs b/BodyshopUploader/ViewModels/MainViewModel.cs
index 493e8f6..a27ea6c 100644
--- a/BodyshopUploader/ViewModels/MainViewModel.cs
+++ b/BodyshopUploader/ViewModels/MainViewModel.cs
@@ -359,5 +359,10 @@ namespace BodyshopPartner.ViewModels
Utils.SquirrelAwareHelper.AddHttpExcetion();
}
+
+ public void ConfigurePaintScale()
+ {
+ Utils.PaintScaleConfig.RegisterScheduledTask();
+ }
}
}
diff --git a/BodyshopUploader/Views/Main.xaml b/BodyshopUploader/Views/Main.xaml
index d19f67e..cad3e32 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="600"
+ Height="650"
Width="800"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
@@ -162,6 +162,9 @@
+
@@ -246,6 +249,11 @@
Path=EmsExportPath}"
materialDesign:HintAssist.Hint="{x:Static p:Resources.Label_EmsExport}"
TextChanged="EmsExportPath_TextChanged" />
+