IO-227 Succesful export of PPG information.
This commit is contained in:
@@ -67,7 +67,7 @@
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="PaintScalePath" serializeAs="String">
|
||||
<value />
|
||||
<value>C:\Color\PPGExport</value>
|
||||
</setting>
|
||||
<setting name="EmsExportPath" serializeAs="String">
|
||||
<value>C:\CIECA\MITCHELL\EXPORT</value>
|
||||
|
||||
@@ -188,6 +188,7 @@
|
||||
<Compile Include="Utils\LoginHelpers.cs" />
|
||||
<Compile Include="Utils\Notifications.cs" />
|
||||
<Compile Include="Utils\OEConnection.cs" />
|
||||
<Compile Include="Utils\PaintScaleConfig.cs" />
|
||||
<Compile Include="Utils\PowerModeEventHandler.cs" />
|
||||
<Compile Include="Utils\PPGMixData.cs" />
|
||||
<Compile Include="Utils\Queries\JobsQueries.cs" />
|
||||
@@ -252,6 +253,9 @@
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Utils\Scripts\PaintScaleExport.ps1">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Resource Include="Assets\logo1024.png" />
|
||||
<Resource Include="Assets\favicon.ico" />
|
||||
<Resource Include="favicon.ico" />
|
||||
@@ -518,6 +522,9 @@
|
||||
<PackageReference Include="System.Xml.XDocument">
|
||||
<Version>4.3.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="TaskScheduler">
|
||||
<Version>2.9.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="ToastNotifications.Messages">
|
||||
<Version>2.5.1</Version>
|
||||
</PackageReference>
|
||||
|
||||
@@ -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")]
|
||||
18
BodyshopUploader/Properties/Resources.Designer.cs
generated
18
BodyshopUploader/Properties/Resources.Designer.cs
generated
@@ -186,6 +186,15 @@ namespace BodyshopPartner.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to (Re)Configure Paint Scale Task.
|
||||
/// </summary>
|
||||
public static string Label_ConfigurePaintScale {
|
||||
get {
|
||||
return ResourceManager.GetString("Label_ConfigurePaintScale", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to EMS Export Path.
|
||||
/// </summary>
|
||||
@@ -222,6 +231,15 @@ namespace BodyshopPartner.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Paint Scale Path.
|
||||
/// </summary>
|
||||
public static string Label_PaintScalePath {
|
||||
get {
|
||||
return ResourceManager.GetString("Label_PaintScalePath", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to QuickBooks File Path.
|
||||
/// </summary>
|
||||
|
||||
@@ -159,6 +159,9 @@
|
||||
<data name="Label_BrowsePaintScalePath" xml:space="preserve">
|
||||
<value>Browse Paint Scale Path</value>
|
||||
</data>
|
||||
<data name="Label_ConfigurePaintScale" xml:space="preserve">
|
||||
<value>(Re)Configure Paint Scale Task</value>
|
||||
</data>
|
||||
<data name="Label_EmsExport" xml:space="preserve">
|
||||
<value>EMS Export Path</value>
|
||||
</data>
|
||||
@@ -171,6 +174,9 @@
|
||||
<data name="Label_MonitorStatus" xml:space="preserve">
|
||||
<value>Monitor Status</value>
|
||||
</data>
|
||||
<data name="Label_PaintScalePath" xml:space="preserve">
|
||||
<value>Paint Scale Path</value>
|
||||
</data>
|
||||
<data name="Label_QbFilePath" xml:space="preserve">
|
||||
<value>QuickBooks File Path</value>
|
||||
</data>
|
||||
|
||||
2
BodyshopUploader/Properties/Settings.Designer.cs
generated
2
BodyshopUploader/Properties/Settings.Designer.cs
generated
@@ -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"]));
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="PaintScalePath" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
<Value Profile="(Default)">C:\Color\PPGExport</Value>
|
||||
</Setting>
|
||||
<Setting Name="EmsExportPath" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">C:\CIECA\MITCHELL\EXPORT</Value>
|
||||
|
||||
@@ -47,3 +47,5 @@ C15C0B6EE335E383F2CEF0EFA32027B7210AA312 ImEXOnlinePartner-1.0.22-full.nupkg 518
|
||||
187BA94ACAE7FBF770D1D2894FF3A2F13831E7B3 ImEXOnlinePartner-1.0.24-full.nupkg 5303976
|
||||
8E9C189C1D8D768FEA5E3E4B6726C1591F50026D ImEXOnlinePartner-1.0.25-delta.nupkg 58605
|
||||
F502E648C6A0C95ED82247B106CC2D6CBF14BFA6 ImEXOnlinePartner-1.0.25-full.nupkg 5303888
|
||||
3E5481B1FFA814BF5BAE995F1CF54A7B9C57AAF7 ImEXOnlinePartner-1.0.26-delta.nupkg 246927
|
||||
83CF6EBEB7A28CCA28633494874C9F3C19ABEF64 ImEXOnlinePartner-1.0.26-full.nupkg 5474941
|
||||
@@ -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;
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
@@ -101,9 +111,10 @@ namespace BodyshopPartner.Utils
|
||||
|
||||
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("ROStatus", "Open"),
|
||||
new XElement("Customer", $"{job.ownr_ln}, {job.ownr_fn}"),
|
||||
new XElement("ROPainterNotes", ""),
|
||||
new XElement("LicensePlateNum", job.plate_no?.Value),
|
||||
@@ -111,31 +122,29 @@ 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.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
39
BodyshopUploader/Utils/PaintScaleConfig.cs
Normal file
39
BodyshopUploader/Utils/PaintScaleConfig.cs
Normal file
@@ -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.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
32
BodyshopUploader/Utils/Scripts/PaintScaleExport.ps1
Normal file
32
BodyshopUploader/Utils/Scripts/PaintScaleExport.ps1
Normal file
@@ -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}
|
||||
}
|
||||
@@ -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,12 +69,29 @@ 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();
|
||||
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.");
|
||||
}
|
||||
},
|
||||
onAppUninstall: v => mgr.RemoveShortcutForThisExe(),
|
||||
|
||||
onFirstRun: () =>
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -359,5 +359,10 @@ namespace BodyshopPartner.ViewModels
|
||||
Utils.SquirrelAwareHelper.AddHttpExcetion();
|
||||
|
||||
}
|
||||
|
||||
public void ConfigurePaintScale()
|
||||
{
|
||||
Utils.PaintScaleConfig.RegisterScheduledTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 @@
|
||||
<Button Command="{Binding BrowseForPaintScalePathCommand, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="8"
|
||||
Content="{x:Static p:Resources.Label_BrowsePaintScalePath}" />
|
||||
<Button Command="{Binding ConfigurePaintScaleCommand, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="8"
|
||||
Content="{x:Static p:Resources.Label_ConfigurePaintScale}" />
|
||||
<!--<Button Command="{Binding TestCommand}"
|
||||
Margin="8"
|
||||
Content="OE Test" />-->
|
||||
@@ -246,6 +249,11 @@
|
||||
Path=EmsExportPath}"
|
||||
materialDesign:HintAssist.Hint="{x:Static p:Resources.Label_EmsExport}"
|
||||
TextChanged="EmsExportPath_TextChanged" />
|
||||
<TextBox DockPanel.Dock="Top"
|
||||
Text="{Binding Source={x:Static properties:Settings.Default},
|
||||
Path=PaintScalePath}"
|
||||
materialDesign:HintAssist.Hint="{x:Static p:Resources.Label_PaintScalePath}"
|
||||
TextChanged="PaintScalePath_TextChanged" />
|
||||
<TextBox Height="Auto"
|
||||
materialDesign:HintAssist.Hint="{x:Static p:Resources.Label_InteractionLog}"
|
||||
Text="{Binding HttpServerLog}"
|
||||
|
||||
@@ -43,16 +43,15 @@ namespace BodyshopPartner.Views
|
||||
Properties.Settings.Default.QuickBooksFilePath = ((System.Windows.Controls.TextBox)sender).Text;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
|
||||
private void PaintScalePath_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
Properties.Settings.Default.PaintScalePath = ((System.Windows.Controls.TextBox)sender).Text;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
private void EmsExportPath_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
Properties.Settings.Default.EmsExportPath = ((System.Windows.Controls.TextBox)sender).Text;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Utils.PPGMixData.PushDataToPPG();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user