IO-766 Import Jobs from Disk Scan
This commit is contained in:
@@ -35,6 +35,7 @@ namespace BodyshopPartner.Utils
|
|||||||
|
|
||||||
EstimatesOnDisk.Add(new ScanResponseItem()
|
EstimatesOnDisk.Add(new ScanResponseItem()
|
||||||
{
|
{
|
||||||
|
Id = job.ciecaid,
|
||||||
Filepath = envfp,
|
Filepath = envfp,
|
||||||
Cieca_Id = job.ciecaid,
|
Cieca_Id = job.ciecaid,
|
||||||
Clm_No = job.clm_no,
|
Clm_No = job.clm_no,
|
||||||
|
|||||||
@@ -183,19 +183,22 @@ namespace BodyshopPartner.Utils
|
|||||||
{
|
{
|
||||||
logger.Trace("/import/ - POST");
|
logger.Trace("/import/ - POST");
|
||||||
//Input will be an array of objects containing XMLs.
|
//Input will be an array of objects containing XMLs.
|
||||||
logger.Info(req);
|
|
||||||
List<ScanResponseItem> HttpResponse = new List<ScanResponseItem>();
|
var requestBody = ParseBody(req);
|
||||||
|
JObject HttpResponse = new JObject();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Do the scan
|
//Do the scan
|
||||||
//Add the items to the response list.
|
//Add the items to the response list.
|
||||||
HttpResponse = await Utils.DiskScan.ScanDiskForEstimates();
|
await JobProcessingQueue.UploadJob(new DTO_QueueItem() { FilePath = requestBody.filepath });
|
||||||
|
HttpResponse.Add("success", true);
|
||||||
}
|
}
|
||||||
catch (Exception Ex)
|
catch (Exception Ex)
|
||||||
{
|
{
|
||||||
logger.Error(Ex, "Error encountered while processing QuickBooks requests.");
|
logger.Error(Ex, "Error encountered while processing QuickBooks requests.");
|
||||||
hlog("Error encountered while processing QuickBooks requests.");
|
hlog("Error encountered while processing QuickBooks requests.");
|
||||||
HttpResponse.Add(new ScanResponseItem() { Id = "-1", Success = false, ErrorMessage = Ex.Message });
|
HttpResponse.Add("success" , false);
|
||||||
|
HttpResponse.Add("error", Ex.ToString());
|
||||||
}
|
}
|
||||||
res.WithCORS().AsText(JsonConvert.SerializeObject(HttpResponse));
|
res.WithCORS().AsText(JsonConvert.SerializeObject(HttpResponse));
|
||||||
}
|
}
|
||||||
@@ -211,6 +214,18 @@ namespace BodyshopPartner.Utils
|
|||||||
res.WithCORS().AsText((string)t.ToString());
|
res.WithCORS().AsText((string)t.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static dynamic ParseBody(System.Net.HttpListenerRequest req)
|
||||||
|
{
|
||||||
|
System.IO.Stream body = req.InputStream;
|
||||||
|
System.Text.Encoding encoding = req.ContentEncoding;
|
||||||
|
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
|
||||||
|
string s = reader.ReadToEnd();
|
||||||
|
body.Close();
|
||||||
|
reader.Close();
|
||||||
|
|
||||||
|
return JsonConvert.DeserializeObject(s);
|
||||||
|
}
|
||||||
|
|
||||||
public static List<QbRequestItem> ParseRequest(System.Net.HttpListenerRequest req)
|
public static List<QbRequestItem> ParseRequest(System.Net.HttpListenerRequest req)
|
||||||
{
|
{
|
||||||
System.IO.Stream body = req.InputStream;
|
System.IO.Stream body = req.InputStream;
|
||||||
|
|||||||
@@ -67,10 +67,8 @@ namespace BodyshopPartner.Utils
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Thread.Sleep(1000);//Allow a small amount of time to pass before processing the queue item so that any writes can finish.
|
await UploadJob(item);
|
||||||
await GetOpCodes();
|
|
||||||
DecodeQueueItemJob(item);
|
|
||||||
await UpsertQueueItem(item);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -84,6 +82,14 @@ namespace BodyshopPartner.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task UploadJob(DTO_QueueItem item)
|
||||||
|
{
|
||||||
|
Thread.Sleep(1000);//Allow a small amount of time to pass before processing the queue item so that any writes can finish.
|
||||||
|
await GetOpCodes();
|
||||||
|
DecodeQueueItemJob(item);
|
||||||
|
await UpsertQueueItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task GetOpCodes()
|
public static async Task GetOpCodes()
|
||||||
{
|
{
|
||||||
var r = new GraphQLRequest
|
var r = new GraphQLRequest
|
||||||
|
|||||||
Reference in New Issue
Block a user