IO-227 Succesful export of PPG information.
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user