Fixed notification + added saving of active shop id.
This commit is contained in:
@@ -9,6 +9,7 @@ using BodyshopUploader.Utils;
|
||||
using BodyshopUploader.Models;
|
||||
using BodyshopUploader.Utils.Growls;
|
||||
using GraphQL.Common.Request;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace BodyshopUploader.Utils
|
||||
{
|
||||
@@ -46,7 +47,7 @@ namespace BodyshopUploader.Utils
|
||||
}
|
||||
}
|
||||
|
||||
private static void ProcessQueuedItems(object ignored)
|
||||
private static async void ProcessQueuedItems(object ignored)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
@@ -66,7 +67,7 @@ namespace BodyshopUploader.Utils
|
||||
{
|
||||
Thread.Sleep(1000);//Allow a small amount of time to pass before processing the queue item so that any writes can finish.
|
||||
DecodeQueueItemJob(item);
|
||||
UpsertQueueItem(item);
|
||||
await UpsertQueueItem(item);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -83,13 +84,7 @@ namespace BodyshopUploader.Utils
|
||||
}
|
||||
|
||||
private static async Task UpsertQueueItem(DTO_QueueItem item)
|
||||
{
|
||||
item.Job.shopid = "52b7357c-0edd-4c95-85c3-dfdbcdfad9ac";
|
||||
item.Job.est_number = "123";
|
||||
item.Job.vehicle.data.shopid = "52b7357c-0edd-4c95-85c3-dfdbcdfad9ac";
|
||||
|
||||
logger.Info("Manually setting the shop id! {0}", item.Job);
|
||||
|
||||
{
|
||||
var r = new GraphQLRequest
|
||||
{
|
||||
Query = @"
|
||||
@@ -101,52 +96,40 @@ namespace BodyshopUploader.Utils
|
||||
}
|
||||
}",
|
||||
Variables = new
|
||||
{
|
||||
{
|
||||
jobInput = item.Job
|
||||
}
|
||||
};
|
||||
|
||||
var d = await Utils.GraphQL.ExecuteQuery(r);
|
||||
if(d!= null)
|
||||
if (d != null)
|
||||
{
|
||||
logger.Trace("Job insert succesful. Show notification");
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Growler.AddNotification(new Notification()
|
||||
{
|
||||
Title = Properties.Resources.Msg_NewJobUploaded,
|
||||
Subtitle = item.Job?.owner?.data.first_name?.Value + " " + item.Job?.owner?.data.last_name?.Value,
|
||||
Message = item.Job?.vehicle?.data.v_model_yr?.Value + " " + item.Job?.vehicle?.data.v_make_desc?.Value + " " + item.Job?.vehicle?.data.v_model_desc?.Value
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Error("Job insert failed. Show notification");
|
||||
//Succesful upsert
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Growler.AddNotification(new Notification()
|
||||
{
|
||||
Title = Properties.Resources.Msg_NewJobUploadError,
|
||||
Subtitle = item.Job?.owner?.first_name?.Value + " " + item.Job?.owner?.last_name?.Value,
|
||||
Message = item.Job?.vehicle?.v_model_yr?.Value + " " + item.Job?.vehicle?.v_make_desc?.Value + " " + item.Job?.vehicle?.v_model_desc?.Value
|
||||
Subtitle = item.Job.owner?.first_name?.Value + " " + item.Job.owner?.last_name?.Value,
|
||||
Message = item.Job.vehicle?.v_model_yr?.Value + " " + item.Job.vehicle?.v_make_desc?.Value + " " + item.Job.vehicle?.v_model_desc?.Value
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_jobs.Dequeue();
|
||||
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Growler.AddNotification(new Notification()
|
||||
{
|
||||
Title = Properties.Resources.Msg_NewJobUploaded,
|
||||
Subtitle = item.Job?.owner?.first_name?.Value + " " + item.Job?.owner?.last_name?.Value,
|
||||
Message = item.Job?.vehicle?.v_model_yr?.Value + " " + item.Job?.vehicle?.v_make_desc?.Value + " " + item.Job?.vehicle?.v_model_desc?.Value
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void MoveFile(string FullPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(FullPath) + @"\Processed\");
|
||||
File.Move(FullPath, System.IO.Path.GetDirectoryName(FullPath) + @"\Processed\" + System.IO.Path.GetFileNameWithoutExtension(FullPath) + DateTime.Now.Ticks.ToString() + ".bak");
|
||||
|
||||
}
|
||||
catch (Exception Ex)
|
||||
{
|
||||
logger.Error(Ex, "Can't move file {0} - it's gone!", FullPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user