Added fetching for Shop Region + OPCODE decoding.
This commit is contained in:
@@ -48,5 +48,12 @@ namespace BodyshopUploader.Models
|
|||||||
get { return _associationActive; }
|
get { return _associationActive; }
|
||||||
set { SetProperty(ref _associationActive, value); }
|
set { SetProperty(ref _associationActive, value); }
|
||||||
}
|
}
|
||||||
|
private string _regionConfig;
|
||||||
|
[JsonProperty("region_config")]
|
||||||
|
public string RegionConfig
|
||||||
|
{
|
||||||
|
get { return _regionConfig; }
|
||||||
|
set { SetProperty(ref _regionConfig, value); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ namespace BodyshopUploader.Utils
|
|||||||
{
|
{
|
||||||
public static class AppMetaData
|
public static class AppMetaData
|
||||||
{
|
{
|
||||||
|
//TODO: Change firebase API Key to be dependent on what environment monitor has been set for.
|
||||||
public static string FirebaseAPIKey_DEV = "AIzaSyDV9MsSHZmpLtjoaTK_ObvjFaJ-nMSd2KA";
|
public static string FirebaseAPIKey_DEV = "AIzaSyDV9MsSHZmpLtjoaTK_ObvjFaJ-nMSd2KA";
|
||||||
public static string ActiveShopId = Properties.Settings.Default.LastSelectedShop;
|
public static string ActiveShopId = Properties.Settings.Default.LastSelectedShop;
|
||||||
|
public static string ShopRegion = "";
|
||||||
|
public static dynamic CiecaOpCodes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -848,11 +848,7 @@ namespace BodyshopUploader.Utils.Decoder
|
|||||||
|
|
||||||
var allLines = new JArray();
|
var allLines = new JArray();
|
||||||
|
|
||||||
//Create new column to capture lbr op code description. in UI, show partno ? partno : op code desc. has to be stamped
|
|
||||||
//If the OEM_PARTNO is empty, use the operation code and look it up in opcode table. If found, take opcode.opcodedescription and populate oem_partno with it
|
|
||||||
//populate lbr_op with opcode.opcodetouse
|
|
||||||
//if part_type is blank, pull in the part type from parttypetousemitchell
|
|
||||||
//if not found, set description to not efined
|
|
||||||
|
|
||||||
#region Code
|
#region Code
|
||||||
//TODO: How to handle price markup and discounts.
|
//TODO: How to handle price markup and discounts.
|
||||||
@@ -964,6 +960,26 @@ namespace BodyshopUploader.Utils.Decoder
|
|||||||
lin.bett_amt = readValues[43];//BETT_AMT
|
lin.bett_amt = readValues[43];//BETT_AMT
|
||||||
lin.bett_tax = readValues[44];//BETT_TAX
|
lin.bett_tax = readValues[44];//BETT_TAX
|
||||||
|
|
||||||
|
//Create new column to capture lbr op code description. in UI, show partno ? partno : op code desc. has to be stamped
|
||||||
|
//If the OEM_PARTNO is empty, use the operation code and look it up in opcode table. If found, take opcode.opcodedescription and populate oem_partno with it
|
||||||
|
//populate lbr_op with opcode.opcodetouse
|
||||||
|
//if part_type is blank, pull in the part type from parttypetousemitchell
|
||||||
|
//if not found, set description to not efined
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(lin.oem_partno.Value))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lin.op_code_desc = Utils.AppMetaData.CiecaOpCodes[lin.lbr_op.Value]["desc"].Value;
|
||||||
|
}
|
||||||
|
catch (Exception Ex)
|
||||||
|
{
|
||||||
|
logger.Warn(Ex, "Couldnt find OpCodeDesc from {0} ", lin.lbr_op.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
allLines.Add(lin);
|
allLines.Add(lin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -984,6 +1000,10 @@ namespace BodyshopUploader.Utils.Decoder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static object ReflectPropertyValue(object source, string property)
|
||||||
|
{
|
||||||
|
return source.GetType().GetProperty(property).GetValue(source, null);
|
||||||
|
}
|
||||||
|
|
||||||
public static void ParseTtlFile(ref dynamic j, string RootFilePath)
|
public static void ParseTtlFile(ref dynamic j, string RootFilePath)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ namespace BodyshopUploader.Utils
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Thread.Sleep(1000);//Allow a small amount of time to pass before processing the queue item so that any writes can finish.
|
Thread.Sleep(1000);//Allow a small amount of time to pass before processing the queue item so that any writes can finish.
|
||||||
|
await GetOpCodes();
|
||||||
DecodeQueueItemJob(item);
|
DecodeQueueItemJob(item);
|
||||||
await UpsertQueueItem(item);
|
await UpsertQueueItem(item);
|
||||||
}
|
}
|
||||||
@@ -78,6 +79,26 @@ namespace BodyshopUploader.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async Task GetOpCodes()
|
||||||
|
{
|
||||||
|
var r = new GraphQLRequest
|
||||||
|
{
|
||||||
|
Query = @"query MyQuery($key: String!) {
|
||||||
|
masterdata(where: {key: {_eq: $key}}) {
|
||||||
|
value
|
||||||
|
key
|
||||||
|
}
|
||||||
|
}",
|
||||||
|
Variables = new
|
||||||
|
{
|
||||||
|
key = "CA_BC_ciecaopcodes"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var data = await Utils.GraphQL.ExecuteQuery(r);
|
||||||
|
|
||||||
|
Utils.AppMetaData.CiecaOpCodes = JObject.Parse(data.masterdata[0].value.Value);
|
||||||
|
}
|
||||||
|
|
||||||
private static void DecodeQueueItemJob(DTO_QueueItem item)
|
private static void DecodeQueueItemJob(DTO_QueueItem item)
|
||||||
{
|
{
|
||||||
item.Job = Utils.Decoder.EstimateDecoder.CIECAEstimateImport.DecodeEstimate(item.FilePath);
|
item.Job = Utils.Decoder.EstimateDecoder.CIECAEstimateImport.DecodeEstimate(item.FilePath);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using BodyshopUploader.Utils.Growls;
|
|||||||
using GraphQL.Client;
|
using GraphQL.Client;
|
||||||
using GraphQL.Common.Request;
|
using GraphQL.Common.Request;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
@@ -138,6 +139,7 @@ namespace BodyshopUploader.ViewModels
|
|||||||
bodyshops {
|
bodyshops {
|
||||||
shopname
|
shopname
|
||||||
id
|
id
|
||||||
|
region_config
|
||||||
associations {
|
associations {
|
||||||
id
|
id
|
||||||
active
|
active
|
||||||
@@ -194,31 +196,51 @@ namespace BodyshopUploader.ViewModels
|
|||||||
Properties.Settings.Default.LastSelectedShop = ActiveShop.Id;
|
Properties.Settings.Default.LastSelectedShop = ActiveShop.Id;
|
||||||
Properties.Settings.Default.Save();
|
Properties.Settings.Default.Save();
|
||||||
Utils.AppMetaData.ActiveShopId = ActiveShop.Id;
|
Utils.AppMetaData.ActiveShopId = ActiveShop.Id;
|
||||||
|
Utils.AppMetaData.ShopRegion = ActiveShop.RegionConfig;
|
||||||
IndeterminateLoading = false;
|
IndeterminateLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task TestGql()
|
public async Task TestGql()
|
||||||
{
|
{
|
||||||
Notification _n = new Notification()
|
//Notification _n = new Notification()
|
||||||
{
|
|
||||||
Id = 123,
|
|
||||||
Title = "This is a title",
|
|
||||||
Subtitle = "Subtitle",
|
|
||||||
Message = "Somethin"
|
|
||||||
};
|
|
||||||
Growler.AddNotification(_n);
|
|
||||||
|
|
||||||
//var r = new GraphQLRequest
|
|
||||||
//{
|
//{
|
||||||
// Query = @"
|
// Id = 123,
|
||||||
// query QUERY_BODYSHOPS {
|
// Title = "This is a title",
|
||||||
// bodyshops {
|
// Subtitle = "Subtitle",
|
||||||
// shopname
|
// Message = "Somethin"
|
||||||
// id
|
|
||||||
// }
|
|
||||||
// }"
|
|
||||||
//};
|
//};
|
||||||
//await Utils.GraphQL.ExecuteQuery(r);
|
//Growler.AddNotification(_n);
|
||||||
|
|
||||||
|
var r = new GraphQLRequest
|
||||||
|
{
|
||||||
|
Query = @"query MyQuery($key: String!) {
|
||||||
|
masterdata(where: {key: {_eq: $key}}) {
|
||||||
|
value
|
||||||
|
key
|
||||||
|
}
|
||||||
|
}",
|
||||||
|
Variables = new
|
||||||
|
{
|
||||||
|
key = Utils.AppMetaData.ShopRegion + "_ciecaopcodes"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var data = await Utils.GraphQL.ExecuteQuery(r);
|
||||||
|
|
||||||
|
//var t = Newtonsoft.Json.JsonConvert.DeserializeObject<List<dynamic>>(data.masterdata[0].value.Value);
|
||||||
|
Utils.AppMetaData.CiecaOpCodes = JObject.Parse(data.masterdata[0].value.Value);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var aa = Utils.AppMetaData.CiecaOpCodes.Property("OP1").Children();
|
||||||
|
var cc = Utils.AppMetaData.CiecaOpCodes["OP1"]["desc"].Value;
|
||||||
|
var ab = Utils.AppMetaData.CiecaOpCodes.Property("OP1.desc");
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception EX)
|
||||||
|
{
|
||||||
|
logger.Warn("Err");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user