Refactor GQL code. Auto load and save active shops. Auto start monitors.

This commit is contained in:
Patrick Fic
2020-01-20 15:42:59 -08:00
parent bc5cb13113
commit fa75c58633
11 changed files with 166 additions and 68 deletions

View File

@@ -83,15 +83,12 @@ namespace BodyshopUploader.Utils
}
private static async Task UpsertQueueItem(DTO_QueueItem item)
{
//Save the job to the DB.
{
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("Should upsert the job graphqlly here. {0}", item.Job);
logger.Info("Manually setting the shop id! {0}", item.Job);
var r = new GraphQLRequest
{
@@ -104,20 +101,25 @@ namespace BodyshopUploader.Utils
}
}",
Variables = new
{
{
jobInput = item.Job
}
};
using (var g = Utils.GraphQL.CreateGQLClient())
var d = await Utils.GraphQL.ExecuteQuery(r);
if(d!= null)
{
var graphQLResponse = await g.PostAsync(r);
if(graphQLResponse.Errors == null)
App.Current.Dispatcher.Invoke(() =>
{
logger.Trace("Job posted succesfully.");
}
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
});
});
}
_jobs.Dequeue();
App.Current.Dispatcher.Invoke(() =>