Added Viewer and
change to App Setting File from Constants
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.IO;
|
||||
@ -7,6 +6,7 @@ using System.Linq;
|
||||
|
||||
namespace OI.Metrology.Archive.ApiContollers;
|
||||
|
||||
using OI.Metrology.Archive.Models;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
using OI.Metrology.Shared.Services;
|
||||
@ -21,15 +21,14 @@ 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 IConfiguration Config { get; }
|
||||
private readonly IMetrologyRepo _Repo;
|
||||
private readonly AppSettings _AppSettings;
|
||||
private readonly IAttachmentsService _AttachmentsService;
|
||||
|
||||
protected IMetrologyRepo _Repo;
|
||||
protected IAttachmentsService _AttachmentsService;
|
||||
|
||||
public ToolTypesController(IConfiguration config, IMetrologyRepo repo, IAttachmentsService attachmentsService)
|
||||
public ToolTypesController(AppSettings appSettings, IMetrologyRepo repo, IAttachmentsService attachmentsService)
|
||||
{
|
||||
Config = config;
|
||||
_Repo = repo;
|
||||
_AppSettings = appSettings;
|
||||
_AttachmentsService = attachmentsService;
|
||||
}
|
||||
|
||||
@ -67,7 +66,7 @@ public class ToolTypesController : Controller
|
||||
};
|
||||
return Json(r, new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
|
||||
}
|
||||
//Just Changed here
|
||||
// Just Changed here
|
||||
// Gets headers, request/response format is to allow paging with igniteUI
|
||||
// The headerid parameter is used for navigating directly to a header, when the button is clicked in Awaiting Dispo
|
||||
[HttpGet("/api/tooltypes/{id}/headers")]
|
||||
@ -77,11 +76,11 @@ public class ToolTypesController : Controller
|
||||
[FromQuery] DateTime? dateend,
|
||||
[FromQuery] int? page,
|
||||
[FromQuery] int? pagesize,
|
||||
[FromQuery] long? headerid, bool isSharePoint)
|
||||
[FromQuery] long? headerid)
|
||||
{
|
||||
long totalRecs;
|
||||
|
||||
System.Data.DataTable dt = _Repo.GetHeaders(id, datebegin, dateend, page, pagesize, headerid, out totalRecs, isSharePoint);
|
||||
System.Data.DataTable dt = _Repo.GetHeaders(id, datebegin, dateend, page, pagesize, headerid, out totalRecs);
|
||||
|
||||
var r = new
|
||||
{
|
||||
@ -98,11 +97,11 @@ public class ToolTypesController : Controller
|
||||
public IActionResult GetHeaderTitles(
|
||||
int id,
|
||||
[FromQuery] int? page,
|
||||
[FromQuery] int? pagesize, bool isArchive)
|
||||
[FromQuery] int? pagesize)
|
||||
{
|
||||
long totalRecs;
|
||||
|
||||
IEnumerable<HeaderCommon> dt = _Repo.GetHeaderTitles(id, page, pagesize, out totalRecs, isArchive);
|
||||
IEnumerable<HeaderCommon> dt = _Repo.GetHeaderTitles(id, page, pagesize, out totalRecs);
|
||||
|
||||
var r = new
|
||||
{
|
||||
@ -118,11 +117,11 @@ public class ToolTypesController : Controller
|
||||
[HttpGet("/api/tooltypes/{id}/headers/{headerid}/fields")]
|
||||
public IActionResult GetHeaderFields(
|
||||
int id,
|
||||
long headerid, bool isArchive)
|
||||
long headerid)
|
||||
{
|
||||
var r = new
|
||||
{
|
||||
Results = _Repo.GetHeaderFields(id, headerid, isArchive).Select(x => new { Column = x.Key, x.Value }).ToList()
|
||||
Results = _Repo.GetHeaderFields(id, headerid).Select(x => new { Column = x.Key, x.Value }).ToList()
|
||||
};
|
||||
string json = JsonConvert.SerializeObject(r);
|
||||
|
||||
@ -148,12 +147,12 @@ public class ToolTypesController : Controller
|
||||
[HttpGet("/api/tooltypes/{id}/headers/{headerid}/data")]
|
||||
public IActionResult GetData(
|
||||
int id,
|
||||
long headerid, bool isSharePoint)
|
||||
long headerid)
|
||||
{
|
||||
|
||||
var r = new
|
||||
{
|
||||
Results = _Repo.GetData(id, headerid, isSharePoint)
|
||||
Results = _Repo.GetData(id, headerid)
|
||||
};
|
||||
string json = JsonConvert.SerializeObject(r);
|
||||
|
||||
@ -166,7 +165,7 @@ public class ToolTypesController : Controller
|
||||
int toolTypeId,
|
||||
string tabletype,
|
||||
string attachmentId,
|
||||
string filename, bool isArchive)
|
||||
string filename)
|
||||
{
|
||||
|
||||
ToolType tt = _Repo.GetToolTypeByID(toolTypeId);
|
||||
@ -177,8 +176,6 @@ public class ToolTypesController : Controller
|
||||
if (!Guid.TryParse(attachmentId, out attachmentIdParsed))
|
||||
return Content("Invalid attachment id");
|
||||
|
||||
//try
|
||||
// {
|
||||
// figure out what content type to use. this is very simple because there are only two types being used
|
||||
string contenttype = "application/pdf";
|
||||
if (filename.ToLower().TrimEnd().EndsWith(".txt"))
|
||||
@ -186,18 +183,7 @@ public class ToolTypesController : Controller
|
||||
|
||||
// Get attachment stream and feed it to the client
|
||||
Stream fs = _AttachmentsService.GetAttachmentStreamByAttachmentId(tt, header, attachmentIdParsed, filename);
|
||||
/*if (isArchive)
|
||||
{
|
||||
fs = attachmentsService.GetAttachmentStreamByAttachmentIdArchive(tt, header, attachmentIdParsed, filename);
|
||||
//fs = attachmentsService.GetAttachmentStreamByAttachmentId
|
||||
}*/
|
||||
|
||||
return File(fs, contenttype);
|
||||
//}
|
||||
/*catch (Exception ex)
|
||||
{
|
||||
return Content(ex.Message);
|
||||
}*/
|
||||
}
|
||||
|
||||
// This endpoint triggers writing of the OI Export file
|
||||
@ -247,13 +233,9 @@ public class ToolTypesController : Controller
|
||||
// The output file will only have one line, the header columns are output first
|
||||
// Then each detail rows has it's columns appended
|
||||
// H1, H2, H3, D1.1, D1.2, D1.3, D2.1, D2.2, D2.3, etc
|
||||
|
||||
// Get the configured export path
|
||||
string exportRootPath = Config[Constants.OIExportPathKey];
|
||||
|
||||
// Write the file
|
||||
System.IO.File.WriteAllText(
|
||||
Path.Join(exportRootPath, filename),
|
||||
Path.Join(_AppSettings.OIExportPath, filename),
|
||||
sb.ToString());
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user