Added supplement checking.
This commit is contained in:
50
BodyshopUploader/Utils/Queries/JobsQueries.cs
Normal file
50
BodyshopUploader/Utils/Queries/JobsQueries.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using GraphQL.Common.Request;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BodyshopUploader.Utils.Queries
|
||||
{
|
||||
class JobsQueries
|
||||
{
|
||||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static async Task<bool> GetJobUuidByClmNo(string ClmNo)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ClmNo))
|
||||
return false;
|
||||
|
||||
var r = new GraphQLRequest
|
||||
{
|
||||
Query = @"query QUERY_JOB_BY_CLM_NO($clm_no: String!) {
|
||||
jobs(where: {clm_no: {_eq: $clm_no}}) {
|
||||
id
|
||||
}
|
||||
}",
|
||||
Variables = new
|
||||
{
|
||||
clm_no = ClmNo
|
||||
}
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var d = await Utils.GraphQL.ExecuteQuery(r);
|
||||
return d.jobs?.Count > 0;
|
||||
|
||||
}
|
||||
catch (ArgumentOutOfRangeException Ex)
|
||||
{
|
||||
logger.Trace(Ex, "No jobs returned in GQL query.");
|
||||
return false;
|
||||
}
|
||||
catch (Exception Ex)
|
||||
{
|
||||
logger.Error(Ex, "Querying for jobs by clm_no failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user