diff --git a/BodyshopUploader/App.config b/BodyshopUploader/App.config
index 93e04ab..7986bd5 100644
--- a/BodyshopUploader/App.config
+++ b/BodyshopUploader/App.config
@@ -81,6 +81,9 @@
0
+
+ C:\CIECA\CCC\IMPORT
+
diff --git a/BodyshopUploader/ImEXOnlinePartner.csproj b/BodyshopUploader/ImEXOnlinePartner.csproj
index e1de7e2..006c7b2 100644
--- a/BodyshopUploader/ImEXOnlinePartner.csproj
+++ b/BodyshopUploader/ImEXOnlinePartner.csproj
@@ -172,6 +172,7 @@
+
Component
diff --git a/BodyshopUploader/Properties/Resources.Designer.cs b/BodyshopUploader/Properties/Resources.Designer.cs
index 689c85f..018a55c 100644
--- a/BodyshopUploader/Properties/Resources.Designer.cs
+++ b/BodyshopUploader/Properties/Resources.Designer.cs
@@ -186,6 +186,15 @@ namespace RomeOnlinePartner.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Brose for PPC Export Path.
+ ///
+ public static string Label_BrowseForPpcExport {
+ get {
+ return ResourceManager.GetString("Label_BrowseForPpcExport", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Browse for QuickBooks File.
///
@@ -294,6 +303,15 @@ namespace RomeOnlinePartner.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Parts Price Change Export Path.
+ ///
+ public static string Label_PpcExport {
+ get {
+ return ResourceManager.GetString("Label_PpcExport", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to QuickBooks File Path.
///
diff --git a/BodyshopUploader/Properties/Resources.resx b/BodyshopUploader/Properties/Resources.resx
index c599f83..4d938a3 100644
--- a/BodyshopUploader/Properties/Resources.resx
+++ b/BodyshopUploader/Properties/Resources.resx
@@ -159,6 +159,9 @@
Browse for EMS Export Path
+
+ Brose for PPC Export Path
+
Browse for QuickBooks File
@@ -195,6 +198,9 @@
RO ->Paint Scale Path
+
+ Parts Price Change Export Path
+
QuickBooks File Path
diff --git a/BodyshopUploader/Properties/Settings.Designer.cs b/BodyshopUploader/Properties/Settings.Designer.cs
index e5777fb..78c3fbe 100644
--- a/BodyshopUploader/Properties/Settings.Designer.cs
+++ b/BodyshopUploader/Properties/Settings.Designer.cs
@@ -200,5 +200,17 @@ namespace RomeOnlinePartner.Properties {
this["PaintScaleImportTimer"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("C:\\CIECA\\CCC\\IMPORT")]
+ public string PpcExportPath {
+ get {
+ return ((string)(this["PpcExportPath"]));
+ }
+ set {
+ this["PpcExportPath"] = value;
+ }
+ }
}
}
diff --git a/BodyshopUploader/Properties/Settings.settings b/BodyshopUploader/Properties/Settings.settings
index 2c58d3d..a448122 100644
--- a/BodyshopUploader/Properties/Settings.settings
+++ b/BodyshopUploader/Properties/Settings.settings
@@ -47,5 +47,8 @@
0
+
+ C:\CIECA\CCC\IMPORT
+
\ No newline at end of file
diff --git a/BodyshopUploader/Utils/CCCPartsPriceChange.cs b/BodyshopUploader/Utils/CCCPartsPriceChange.cs
new file mode 100644
index 0000000..85cf0fc
--- /dev/null
+++ b/BodyshopUploader/Utils/CCCPartsPriceChange.cs
@@ -0,0 +1,178 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using DotNetDBF;
+using Newtonsoft.Json.Linq;
+
+namespace RomeOnlinePartner.Utils
+{
+ class CCCPartsPriceChange
+ {
+
+ private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
+ private static string workingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
+
+ private static string emsBasePath = workingDirectory + @"\EmsBase";
+ private static string TempEmsDir = Properties.Settings.Default.PpcExportPath;
+
+ private static Encoding DbfFileCharEncoding = Encoding.ASCII;
+ private static byte DbfFileSignature = DBFSignature.DBase3; //DBFSignature.WithMemo;
+
+ private static byte DbfFileLanguageDriver = 0; //0x37;
+
+ public static void SendPartsPriceChange(dynamic Job)
+ {
+ Directory.CreateDirectory(TempEmsDir);
+ GenerateLinFile(Job);
+ GenerateEnvFile(Job);
+ }
+
+ public static void GenerateLinFile(dynamic Job)
+ {
+ try
+ {
+ DBFField[] StandardEmsFields = Utils.OEConnection.ReadDbfFields(emsBasePath + @"\EMS.LIN");
+
+ using (var fileStream = File.Create(TempEmsDir + $@"\{Utils.OEConnection.GenerateFileName(Job)}.LIN"))
+ {
+ using (var writer = new DBFWriter())
+ {
+ writer.CharEncoding = DbfFileCharEncoding;
+ writer.Signature = DbfFileSignature;
+ writer.LanguageDriver = DbfFileLanguageDriver;
+
+ writer.Fields = StandardEmsFields;
+
+
+
+ foreach (var jobline in Job.joblines)
+ {
+ writer.AddRecord(
+ jobline?.line_no?.Value,
+jobline?.line_ind?.Value,
+null, //jobline?.line_ref?.Value,
+jobline?.tran_code?.Value ?? "2",
+null, //jobline?.db_ref?.Value,
+jobline?.unq_seq?.Value,
+null, //jobline?.who_pays?.Value,
+jobline?.line_desc?.Value,
+null, //jobline?.part_type?.Value,
+ //partsOrderLine.jobline?.part_type?.Value,
+null, //partsOrderLine.jobline?.part_descj?.Value,
+null, //jobline?.glass_flag?.Value,
+null, //jobline?.oem_partno?.Value,
+null, //jobline?.price_inc?.Value,
+null, //jobline?.alt_part_i?.Value,
+null, //jobline?.tax_part?.Value,
+null, //jobline?.db_price?.Value,
+ jobline.act_price?.Value,
+jobline?.price_j?.Value,
+null, //jobline?.cert_part?.Value,
+null, //jobline?.part_qty?.Value,
+null, //jobline?.alt_co_id?.Value,
+null, //jobline?.alt_partno?.Value,
+null, //jobline?.alt_overrd?.Value,
+null, //jobline?.alt_partm?.Value,
+null, //jobline?.prt_dsmk_p?.Value,
+null, //jobline?.prt_dsmk_m?.Value,
+null, //jobline?.mod_lbr_ty?.Value,
+null, //jobline?.db_hrs?.Value,
+null, //jobline?.mod_lb_hrs?.Value,
+null, //jobline?.lbr_inc?.Value,
+null, //jobline?.lbr_op?.Value,
+null, //jobline?.lbr_hrs_j?.Value,
+null, //jobline?.lbr_typ_j?.Value,
+null, //jobline?.lbr_op_j?.Value,
+null, //jobline?.paint_stg?.Value,
+null, //jobline?.paint_tone?.Value,
+null, //jobline?.lbr_tax?.Value,
+null, //jobline?.lbr_amt?.Value,
+null, //jobline?.misc_amt?.Value,
+null, //jobline?.misc_sublt?.Value,
+null, //jobline?.misc_tax?.Value,
+null, //jobline?.bett_type?.Value,
+null, //jobline?.bett_pctg?.Value,
+null, //jobline?.bett_amt?.Value,
+null //jobline?.bett_tax?.Value
+
+
+ ); ;
+ }
+
+
+
+ writer.Write(fileStream);
+
+ }
+ }
+
+ }
+ catch (Exception ex)
+ {
+ logger.Error(ex, "Error when creating LIN file."); throw ex;
+ }
+
+ }
+ public static void GenerateEnvFile(dynamic Job)
+ {
+ try
+ {
+ DBFField[] StandardEmsFields = Utils.OEConnection.ReadDbfFields(emsBasePath + @"\EMS.ENV");
+
+ using (var fileStream = File.Create(TempEmsDir + $@"\{Utils.OEConnection.GenerateFileName(Job)}.ENV"))
+ {
+ using (var writer = new DBFWriter())
+ {
+ writer.CharEncoding = DbfFileCharEncoding;
+ writer.Signature = DbfFileSignature;
+ writer.LanguageDriver = DbfFileLanguageDriver;
+
+ writer.Fields = StandardEmsFields;
+
+ writer.AddRecord(
+ "C",//EST_SYSTEM,
+ null,//"21.3",//SW_VERSION,
+ null,//"OCT_21_V",//DB_VERSION,
+ null,//DB_DATE
+ "",//UNQFILE_ID,
+ Job.ro_number?.Value,//RO_ID,
+ Job.ciecaid?.Value,//ESTFILE_ID,
+ null,//GetSupplementNumber(Job),//SUPP_NO,
+ null, //EST_CTRY,
+ null,//TOP_SECRET,
+ null,//H_TRANS_ID,
+ null,//H_CTRL_NO,
+ Job.trans_type?.Value,//TRANS_TYPE,
+ false,//STATUS,
+ null,// Job.create_dt?.Value,//CREATE_DT,
+ null,//Job.create_tm?.Value,//CREATE_TM,
+ null,//TRANSMT_DT,
+ null,//TRANSMT_TM,
+ true,//INCL_ADMIN,
+ true,//INCL_VEH,
+ Job.incl_est?.Value,//INCL_EST,
+ true,//INCL_PROFL,
+ true,//INCL_TOTAL,
+ false,//INCL_VENDR,
+ null//EMS_VER,
+ ); ;
+
+ writer.Write(fileStream);
+
+ }
+ }
+
+ }
+ catch (Exception ex)
+ {
+ logger.Error(ex, "Error when creating ENV file."); throw ex;
+ }
+
+ }
+
+ }
+}
diff --git a/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs b/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs
index fdedfad..5e86ec8 100644
--- a/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs
+++ b/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs
@@ -65,7 +65,8 @@ namespace RomeOnlinePartner.Utils.Decoder
{
var reader = new DBFReader(fis);
- reader.SetSelectFields(new string[] { "EST_SYSTEM"
+ reader.SetSelectFields(new string[] { "EST_SYSTEM", "ESTFILE_ID"
+
});
var readValues = reader.NextRecord();
diff --git a/BodyshopUploader/Utils/HTTPServer.cs b/BodyshopUploader/Utils/HTTPServer.cs
index 8d674ce..086e056 100644
--- a/BodyshopUploader/Utils/HTTPServer.cs
+++ b/BodyshopUploader/Utils/HTTPServer.cs
@@ -79,6 +79,16 @@ namespace RomeOnlinePartner.Utils
(req, res, props) => { HandleOec(req, res); }
, "POST");
+ Route.Add("/ppc/", (req, res, props) =>
+ {
+ hlog("Received an PPC from Rome Online");
+ res.WithCORS();
+ res.Close();
+ }, "OPTIONS");
+ Route.Add("/ppc/",
+ (req, res, props) => { HandlePpc(req, res); }
+ , "POST");
+
Route.Add("/paintscale/export/", (req, res, props) =>
{
hlog("Received a Paint Scale Export Request");
@@ -148,6 +158,27 @@ namespace RomeOnlinePartner.Utils
res.WithCORS().AsText(JsonConvert.SerializeObject(HttpResponse));
}
+ private static void HandlePpc(System.Net.HttpListenerRequest req, System.Net.HttpListenerResponse res)
+ {
+ logger.Trace("/ppc/ - POST");
+ //Input will be an array of objects containing XMLs.
+
+ var requestBody = ParseBody(req);
+ JObject HttpResponse = new JObject();
+ try
+ {
+ Utils.CCCPartsPriceChange.SendPartsPriceChange(requestBody);
+ 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("error", Ex.ToString());
+ }
+ res.WithCORS().AsText(JsonConvert.SerializeObject(HttpResponse));
+ }
private static void HandleQbPost(System.Net.HttpListenerRequest req, System.Net.HttpListenerResponse res)
{
diff --git a/BodyshopUploader/ViewModels/MainViewModel.commands.cs b/BodyshopUploader/ViewModels/MainViewModel.commands.cs
index dbb9ec2..dafd50d 100644
--- a/BodyshopUploader/ViewModels/MainViewModel.commands.cs
+++ b/BodyshopUploader/ViewModels/MainViewModel.commands.cs
@@ -184,7 +184,21 @@ namespace RomeOnlinePartner.ViewModels
return _browseForEmsFolderCommand;
}
}
-
+ private ICommand _browseForPpcFolderCommand;
+ public ICommand BrowseForPpcFolderCommand
+ {
+ get
+ {
+ if (_browseForPpcFolderCommand == null)
+ {
+ _browseForPpcFolderCommand = new RelayCommand(
+ p => true,
+ p => BrowseForPpcFolder()
+ );
+ }
+ return _browseForPpcFolderCommand;
+ }
+ }
private ICommand _browseForPaintScalePathCommand;
public ICommand BrowseForPaintScalePathCommand
diff --git a/BodyshopUploader/ViewModels/MainViewModel.cs b/BodyshopUploader/ViewModels/MainViewModel.cs
index 1a1efea..92144de 100644
--- a/BodyshopUploader/ViewModels/MainViewModel.cs
+++ b/BodyshopUploader/ViewModels/MainViewModel.cs
@@ -242,8 +242,16 @@ namespace RomeOnlinePartner.ViewModels
Properties.Settings.Default.EmsExportPath = dialog.SelectedPath;
Properties.Settings.Default.Save();
}
-
-
+ }
+ public void BrowseForPpcFolder()
+ {
+ var dialog = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog();
+ dialog.SelectedPath = Properties.Settings.Default.PpcExportPath;
+ if (dialog.ShowDialog().GetValueOrDefault())
+ {
+ Properties.Settings.Default.PpcExportPath = dialog.SelectedPath;
+ Properties.Settings.Default.Save();
+ }
}
public void BrowseForPaintScalePath()
diff --git a/BodyshopUploader/Views/Main.xaml b/BodyshopUploader/Views/Main.xaml
index c1347fc..23fbbfe 100644
--- a/BodyshopUploader/Views/Main.xaml
+++ b/BodyshopUploader/Views/Main.xaml
@@ -153,22 +153,6 @@
Margin="8"
Content="{x:Static p:Resources.Label_RemoveAllPaths}" />
-
-
-
-
-
-
@@ -248,30 +232,87 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+ materialDesign:HintAssist.Hint="{x:Static p:Resources.Label_ArmsExportPath}"
+ TextChanged="ArmsExportPath_TextChanged" />
+
+
+
+
-
+ AcceptsReturn="True" />
+
+
diff --git a/BodyshopUploader/Views/Main.xaml.cs b/BodyshopUploader/Views/Main.xaml.cs
index 03a48ca..32c49fb 100644
--- a/BodyshopUploader/Views/Main.xaml.cs
+++ b/BodyshopUploader/Views/Main.xaml.cs
@@ -73,5 +73,11 @@ namespace RomeOnlinePartner.Views
Properties.Settings.Default.EmsExportPath = ((System.Windows.Controls.TextBox)sender).Text;
Properties.Settings.Default.Save();
}
+
+ private void PpcExportPath_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ Properties.Settings.Default.PpcExportPath = ((System.Windows.Controls.TextBox)sender).Text;
+ Properties.Settings.Default.Save();
+ }
}
}