From 73a2cb4fcbcf988c827886f878973e46d48b4802 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 17 Jan 2020 20:08:21 -0800 Subject: [PATCH] Added vehicle changes & updates. --- BodyshopUploader/App.config | 3 + .../Properties/Settings.Designer.cs | 14 +++- BodyshopUploader/Properties/Settings.settings | 3 + .../Utils/Decoder/EstimateDecoder.cs | 77 ++++++++++++++++--- BodyshopUploader/Utils/JobProcessingQueue.cs | 15 +++- 5 files changed, 97 insertions(+), 15 deletions(-) diff --git a/BodyshopUploader/App.config b/BodyshopUploader/App.config index 98477bb..1a9db1e 100644 --- a/BodyshopUploader/App.config +++ b/BodyshopUploader/App.config @@ -37,6 +37,9 @@ + + False + \ No newline at end of file diff --git a/BodyshopUploader/Properties/Settings.Designer.cs b/BodyshopUploader/Properties/Settings.Designer.cs index 72b50dd..6e20028 100644 --- a/BodyshopUploader/Properties/Settings.Designer.cs +++ b/BodyshopUploader/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace BodyshopUploader.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -56,5 +56,17 @@ namespace BodyshopUploader.Properties { this["MonitoringPaths"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool AutoStartMonitors { + get { + return ((bool)(this["AutoStartMonitors"])); + } + set { + this["AutoStartMonitors"] = value; + } + } } } diff --git a/BodyshopUploader/Properties/Settings.settings b/BodyshopUploader/Properties/Settings.settings index 2cd3009..d6b608b 100644 --- a/BodyshopUploader/Properties/Settings.settings +++ b/BodyshopUploader/Properties/Settings.settings @@ -11,5 +11,8 @@ + + False + \ No newline at end of file diff --git a/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs b/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs index d553804..6afe921 100644 --- a/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs +++ b/BodyshopUploader/Utils/Decoder/EstimateDecoder.cs @@ -30,7 +30,7 @@ namespace BodyshopUploader.Utils.Decoder string _dir = Path.GetDirectoryName(FilePath) + @"\"; ParseAd1File(ref ret, _dir); - //ParseVehFile(ref ret, _dir); + ParseVehFile(ref ret, _dir); //ParseStlFile(ref ret, _dir); //ParseTtlFile(ref ret, _dir); //ParseLinFile(ref ret, _dir); @@ -212,16 +212,73 @@ namespace BodyshopUploader.Utils.Decoder { using (Stream fis = File.Open(RootFilePath + j.ciecaid.Value + "v.veh", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { - var reader = new DBFReader(fis); - reader.SetSelectFields(new string[] { "V_MODEL_YR", "V_MAKEDESC", "V_MODEL", "V_COLOR", "PLATE_NO", "V_VIN" }); - var readValues = reader.NextRecord(); - j.V_Model_Yr = readValues[0].ToString(); - j.V_Make_Desc = readValues[1].ToString(); - j.V_Model = readValues[2].ToString(); - j.V_Color = readValues[3].ToString(); - j.Lic_Plate = readValues[4].ToString(); - j.V_Vin = readValues[5].ToString(); + dynamic v = new JObject(); + var reader = new DBFReader(fis); + reader.SetSelectFields(new string[] { "IMPACT_1", + "IMPACT_2", + "DB_V_CODE", + "PLATE_NO", + "PLATE_ST", + "V_VIN", + "V_COND", + "V_PROD_DT", + "V_MODEL_YR", + "V_MAKECODE", + "V_MAKEDESC", + "V_MODEL", + "V_TYPE", // + "V_BSTYLE", + "V_TRIMCODE", + "TRIM_COLOR", + "V_MLDGCODE", + "V_ENGINE", + + "V_COLOR", + "V_TONE", + "V_STAGE", + "PAINT_CD1", + "PAINT_CD2", + "PAINT_CD3" + }); + + var readValues = reader.NextRecord(); + + dynamic d = new JObject(); + d.impact1 = readValues[0]?.ToString(); + d.impact2 = readValues[1]?.ToString(); + + j.area_of_damage = d; + + v.db_v_code = readValues[2]?.ToString(); + v.plate_no = readValues[3]?.ToString(); + v.plate_st = readValues[4]?.ToString(); + v.v_vin = readValues[5]?.ToString(); + v.v_cond = readValues[6]?.ToString(); + v.v_prod_dt = readValues[7]?.ToString(); + v.v_model_yr = readValues[8]?.ToString(); + v.v_makecode = readValues[9]?.ToString(); + v.v_make_desc = readValues[10]?.ToString(); + v.v_model_desc = readValues[11]?.ToString(); + v.v_type = readValues[12]?.ToString(); + v.v_bstyle = readValues[13]?.ToString(); + v.v_trimcode = readValues[14]?.ToString(); + v.trim_color = readValues[15]?.ToString(); + v.v_mldgcode = readValues[16]?.ToString(); + v.v_engine = readValues[17]?.ToString(); + // v.v_options = readValues[18]?.ToString(); + v.v_color = readValues[18]?.ToString(); + v.v_tone = readValues[19]?.ToString(); + v.v_stage = readValues[20]?.ToString(); + + dynamic p = new JObject(); + p.paint_cd1 = readValues[21]?.ToString(); + p.paint_cd2 = readValues[22]?.ToString(); + p.paint_cd3 = readValues[23]?.ToString(); + v.v_paint_codes = p; + + j.vehicle = new JObject(); + j.vehicle.data = v; } return; } diff --git a/BodyshopUploader/Utils/JobProcessingQueue.cs b/BodyshopUploader/Utils/JobProcessingQueue.cs index 9252754..7fe78df 100644 --- a/BodyshopUploader/Utils/JobProcessingQueue.cs +++ b/BodyshopUploader/Utils/JobProcessingQueue.cs @@ -87,10 +87,13 @@ namespace BodyshopUploader.Utils private static async Task UpsertQueueItem(DTO_QueueItem item) { //Save the job to the DB. - logger.Info("Should upsert the job graphqlly here. {0}", item.Job); + item.Job.shopid = "52b7357c-0edd-4c95-85c3-dfdbcdfad9ac"; - item.Job.est_number = "lul?"; + item.Job.est_number = "123"; + item.Job.vehicle.data.shopid = "52b7357c-0edd-4c95-85c3-dfdbcdfad9ac"; + + logger.Info("Should upsert the job graphqlly here. {0}", item.Job); var r = new GraphQLRequest { @@ -112,8 +115,12 @@ namespace BodyshopUploader.Utils using (var g = Utils.GraphQL.CreateGQLClient()) { var graphQLResponse = await g.PostAsync(r); - logger.Info(graphQLResponse.Data.jobs); + if(graphQLResponse.Errors == null) + { + logger.Trace("Job posted succesfully."); + } } + _jobs.Dequeue(); App.Current.Dispatcher.Invoke(() => { @@ -125,7 +132,7 @@ namespace BodyshopUploader.Utils }); }); - _jobs.Dequeue(); + } private static void MoveFile(string FullPath)