diff --git a/.vscode/thunder-tests/thunderCollection.json b/.vscode/thunder-tests/thunderCollection.json index c446e0a..717b1a2 100644 --- a/.vscode/thunder-tests/thunderCollection.json +++ b/.vscode/thunder-tests/thunderCollection.json @@ -1,7 +1,7 @@ [ { "_id": "3743bec1-1f73-492a-9b9f-5889f239b5fc", - "colName": "InfinityQS", + "colName": "InfinityQS EC Only", "created": "2023-02-27T20:07:11.913Z", "sortNum": 10000, "folders": [] diff --git a/.vscode/thunder-tests/thunderclient.json b/.vscode/thunder-tests/thunderclient.json index 617b1e8..c1c1e9c 100644 --- a/.vscode/thunder-tests/thunderclient.json +++ b/.vscode/thunder-tests/thunderclient.json @@ -347,16 +347,16 @@ "colId": "5bfd00bc-b58c-49d3-9f27-5acadd060a51", "containerId": "", "name": "GetHeaders", - "url": "https://mestsa008.infineon.com:50302/api/export/headers", + "url": "https://messa017.infineon.com/api/export/headers", "method": "GET", "sortNum": 10000, "created": "2023-03-08T17:31:19.471Z", - "modified": "2023-03-08T18:48:51.819Z", + "modified": "2023-04-07T15:10:34.584Z", "headers": [], "params": [], "body": { "type": "json", - "raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": 1678296039\n}", + "raw": "{\n \"PSN\": \"4830\",\n \"Reactor\": \"41\",\n \"RDS\": \"584740\",\n \"ID\": 1680657537,\n \"Path\": \"\\\\\\\\messdv002.na.infineon.com\\\\Candela\\\\Archive\\\\API\\\\2023_Week_14\\\\-4830\\\\-41\\\\-584740\\\\-1680657537\\\\638162291037289598.json\"\n}", "form": [] }, "tests": [] @@ -366,16 +366,16 @@ "colId": "5bfd00bc-b58c-49d3-9f27-5acadd060a51", "containerId": "", "name": "GetExport", - "url": "https://mestsa008.infineon.com:50302/api/export/export", + "url": "https://messa017.infineon.com/api/export/export", "method": "GET", "sortNum": 15000, "created": "2023-03-08T17:31:19.472Z", - "modified": "2023-03-08T17:31:19.472Z", + "modified": "2023-04-07T15:10:45.402Z", "headers": [], "params": [], "body": { "type": "json", - "raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": 1678296039\n}", + "raw": "{\n \"PSN\": \"4830\",\n \"Reactor\": \"41\",\n \"RDS\": \"584740\",\n \"ID\": 1680657537,\n \"Path\": \"\\\\\\\\messdv002.na.infineon.com\\\\Candela\\\\Archive\\\\API\\\\2023_Week_14\\\\-4830\\\\-41\\\\-584740\\\\-1680657537\\\\638162291037289598.json\"\n}", "form": [] }, "tests": [] @@ -385,16 +385,16 @@ "colId": "5bfd00bc-b58c-49d3-9f27-5acadd060a51", "containerId": "", "name": "GetLogistics", - "url": "https://mestsa008.infineon.com:50302/api/export/logistics", + "url": "https://messa017.infineon.com/api/export/logistics", "method": "GET", "sortNum": 30000, "created": "2023-03-08T17:31:19.473Z", - "modified": "2023-03-08T17:31:19.473Z", + "modified": "2023-04-07T15:10:49.000Z", "headers": [], "params": [], "body": { "type": "json", - "raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": 1678296039\n}", + "raw": "{\n \"PSN\": \"4830\",\n \"Reactor\": \"41\",\n \"RDS\": \"584740\",\n \"ID\": 1680657537,\n \"Path\": \"\\\\\\\\messdv002.na.infineon.com\\\\Candela\\\\Archive\\\\API\\\\2023_Week_14\\\\-4830\\\\-41\\\\-584740\\\\-1680657537\\\\638162291037289598.json\"\n}", "form": [] }, "tests": [] @@ -404,16 +404,16 @@ "colId": "5bfd00bc-b58c-49d3-9f27-5acadd060a51", "containerId": "", "name": "GetProcessDataStandardFormat", - "url": "https://mestsa008.infineon.com:50302/api/export/pdsf", + "url": "https://messa017.infineon.com/api/export/pdsf", "method": "GET", "sortNum": 40000, "created": "2023-03-08T17:31:19.474Z", - "modified": "2023-03-08T17:31:19.474Z", + "modified": "2023-04-07T15:10:53.080Z", "headers": [], "params": [], "body": { "type": "json", - "raw": "{\n \"PSN\": \"4698\",\n \"RDS\": \"578824\",\n \"Reactor\": \"62\",\n \"ID\": 1678296039\n}", + "raw": "{\n \"PSN\": \"4830\",\n \"Reactor\": \"41\",\n \"RDS\": \"584740\",\n \"ID\": 1680657537,\n \"Path\": \"\\\\\\\\messdv002.na.infineon.com\\\\Candela\\\\Archive\\\\API\\\\2023_Week_14\\\\-4830\\\\-41\\\\-584740\\\\-1680657537\\\\638162291037289598.json\"\n}", "form": [] }, "tests": [] diff --git a/Archive/Controllers/PagesController.cs b/Archive/Controllers/PagesController.cs index a8fe79c..7f5dc51 100644 --- a/Archive/Controllers/PagesController.cs +++ b/Archive/Controllers/PagesController.cs @@ -6,7 +6,6 @@ using OI.Metrology.Shared.Repositories; using OI.Metrology.Shared.ViewModels; using System; using System.Collections.Generic; -using IO = System.IO; namespace OI.Metrology.Archive.Controllers; @@ -69,50 +68,6 @@ public class PagesController : Controller public IActionResult Crash() => throw new Exception("Test unhandled exception"); - [HttpGet] - [Route("/Step1")] - [Route("/Metrology/Step1")] - public IActionResult Step1(string mod = "", string equipment = "", string layer = "", string zone = "", string rds = "", string initials = "") - { - string directory = "D:/Tmp/Metrology"; - if (!IO.Directory.Exists(directory)) - _ = IO.Directory.CreateDirectory(directory); - string[] model = new string[] { mod, equipment, layer, zone, rds, initials }; - if (!string.IsNullOrEmpty(initials)) - IO.File.WriteAllLines(IO.Path.Combine(directory, $"{DateTime.Now.Ticks}-{initials}.rsv"), model); - return View(model); - } - - [HttpGet] - [Route("/Step2")] - [Route("/Metrology/Step2")] - public IActionResult Step2(string mod) => - View(new string[] { mod }); - - [HttpGet] - [Route("/Step3")] - [Route("/Metrology/Step3")] - public IActionResult Step3(string mod, string equipment) => - View(new string[] { mod, equipment }); - - [HttpGet] - [Route("/Step4")] - [Route("/Metrology/Step4")] - public IActionResult Step4(string mod, string equipment, string layer) => - View(new string[] { mod, equipment, layer }); - - [HttpGet] - [Route("/Step5")] - [Route("/Metrology/Step5")] - public IActionResult Step5(string mod, string equipment, string layer, string zone) => - View(new string[] { mod, equipment, layer, zone }); - - [HttpGet] - [Route("/Step6")] - [Route("/Metrology/Step6")] - public IActionResult Step6(string mod, string equipment, string layer, string zone, string rds) => - View(new string[] { mod, equipment, layer, zone, rds }); - [HttpGet] [Route("/RdsMax")] [Route("/Metrology/RdsMax")] @@ -123,9 +78,4 @@ public class PagesController : Controller return View(results); } - [HttpGet] - [Route("/Reactor")] - [Route("/Metrology/Reactor")] - public IActionResult Reactor() => View(new RunInfo()); - } \ No newline at end of file diff --git a/Archive/Repositories/SQLDbConnectionFactory.cs b/Archive/Repositories/SQLDbConnectionFactory.cs index 99174f7..66ed16c 100644 --- a/Archive/Repositories/SQLDbConnectionFactory.cs +++ b/Archive/Repositories/SQLDbConnectionFactory.cs @@ -12,7 +12,7 @@ public class SQLDbConnectionFactory : IDbConnectionFactory public SQLDbConnectionFactory(AppSettings appSettings) => _AppSettings = appSettings; - public DbConnection GetDbConnection() + public DbConnection GetDbConnection(bool? useOI2Sql = null) { DbProviderFactories.RegisterFactory( typeof(SqlConnection).Namespace, diff --git a/Archive/Views/Pages/Reactor.cshtml b/Archive/Views/Pages/Reactor.cshtml deleted file mode 100644 index 5fcf203..0000000 --- a/Archive/Views/Pages/Reactor.cshtml +++ /dev/null @@ -1,377 +0,0 @@ -@model OI.Metrology.Shared.ViewModels.RunInfo -@{ - ViewData["Title"] = "Reactor"; -} - - -

Reactor

- -
-
- - - -
-
- - - -
   -
- -
   -
- -
- - -
-
- -
-
- -
-
- - \ No newline at end of file diff --git a/Server/ApiControllers/ReactorsController.cs b/Server/ApiControllers/ReactorsController.cs new file mode 100644 index 0000000..ada6c98 --- /dev/null +++ b/Server/ApiControllers/ReactorsController.cs @@ -0,0 +1,53 @@ +using Microsoft.AspNetCore.Mvc; +using OI.Metrology.Shared.Models.Stateless; +using System.Globalization; +using System.Text.Json; + +namespace OI.Metrology.Server.ApiControllers; + +[Route("api/[controller]")] +public class ReactorsController : Controller, IReactorsController +{ + + private readonly IReactorsRepository _ReactorsRepository; + + public ReactorsController(IReactorsRepository reactorsRepository) => + _ReactorsRepository = reactorsRepository; + + [HttpGet("{even}")] + public IActionResult Get(bool even) => + Json(even ? _ReactorsRepository.EvenReactors() : _ReactorsRepository.OddReactors(), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); + + [HttpPost()] + public IActionResult Post(Shared.DataModels.WorkMaterialOut workMaterialOut) + { + string? result = null; + if (workMaterialOut is null) + throw new Exception(); + if (workMaterialOut.Username is null || workMaterialOut.Username.Length < 2) + throw new ArgumentException(nameof(workMaterialOut.Username)); + if (workMaterialOut.RunDataSheet is null || workMaterialOut.RunDataSheet.Length < 2) + throw new ArgumentException(nameof(workMaterialOut.RunDataSheet)); + string? fileName = null; + DateTime dateTime = DateTime.Now; + Calendar calendar = new CultureInfo("en-US").Calendar; + string json = JsonSerializer.Serialize(workMaterialOut, new JsonSerializerOptions { WriteIndented = true }); + string weekOfYear = $"{dateTime:yyyy}_Week_{calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}"; + string directory = Path.Combine("D:/Tmp/Metrology", weekOfYear, dateTime.ToString("yyyy-MM-dd")); + if (!Directory.Exists(directory)) + _ = Directory.CreateDirectory(directory); + for (int i = 1; i < int.MaxValue; i++) + { + result = $"{workMaterialOut.Username.ToUpper()[0]}{dateTime:mmss}"; + fileName = Path.Combine(directory, $"WMO-{result}.json"); + if (!System.IO.File.Exists(fileName)) + break; + dateTime = dateTime.AddSeconds(i); + } + if (fileName is null) + throw new Exception(); + System.IO.File.WriteAllText(fileName, json); + return Ok(result); + } + +} \ No newline at end of file diff --git a/Server/ApiControllers/WorkMaterialController.cs b/Server/ApiControllers/WorkMaterialController.cs new file mode 100644 index 0000000..adf8bee --- /dev/null +++ b/Server/ApiControllers/WorkMaterialController.cs @@ -0,0 +1,20 @@ +using Microsoft.AspNetCore.Mvc; +using OI.Metrology.Shared.Models.Stateless; +using System.Text.Json; + +namespace OI.Metrology.Server.ApiControllers; + +[Route("api/[controller]")] +public class WorkMaterialController : Controller, IWorkMaterialController +{ + + private readonly IWorkMaterialRepository _WorkMaterialRepository; + + public WorkMaterialController(IWorkMaterialRepository WorkMaterialRepository) => + _WorkMaterialRepository = WorkMaterialRepository; + + [HttpGet("{mid}")] + public IActionResult GetCassette(string mid) => + Json(_WorkMaterialRepository.GetCassette(mid), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); + +} \ No newline at end of file diff --git a/Server/Controllers/ReactorsController.cs b/Server/Controllers/ReactorsController.cs new file mode 100644 index 0000000..9044495 --- /dev/null +++ b/Server/Controllers/ReactorsController.cs @@ -0,0 +1,82 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using OI.Metrology.Server.Models; +using OI.Metrology.Shared.ViewModels; + +namespace OI.Metrology.Server.Controllers; + +public class ReactorsController : Controller +{ + + private readonly bool _IsTestDatabase; + private readonly AppSettings _AppSettings; + + public ReactorsController(AppSettings appSettings) + { + _AppSettings = appSettings; + _IsTestDatabase = appSettings.ConnectionString.Contains("test", StringComparison.InvariantCultureIgnoreCase); + } + + public override void OnActionExecuted(ActionExecutedContext context) + { + base.OnActionExecuted(context); + ViewBag.IsTestDatabase = _IsTestDatabase; + } + + private string GetApiUrl() => string.IsNullOrEmpty(_AppSettings.ApiUrl) ? Url.Content("~/") : _AppSettings.ApiUrl[0] == '~' ? Url.Content(_AppSettings.ApiUrl) : _AppSettings.ApiUrl; + + [HttpGet] + [Route("/Step1")] + [Route("/Metrology/Step1")] + public IActionResult Step1(string mod = "", string equipment = "", string layer = "", string zone = "", string rds = "", string initials = "") + { + string directory = "D:/Tmp/Metrology"; + if (!Directory.Exists(directory)) + _ = Directory.CreateDirectory(directory); + string[] model = new string[] { mod, equipment, layer, zone, rds, initials }; + if (!string.IsNullOrEmpty(initials)) + System.IO.File.WriteAllLines(Path.Combine(directory, $"{DateTime.Now.Ticks}-{initials}.rsv"), model); + return View(model); + } + + [HttpGet] + [Route("/Step2")] + [Route("/Metrology/Step2")] + public IActionResult Step2(string mod) => + View(new string[] { mod }); + + [HttpGet] + [Route("/Step3")] + [Route("/Metrology/Step3")] + public IActionResult Step3(string mod, string equipment) => + View(new string[] { mod, equipment }); + + [HttpGet] + [Route("/Step4")] + [Route("/Metrology/Step4")] + public IActionResult Step4(string mod, string equipment, string layer) => + View(new string[] { mod, equipment, layer }); + + [HttpGet] + [Route("/Step5")] + [Route("/Metrology/Step5")] + public IActionResult Step5(string mod, string equipment, string layer, string zone) => + View(new string[] { mod, equipment, layer, zone }); + + [HttpGet] + [Route("/Step6")] + [Route("/Metrology/Step6")] + public IActionResult Step6(string mod, string equipment, string layer, string zone, string rds) => + View(new string[] { mod, equipment, layer, zone, rds }); + + [HttpGet] + [Route("/Reactor")] + [Route("/Metrology/Reactor")] + public IActionResult Reactor() => View(new RunInfo()); + + [HttpGet] + [Route("/WorkMaterial")] + [Route("/Metrology/WorkMaterial")] + public IActionResult WorkMaterial() => View(); + +} \ No newline at end of file diff --git a/Server/Data/Tests/Reactors-GetReactors.json b/Server/Data/Tests/Reactors-GetReactors.json new file mode 100644 index 0000000..27ef7be --- /dev/null +++ b/Server/Data/Tests/Reactors-GetReactors.json @@ -0,0 +1,33 @@ +{ + "Results": [ + 20, + 22, + 24, + 26, + 28, + 30, + 32, + 34, + 36, + 38, + 40, + 42, + 44, + 46, + 48, + 50, + 52, + 54, + 56, + 58, + 60, + 62, + 64, + 66, + 68, + 70, + 72, + 74 + ], + "TotalRows": 28 +} \ No newline at end of file diff --git a/Server/Data/Tests/WorkMaterial-GetCassette.json b/Server/Data/Tests/WorkMaterial-GetCassette.json new file mode 100644 index 0000000..b024417 --- /dev/null +++ b/Server/Data/Tests/WorkMaterial-GetCassette.json @@ -0,0 +1,280 @@ +{ + "Results": [ + { + "RunDataSheet": "586337", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 1, + "Pocket": "1", + "Zone": "1" + }, + { + "RunDataSheet": "586337", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 2, + "Pocket": "2", + "Zone": "1" + }, + { + "RunDataSheet": "586337", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 3, + "Pocket": "3", + "Zone": "1" + }, + { + "RunDataSheet": "586337", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 4, + "Pocket": "4", + "Zone": "1" + }, + { + "RunDataSheet": "586337", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 5, + "Pocket": "5", + "Zone": "1" + }, + { + "RunDataSheet": "586337", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 6, + "Pocket": "6", + "Zone": "1" + }, + { + "RunDataSheet": "586337", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 7, + "Pocket": "7", + "Zone": "1" + }, + { + "RunDataSheet": "586337", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 8, + "Pocket": "8", + "Zone": "1" + }, + { + "RunDataSheet": "586345", + "Reactor": 52, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 9, + "Pocket": "1", + "Zone": "1" + }, + { + "RunDataSheet": "586345", + "Reactor": 52, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 10, + "Pocket": "2", + "Zone": "1" + }, + { + "RunDataSheet": "586345", + "Reactor": 52, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 11, + "Pocket": "3", + "Zone": "1" + }, + { + "RunDataSheet": "586345", + "Reactor": 52, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 12, + "Pocket": "4", + "Zone": "1" + }, + { + "RunDataSheet": "586345", + "Reactor": 52, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 13, + "Pocket": "5", + "Zone": "1" + }, + { + "RunDataSheet": "586345", + "Reactor": 52, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 14, + "Pocket": "6", + "Zone": "1" + }, + { + "RunDataSheet": "586345", + "Reactor": 52, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 15, + "Pocket": "7", + "Zone": "1" + }, + { + "RunDataSheet": "586345", + "Reactor": 52, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 16, + "Pocket": "8", + "Zone": "1" + }, + { + "RunDataSheet": "586347", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 17, + "Pocket": "1", + "Zone": "1" + }, + { + "RunDataSheet": "586347", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 18, + "Pocket": "2", + "Zone": "1" + }, + { + "RunDataSheet": "586347", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 19, + "Pocket": "3", + "Zone": "1" + }, + { + "RunDataSheet": "586347", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 20, + "Pocket": "4", + "Zone": "1" + }, + { + "RunDataSheet": "586347", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 21, + "Pocket": "5", + "Zone": "1" + }, + { + "RunDataSheet": "586347", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 22, + "Pocket": "6", + "Zone": "1" + }, + { + "RunDataSheet": "586347", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 23, + "Pocket": "7", + "Zone": "1" + }, + { + "RunDataSheet": "586347", + "Reactor": 54, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 24, + "Pocket": "8", + "Zone": "1" + }, + { + "RunDataSheet": "586381", + "Reactor": 52, + "PSN": "4445", + "RecipeName": "Phosphorus", + "RecipeNumber": 743, + "SpecType": "Production", + "SlotNumber": 25, + "Pocket": "1", + "Zone": "1" + } + ], + "TotalRows": 25 +} \ No newline at end of file diff --git a/Server/OI.Metrology.Server.csproj b/Server/OI.Metrology.Server.csproj index 8031c60..4972373 100644 --- a/Server/OI.Metrology.Server.csproj +++ b/Server/OI.Metrology.Server.csproj @@ -28,7 +28,7 @@ - + @@ -122,6 +122,9 @@ Always + + Always + Always @@ -143,5 +146,8 @@ Always + + Always + \ No newline at end of file diff --git a/Server/Program.cs b/Server/Program.cs index 18ac690..c35a994 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -67,6 +67,7 @@ public class Program _ = webApplicationBuilder.Services.AddSingleton(_ => appSettings); _ = webApplicationBuilder.Services.AddSingleton(); + _ = webApplicationBuilder.Services.AddSingleton(); _ = webApplicationBuilder.Services.AddSingleton(_ => clientSettingsRepository); _ = webApplicationBuilder.Services.AddSingleton(); _ = webApplicationBuilder.Services.AddSingleton(_ => new(appSettings.MockRoot)); @@ -75,6 +76,7 @@ public class Program _ = webApplicationBuilder.Services.AddSingleton>(_ => appSettingsRepository); _ = webApplicationBuilder.Services.AddSingleton(_ => new(appSettings.MockRoot, sqlDbConnectionFactory)); _ = webApplicationBuilder.Services.AddSingleton(_ => new(appSettings.MockRoot, sqlDbConnectionFactory)); + _ = webApplicationBuilder.Services.AddSingleton(_ => new(appSettings.MockRoot, sqlDbConnectionFactory)); _ = webApplicationBuilder.Services.AddScoped(); _ = webApplicationBuilder.Services.AddScoped(); diff --git a/Archive/ApiControllers/ReactorsController.cs b/Server/Repositories/ReactorsRepository.cs similarity index 50% rename from Archive/ApiControllers/ReactorsController.cs rename to Server/Repositories/ReactorsRepository.cs index 9309292..94888a8 100644 --- a/Archive/ApiControllers/ReactorsController.cs +++ b/Server/Repositories/ReactorsRepository.cs @@ -1,27 +1,15 @@ -using Microsoft.AspNetCore.Mvc; -using System.Linq; - -namespace OI.Metrology.Archive.ApiControllers; - -using OI.Metrology.Archive.Models; +using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.Models.Stateless; -using System.Text.Json; -public class ReactorsController : Controller +namespace OI.Metrology.Server.Repository; + +public class ReactorsRepository : IReactorsRepository { - private readonly AppSettings _AppSettings; - private readonly IMetrologyRepository _MetrologyRepository; - - public ReactorsController(AppSettings appSettings, IMetrologyRepository metrologyRepository) + Result IReactorsRepository.EvenReactors() { - _AppSettings = appSettings; - _MetrologyRepository = metrologyRepository; - } - - private static int[] EvenReactors() - { - int[] results = new int[] { + Result results; + int[] collection = new int[] { 20, 22, 24, @@ -51,12 +39,18 @@ public class ReactorsController : Controller 72, 74 }; + results = new() + { + Results = collection, + TotalRows = collection.Length, + }; return results; } - private static int[] OddReactors() + Result IReactorsRepository.OddReactors() { - int[] results = new int[] { + Result results; + int[] collection = new int[] { 21, 23, 25, @@ -85,15 +79,12 @@ public class ReactorsController : Controller 77, 79 }; + results = new() + { + Results = collection, + TotalRows = collection.Length, + }; return results; } - [HttpGet("/api/reactors/{even}")] - public IActionResult Index(bool even) - { - int[] n = even ? EvenReactors() : OddReactors(); - var r = n.Select(l => new { Name = $"R{l}", Id = l }); - return Json(r, new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true }); - } - } \ No newline at end of file diff --git a/Server/Repositories/WorkMaterialRepository.cs b/Server/Repositories/WorkMaterialRepository.cs new file mode 100644 index 0000000..ca6f0f0 --- /dev/null +++ b/Server/Repositories/WorkMaterialRepository.cs @@ -0,0 +1,158 @@ +using OI.Metrology.Shared.DataModels; +using OI.Metrology.Shared.Models.Stateless; +using OI.Metrology.Shared.Repositories; +using System.Data; +using System.Data.Common; +using System.Text; +using System.Text.Json; +using System.Text.RegularExpressions; + +namespace OI.Metrology.Server.Repository; + +public class WorkMaterialRepository : IWorkMaterialRepository +{ + + private readonly string _MockRoot; + private readonly string _RepositoryName; + private readonly IDbConnectionFactory _DBConnectionFactory; + + public WorkMaterialRepository(string mockRoot, IDbConnectionFactory dbConnectionFactory) + { + _MockRoot = mockRoot; + _DBConnectionFactory = dbConnectionFactory; + _RepositoryName = nameof(WorkMaterialRepository)[..^10]; + } + + string IWorkMaterialRepository.GetCommandText(int? workOrderNumber, int? workOrderStep, int? workOrderCassette) + { + StringBuilder result = new(); + _ = result.Append("select ( "). + Append(" select wm_b.slot_no, "). + Append(" wm_b.rds_no, "). + Append(" rr.reactor, "). + Append(" wm_b.pocket_no, "). + Append(" wm_b.zone, "). + Append(" rr.ps_no, "). + Append(" rr.recipe_name, "). + Append(" rr.recipe_no, "). + Append(" rr.spec_type "). + Append(" from lsl2sql.dbo.wm_in_slot_no wm_b "). + Append(" inner join lsl2sql.dbo.react_run rr "). + Append(" on wm_b.wo_no = rr.wo_no "). + Append(" and wm_b.rds_no = rr.rds_no "). + Append(" where wm_b.wo_no = ").Append(workOrderNumber is null ? -1 : workOrderNumber.Value).Append(' '). + Append(" and wm_b.proc_step_no = ").Append(workOrderStep is null ? -1 : workOrderStep.Value).Append(' '). + Append(" and wm_b.in_cass_no = ").Append(workOrderCassette is null ? -1 : workOrderCassette.Value).Append(' '). + Append(" and wm_b.rds_no = wm.rds_no "). + Append(" order by wm_b.slot_no "). + Append(" for json path "). + Append(" ) [group] "). + Append("from lsl2sql.dbo.wm_in_slot_no wm "). + Append("where wm.wo_no = ").Append(workOrderNumber is null ? -1 : workOrderNumber.Value).Append(' '). + Append(" and wm.proc_step_no = ").Append(workOrderStep is null ? -1 : workOrderStep.Value).Append(' '). + Append(" and wm.in_cass_no = ").Append(workOrderCassette is null ? -1 : workOrderCassette.Value).Append(' '). + Append("group by wm.rds_no "). + Append("order by wm.rds_no "). + Append("for json path "); + return result.ToString(); + } + + private static StringBuilder GetForJsonPath(IDbConnectionFactory dbConnectionFactory, string commandText) + { + StringBuilder stringBuilder = new(); + using DbConnection dbConnection = dbConnectionFactory.GetDbConnection(useOI2Sql: true); + DbCommand dbCommand = dbConnection.CreateCommand(); + dbCommand.CommandText = commandText; + DbDataReader dbDataReader = dbCommand.ExecuteReader(CommandBehavior.SequentialAccess); + while (dbDataReader.Read()) + _ = stringBuilder.Append(dbDataReader.GetString(0)); + return stringBuilder; + } + + private static (int?, int?, int?, bool) GetWorkOrder(string mid) + { + int? workOrderStep = null; + int? workOrderNumber = null; + MatchCollection[] collection; + int? workOrderCassette = null; + if (string.IsNullOrEmpty(mid)) + collection = Array.Empty(); + else + { + string pattern = @"^([oiOI])?([0-9]{6,7})\.([0-5]{1})\.([0-9]{1,2})$"; // o171308.1.51 + collection = (from l in mid.Split('-') select Regex.Matches(l, pattern)).ToArray(); + } + foreach (MatchCollection matchCollection in collection) + { + if (matchCollection.Count == 0) + continue; + if (!matchCollection[0].Success || matchCollection[0].Groups.Count != 5) + continue; + if (!int.TryParse(matchCollection[0].Groups[3].Value, out int workOrderStepValue)) + continue; + if (!int.TryParse(matchCollection[0].Groups[2].Value, out int workOrderNumberValue)) + continue; + if (!int.TryParse(matchCollection[0].Groups[4].Value, out int workOrderCassetteValue)) + continue; + workOrderStep = workOrderStepValue; + workOrderNumber = workOrderNumberValue; + workOrderCassette = workOrderCassetteValue; + break; + } + return new(workOrderNumber, workOrderStep, workOrderCassette, workOrderStep is not null || workOrderNumber is not null || workOrderCassette is not null); + } + + Result IWorkMaterialRepository.GetCassette(string mid) + { + Result? result; + if (!string.IsNullOrEmpty(_MockRoot)) + { + string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), $"{_RepositoryName}-{nameof(IWorkMaterialRepository.GetCassette)}.json")); + result = JsonSerializer.Deserialize>(json); + if (result is null) + throw new NullReferenceException(nameof(result)); + } + else + { + WorkMaterialV2[] results; + (int? workOrderNumber, int? workOrderStep, int? workOrderCassette, bool isWorkOrder) = GetWorkOrder(mid); + if (!isWorkOrder) + results = Array.Empty(); + else + { + WorkMaterial[]? group; + JsonProperty[] jsonProperties; + List collection = new(); + IWorkMaterialRepository workMaterialRepository = this; + string commandText = workMaterialRepository.GetCommandText(workOrderNumber, workOrderStep, workOrderCassette); + StringBuilder stringBuilder = GetForJsonPath(_DBConnectionFactory, commandText); + JsonElement[]? jsonElements = JsonSerializer.Deserialize(stringBuilder.ToString()); + if (jsonElements is null) + throw new NullReferenceException(nameof(jsonElements)); + foreach (JsonElement jsonElement in jsonElements) + { + if (jsonElement.ValueKind != JsonValueKind.Object) + continue; + jsonProperties = jsonElement.EnumerateObject().ToArray(); + if (!jsonProperties.Any()) + continue; + group = JsonSerializer.Deserialize(jsonProperties.First().Value.ToString(), new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); + if (group is null) + continue; + foreach (WorkMaterial workMaterial in group) + collection.Add(workMaterial); + } + if (collection is null) + throw new NullReferenceException(nameof(collection)); + results = WorkMaterial.Convert(collection); + } + result = new() + { + Results = results, + TotalRows = results.Length, + }; + } + return result; + } + +} \ No newline at end of file diff --git a/Server/Services/SQLDbConnectionFactory.cs b/Server/Services/SQLDbConnectionFactory.cs index ee12b97..a4331c9 100644 --- a/Server/Services/SQLDbConnectionFactory.cs +++ b/Server/Services/SQLDbConnectionFactory.cs @@ -13,7 +13,7 @@ public class SQLDbConnectionFactory : IDbConnectionFactory public SQLDbConnectionFactory(AppSettings appSettings) => _AppSettings = appSettings; - public DbConnection GetDbConnection() + public DbConnection GetDbConnection(bool? useOI2Sql) { DbProviderFactories.RegisterFactory( typeof(SqlConnection).Namespace, @@ -22,9 +22,12 @@ public class SQLDbConnectionFactory : IDbConnectionFactory if (string.IsNullOrEmpty(_AppSettings.ConnectionString)) throw new Exception("Connection string is missing"); - DbConnection c = SqlClientFactory.Instance.CreateConnection(); - c.ConnectionString = _AppSettings.ConnectionString; - c.Open(); - return c; + if (string.IsNullOrEmpty(_AppSettings.OI2SqlConnectionString)) + throw new Exception("Connection string is missing"); + + DbConnection dbConnection = SqlClientFactory.Instance.CreateConnection(); + dbConnection.ConnectionString = useOI2Sql is not null && useOI2Sql.Value ? _AppSettings.OI2SqlConnectionString : _AppSettings.ConnectionString; + dbConnection.Open(); + return dbConnection; } } \ No newline at end of file diff --git a/Server/Views/Reactors/Reactor.cshtml b/Server/Views/Reactors/Reactor.cshtml new file mode 100644 index 0000000..6fdd0b7 --- /dev/null +++ b/Server/Views/Reactors/Reactor.cshtml @@ -0,0 +1,52 @@ +@{ + ViewData["Title"] = "Reactor"; +} + + +

Reactor

+ +
+
+ + + +
+
+ + + +
   +
+ +
   +
+ +
+
+ +
+
+ + \ No newline at end of file diff --git a/Archive/Views/Pages/Step1.cshtml b/Server/Views/Reactors/Step1.cshtml similarity index 100% rename from Archive/Views/Pages/Step1.cshtml rename to Server/Views/Reactors/Step1.cshtml diff --git a/Archive/Views/Pages/Step2.cshtml b/Server/Views/Reactors/Step2.cshtml similarity index 100% rename from Archive/Views/Pages/Step2.cshtml rename to Server/Views/Reactors/Step2.cshtml diff --git a/Archive/Views/Pages/Step3.cshtml b/Server/Views/Reactors/Step3.cshtml similarity index 100% rename from Archive/Views/Pages/Step3.cshtml rename to Server/Views/Reactors/Step3.cshtml diff --git a/Archive/Views/Pages/Step4.cshtml b/Server/Views/Reactors/Step4.cshtml similarity index 100% rename from Archive/Views/Pages/Step4.cshtml rename to Server/Views/Reactors/Step4.cshtml diff --git a/Archive/Views/Pages/Step5.cshtml b/Server/Views/Reactors/Step5.cshtml similarity index 100% rename from Archive/Views/Pages/Step5.cshtml rename to Server/Views/Reactors/Step5.cshtml diff --git a/Archive/Views/Pages/Step6.cshtml b/Server/Views/Reactors/Step6.cshtml similarity index 100% rename from Archive/Views/Pages/Step6.cshtml rename to Server/Views/Reactors/Step6.cshtml diff --git a/Server/Views/Reactors/WorkMaterial.cshtml b/Server/Views/Reactors/WorkMaterial.cshtml new file mode 100644 index 0000000..1e348ff --- /dev/null +++ b/Server/Views/Reactors/WorkMaterial.cshtml @@ -0,0 +1,118 @@ +@model string[] +@{ + ViewData["Title"] = "WM Out"; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +   +
+
+ +
+
+
+ +
+
+
+ +
+
+ + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ +
+
+
+ + diff --git a/Server/wwwroot/js/site.js b/Server/wwwroot/js/site.js index 293cee3..69b64d3 100644 --- a/Server/wwwroot/js/site.js +++ b/Server/wwwroot/js/site.js @@ -2,6 +2,7 @@ var _CdeId = null; var _apiUrl = null; var _BioRadId = null; var _toolType = null; +var _workMaterial = {}; var _initialHeaderId = null; var _toolTypeMetaData = null; var _initialHeaderAttachmentId = null; @@ -473,7 +474,7 @@ function recipeParametersButtonRunInfo() { stringified = stringified.replace(/"Tool":/gm, '"MesEntity":'); stringified = stringified.replace(/"Equipment ID":/gm, '"MesEntity":'); var jsonObject = JSON.parse(stringified); - DisplayWSMessage("info", "Recipe Parameters - Work In Progress ***", null); + DisplayWSMessage("info", "Recipe Parameters", null); $("#ModalHeaderGrid").igGrid({ dataSource: jsonObject, dataSourceType: 'json', @@ -794,4 +795,155 @@ function copy() { // Copy the text inside the text field navigator.clipboard.writeText(copyText.value); -} \ No newline at end of file +} + +function clearWorkMaterial() { + _workMaterial = {}; + $("#scan").val(""); + $("#zone1").show(); + $("#zone1").show(); + $("#zone2").show(); + $("#layer1").show(); + $("#layer2").show(); + $("#layer3").show(); + $("#username").val(""); + $("#runDataSheet1").hide(); + $("#runDataSheet2").hide(); + $("#runDataSheet3").hide(); + $("#runDataSheet4").hide(); + $("#runDataSheet5").hide(); + $("#runDataSheet6").hide(); + $("#runDataSheet1").val(""); + $("#runDataSheet2").val(""); + $("#runDataSheet3").val(""); + $("#runDataSheet4").val(""); + $("#runDataSheet5").val(""); + $("#runDataSheet6").val(""); + var gridCreated = $("#cassetteGrid").data("igGrid"); + if (gridCreated) + $("#cassetteGrid").igGrid("destroy"); +} + +function postWorkMaterial() { + var row = $("#cassetteGrid").igGrid("selectedRow"); + if (row == null) + return; + var data = $("#cassetteGrid").igGrid("findRecordByKey", row.id); + if (data == null) + return; + if (!_workMaterial['layer']) + ShowErrorMessage("Select layer and try agian"); + else { + _workMaterial['psn'] = data.PSN; + _workMaterial['pocket'] = data.Pocket; + _workMaterial['reactor'] = data.Reactor; + _workMaterial['slotNumber'] = data.SlotNumber; + _workMaterial['runDataSheet'] = data.RunDataSheet; + $.post(_apiUrl + "/api/Reactors/", _workMaterial, function (data) { + DisplayWSMessage("info", "Data Saved use [" + data + "]", null); + }).fail(function () { + ShowErrorMessage("Error"); + }); + } +} + +function initWorkMaterial(apiUrl) { + _apiUrl = apiUrl; + $("#runDataSheet1").hide(); + $("#runDataSheet2").hide(); + $("#runDataSheet3").hide(); + $("#runDataSheet4").hide(); + $("#runDataSheet5").hide(); + $("#runDataSheet6").hide(); +}; + +function zone(zoneNumber) { + var scan = $("#scan").val(); + _workMaterial['zone'] = zoneNumber; + var username = $("#username").val(); + if (!scan || scan === "" || scan.length < 3 || scan[0] !== 'o') { + ShowErrorMessage("Invalid WM Out"); + } + else if (!username || username === "" || username.length < 2) { + ShowErrorMessage("Invalid username"); + } + else { + $("#zone1").hide(); + $("#zone2").hide(); + _workMaterial['scan'] = scan; + $("#zone" + zoneNumber).show(); + _workMaterial['username'] = username; + $.getJSON(_apiUrl + "/api/WorkMaterial/" + scan + "/", function (data) { + if (data.Results.length === 0) + ShowErrorMessage("No data found"); + var filtered = []; + for (var i = 0; i < data.Results.length; i++) { + if (data.Results[i].Zone != zoneNumber) + continue; + filtered.push(data.Results[i]); + } + if (data.Results.length !== 0 && filtered.length === 0) + ShowErrorMessage("All data filted"); + else { + $("#cassetteGrid").igGrid({ + dataSource: filtered, + primaryKey: "SlotNumber", + features: [ + { name: "Selection", mode: "row", multipleSelection: false, rowSelectionChanged: postWorkMaterial }, + { name: 'Resizing' }, + { name: "Filtering", type: "local" }, + ], + }); + var distinct = []; + for (var i = 0; i < filtered.length; i++) { + if (distinct.indexOf(filtered[i].RunDataSheet) > -1) + continue; + distinct.push(filtered[i].RunDataSheet); + } + if (distinct.length > 0) { + $("#runDataSheet1").val(distinct[0]); + $("#runDataSheet1").show(); + } + if (distinct.length > 1) { + $("#runDataSheet2").val(distinct[1]); + $("#runDataSheet2").show(); + } + if (distinct.length > 2) { + $("#runDataSheet3").val(distinct[2]); + $("#runDataSheet3").show(); + } + if (distinct.length > 3) { + $("#runDataSheet4").val(distinct[3]); + $("#runDataSheet4").show(); + } + if (distinct.length > 4) { + $("#runDataSheet5").val(distinct[4]); + $("#runDataSheet5").show(); + } + if (distinct.length > 5) { + $("#runDataSheet6").val(distinct[4]); + $("#runDataSheet6").show(); + } + $("#cassetteGrid").on("dblclick", "tr", postWorkMaterial); + } + }); + } +}; + +function layer(layerNumber) { + $("#layer1").hide(); + $("#layer2").hide(); + $("#layer3").hide(); + $("#layer" + layerNumber).show(); + _workMaterial['layer'] = layerNumber; +}; + +function runDataSheet(runDataSheetIndex) { + var runDataSheet = $("#runDataSheet" + runDataSheetIndex).val(); + _workMaterial['runDataSheet'] = runDataSheet; + $("#cassetteGrid").igGridFiltering("filter", ([{ fieldName: "RunDataSheet", expr: runDataSheet, cond: "equals" }])); +}; + +function restartButton(apiUrl) { + clearWorkMaterial(); +}; \ No newline at end of file diff --git a/Shared/DataModels/WorkMaterial.cs b/Shared/DataModels/WorkMaterial.cs new file mode 100644 index 0000000..d618588 --- /dev/null +++ b/Shared/DataModels/WorkMaterial.cs @@ -0,0 +1,41 @@ +namespace OI.Metrology.Shared.DataModels; + +public record WorkMaterial(int SLOT_NO, + string RDS_NO, + int REACTOR, + string POCKET_NO, + string ZONE, + string PS_NO, + string RECIPE_NAME, + int RECIPE_NO, + string SPEC_TYPE) +{ + + public static WorkMaterialV2[] Convert(List collection) + { + List results = new(); + foreach (WorkMaterial item in collection) + results.Add(Map(item)); + return results.ToArray(); + } + + public static WorkMaterialV2 Map(WorkMaterial item) + { + WorkMaterialV2 result = new(item.SLOT_NO, + item.RDS_NO, + item.REACTOR, + item.POCKET_NO, + item.ZONE, + item.PS_NO); + return result; + } + +} + +public record WorkMaterialV2(int SlotNumber, + string RunDataSheet, + int Reactor, + string Pocket, + string Zone, + string PSN) +{ } \ No newline at end of file diff --git a/Shared/DataModels/WorkMaterialOut.cs b/Shared/DataModels/WorkMaterialOut.cs new file mode 100644 index 0000000..e7b5bf7 --- /dev/null +++ b/Shared/DataModels/WorkMaterialOut.cs @@ -0,0 +1,16 @@ +namespace OI.Metrology.Shared.DataModels; + +public class WorkMaterialOut +{ + + public string? Layer { get; set; } + public string? PSN { get; set; } + public string? Pocket { get; set; } + public int? Reactor { get; set; } + public string? RunDataSheet { get; set; } + public string? Scan { get; set; } + public int? SlotNumber { get; set; } + public string? Username { get; set; } + public string? Zone { get; set; } + +} \ No newline at end of file diff --git a/Shared/Models/Stateless/IReactorsController.cs b/Shared/Models/Stateless/IReactorsController.cs new file mode 100644 index 0000000..1e0aec3 --- /dev/null +++ b/Shared/Models/Stateless/IReactorsController.cs @@ -0,0 +1,14 @@ +namespace OI.Metrology.Shared.Models.Stateless; + +public interface IReactorsController +{ + + enum Action : int + { + Get = 0 + } + + static string GetRouteName() => nameof(IReactorsController)[1..^10]; + T Get(bool even); + +} \ No newline at end of file diff --git a/Shared/Models/Stateless/IReactorsRepository.cs b/Shared/Models/Stateless/IReactorsRepository.cs new file mode 100644 index 0000000..42a9812 --- /dev/null +++ b/Shared/Models/Stateless/IReactorsRepository.cs @@ -0,0 +1,12 @@ + +using OI.Metrology.Shared.DataModels; + +namespace OI.Metrology.Shared.Models.Stateless; + +public interface IReactorsRepository +{ + + Result EvenReactors(); + Result OddReactors(); + +} \ No newline at end of file diff --git a/Shared/Models/Stateless/IWorkMaterialController.cs b/Shared/Models/Stateless/IWorkMaterialController.cs new file mode 100644 index 0000000..9b8d218 --- /dev/null +++ b/Shared/Models/Stateless/IWorkMaterialController.cs @@ -0,0 +1,14 @@ +namespace OI.Metrology.Shared.Models.Stateless; + +public interface IWorkMaterialController +{ + + enum Action : int + { + Get = 0 + } + + static string GetRouteName() => nameof(IWorkMaterialController)[1..^10]; + T GetCassette(string mid); + +} \ No newline at end of file diff --git a/Shared/Models/Stateless/IWorkMaterialRepository.cs b/Shared/Models/Stateless/IWorkMaterialRepository.cs new file mode 100644 index 0000000..5ab6086 --- /dev/null +++ b/Shared/Models/Stateless/IWorkMaterialRepository.cs @@ -0,0 +1,12 @@ + +using OI.Metrology.Shared.DataModels; + +namespace OI.Metrology.Shared.Models.Stateless; + +public interface IWorkMaterialRepository +{ + + string GetCommandText(int? workOrderNumber, int? workOrderStep, int? workOrderCassette); + Result GetCassette(string mid); + +} \ No newline at end of file diff --git a/Shared/Repositories/IDbConnectionFactory.cs b/Shared/Repositories/IDbConnectionFactory.cs index 1a56665..0b5e147 100644 --- a/Shared/Repositories/IDbConnectionFactory.cs +++ b/Shared/Repositories/IDbConnectionFactory.cs @@ -4,5 +4,5 @@ namespace OI.Metrology.Shared.Repositories; public interface IDbConnectionFactory { - DbConnection GetDbConnection(); + DbConnection GetDbConnection(bool? useOI2Sql = null); } \ No newline at end of file diff --git a/Tests/OI.Metrology.Tests.csproj b/Tests/OI.Metrology.Tests.csproj index 3a478d7..939e26b 100644 --- a/Tests/OI.Metrology.Tests.csproj +++ b/Tests/OI.Metrology.Tests.csproj @@ -32,7 +32,7 @@ - + diff --git a/Tests/UnitTestReactorController.cs b/Tests/UnitTestReactorController.cs index 4a6c3a5..ee2265c 100644 --- a/Tests/UnitTestReactorController.cs +++ b/Tests/UnitTestReactorController.cs @@ -1,109 +1,72 @@ -// using Microsoft.AspNetCore.Mvc.Testing; -// using Microsoft.Extensions.DependencyInjection; -// using Serilog; -// using System.Net; +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Extensions.DependencyInjection; +using OI.Metrology.Shared.DataModels; +using OI.Metrology.Shared.Models.Stateless; +using Serilog; -// namespace OI.Metrology.Tests; +namespace OI.Metrology.Tests; -// [TestClass] -// public class UnitTestReactorController -// { +[TestClass] +public class UnitTestReactorController +{ -// private static TestContext? _TestContext; -// private static WebApplicationFactory? _WebApplicationFactory; +#pragma warning disable CS8618 -// [ClassInitialize] -// public static void ClassInitAsync(TestContext testContext) -// { -// _TestContext = testContext; -// _WebApplicationFactory = new WebApplicationFactory(); -// } + private static ILogger _Logger; + private static string _ControllerName; + private static TestContext _TestContext; + private static WebApplicationFactory _WebApplicationFactory; -// [TestMethod] -// public async Task GetReactors_ShouldReturnAllReactorsAsync() -// { -// HttpResponseMessage httpResponseMessage; -// if (_WebApplicationFactory is null) -// throw new NullReferenceException(nameof(_WebApplicationFactory)); -// HttpClient httpClient = _WebApplicationFactory.CreateClient(); -// ILogger log = Log.ForContext(); -// log.Information("Starting Web Application"); -// IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; -// Archive.Models.AppSettings appSettings = serviceProvider.GetRequiredService(); -// httpResponseMessage = await httpClient.GetAsync($"api/{nameof(Archive.ApiControllers.ReactorsController)[..^10]}/true"); -// Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode); -// Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString()); -// httpResponseMessage = await httpClient.GetAsync($"api/{nameof(Archive.ApiControllers.ReactorsController)[..^10]}/false"); -// Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode); -// // string result = await httpResponseMessage.Content.ReadAsStringAsync(); -// // Assert.AreEqual("\"Sample Name 1\"", result); -// httpClient.Dispose(); -// log.Information($"{_TestContext?.TestName} completed"); -// } +#pragma warning restore -// // [TestMethod] -// // public void GetAllProducts_ShouldReturnAllProducts() -// // { -// // var testProducts = GetTestProducts(); -// // var controller = new OI.Metrology.Archive.ApiControllers.ReactorsController(testProducts); + [ClassInitialize] + public static void ClassInitAsync(TestContext testContext) + { + _TestContext = testContext; + _Logger = Log.ForContext(); + _WebApplicationFactory = new WebApplicationFactory(); + _ControllerName = nameof(Server.ApiControllers.ReactorsController)[..^10]; + } -// // var result = controller.GetAllProducts() as List; -// // Assert.AreEqual(testProducts.Count, result.Count); -// // } + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } -// // [TestMethod] -// // public async Task GetAllProductsAsync_ShouldReturnAllProducts() -// // { -// // var testProducts = GetTestProducts(); -// // var controller = new OI.Metrology.Archive.ApiControllers.ReactorsController(testProducts); + [TestMethod] + public void TestControllerName() + { + _Logger.Information("Starting Web Application"); + Assert.AreEqual(IReactorsController.GetRouteName(), _ControllerName); + _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); + } -// // var result = await controller.GetAllProductsAsync() as List; -// // Assert.AreEqual(testProducts.Count, result.Count); -// // } + [TestMethod] + public void GetReactors() + { + _Logger.Information("Starting Web Application"); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + IReactorsRepository reactorsRepository = serviceProvider.GetRequiredService(); + Result result = reactorsRepository.EvenReactors(); + Assert.IsNotNull(result?.Results); + _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); + } -// // [TestMethod] -// // public void GetProduct_ShouldReturnCorrectProduct() -// // { -// // var testProducts = GetTestProducts(); -// // var controller = new OI.Metrology.Archive.ApiControllers.ReactorsController(testProducts); + [TestMethod] + public async Task GetReactorsApi() + { + HttpClient httpClient = _WebApplicationFactory.CreateClient(); + _Logger.Information("Starting Web Application"); + string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/true/"); + File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetReactors)}.json"), json); + Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); + Assert.IsNotNull(result?.Results); + _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); + } -// // var result = controller.GetProduct(4) as OkNegotiatedContentResult; -// // Assert.IsNotNull(result); -// // Assert.AreEqual(testProducts[3].Name, result.Content.Name); -// // } - -// // [TestMethod] -// // public async Task GetProductAsync_ShouldReturnCorrectProduct() -// // { -// // var testProducts = GetTestProducts(); -// // var controller = new OI.Metrology.Archive.ApiControllers.ReactorsController(testProducts); - -// // var result = await controller.GetProductAsync(4) as OkNegotiatedContentResult; -// // Assert.IsNotNull(result); -// // Assert.AreEqual(testProducts[3].Name, result.Content.Name); -// // } - -// // [TestMethod] -// // public void GetProduct_ShouldNotFindProduct() -// // { -// // var controller = new OI.Metrology.Archive.ApiControllers.ReactorsController(GetTestProducts()); - -// // var result = controller.GetProduct(999); -// // Assert.IsInstanceOfType(result, typeof(NotFoundResult)); -// // } - -// // private List GetTestProducts() -// // { -// // var testProducts = new List(); -// // testProducts.Add(new Product { Id = 1, Name = "Demo1", Price = 1 }); -// // testProducts.Add(new Product { Id = 2, Name = "Demo2", Price = 3.75M }); -// // testProducts.Add(new Product { Id = 3, Name = "Demo3", Price = 16.99M }); -// // testProducts.Add(new Product { Id = 4, Name = "Demo4", Price = 11.00M }); - -// // return testProducts; -// // } - -// [ClassCleanup] -// public static void ClassCleanup() => _WebApplicationFactory?.Dispose(); - -// } \ No newline at end of file +} \ No newline at end of file diff --git a/Tests/UnitTestWorkMaterialController.cs b/Tests/UnitTestWorkMaterialController.cs new file mode 100644 index 0000000..a966212 --- /dev/null +++ b/Tests/UnitTestWorkMaterialController.cs @@ -0,0 +1,78 @@ +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Extensions.DependencyInjection; +using OI.Metrology.Shared.DataModels; +using OI.Metrology.Shared.Models.Stateless; +using Serilog; + +namespace OI.Metrology.Tests; + +[TestClass] +public class UnitTestWorkMaterialController +{ + +#pragma warning disable CS8618 + + private static ILogger _Logger; + private static string _ControllerName; + private static TestContext _TestContext; + private static WebApplicationFactory _WebApplicationFactory; + +#pragma warning restore + + [ClassInitialize] + public static void ClassInitAsync(TestContext testContext) + { + _TestContext = testContext; + _Logger = Log.ForContext(); + _WebApplicationFactory = new WebApplicationFactory(); + _ControllerName = nameof(Server.ApiControllers.WorkMaterialController)[..^10]; + } + + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + + [TestMethod] + public void TestControllerName() + { + _Logger.Information("Starting Web Application"); + Assert.AreEqual(IWorkMaterialController.GetRouteName(), _ControllerName); + _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void GetCassette() + { + _Logger.Information("Starting Web Application"); + IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; + IWorkMaterialRepository workMaterialRepository = serviceProvider.GetRequiredService(); + Result result = workMaterialRepository.GetCassette("O171927.1.37"); + Assert.IsNotNull(result?.Results); + _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); + } + +#if DEBUG + [Ignore] +#endif + [TestMethod] + public async Task GetCassetteApi() + { + HttpClient httpClient = _WebApplicationFactory.CreateClient(); + _Logger.Information("Starting Web Application"); + string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/O171927.1.37/"); + File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCassette)}.json"), json); + Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); + Assert.IsNotNull(result?.Results); + _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); + } + +} \ No newline at end of file diff --git a/View/OI.Metrology.View.csproj b/View/OI.Metrology.View.csproj index a539bc7..5b083bc 100644 --- a/View/OI.Metrology.View.csproj +++ b/View/OI.Metrology.View.csproj @@ -9,7 +9,7 @@ - + diff --git a/azure-pipelines-server-development.yml b/azure-pipelines-server-development.yml index 9ffd3b2..357dc5e 100644 --- a/azure-pipelines-server-development.yml +++ b/azure-pipelines-server-development.yml @@ -79,6 +79,10 @@ steps: workingDirectory: Server displayName: "Safe storage of app secrets - Server" + - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' + workingDirectory: Tests + displayName: "Core Build - Tests" + - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' workingDirectory: Server displayName: "Core Build - Server" diff --git a/azure-pipelines-server.yml b/azure-pipelines-server.yml index 3fa7c5e..10af968 100644 --- a/azure-pipelines-server.yml +++ b/azure-pipelines-server.yml @@ -31,223 +31,223 @@ stages: - job: IFX steps: - script: | - set exeName=OI.Metrology.Server - echo %exeName% - echo ##vso[task.setvariable variable=ExeName;]%exeName% - echo $(ExeName) - displayName: ExeName + set exeName=OI.Metrology.Server + echo %exeName% + echo ##vso[task.setvariable variable=ExeName;]%exeName% + echo $(ExeName) + displayName: ExeName - - script: | - set coreVersion=net7.0 - echo %coreVersion% - echo ##vso[task.setvariable variable=CoreVersion;]%coreVersion% - echo $(CoreVersion) - displayName: CoreVersion + - script: | + set coreVersion=net7.0 + echo %coreVersion% + echo ##vso[task.setvariable variable=CoreVersion;]%coreVersion% + echo $(CoreVersion) + displayName: CoreVersion - - script: | - set configuration=Debug - echo %configuration% - echo ##vso[task.setvariable variable=Configuration;]%configuration% - echo $(Configuration) - displayName: Configuration + - script: | + set configuration=Debug + echo %configuration% + echo ##vso[task.setvariable variable=Configuration;]%configuration% + echo $(Configuration) + displayName: Configuration - - script: | - set nugetSource=https://messa017.infineon.com/v3/index.json - echo %nugetSource% - echo ##vso[task.setvariable variable=NugetSource;]%nugetSource% - echo $(NugetSource) - displayName: NugetSource + - script: | + set nugetSource=https://messa017.infineon.com/v3/index.json + echo %nugetSource% + echo ##vso[task.setvariable variable=NugetSource;]%nugetSource% + echo $(NugetSource) + displayName: NugetSource - - script: | - set gitCommit=$(Build.SourceVersion) - set gitCommitSeven=%gitCommit:~0,7% - echo %gitCommitSeven% - echo ##vso[task.setvariable variable=GitCommitSeven;]%gitCommitSeven% - echo $(GitCommitSeven) - displayName: GitCommitSeven + - script: | + set gitCommit=$(Build.SourceVersion) + set gitCommitSeven=%gitCommit:~0,7% + echo %gitCommitSeven% + echo ##vso[task.setvariable variable=GitCommitSeven;]%gitCommitSeven% + echo $(GitCommitSeven) + displayName: GitCommitSeven - - script: | - set uuId=A6302662940458499454E35D28FCC9F7 - echo %uuId% - echo ##vso[task.setvariable variable=UUId;]%uuId% - echo $(UUId) - displayName: UUId + - script: | + set uuId=A6302662940458499454E35D28FCC9F7 + echo %uuId% + echo ##vso[task.setvariable variable=UUId;]%uuId% + echo $(UUId) + displayName: UUId - - script: | - set pwEncoding=AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAtBhT01pNnUGaN/uPLxZGvAAAAAACAAAAAAADZgAAwAAAABAAAAAM4xlYguhv7jzchU8dq9pVAAAAAASAAACgAAAAEAAAANS9rIoaYfNq5TwCmTrqElsgAAAA7O4J52FqCctXlCxYB2J5b/W4T+pZCN2zwFj7XCAFW6IUAAAAhQsBDOERAUZJdtSy8AfxwOAZflo= - echo %pwEncoding% - echo ##vso[task.setvariable variable=PwEncoding;]%pwEncoding% - echo $(PwEncoding) - displayName: PwEncoding + - script: | + set pwEncoding=AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAtBhT01pNnUGaN/uPLxZGvAAAAAACAAAAAAADZgAAwAAAABAAAAAM4xlYguhv7jzchU8dq9pVAAAAAASAAACgAAAAEAAAANS9rIoaYfNq5TwCmTrqElsgAAAA7O4J52FqCctXlCxYB2J5b/W4T+pZCN2zwFj7XCAFW6IUAAAAhQsBDOERAUZJdtSy8AfxwOAZflo= + echo %pwEncoding% + echo ##vso[task.setvariable variable=PwEncoding;]%pwEncoding% + echo $(PwEncoding) + displayName: PwEncoding - - script: | - echo $(Build.BuildId) - echo $(Build.Reason) - echo $(Build.Repository.Id) - echo $(Build.Repository.Name) - echo $(Build.SourceVersion) - echo $(Configuration) - echo $(CoreVersion) - echo $(GitCommitSeven) - echo $(NugetSource) - echo $(PwEncoding) - echo $(UUId) - REM echo $(pipelinePassword) - displayName: "Echo Check" + - script: | + echo $(Build.BuildId) + echo $(Build.Reason) + echo $(Build.Repository.Id) + echo $(Build.Repository.Name) + echo $(Build.SourceVersion) + echo $(Configuration) + echo $(CoreVersion) + echo $(GitCommitSeven) + echo $(NugetSource) + echo $(PwEncoding) + echo $(UUId) + REM echo $(pipelinePassword) + displayName: "Echo Check" - - script: '"C:\program files\dotnet\dotnet.exe" nuget locals all --clear' - displayName: "Nuget Clear" - enabled: false + - script: '"C:\program files\dotnet\dotnet.exe" nuget locals all --clear' + displayName: "Nuget Clear" + enabled: false - - script: | - "C:\program files\dotnet\dotnet.exe" user-secrets init - "C:\program files\dotnet\dotnet.exe" user-secrets set "BuildNumber" "$(Build.BuildId)" - "C:\program files\dotnet\dotnet.exe" user-secrets set "GitCommitSeven" "$(GitCommitSeven)" - "C:\program files\dotnet\dotnet.exe" user-secrets list - workingDirectory: Server - displayName: "Safe storage of app secrets - Server" + - script: | + "C:\program files\dotnet\dotnet.exe" user-secrets init + "C:\program files\dotnet\dotnet.exe" user-secrets set "BuildNumber" "$(Build.BuildId)" + "C:\program files\dotnet\dotnet.exe" user-secrets set "GitCommitSeven" "$(GitCommitSeven)" + "C:\program files\dotnet\dotnet.exe" user-secrets list + workingDirectory: Server + displayName: "Safe storage of app secrets - Server" - - script: | - "C:\program files\dotnet\dotnet.exe" user-secrets set "IsDevelopment" true - "C:\program files\dotnet\dotnet.exe" user-secrets set "MockRoot" "/Data/Tests" - "C:\program files\dotnet\dotnet.exe" user-secrets set "URLs" "http://localhost:5002;" - "C:\program files\dotnet\dotnet.exe" user-secrets set "MonAResource" "OI_Metrology_Viewer_IFX" - "C:\program files\dotnet\dotnet.exe" user-secrets set "ApiExportPath" "\\messdv002.na.infineon.com\Candela\Archive\API" - "C:\program files\dotnet\dotnet.exe" user-secrets set "ConnectionString" "Data Source=MESSAD1001\TEST1,59583;Integrated Security=True;Initial Catalog=Metrology;" - "C:\program files\dotnet\dotnet.exe" user-secrets set "Oi2SqlConnectionString" "Data Source=MESSAD1001\TEST1,59583;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;" - workingDirectory: Server - displayName: "Safe storage of app secrets II - Server" + - script: | + "C:\program files\dotnet\dotnet.exe" user-secrets set "IsDevelopment" true + "C:\program files\dotnet\dotnet.exe" user-secrets set "MockRoot" "/Data/Tests" + "C:\program files\dotnet\dotnet.exe" user-secrets set "URLs" "http://localhost:5002;" + "C:\program files\dotnet\dotnet.exe" user-secrets set "MonAResource" "OI_Metrology_Viewer_IFX" + "C:\program files\dotnet\dotnet.exe" user-secrets set "ApiExportPath" "\\messdv002.na.infineon.com\Candela\Archive\API" + "C:\program files\dotnet\dotnet.exe" user-secrets set "ConnectionString" "Data Source=MESSAD1001\TEST1,59583;Integrated Security=True;Initial Catalog=Metrology;" + "C:\program files\dotnet\dotnet.exe" user-secrets set "Oi2SqlConnectionString" "Data Source=MESSAD1001\TEST1,59583;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;" + workingDirectory: Server + displayName: "Safe storage of app secrets II - Server" - - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' - workingDirectory: Tests - displayName: "Core Build - Tests" + - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' + workingDirectory: Tests + displayName: "Core Build - Tests" - - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' - workingDirectory: Server - displayName: "Core Build - Server" + - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' + workingDirectory: Server + displayName: "Core Build - Server" - - powershell: Get-ChildItem .\ -include TestResults -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } - workingDirectory: "$(System.DefaultWorkingDirectory)/.vscode" - displayName: "PowerShell Script" + - powershell: Get-ChildItem .\ -include TestResults -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } + workingDirectory: "$(System.DefaultWorkingDirectory)/.vscode" + displayName: "PowerShell Script" - - script: "dotnet test --configuration $(Configuration)" - workingDirectory: Tests - displayName: "Core Test" - enabled: false + - script: "dotnet test --configuration $(Configuration)" + workingDirectory: Tests + displayName: "Core Test" + enabled: false - - script: '"C:\program files\dotnet\dotnet.exe" tool restore' - workingDirectory: Server - displayName: "Tool Restore" - enabled: false + - script: '"C:\program files\dotnet\dotnet.exe" tool restore' + workingDirectory: Server + displayName: "Tool Restore" + enabled: false - - script: '"C:\program files\dotnet\dotnet.exe" ReportGenerator -reports:.vscode/TestResults/*/coverage.cobertura.xml -targetDir:$(Build.ArtifactStagingDirectory)\Coverage -reportTypes:Html_Dark' - workingDirectory: Server - displayName: "Report Generator" - enabled: false + - script: '"C:\program files\dotnet\dotnet.exe" ReportGenerator -reports:.vscode/TestResults/*/coverage.cobertura.xml -targetDir:$(Build.ArtifactStagingDirectory)\Coverage -reportTypes:Html_Dark' + workingDirectory: Server + displayName: "Report Generator" + enabled: false - - task: PublishTestResults@2 - displayName: "Publish Test Results **/*.trx" - inputs: - testResultsFormat: VSTest - testResultsFiles: "**/*.trx" - testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" - searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" + - task: PublishTestResults@2 + displayName: "Publish Test Results **/*.trx" + inputs: + testResultsFormat: VSTest + testResultsFiles: "**/*.trx" + testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" + searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" - - task: PublishTestResults@2 - displayName: "Publish Test Results **/coverage.cobertura.xml" - inputs: - testResultsFormat: VSTest - testResultsFiles: "**/coverage.cobertura.xml" - testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" - searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" + - task: PublishTestResults@2 + displayName: "Publish Test Results **/coverage.cobertura.xml" + inputs: + testResultsFormat: VSTest + testResultsFiles: "**/coverage.cobertura.xml" + testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" + searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: "Cobertura" - summaryFileLocation: "$(System.DefaultWorkingDirectory)/.vscode/TestResults/*/coverage.cobertura.xml" - enabled: false + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: "Cobertura" + summaryFileLocation: "$(System.DefaultWorkingDirectory)/.vscode/TestResults/*/coverage.cobertura.xml" + enabled: false - - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1 - displayName: "Create work item" - inputs: - teamProject: "Mesa_FI" - workItemType: Bug - title: $(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration) - assignedTo: "$(Build.RequestedForId)" - enabled: false + - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1 + displayName: "Create work item" + inputs: + teamProject: "Mesa_FI" + workItemType: Bug + title: $(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration) + assignedTo: "$(Build.RequestedForId)" + enabled: false - - script: '"C:\program files\dotnet\dotnet.exe" publish --configuration $(Configuration) --runtime win-x64 --self-contained -o "D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server" --source $(NugetSource)' - workingDirectory: Server - displayName: "Core Publish" + - script: '"C:\program files\dotnet\dotnet.exe" publish --configuration $(Configuration) --runtime win-x64 --self-contained -o "D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server" --source $(NugetSource)' + workingDirectory: Server + displayName: "Core Publish" - - task: DownloadSecureFile@1 - name: downloadSecureFileKDBX - displayName: "Download secure file" - inputs: - secureFile: "Infineon-NA.kdbx" + - task: DownloadSecureFile@1 + name: downloadSecureFileKDBX + displayName: "Download secure file" + inputs: + secureFile: "Infineon-NA.kdbx" - - script: echo "<$(downloadSecureFileKDBX.secureFilePath)>" - displayName: "Echo Path" + - script: echo "<$(downloadSecureFileKDBX.secureFilePath)>" + displayName: "Echo Path" - - script: '"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)' - workingDirectory: Tests - displayName: "Core Clean - Tests" - enabled: false + - script: '"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)' + workingDirectory: Tests + displayName: "Core Clean - Tests" + enabled: false - - script: '"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)' - workingDirectory: src/BaGet - displayName: "Core Clean - Server" + - script: '"C:\program files\dotnet\dotnet.exe" clean --configuration $(Configuration)' + workingDirectory: Server + displayName: "Core Clean - Server" - - powershell: | - $data = @('$(downloadSecureFileKDBX.secureFilePath)', '-c:GetEntryString', '-Field:Password', '-refx-UUID:$(UUId)', '-pw-enc:$(PwEncoding)') - $data.count - $processStartInfo = New-Object System.Diagnostics.ProcessStartInfo - $processStartInfo.FileName = "C:\Users\$(USERNAME)\AppData\Local\IFXApps\KeePass-2.51.1---KPScript-2.51.1\KPScript.exe" - $processStartInfo.RedirectStandardError = $true - $processStartInfo.RedirectStandardOutput = $true - $processStartInfo.UseShellExecute = $false - $processStartInfo.Arguments = $data - $process = New-Object System.Diagnostics.Process - $process.StartInfo = $processStartInfo - $process.Start() | Out-Null - $process.WaitForExit() - $stdout = $process.StandardOutput.ReadToEnd() - $stderr = $process.StandardError.ReadToEnd() - Write-Host "stderr: $stderr" - Write-Host "exit code: " + $process.ExitCode - Write-Host "##vso[task.setvariable variable=pipelinePassword;]$stdout" - displayName: pipelinePassword + - powershell: | + $data = @('$(downloadSecureFileKDBX.secureFilePath)', '-c:GetEntryString', '-Field:Password', '-refx-UUID:$(UUId)', '-pw-enc:$(PwEncoding)') + $data.count + $processStartInfo = New-Object System.Diagnostics.ProcessStartInfo + $processStartInfo.FileName = "C:\Users\$(USERNAME)\AppData\Local\IFXApps\KeePass-2.51.1---KPScript-2.51.1\KPScript.exe" + $processStartInfo.RedirectStandardError = $true + $processStartInfo.RedirectStandardOutput = $true + $processStartInfo.UseShellExecute = $false + $processStartInfo.Arguments = $data + $process = New-Object System.Diagnostics.Process + $process.StartInfo = $processStartInfo + $process.Start() | Out-Null + $process.WaitForExit() + $stdout = $process.StandardOutput.ReadToEnd() + $stderr = $process.StandardError.ReadToEnd() + Write-Host "stderr: $stderr" + Write-Host "exit code: " + $process.ExitCode + Write-Host "##vso[task.setvariable variable=pipelinePassword;]$stdout" + displayName: pipelinePassword - - script: 'sc create "$(Build.Repository.Name)-$(Configuration)" start= delayed-auto DisplayName= "$(Build.Repository.Name)-$(Configuration)-$(GitCommitSeven)-$(Build.BuildId)" binPath= D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server\$(ExeName).exe obj= INFINEON\$(USERNAME) password="$(pipelinePassword)"' - workingDirectory: Server - displayName: "Service Control - Create" - continueOnError: true + - script: 'sc create "$(ExeName)" start= delayed-auto DisplayName= "$(Build.Repository.Name)-$(Configuration)-$(GitCommitSeven)-$(Build.BuildId)" binPath= D:\$(CoreVersion)\$(Build.Repository.Name)\Server\$(ExeName).exe obj= INFINEON\$(USERNAME) password="$(pipelinePassword)"' + workingDirectory: Server + displayName: "Service Control - Create" + continueOnError: true - - script: 'sc configure "$(ExeName)-$(Configuration)" DisplayName= "$(Build.Repository.Name)-$(Configuration)-$(GitCommitSeven)-$(Build.BuildId)"' - displayName: "Service Control - Configure" + - script: 'sc config "$(ExeName)" DisplayName= "$(Build.Repository.Name)-$(Configuration)-$(GitCommitSeven)-$(Build.BuildId)"' + displayName: "Service Control - Configure" - - script: 'sc stop "$(ExeName)-$(Configuration)"' - displayName: "Service Control - Stop" - continueOnError: true + - script: 'sc stop "$(ExeName)"' + displayName: "Service Control - Stop" + continueOnError: true - - script: 'rmdir "D:\$(CoreVersion)\$(Build.Repository.Name)\Server"' - displayName: "Remove directory" - continueOnError: true + - script: 'rmdir "D:\$(CoreVersion)\$(Build.Repository.Name)\Server"' + displayName: "Remove directory" + continueOnError: true - - script: 'mklink /J "D:\$(CoreVersion)\$(Build.Repository.Name)\Server" "D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server"' - displayName: "Link directory" - continueOnError: true + - script: 'mklink /J "D:\$(CoreVersion)\$(Build.Repository.Name)\Server" "D:\$(CoreVersion)\$(Build.Repository.Name)\$(GitCommitSeven)-$(Build.BuildId)-$(Build.Repository.Name)-$(Configuration)\Server"' + displayName: "Link directory" + continueOnError: true - - script: 'sc start "$(ExeName)-$(Configuration)"' - displayName: "Service Control - Start" + - script: 'sc start "$(ExeName)"' + displayName: "Service Control - Start" - - task: PublishBuildArtifacts@1 - displayName: "Publish Artifact: drop" - enabled: false + - task: PublishBuildArtifacts@1 + displayName: "Publish Artifact: drop" + enabled: false - - script: 'echo $(Build.SourceVersion)-$(Build.BuildId)>bin_x_x_\$(Configuration)\$(CoreVersion)\win-x64\$(Build.Repository.Name).txt' - displayName: "Force Fail" - enabled: false + - script: 'echo $(Build.SourceVersion)-$(Build.BuildId)>bin_x_x_\$(Configuration)\$(CoreVersion)\win-x64\$(Build.Repository.Name).txt' + displayName: "Force Fail" + enabled: false - stage: EC @@ -312,6 +312,10 @@ stages: workingDirectory: Server displayName: "Safe storage of app secrets - Server" + - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' + workingDirectory: Tests + displayName: "Core Build - Tests" + - script: '"C:\program files\dotnet\dotnet.exe" build --configuration $(Configuration) --source $(NugetSource)' workingDirectory: Server displayName: "Core Build - Server"