Basic implementation of updating which shop is active.

This commit is contained in:
Patrick Fic
2020-01-20 12:28:08 -08:00
parent 73a2cb4fcb
commit bc5cb13113
9 changed files with 299 additions and 12 deletions

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BodyshopUploader.Utils
{
public static class ApplicationExceptionHandler
{
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
public static void InitExceptionHandlers()
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
//do something with the file contents
}
public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
logger.Fatal((e.ExceptionObject as Exception), "Unhandled generic exception.");
}
}
}

View File

@@ -79,8 +79,6 @@ namespace BodyshopUploader.Utils
private static void DecodeQueueItemJob(DTO_QueueItem item)
{
//Process the job.
logger.Info("Should process the job here. {0}", item.FilePath);
item.Job = Utils.Decoder.EstimateDecoder.CIECAEstimateImport.DecodeEstimate(item.FilePath);
}

View File

@@ -0,0 +1,57 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace BodyshopUploader.Utils
{
class JsonPathConverter : JsonConverter
{
public override object ReadJson(JsonReader reader, Type objectType,
object existingValue, JsonSerializer serializer)
{
JObject jo = JObject.Load(reader);
object targetObj = Activator.CreateInstance(objectType);
foreach (PropertyInfo prop in objectType.GetProperties()
.Where(p => p.CanRead && p.CanWrite))
{
JsonPropertyAttribute att = prop.GetCustomAttributes(true)
.OfType<JsonPropertyAttribute>()
.FirstOrDefault();
string jsonPath = (att != null ? att.PropertyName : prop.Name);
JToken token = jo.SelectToken(jsonPath);
if (token != null && token.Type != JTokenType.Null)
{
object value = token.ToObject(prop.PropertyType, serializer);
prop.SetValue(targetObj, value, null);
}
}
return targetObj;
}
public override bool CanConvert(Type objectType)
{
// CanConvert is not called when [JsonConverter] attribute is used
return false;
}
public override bool CanWrite
{
get { return false; }
}
public override void WriteJson(JsonWriter writer, object value,
JsonSerializer serializer)
{
throw new NotImplementedException();
}
}
}