TargetFramework update,
reference updates and added tests for Viewer
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
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.IO;
|
||||
@ -8,13 +8,13 @@ using System.IO;
|
||||
namespace OI.Metrology.Archive.ApiControllers;
|
||||
public class AttachmentsController : Controller
|
||||
{
|
||||
private readonly IMetrologyRepo _Repo;
|
||||
private readonly IAttachmentsService _AttachmentsService;
|
||||
private readonly IMetrologyRepository _MetrologyRepository;
|
||||
|
||||
public AttachmentsController(IMetrologyRepo repo, IAttachmentsService attachmentsService)
|
||||
public AttachmentsController(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService)
|
||||
{
|
||||
_Repo = repo;
|
||||
_AttachmentsService = attachmentsService;
|
||||
_MetrologyRepository = metrologyRepository;
|
||||
}
|
||||
|
||||
// this endpoint was created in hope that it would make retrieving attachments to display in OpenInsight easier
|
||||
@ -27,7 +27,7 @@ public class AttachmentsController : Controller
|
||||
string title,
|
||||
string filename)
|
||||
{
|
||||
ToolType tt = _Repo.GetToolTypeByName(toolTypeName);
|
||||
ToolType tt = _MetrologyRepository.GetToolTypeByName(toolTypeName);
|
||||
|
||||
bool header = !string.Equals(tabletype.Trim(), "data", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace OI.Metrology.Archive.ApiContollers;
|
||||
namespace OI.Metrology.Archive.ApiControllers;
|
||||
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using System.Text.Json;
|
||||
|
||||
// this controller is for the Awaiting Dispo functionality
|
||||
|
||||
public class AwaitingDispoController : Controller
|
||||
{
|
||||
private readonly IMetrologyRepo _Repo;
|
||||
private readonly IMetrologyRepository _MetrologyRepository;
|
||||
|
||||
public AwaitingDispoController(IMetrologyRepo repo) => _Repo = repo;
|
||||
public AwaitingDispoController(IMetrologyRepository metrologyRepository) => _MetrologyRepository = metrologyRepository;
|
||||
|
||||
// returns the data to show in the Awaiting Dispo grid
|
||||
// marked no-cache, just-in-case since igniteUI automatically adds a query string parameter to prevent caching
|
||||
@ -21,7 +21,7 @@ public class AwaitingDispoController : Controller
|
||||
{
|
||||
var r = new
|
||||
{
|
||||
Results = _Repo.GetAwaitingDispo()
|
||||
Results = _MetrologyRepository.GetAwaitingDispo()
|
||||
};
|
||||
return Json(r, new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
|
||||
}
|
||||
@ -30,7 +30,7 @@ public class AwaitingDispoController : Controller
|
||||
[HttpPost("/api/awaitingdispo/markasreviewed")]
|
||||
public IActionResult MarkAsReviewed([FromQuery] long headerid, [FromQuery] int tooltypeid)
|
||||
{
|
||||
_ = _Repo.UpdateReviewDate(tooltypeid, headerid, false);
|
||||
_ = _MetrologyRepository.UpdateReviewDate(tooltypeid, headerid, false);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ public class AwaitingDispoController : Controller
|
||||
[HttpPost("/api/awaitingdispo/markasawaiting")]
|
||||
public IActionResult MarkAsAwaiting([FromQuery] long headerid, [FromQuery] int tooltypeid)
|
||||
{
|
||||
if (_Repo.UpdateReviewDate(tooltypeid, headerid, true) <= 1)
|
||||
if (_MetrologyRepository.UpdateReviewDate(tooltypeid, headerid, true) <= 1)
|
||||
return Ok();
|
||||
else
|
||||
return StatusCode(444);
|
||||
|
@ -4,30 +4,30 @@ using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OI.Metrology.Archive.Models;
|
||||
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;
|
||||
using System.Linq;
|
||||
|
||||
namespace OI.Metrology.Archive.ApiContollers;
|
||||
namespace OI.Metrology.Archive.ApiControllers;
|
||||
|
||||
[ApiController]
|
||||
public class InboundController : ControllerBase
|
||||
{
|
||||
private readonly ILogger _Logger;
|
||||
private readonly IMetrologyRepo _Repo;
|
||||
private readonly AppSettings _AppSettings;
|
||||
private readonly IAttachmentsService _AttachmentService;
|
||||
private readonly IInboundDataService _InboundDataService;
|
||||
private readonly IMetrologyRepository _MetrologyRepository;
|
||||
|
||||
public InboundController(AppSettings appSettings, ILogger<InboundController> logger, IMetrologyRepo repo, IInboundDataService inboundDataService, IAttachmentsService attachmentService)
|
||||
public InboundController(AppSettings appSettings, ILogger<InboundController> logger, IMetrologyRepository metrologyRepository, IInboundDataService inboundDataService, IAttachmentsService attachmentService)
|
||||
{
|
||||
_Repo = repo;
|
||||
_Logger = logger;
|
||||
_AppSettings = appSettings;
|
||||
_AttachmentService = attachmentService;
|
||||
_InboundDataService = inboundDataService;
|
||||
_MetrologyRepository = metrologyRepository;
|
||||
}
|
||||
|
||||
// this class represents the API response back to the client
|
||||
@ -61,9 +61,9 @@ public class InboundController : ControllerBase
|
||||
return Unauthorized(r);
|
||||
}
|
||||
|
||||
ToolType toolType = _Repo.GetToolTypeByName(tooltype);
|
||||
ToolType toolType = _MetrologyRepository.GetToolTypeByName(tooltype);
|
||||
|
||||
if (toolType == null)
|
||||
if (toolType is null)
|
||||
{
|
||||
r.Errors.Add("Invalid tool type: " + tooltype);
|
||||
return BadRequest(r);
|
||||
@ -71,9 +71,9 @@ public class InboundController : ControllerBase
|
||||
|
||||
// get metadata
|
||||
|
||||
List<ToolTypeMetadata> metaData = _Repo.GetToolTypeMetadataByToolTypeID(toolType.ID).ToList();
|
||||
List<ToolTypeMetadata> metaData = _MetrologyRepository.GetToolTypeMetadataByToolTypeID(toolType.ID).ToList();
|
||||
|
||||
if (metaData == null)
|
||||
if (metaData is null)
|
||||
{
|
||||
r.Errors.Add("Invalid metadata for tool type: " + tooltype);
|
||||
return BadRequest(r);
|
||||
@ -81,7 +81,7 @@ public class InboundController : ControllerBase
|
||||
|
||||
// validate fields
|
||||
|
||||
if (jsonbody != null)
|
||||
if (jsonbody is not null)
|
||||
_InboundDataService.ValidateJSONFields(jsonbody, 0, metaData, r.Errors, r.Warnings);
|
||||
else
|
||||
r.Errors.Add("Invalid json");
|
||||
@ -118,12 +118,12 @@ public class InboundController : ControllerBase
|
||||
return Unauthorized("Remote IP is not on allowed list");
|
||||
}
|
||||
|
||||
ToolType toolType = _Repo.GetToolTypeByName(tooltype);
|
||||
ToolType toolType = _MetrologyRepository.GetToolTypeByName(tooltype);
|
||||
|
||||
if (toolType == null)
|
||||
if (toolType is null)
|
||||
return BadRequest($"Invalid tool type: {tooltype}");
|
||||
|
||||
if (Request.Form == null)
|
||||
if (Request.Form is null)
|
||||
return BadRequest($"Invalid form");
|
||||
|
||||
if (Request.Form.Files.Count != 1)
|
||||
|
@ -1,22 +1,22 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Linq;
|
||||
|
||||
namespace OI.Metrology.Archive.ApiContollers;
|
||||
namespace OI.Metrology.Archive.ApiControllers;
|
||||
|
||||
using OI.Metrology.Archive.Models;
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using System.Text.Json;
|
||||
|
||||
public class ReactorsController : Controller
|
||||
{
|
||||
|
||||
private readonly IMetrologyRepo _Repo;
|
||||
private readonly AppSettings _AppSettings;
|
||||
private readonly IMetrologyRepository _MetrologyRepository;
|
||||
|
||||
public ReactorsController(AppSettings appSettings, IMetrologyRepo repo)
|
||||
public ReactorsController(AppSettings appSettings, IMetrologyRepository metrologyRepository)
|
||||
{
|
||||
_Repo = repo;
|
||||
_AppSettings = appSettings;
|
||||
_MetrologyRepository = metrologyRepository;
|
||||
}
|
||||
|
||||
private static int[] EvenReactors()
|
||||
|
@ -4,11 +4,11 @@ using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace OI.Metrology.Archive.ApiContollers;
|
||||
namespace OI.Metrology.Archive.ApiControllers;
|
||||
|
||||
using OI.Metrology.Archive.Models;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using OI.Metrology.Shared.Services;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
@ -21,15 +21,15 @@ public class ToolTypesController : Controller
|
||||
// it is named after the /api/tooltypes prefix
|
||||
// the URL pattern is RESTful and the tool type is the root of every request
|
||||
|
||||
private readonly IMetrologyRepo _Repo;
|
||||
private readonly AppSettings _AppSettings;
|
||||
private readonly IAttachmentsService _AttachmentsService;
|
||||
private readonly IMetrologyRepository _MetrologyRepository;
|
||||
|
||||
public ToolTypesController(AppSettings appSettings, IMetrologyRepo repo, IAttachmentsService attachmentsService)
|
||||
public ToolTypesController(AppSettings appSettings, IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService)
|
||||
{
|
||||
_Repo = repo;
|
||||
_AppSettings = appSettings;
|
||||
_AttachmentsService = attachmentsService;
|
||||
_MetrologyRepository = metrologyRepository;
|
||||
}
|
||||
|
||||
// Get a list of tooltypes, returns just Name and ID
|
||||
@ -38,7 +38,7 @@ public class ToolTypesController : Controller
|
||||
{
|
||||
var r = new
|
||||
{
|
||||
Results = _Repo.GetToolTypes().Select(tt => new { tt.ToolTypeName, tt.ID })
|
||||
Results = _MetrologyRepository.GetToolTypes().Select(tt => new { tt.ToolTypeName, tt.ID })
|
||||
};
|
||||
return Json(r, new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
|
||||
}
|
||||
@ -48,8 +48,8 @@ public class ToolTypesController : Controller
|
||||
[HttpGet("/api/tooltypes/{id}")]
|
||||
public IActionResult GetToolTypeMetadata(int id, string sortby = "")
|
||||
{
|
||||
ToolType tt = _Repo.GetToolTypeByID(id);
|
||||
IEnumerable<ToolTypeMetadata> md = _Repo.GetToolTypeMetadataByToolTypeID(id);
|
||||
ToolType tt = _MetrologyRepository.GetToolTypeByID(id);
|
||||
IEnumerable<ToolTypeMetadata> md = _MetrologyRepository.GetToolTypeMetadataByToolTypeID(id);
|
||||
|
||||
if (string.Equals(sortby, "grid", StringComparison.OrdinalIgnoreCase))
|
||||
md = md.OrderBy(f => f.GridDisplayOrder).ToList();
|
||||
@ -80,7 +80,7 @@ public class ToolTypesController : Controller
|
||||
{
|
||||
long totalRecs;
|
||||
|
||||
System.Data.DataTable dt = _Repo.GetHeaders(id, datebegin, dateend, page, pagesize, headerid, out totalRecs);
|
||||
System.Data.DataTable dt = _MetrologyRepository.GetHeaders(id, datebegin, dateend, page, pagesize, headerid, out totalRecs);
|
||||
|
||||
var r = new
|
||||
{
|
||||
@ -101,7 +101,7 @@ public class ToolTypesController : Controller
|
||||
{
|
||||
long totalRecs;
|
||||
|
||||
IEnumerable<HeaderCommon> dt = _Repo.GetHeaderTitles(id, page, pagesize, out totalRecs);
|
||||
IEnumerable<HeaderCommon> dt = _MetrologyRepository.GetHeaderTitles(id, page, pagesize, out totalRecs);
|
||||
|
||||
var r = new
|
||||
{
|
||||
@ -121,7 +121,7 @@ public class ToolTypesController : Controller
|
||||
{
|
||||
var r = new
|
||||
{
|
||||
Results = _Repo.GetHeaderFields(id, headerid).Select(x => new { Column = x.Key, x.Value }).ToList()
|
||||
Results = _MetrologyRepository.GetHeaderFields(id, headerid).Select(x => new { Column = x.Key, x.Value }).ToList()
|
||||
};
|
||||
string json = JsonConvert.SerializeObject(r);
|
||||
|
||||
@ -137,7 +137,7 @@ public class ToolTypesController : Controller
|
||||
|
||||
var r = new
|
||||
{
|
||||
Results = _Repo.GetDataSharePoint(id, title)
|
||||
Results = _MetrologyRepository.GetDataSharePoint(id, title)
|
||||
};
|
||||
string json = JsonConvert.SerializeObject(r);
|
||||
|
||||
@ -152,7 +152,7 @@ public class ToolTypesController : Controller
|
||||
|
||||
var r = new
|
||||
{
|
||||
Results = _Repo.GetData(id, headerid)
|
||||
Results = _MetrologyRepository.GetData(id, headerid)
|
||||
};
|
||||
string json = JsonConvert.SerializeObject(r);
|
||||
|
||||
@ -168,7 +168,7 @@ public class ToolTypesController : Controller
|
||||
string filename)
|
||||
{
|
||||
|
||||
ToolType tt = _Repo.GetToolTypeByID(toolTypeId);
|
||||
ToolType tt = _MetrologyRepository.GetToolTypeByID(toolTypeId);
|
||||
|
||||
bool header = !string.Equals(tabletype.Trim(), "data", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
@ -191,7 +191,7 @@ public class ToolTypesController : Controller
|
||||
public IActionResult OIExport(int toolTypeId, long headerid)
|
||||
{
|
||||
// Call the export stored procedure
|
||||
System.Data.DataSet ds = _Repo.GetOIExportData(toolTypeId, headerid);
|
||||
System.Data.DataSet ds = _MetrologyRepository.GetOIExportData(toolTypeId, headerid);
|
||||
|
||||
try
|
||||
{
|
||||
@ -213,7 +213,7 @@ public class ToolTypesController : Controller
|
||||
|
||||
foreach (object o in ds.Tables[1].Rows[0].ItemArray)
|
||||
{
|
||||
if ((o != null) && (!Convert.IsDBNull(o)))
|
||||
if ((o is not null) && (!Convert.IsDBNull(o)))
|
||||
_ = sb.Append(Convert.ToString(o));
|
||||
_ = sb.Append('\t');
|
||||
}
|
||||
@ -223,7 +223,7 @@ public class ToolTypesController : Controller
|
||||
{
|
||||
foreach (object o in dr.ItemArray)
|
||||
{
|
||||
if ((o != null) && (!Convert.IsDBNull(o)))
|
||||
if ((o is not null) && (!Convert.IsDBNull(o)))
|
||||
_ = sb.Append(Convert.ToString(o));
|
||||
_ = sb.Append('\t');
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public class ErrorHandlerController : Controller
|
||||
public IActionResult Index()
|
||||
{
|
||||
IExceptionHandlerFeature error = HttpContext.Features.Get<IExceptionHandlerFeature>();
|
||||
if (error == null)
|
||||
if (error is null)
|
||||
{
|
||||
return Redirect("~/");
|
||||
}
|
||||
@ -24,7 +24,7 @@ public class ErrorHandlerController : Controller
|
||||
_Logger.LogError("Unhandled exception: " + error.Error.ToString());
|
||||
dynamic r = new
|
||||
{
|
||||
Message = error.Error == null ? "Error" : error.Error.Message
|
||||
Message = error.Error is null ? "Error" : error.Error.Message
|
||||
};
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, r);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OI.Metrology.Archive.Models;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using OI.Metrology.Shared.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -17,14 +17,14 @@ public class ExportController : Controller
|
||||
{
|
||||
private readonly ILogger _Logger;
|
||||
private readonly bool _IsTestDatabase;
|
||||
private readonly IMetrologyRepo _Repo;
|
||||
private readonly AppSettings _AppSettings;
|
||||
private readonly IMetrologyRepository _MetrologyRepository;
|
||||
|
||||
public ExportController(AppSettings appSettings, ILogger<ExportController> logger, IMetrologyRepo repo)
|
||||
public ExportController(AppSettings appSettings, ILogger<ExportController> logger, IMetrologyRepository metrologyRepository)
|
||||
{
|
||||
_Repo = repo;
|
||||
_Logger = logger;
|
||||
_AppSettings = appSettings;
|
||||
_MetrologyRepository = metrologyRepository;
|
||||
_IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ public class ExportController : Controller
|
||||
{
|
||||
if (model.StartTime > model.EndTime)
|
||||
ModelState.AddModelError("EndTime", "End time must be after start time");
|
||||
IEnumerable<ToolType> toolTypes = _Repo.GetToolTypes();
|
||||
IEnumerable<ToolType> toolTypes = _MetrologyRepository.GetToolTypes();
|
||||
toolType = toolTypes.Where(tt => tt.ID.ToString() == model.ToolType).SingleOrDefault();
|
||||
if (toolType is null)
|
||||
ModelState.AddModelError("ToolType", "Invalid selection");
|
||||
@ -94,7 +94,7 @@ public class ExportController : Controller
|
||||
string fileName = string.Format("Export_{0}_{1:yyyyMMddHHmm}_to_{2:yyyyMMddHHmm}.csv", toolTypeName, startTime, endTime);
|
||||
StringBuilder sb = new();
|
||||
|
||||
System.Data.DataTable dt = _Repo.ExportData(spName, startTime, endTime);
|
||||
System.Data.DataTable dt = _MetrologyRepository.ExportData(spName, startTime, endTime);
|
||||
|
||||
_ = sb.AppendLine(GetColumnHeaders(dt));
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using OI.Metrology.Archive.Models;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
using OI.Metrology.Shared.ViewModels;
|
||||
using System;
|
||||
@ -13,12 +14,12 @@ public class PagesController : Controller
|
||||
{
|
||||
private readonly bool _IsTestDatabase;
|
||||
private readonly IRdsMaxRepo _RdsMaxRepo;
|
||||
private readonly IMetrologyRepo _MetrologyRepo;
|
||||
private readonly IMetrologyRepository _MetrologyRepo;
|
||||
|
||||
public PagesController(AppSettings appSettings, IMetrologyRepo metrologyRepo, IRdsMaxRepo rdsMaxRepo)
|
||||
public PagesController(AppSettings appSettings, IMetrologyRepository metrologyRepository, IRdsMaxRepo rdsMaxRepo)
|
||||
{
|
||||
_RdsMaxRepo = rdsMaxRepo;
|
||||
_MetrologyRepo = metrologyRepo;
|
||||
_MetrologyRepo = metrologyRepository;
|
||||
_IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
|
@ -1,61 +1,24 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace OI.Metrology.Archive.Models;
|
||||
|
||||
public class AppSettings
|
||||
public record AppSettings(string ApiLoggingContentTypes,
|
||||
string ApiLoggingPathPrefixes,
|
||||
string ApiLogPath,
|
||||
string AttachmentPath,
|
||||
string BuildNumber,
|
||||
string Company,
|
||||
string ConnectionString,
|
||||
string GitCommitSeven,
|
||||
string InboundApiAllowedIPList,
|
||||
string MonAResource,
|
||||
string MonASite,
|
||||
string Oi2SqlConnectionString,
|
||||
string OIExportPath,
|
||||
string URLs,
|
||||
string WorkingDirectoryName)
|
||||
{
|
||||
|
||||
public string ApiLoggingContentTypes { init; get; }
|
||||
public string ApiLoggingPathPrefixes { init; get; }
|
||||
public string ApiLogPath { init; get; }
|
||||
public string AttachmentPath { init; get; }
|
||||
public string BuildNumber { init; get; }
|
||||
public string Company { init; get; }
|
||||
public string ConnectionString { init; get; }
|
||||
public string GitCommitSeven { init; get; }
|
||||
public string InboundApiAllowedIPList { init; get; }
|
||||
public string MonAResource { init; get; }
|
||||
public string MonASite { init; get; }
|
||||
public string OIExportPath { init; get; }
|
||||
public string Oi2SqlConnectionString { init; get; }
|
||||
public string URLs { init; get; }
|
||||
public string WorkingDirectoryName { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string apiLoggingContentTypes,
|
||||
string apiLoggingPathPrefixes,
|
||||
string apiLogPath,
|
||||
string attachmentPath,
|
||||
string buildNumber,
|
||||
string company,
|
||||
string connectionString,
|
||||
string gitCommitSeven,
|
||||
string inboundApiAllowedIPList,
|
||||
string monAResource,
|
||||
string monASite,
|
||||
string oi2SqlConnectionString,
|
||||
string oiExportPath,
|
||||
string urls,
|
||||
string workingDirectoryName)
|
||||
{
|
||||
ApiLoggingContentTypes = apiLoggingContentTypes;
|
||||
ApiLoggingPathPrefixes = apiLoggingPathPrefixes;
|
||||
ApiLogPath = apiLogPath;
|
||||
AttachmentPath = attachmentPath;
|
||||
BuildNumber = buildNumber;
|
||||
Company = company;
|
||||
ConnectionString = connectionString;
|
||||
GitCommitSeven = gitCommitSeven;
|
||||
InboundApiAllowedIPList = inboundApiAllowedIPList;
|
||||
MonAResource = monAResource;
|
||||
MonASite = monASite;
|
||||
Oi2SqlConnectionString = oi2SqlConnectionString;
|
||||
OIExportPath = oiExportPath;
|
||||
URLs = urls;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
|
@ -37,6 +37,8 @@ public class AppSettings
|
||||
private static Models.AppSettings Get(AppSettings appSettings)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
if (appSettings is null)
|
||||
throw new NullReferenceException(nameof(appSettings));
|
||||
if (appSettings.ApiLoggingContentTypes is null)
|
||||
throw new NullReferenceException(nameof(ApiLoggingContentTypes));
|
||||
if (appSettings.ApiLoggingPathPrefixes is null)
|
||||
|
@ -12,7 +12,7 @@
|
||||
<Nullable>disable</Nullable>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<InternalsVisibleTo Include="Tests" />
|
||||
@ -29,22 +29,22 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.0.123" />
|
||||
<PackageReference Include="EntityFramework" Version="6.4.4" />
|
||||
<PackageReference Include="jQuery" Version="3.6.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
|
||||
<PackageReference Include="jQuery" Version="3.6.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="6.1.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00032" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.4" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\Shared.csproj" />
|
||||
<ProjectReference Include="..\Shared\OI.Metrology.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="moves\" />
|
@ -9,6 +9,7 @@ using OI.Metrology.Archive.Models;
|
||||
using OI.Metrology.Archive.Repositories;
|
||||
using OI.Metrology.Archive.Services;
|
||||
using OI.Metrology.Shared.Models;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
using OI.Metrology.Shared.Services;
|
||||
using Serilog;
|
||||
@ -65,13 +66,13 @@ public class Program
|
||||
{
|
||||
_ = webApplicationBuilder.Services.Configure<ApiBehaviorOptions>(options => options.SuppressModelStateInvalidFilter = true);
|
||||
_ = webApplicationBuilder.Services.AddControllersWithViews();
|
||||
_ = new MetrologyRepo(new SQLDbConnectionFactory(_AppSettings), null);
|
||||
_ = new MetrologyRepository(new SQLDbConnectionFactory(_AppSettings), null);
|
||||
_ = webApplicationBuilder.Services.AddDistributedMemoryCache();
|
||||
_ = webApplicationBuilder.Services.AddMemoryCache();
|
||||
_ = webApplicationBuilder.Services.AddSingleton<AppSettings, AppSettings>(_ => _AppSettings);
|
||||
_ = webApplicationBuilder.Services.AddScoped<IAttachmentsService, AttachmentsService>();
|
||||
_ = webApplicationBuilder.Services.AddScoped<IInboundDataService, InboundDataService>();
|
||||
_ = webApplicationBuilder.Services.AddScoped<IMetrologyRepo, MetrologyRepo>();
|
||||
_ = webApplicationBuilder.Services.AddScoped<IMetrologyRepository, MetrologyRepository>();
|
||||
_ = webApplicationBuilder.Services.AddScoped<IRdsMaxRepo, RdsMaxRepo>();
|
||||
_ = webApplicationBuilder.Services.AddSingleton<IDbConnectionFactory, SQLDbConnectionFactory>();
|
||||
_ = webApplicationBuilder.Services.AddSwaggerGen();
|
||||
@ -87,8 +88,10 @@ public class Program
|
||||
_ = webApplicationBuilder.Services.AddSingleton<IHostLifetime, WindowsServiceLifetime>();
|
||||
_ = webApplicationBuilder.Logging.AddEventLog(settings =>
|
||||
{
|
||||
#pragma warning disable CA1416
|
||||
if (string.IsNullOrEmpty(settings.SourceName))
|
||||
settings.SourceName = webApplicationBuilder.Environment.ApplicationName;
|
||||
#pragma warning restore
|
||||
});
|
||||
}
|
||||
WebApplication webApplication = webApplicationBuilder.Build();
|
||||
|
@ -2,6 +2,7 @@
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -12,12 +13,12 @@ using System.Transactions;
|
||||
|
||||
namespace OI.Metrology.Archive.Repositories;
|
||||
|
||||
public class MetrologyRepo : IMetrologyRepo
|
||||
public class MetrologyRepository : IMetrologyRepository
|
||||
{
|
||||
private readonly IDbConnectionFactory _DBConnectionFactory;
|
||||
private readonly IMemoryCache _Cache;
|
||||
|
||||
public MetrologyRepo(IDbConnectionFactory dbConnectionFactory, IMemoryCache memoryCache)
|
||||
public MetrologyRepository(IDbConnectionFactory dbConnectionFactory, IMemoryCache memoryCache)
|
||||
{
|
||||
_DBConnectionFactory = dbConnectionFactory;
|
||||
_Cache = memoryCache;
|
||||
@ -136,10 +137,10 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
// build field map
|
||||
foreach (ToolTypeMetadata f in fields)
|
||||
{
|
||||
if ((f.ApiName != null) && f.ApiName.Contains('\\'))
|
||||
if ((f.ApiName is not null) && f.ApiName.Contains('\\'))
|
||||
{
|
||||
string n = f.ApiName.Split('\\')[0].Trim().ToUpper();
|
||||
if (containerField == null)
|
||||
if (containerField is null)
|
||||
containerField = n;
|
||||
else if (!string.Equals(containerField, n))
|
||||
throw new Exception("Only one container field is allowed");
|
||||
@ -153,7 +154,7 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
}
|
||||
}
|
||||
|
||||
if (containerField == null)
|
||||
if (containerField is null)
|
||||
{
|
||||
// No container field, just insert a single row
|
||||
|
||||
@ -164,7 +165,7 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
// Find the container field in the json
|
||||
JProperty contJP = jsonrow.Children<JProperty>().Where(c => string.Equals(c.Name.Trim(), containerField, StringComparison.OrdinalIgnoreCase)).SingleOrDefault();
|
||||
|
||||
if ((contJP != null) && (contJP.Value is JArray array))
|
||||
if ((contJP is not null) && (contJP.Value is JArray array))
|
||||
{
|
||||
JArray contRows = array;
|
||||
|
||||
@ -233,7 +234,7 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
}
|
||||
}
|
||||
|
||||
if ((containerrow != null) && (containerFieldmap != null))
|
||||
if ((containerrow is not null) && (containerFieldmap is not null))
|
||||
{
|
||||
|
||||
foreach (JProperty jp in containerrow.Children<JProperty>())
|
||||
@ -264,7 +265,7 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
cmd.CommandText = columns.TrimEnd(',') + parms.TrimEnd(',') + ";SELECT SCOPE_IDENTITY();";
|
||||
|
||||
object o = cmd.ExecuteScalar();
|
||||
if ((o == null) || Convert.IsDBNull(o))
|
||||
if ((o is null) || Convert.IsDBNull(o))
|
||||
throw new Exception("Unexpected query result");
|
||||
return Convert.ToInt64(o);
|
||||
}
|
||||
@ -304,7 +305,7 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
{
|
||||
if (!firstField)
|
||||
_ = sb.Append(',');
|
||||
if (f.GridAttributes != null && f.GridAttributes.Contains("isNull"))
|
||||
if (f.GridAttributes is not null && f.GridAttributes.Contains("isNull"))
|
||||
{
|
||||
_ = sb.AppendFormat("{0}", "ISNULL(" + f.ColumnName + ", '')[" + f.ColumnName + "]");
|
||||
}
|
||||
@ -322,11 +323,11 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
public DataTable GetHeaders(int toolTypeId, DateTime? startTime, DateTime? endTime, int? pageNo, int? pageSize, long? headerId, out long totalRecords)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt == null)
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
|
||||
IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId);
|
||||
if (md == null)
|
||||
if (md is null)
|
||||
throw new Exception("Invalid tool type metadata");
|
||||
|
||||
DataTable dt = new();
|
||||
@ -418,11 +419,11 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
public DataTable GetData(int toolTypeId, long headerid)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt == null)
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
|
||||
IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId);
|
||||
if (md == null)
|
||||
if (md is null)
|
||||
throw new Exception("Invalid tool type metadata");
|
||||
|
||||
DataTable dt = new();
|
||||
@ -529,11 +530,11 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
public DataTable GetDataSharePoint(int toolTypeId, string headerid)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt == null)
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
|
||||
IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId);
|
||||
if (md == null)
|
||||
if (md is null)
|
||||
throw new Exception("Invalid tool type metadata");
|
||||
|
||||
DataTable dt = new();
|
||||
@ -624,7 +625,7 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
public Guid GetHeaderAttachmentID(int toolTypeId, long headerId)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt == null)
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
|
||||
using DbConnection conn = GetDbConnection();
|
||||
@ -637,7 +638,7 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
public Guid GetDataAttachmentID(int toolTypeId, long headerId, string title)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt == null)
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
|
||||
using DbConnection conn = GetDbConnection();
|
||||
@ -656,7 +657,7 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
public DataSet GetOIExportData(int toolTypeId, long headerid)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt == null)
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(tt.OIExportSPName))
|
||||
@ -685,7 +686,7 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
public IEnumerable<HeaderCommon> GetHeaderTitles(int toolTypeId, int? pageNo, int? pageSize, out long totalRecords)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt == null)
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
|
||||
DbConnection conn = GetDbConnection();
|
||||
@ -717,11 +718,11 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
public IEnumerable<KeyValuePair<string, string>> GetHeaderFields(int toolTypeId, long headerid)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt == null)
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
|
||||
IEnumerable<ToolTypeMetadata> md = GetToolTypeMetadataByToolTypeID(toolTypeId);
|
||||
if (md == null)
|
||||
if (md is null)
|
||||
throw new Exception("Invalid tool type metadata");
|
||||
|
||||
List<KeyValuePair<string, string>> r = new();
|
||||
@ -749,10 +750,10 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
foreach (ToolTypeMetadata m in md.Where(m => m.Header == true && m.TableDisplayOrder > 0).OrderBy(m => m.TableDisplayOrder))
|
||||
{
|
||||
string v = "";
|
||||
if (dr != null)
|
||||
if (dr is not null)
|
||||
{
|
||||
object o = dr[m.ColumnName];
|
||||
if (o != null && !Convert.IsDBNull(o))
|
||||
if (o is not null && !Convert.IsDBNull(o))
|
||||
v = Convert.ToString(o);
|
||||
}
|
||||
KeyValuePair<string, string> kvp = new(m.DisplayTitle, v);
|
||||
@ -771,7 +772,7 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
public int UpdateReviewDate(int toolTypeId, long headerId, bool clearDate)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt == null)
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
|
||||
using DbConnection conn = GetDbConnection();
|
||||
@ -792,7 +793,7 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
public Guid GetHeaderAttachmentIDByTitle(int toolTypeId, string title)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt == null)
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
|
||||
using DbConnection conn = GetDbConnection();
|
||||
@ -804,7 +805,7 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
public Guid GetDataAttachmentIDByTitle(int toolTypeId, string title)
|
||||
{
|
||||
ToolType tt = GetToolTypeByID(toolTypeId);
|
||||
if (tt == null)
|
||||
if (tt is null)
|
||||
throw new Exception("Invalid tool type ID");
|
||||
|
||||
using DbConnection conn = GetDbConnection();
|
||||
@ -813,8 +814,8 @@ public class MetrologyRepo : IMetrologyRepo
|
||||
return conn.ExecuteScalar<Guid>(sql, param: new { Title = title });
|
||||
}
|
||||
|
||||
string IMetrologyRepo.GetHeaderInsertDate(int toolTypeId, long headerId) => throw new NotImplementedException();
|
||||
void IMetrologyRepo.SetHeaderDirName(string tableName, long headerId, string dateDir) => throw new NotImplementedException();
|
||||
string IMetrologyRepo.GetDataInsertDate(int toolTypeId, long headerId, string title) => throw new NotImplementedException();
|
||||
void IMetrologyRepo.SetDataDirName(string tableName, long headerId, string title, string dateDir) => throw new NotImplementedException();
|
||||
string IMetrologyRepository.GetHeaderInsertDate(int toolTypeId, long headerId) => throw new NotImplementedException();
|
||||
void IMetrologyRepository.SetHeaderDirName(string tableName, long headerId, string dateDir) => throw new NotImplementedException();
|
||||
string IMetrologyRepository.GetDataInsertDate(int toolTypeId, long headerId, string title) => throw new NotImplementedException();
|
||||
void IMetrologyRepository.SetDataDirName(string tableName, long headerId, string title, string dateDir) => throw new NotImplementedException();
|
||||
}
|
@ -6,27 +6,27 @@ namespace OI.Metrology.Archive.Services;
|
||||
|
||||
using OI.Metrology.Archive.Models;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using OI.Metrology.Shared.Services;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
public class AttachmentsService : IAttachmentsService
|
||||
{
|
||||
|
||||
private readonly IMetrologyRepo _Repo;
|
||||
private readonly AppSettings _AppSettings;
|
||||
private readonly IMetrologyRepository _MetrologyRepository;
|
||||
|
||||
public AttachmentsService(AppSettings appSettings, IMetrologyRepo repo)
|
||||
public AttachmentsService(AppSettings appSettings, IMetrologyRepository metrologyRepository)
|
||||
{
|
||||
_Repo = repo;
|
||||
_AppSettings = appSettings;
|
||||
_MetrologyRepository = metrologyRepository;
|
||||
}
|
||||
protected Stream GetAttachmentStream(string tableName, Guid attachmentId, string filename)
|
||||
{
|
||||
if (attachmentId.Equals(Guid.Empty))
|
||||
throw new Exception("No attachments found");
|
||||
|
||||
DateTime insertDate = Convert.ToDateTime(_Repo.GetAttachmentInsertDateByGUID(tableName, attachmentId));
|
||||
DateTime insertDate = Convert.ToDateTime(_MetrologyRepository.GetAttachmentInsertDateByGUID(tableName, attachmentId));
|
||||
int year = insertDate.Year;
|
||||
DateTime d = insertDate;
|
||||
CultureInfo cul = CultureInfo.CurrentCulture;
|
||||
@ -63,7 +63,7 @@ public class AttachmentsService : IAttachmentsService
|
||||
|
||||
public Stream GetAttachmentStreamByTitle(ToolType toolType, bool header, string title, string filename)
|
||||
{
|
||||
if (toolType == null)
|
||||
if (toolType is null)
|
||||
throw new Exception("Invalid tool type");
|
||||
|
||||
string queryString = "SELECT * FROM " + toolType.DataTableName + " WHERE AttachmentId = @attachmentId";
|
||||
@ -103,19 +103,19 @@ public class AttachmentsService : IAttachmentsService
|
||||
if (header)
|
||||
{
|
||||
tableName = toolType.HeaderTableName;
|
||||
attachmentId = _Repo.GetHeaderAttachmentIDByTitle(toolType.ID, title);
|
||||
attachmentId = _MetrologyRepository.GetHeaderAttachmentIDByTitle(toolType.ID, title);
|
||||
}
|
||||
else
|
||||
{
|
||||
tableName = toolType.DataTableName;
|
||||
attachmentId = _Repo.GetDataAttachmentIDByTitle(toolType.ID, title);
|
||||
attachmentId = _MetrologyRepository.GetDataAttachmentIDByTitle(toolType.ID, title);
|
||||
}
|
||||
return GetAttachmentStream(tableName, attachmentId, filename);
|
||||
}
|
||||
|
||||
public Stream GetAttachmentStreamByAttachmentId(ToolType toolType, bool header, Guid attachmentId, string filename)
|
||||
{
|
||||
if (toolType == null)
|
||||
if (toolType is null)
|
||||
throw new Exception("Invalid tool type");
|
||||
string tableName;
|
||||
if (header)
|
||||
@ -126,7 +126,7 @@ public class AttachmentsService : IAttachmentsService
|
||||
}
|
||||
public Stream GetAttachmentStreamByAttachmentIdArchive(ToolType toolType, bool header, Guid attachmentId, string filename)
|
||||
{
|
||||
if (toolType == null)
|
||||
if (toolType is null)
|
||||
throw new Exception("Invalid tool type");
|
||||
string tableName;
|
||||
if (header)
|
||||
@ -139,21 +139,21 @@ public class AttachmentsService : IAttachmentsService
|
||||
|
||||
private void SaveAttachment(ToolType toolType, long headerId, string dataUniqueId, string filename, Microsoft.AspNetCore.Http.IFormFile uploadedFile)
|
||||
{
|
||||
if (toolType == null)
|
||||
if (toolType is null)
|
||||
throw new Exception("Invalid tool type");
|
||||
|
||||
using System.Transactions.TransactionScope trans = _Repo.StartTransaction();
|
||||
using System.Transactions.TransactionScope trans = _MetrologyRepository.StartTransaction();
|
||||
Guid attachmentId = Guid.Empty;
|
||||
string tableName = "";
|
||||
|
||||
if (string.IsNullOrWhiteSpace(dataUniqueId))
|
||||
{
|
||||
attachmentId = _Repo.GetHeaderAttachmentID(toolType.ID, headerId);
|
||||
attachmentId = _MetrologyRepository.GetHeaderAttachmentID(toolType.ID, headerId);
|
||||
tableName = toolType.HeaderTableName;
|
||||
}
|
||||
else
|
||||
{
|
||||
attachmentId = _Repo.GetDataAttachmentID(toolType.ID, headerId, dataUniqueId);
|
||||
attachmentId = _MetrologyRepository.GetDataAttachmentID(toolType.ID, headerId, dataUniqueId);
|
||||
tableName = toolType.DataTableName;
|
||||
}
|
||||
if (Equals(attachmentId, Guid.Empty))
|
||||
|
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user