Viewer to Server

This commit is contained in:
2023-02-16 15:17:31 -07:00
parent 5c50078c04
commit a25dc93610
968 changed files with 16395 additions and 2385 deletions

View File

@ -1,6 +1,6 @@
using Newtonsoft.Json.Linq;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Repositories;
using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Shared.Services;
using System;
using System.Collections.Generic;
@ -10,9 +10,9 @@ namespace OI.Metrology.Archive.Services;
public class InboundDataService : IInboundDataService
{
private readonly IMetrologyRepo _Repo;
private readonly IMetrologyRepository _MetrologyRepository;
public InboundDataService(IMetrologyRepo repo) => _Repo = repo;
public InboundDataService(IMetrologyRepository metrologyRepository) => _MetrologyRepository = metrologyRepository;
public long DoSQLInsert(JToken jsonbody, ToolType toolType, List<ToolTypeMetadata> metaData)
{
@ -37,11 +37,11 @@ public class InboundDataService : IInboundDataService
long headerId = 0;
using (System.Transactions.TransactionScope transScope = _Repo.StartTransaction())
using (System.Transactions.TransactionScope transScope = _MetrologyRepository.StartTransaction())
{
try
{
_Repo.PurgeExistingData(toolType.ID, uniqueId);
_MetrologyRepository.PurgeExistingData(toolType.ID, uniqueId);
}
catch (Exception ex)
{
@ -50,7 +50,7 @@ public class InboundDataService : IInboundDataService
try
{
headerId = _Repo.InsertToolDataJSON(jsonbody, -1, metaData, toolType.HeaderTableName);
headerId = _MetrologyRepository.InsertToolDataJSON(jsonbody, -1, metaData, toolType.HeaderTableName);
}
catch (Exception ex)
{
@ -60,11 +60,11 @@ public class InboundDataService : IInboundDataService
int detailrow = 1;
try
{
if (detailsArray != null)
if (detailsArray is not null)
{
foreach (JToken detail in detailsArray)
{
_ = _Repo.InsertToolDataJSON(detail, headerId, metaData, toolType.DataTableName);
_ = _MetrologyRepository.InsertToolDataJSON(detail, headerId, metaData, toolType.DataTableName);
detailrow += 1;
}
}
@ -133,7 +133,7 @@ public class InboundDataService : IInboundDataService
if (jp.First is JArray array)
detailsArray = array;
else if ((jp.First is JValue value) && (value.Value == null))
else if ((jp.First is JValue value) && (value.Value is null))
detailsArray = null;
else
errors.Add("Invalid details field");
@ -169,7 +169,7 @@ public class InboundDataService : IInboundDataService
}
// if a Details container if found, process it by recursion
if (detailsArray != null)
if (detailsArray is not null)
{
int i = 1;
foreach (JToken detail in detailsArray)
@ -189,7 +189,7 @@ public class InboundDataService : IInboundDataService
{
// get the json data for this container field, ex: Points
JProperty contJP = jsonbody.Children<JProperty>().Where(jp => string.Equals(jp.Name, containerField, StringComparison.OrdinalIgnoreCase)).SingleOrDefault();
if ((contJP != null) && (contJP.Value is JArray array))
if ((contJP is not null) && (contJP.Value is JArray array))
{
JArray contJPArray = array;