diff --git a/BodyshopUploader/App.config b/BodyshopUploader/App.config
index 4b07ca1..af29398 100644
--- a/BodyshopUploader/App.config
+++ b/BodyshopUploader/App.config
@@ -66,6 +66,9 @@
True
+
+
+
diff --git a/BodyshopUploader/ImEXOnlinePartner.csproj b/BodyshopUploader/ImEXOnlinePartner.csproj
index 3d6f182..957ab28 100644
--- a/BodyshopUploader/ImEXOnlinePartner.csproj
+++ b/BodyshopUploader/ImEXOnlinePartner.csproj
@@ -188,6 +188,7 @@
+
diff --git a/BodyshopUploader/Properties/Resources.Designer.cs b/BodyshopUploader/Properties/Resources.Designer.cs
index aa2489a..4fdd884 100644
--- a/BodyshopUploader/Properties/Resources.Designer.cs
+++ b/BodyshopUploader/Properties/Resources.Designer.cs
@@ -168,6 +168,15 @@ namespace BodyshopPartner.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Browse Paint Scale Path.
+ ///
+ public static string Label_BrowsePaintScalePath {
+ get {
+ return ResourceManager.GetString("Label_BrowsePaintScalePath", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to File Path.
///
diff --git a/BodyshopUploader/Properties/Resources.resx b/BodyshopUploader/Properties/Resources.resx
index 45f3edf..0e08358 100644
--- a/BodyshopUploader/Properties/Resources.resx
+++ b/BodyshopUploader/Properties/Resources.resx
@@ -153,6 +153,9 @@
Browse for QuickBooks File
+
+ Browse Paint Scale Path
+
File Path
diff --git a/BodyshopUploader/Properties/Settings.Designer.cs b/BodyshopUploader/Properties/Settings.Designer.cs
index 33140e5..ecac653 100644
--- a/BodyshopUploader/Properties/Settings.Designer.cs
+++ b/BodyshopUploader/Properties/Settings.Designer.cs
@@ -12,7 +12,7 @@ namespace BodyshopPartner.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -140,5 +140,17 @@ namespace BodyshopPartner.Properties {
this["StartWithWindows"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string PaintScalePath {
+ get {
+ return ((string)(this["PaintScalePath"]));
+ }
+ set {
+ this["PaintScalePath"] = value;
+ }
+ }
}
}
diff --git a/BodyshopUploader/Properties/Settings.settings b/BodyshopUploader/Properties/Settings.settings
index 1f99d4b..3d36951 100644
--- a/BodyshopUploader/Properties/Settings.settings
+++ b/BodyshopUploader/Properties/Settings.settings
@@ -32,5 +32,8 @@
True
+
+
+
\ No newline at end of file
diff --git a/BodyshopUploader/Utils/PPGMixData.cs b/BodyshopUploader/Utils/PPGMixData.cs
new file mode 100644
index 0000000..12d7954
--- /dev/null
+++ b/BodyshopUploader/Utils/PPGMixData.cs
@@ -0,0 +1,148 @@
+using GraphQL;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+
+namespace BodyshopPartner.Utils
+{
+ public static class PPGMixData
+ {
+ private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
+ private static string PpgDataQuery = @"query PPGDataPump($today: timestamptz!, $todayplus5: timestamptz!, $shopid: uuid!) {
+ bodyshops_by_pk(id:$shopid) {
+ id
+ shopname
+ }
+ jobs(where: {_or: [{_and: [{scheduled_in: {_lte: $todayplus5}}, {scheduled_in: {_gte: $today}}]}, {inproduction: {_eq: true}}]}) {
+ id
+ ro_number
+ status
+ ownr_fn
+ ownr_ln
+ ownr_co_nm
+ v_vin
+ v_model_yr
+ v_make_desc
+ v_model_desc
+ v_color
+ plate_no
+ ins_co_nm
+ est_ct_fn
+ est_ct_ln
+ rate_mapa
+ rate_lab
+ job_totals
+ labhrs: joblines_aggregate(where: {mod_lbr_ty: {_neq: ""LAR""}, removed: {_eq: false}}) {
+ aggregate {
+ sum {
+ mod_lb_hrs
+ }
+}
+ }
+ larhrs: joblines_aggregate(where: { mod_lbr_ty: { _eq: ""LAR""}, removed: { _eq: false} }) {
+ aggregate {
+ sum {
+ mod_lb_hrs
+ }
+ }
+}
+ }
+}
+
+";
+ public static async Task PushDataToPPG()
+ {
+ try
+ {
+ //Get the path for the XML file that should be written. Ensure that we can read and write to that directory.
+
+ //Query the database based on the active shop for all work that's coming within the next 5 days + all active work.
+
+ var r = new GraphQLRequest
+ {
+ Query = PpgDataQuery,
+ Variables = new
+ {
+ today = DateTime.Now.Date,
+ todayplus5 = DateTime.Now.Date.AddDays(5),
+ shopid = AppMetaData.ActiveShopId
+ }
+ };
+
+
+ var data = await Utils.GraphQL.ExecuteQuery(r);
+ //Create an XML document node
+ XDocument doc = new XDocument(
+ 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("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("RepairOrders",
+ new XElement("ROCount", data?.jobs?.Count)
+ )
+ )
+ )
+ )
+ );
+
+ foreach(dynamic job in data.jobs)
+ {
+ 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("Customer", $"{job.ownr_ln}, {job.ownr_fn}"),
+ new XElement("ROPainterNotes", ""),
+ new XElement("LicensePlateNum", job.plate_no?.Value),
+ new XElement("VIN", job.v_vin?.Value),
+ 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("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("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)
+
+
+ ));
+
+ }
+
+
+ doc.Save(@"C:\\VPS\\doc.xml");
+ // doc.Save(Properties.Settings.Default.PaintScalePath);
+ //Ensure all values for strings are escaped.
+
+ //Write the file to the disk and start the timer again.
+ }
+ catch (Exception ex)
+ {
+ logger.Error(ex);
+ }
+
+
+ }
+
+ }
+
+
+
+}
diff --git a/BodyshopUploader/ViewModels/MainViewModel.commands.cs b/BodyshopUploader/ViewModels/MainViewModel.commands.cs
index e950439..48ce442 100644
--- a/BodyshopUploader/ViewModels/MainViewModel.commands.cs
+++ b/BodyshopUploader/ViewModels/MainViewModel.commands.cs
@@ -167,6 +167,21 @@ namespace BodyshopPartner.ViewModels
}
}
+ private ICommand _browseForPaintScalePathCommand;
+ public ICommand BrowseForPaintScalePathCommand
+ {
+ get
+ {
+ if (_browseForPaintScalePathCommand == null)
+ {
+ _browseForPaintScalePathCommand = new RelayCommand(
+ p => true,
+ p => BrowseForPaintScalePath()
+ );
+ }
+ return _browseForPaintScalePathCommand;
+ }
+ }
private ICommand _installUpdatesCommand;
public ICommand InstallUpdatesCommand
diff --git a/BodyshopUploader/ViewModels/MainViewModel.cs b/BodyshopUploader/ViewModels/MainViewModel.cs
index eb67f79..b25f3b8 100644
--- a/BodyshopUploader/ViewModels/MainViewModel.cs
+++ b/BodyshopUploader/ViewModels/MainViewModel.cs
@@ -93,7 +93,7 @@ namespace BodyshopPartner.ViewModels
- #if (!DEBUG)
+#if (!DEBUG)
if (!Utils.AppMetaData.IsTest)
{
logger.Debug("Checking if updates are available.");
@@ -121,7 +121,7 @@ namespace BodyshopPartner.ViewModels
// }
//}
- #endif
+#endif
}
@@ -226,6 +226,21 @@ namespace BodyshopPartner.ViewModels
}
+
+ public void BrowseForPaintScalePath()
+ {
+
+ var dialog = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog();
+ dialog.SelectedPath = Properties.Settings.Default.PaintScalePath;
+ if (dialog.ShowDialog().GetValueOrDefault())
+ {
+ Properties.Settings.Default.PaintScalePath = dialog.SelectedPath;
+ Properties.Settings.Default.Save();
+ }
+
+
+ }
+
public void StopAllFolderMonitors()
{
IndeterminateLoading = true;
diff --git a/BodyshopUploader/Views/Main.xaml b/BodyshopUploader/Views/Main.xaml
index 64384af..f614018 100644
--- a/BodyshopUploader/Views/Main.xaml
+++ b/BodyshopUploader/Views/Main.xaml
@@ -156,6 +156,12 @@
+
+