diff --git a/BodyshopUploader/BodyshopPartner.csproj b/BodyshopUploader/BodyshopPartner.csproj index 89fafad..a7c8276 100644 --- a/BodyshopUploader/BodyshopPartner.csproj +++ b/BodyshopUploader/BodyshopPartner.csproj @@ -93,11 +93,20 @@ ..\packages\FirebaseAuthentication.net.3.4.0\lib\netstandard1.1\Firebase.Auth.dll - - ..\packages\GraphQL.Client.1.0.3\lib\netstandard2.0\GraphQL.Client.dll + + ..\packages\GraphQL.Client.3.1.4\lib\net461\GraphQL.Client.dll - - ..\packages\GraphQL.Common.1.0.3\lib\netstandard2.0\GraphQL.Common.dll + + ..\packages\GraphQL.Client.Abstractions.3.1.4\lib\netstandard2.0\GraphQL.Client.Abstractions.dll + + + ..\packages\GraphQL.Client.Abstractions.Websocket.3.1.4\lib\netstandard2.0\GraphQL.Client.Abstractions.Websocket.dll + + + ..\packages\GraphQL.Client.Serializer.Newtonsoft.3.1.4\lib\netstandard2.0\GraphQL.Client.Serializer.Newtonsoft.dll + + + ..\packages\GraphQL.Primitives.3.1.4\lib\netstandard2.0\GraphQL.Primitives.dll ..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net451\Hardcodet.Wpf.TaskbarNotification.dll @@ -241,10 +250,16 @@ True True + + ..\packages\System.Net.WebSockets.Client.Managed.1.0.22\lib\net45\System.Net.WebSockets.Client.Managed.dll + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + ..\packages\System.Reactive.4.3.2\lib\net46\System.Reactive.dll + ..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll True @@ -300,7 +315,15 @@ True True + + ..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + + + diff --git a/BodyshopUploader/Utils/GraphQL.cs b/BodyshopUploader/Utils/GraphQL.cs index 2363818..618d8c7 100644 --- a/BodyshopUploader/Utils/GraphQL.cs +++ b/BodyshopUploader/Utils/GraphQL.cs @@ -1,22 +1,24 @@ using GraphQL.Client; -using GraphQL.Common.Request; -using GraphQL.Common.Response; +using GraphQL; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using GraphQL.Client.Http; +using GraphQL.Client.Serializer.Newtonsoft; namespace BodyshopPartner.Utils { public static class GraphQL { private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); - - public static GraphQLClient CreateGQLClient() + + public static GraphQLHttpClient CreateGQLClient() { - var graphQLClient = new GraphQLClient("https://bodyshop-dev-db.herokuapp.com/v1/graphql"); - graphQLClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + Utils.Auth.authlink.FirebaseToken); + var graphQLClient = new GraphQLHttpClient("https://bodyshop-dev-db.herokuapp.com/v1/graphql", new NewtonsoftJsonSerializer()); + + graphQLClient.HttpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + Utils.Auth.authlink.FirebaseToken); return graphQLClient; } @@ -25,9 +27,10 @@ namespace BodyshopPartner.Utils using (var g = Utils.GraphQL.CreateGQLClient()) { logger.Trace("Firing GQL Query: {0} {1}", r.Query.ToString(), r.Variables); - var graphQLResponse = await g.PostAsync(r); + var graphQLResponse = await g.SendQueryAsync(r); if (graphQLResponse.Errors == null) { + //logger.Trace("GQL Response: {0}", graphQLResponse.Data); return graphQLResponse.Data; } diff --git a/BodyshopUploader/Utils/JobProcessingQueue.cs b/BodyshopUploader/Utils/JobProcessingQueue.cs index 4b6812d..64be94e 100644 --- a/BodyshopUploader/Utils/JobProcessingQueue.cs +++ b/BodyshopUploader/Utils/JobProcessingQueue.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using BodyshopPartner.Utils; using BodyshopPartner.Models; using BodyshopPartner.Utils.Growls; -using GraphQL.Common.Request; +using GraphQL; using Newtonsoft.Json.Linq; using ToastNotifications.Messages; @@ -132,7 +132,7 @@ namespace BodyshopPartner.Utils newJob.est_data.vehicleid = vehuuid; } - if (await Utils.Queries.JobsQueries.GetJobUuidByClmNo(item.Job.clm_no?.Value ?? "")) + if (await Utils.Queries.JobsQueries.CheckSupplementByClaimNo(item.Job.clm_no?.Value ?? "")) { newJob.issupplement = true; }; @@ -141,19 +141,21 @@ namespace BodyshopPartner.Utils var r = new GraphQLRequest { Query = @" - mutation INSERT_AVAILABLE_JOB($jobInput: [available_jobs_insert_input!]!) { - insert_available_jobs(objects: $jobInput) { - returning { - id - } - } - }", +mutation INSERT_AVAILABLE_JOB($jobInput: [available_jobs_insert_input!]!) { + insert_available_jobs(objects: $jobInput, on_conflict: {constraint: available_jobs_clm_no_bodyshopid_key, update_columns: [clm_amt, cieca_id, est_data, issupplement, ownr_name, source_system, supplement_number, vehicle_info]}) { + returning { + id + } + } +} + +", Variables = new { - jobInput = newJob + jobInput = newJob, } }; - + //cieca_id, est_data, issupplement, jobid, ownr_name, source_system, supplement_number, vehicle_info try { var d = await Utils.GraphQL.ExecuteQuery(r); diff --git a/BodyshopUploader/Utils/Queries/JobsQueries.cs b/BodyshopUploader/Utils/Queries/JobsQueries.cs index e7f4965..38350d6 100644 --- a/BodyshopUploader/Utils/Queries/JobsQueries.cs +++ b/BodyshopUploader/Utils/Queries/JobsQueries.cs @@ -1,4 +1,4 @@ -using GraphQL.Common.Request; +using GraphQL; using System; using System.Collections.Generic; using System.Linq; @@ -11,7 +11,7 @@ namespace BodyshopPartner.Utils.Queries { private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); - public static async Task GetJobUuidByClmNo(string ClmNo) + public static async Task CheckSupplementByClaimNo(string ClmNo) { if (string.IsNullOrEmpty(ClmNo)) return false; @@ -19,9 +19,9 @@ namespace BodyshopPartner.Utils.Queries var r = new GraphQLRequest { Query = @"query QUERY_JOB_BY_CLM_NO($clm_no: String!) { - jobs(where: {clm_no: {_eq: $clm_no}}) { - id - } + jobs(where: {clm_no: {_eq: $clm_no}}) { + id + } }", Variables = new { diff --git a/BodyshopUploader/Utils/Queries/VehicleQueries.cs b/BodyshopUploader/Utils/Queries/VehicleQueries.cs index f2917c4..8ed840c 100644 --- a/BodyshopUploader/Utils/Queries/VehicleQueries.cs +++ b/BodyshopUploader/Utils/Queries/VehicleQueries.cs @@ -1,4 +1,4 @@ -using GraphQL.Common.Request; +using GraphQL; using System; using System.Collections.Generic; using System.Linq; diff --git a/BodyshopUploader/ViewModels/MainViewModel.cs b/BodyshopUploader/ViewModels/MainViewModel.cs index ec91092..52b22cc 100644 --- a/BodyshopUploader/ViewModels/MainViewModel.cs +++ b/BodyshopUploader/ViewModels/MainViewModel.cs @@ -1,7 +1,7 @@ using BodyshopPartner.Models; using BodyshopPartner.Utils.Growls; using GraphQL.Client; -using GraphQL.Common.Request; +using GraphQL; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; diff --git a/BodyshopUploader/packages.config b/BodyshopUploader/packages.config index dd91103..17be1ba 100644 --- a/BodyshopUploader/packages.config +++ b/BodyshopUploader/packages.config @@ -3,8 +3,11 @@ - - + + + + + @@ -45,8 +48,10 @@ + + @@ -67,7 +72,9 @@ + +