Creation
This commit is contained in:
1
Server/.vscode/format-report.json
vendored
Normal file
1
Server/.vscode/format-report.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[]
|
36
Server/.vscode/launch.json
vendored
Normal file
36
Server/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||
// Use hover for the description of the existing attributes
|
||||
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
||||
"name": ".NET Core Launch (web)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
// If you have changed target frameworks, make sure to update the program path.
|
||||
"program": "${workspaceFolder}/bin/Debug/net7.0/Expose-MyIT.Server.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"stopAtEntry": false,
|
||||
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
|
||||
"serverReadyAction": {
|
||||
"action": "openExternally",
|
||||
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
|
||||
},
|
||||
"env": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/Views": "${workspaceFolder}/Views"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processName": "Expose-MyIT.Server"
|
||||
}
|
||||
]
|
||||
}
|
12
Server/.vscode/settings.json
vendored
Normal file
12
Server/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"coverage-gutters.coverageBaseDir": "../.vscode/TestResults/*",
|
||||
"cSpell.words": [
|
||||
"Antiforgery",
|
||||
"Blazor",
|
||||
"HSTS",
|
||||
"Infineon",
|
||||
"Serilog",
|
||||
"Setpoint"
|
||||
],
|
||||
"watch": "set ASPNETCORE_ENVIRONMENT=Development&& dotnet watch run"
|
||||
}
|
41
Server/.vscode/tasks.json
vendored
Normal file
41
Server/.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/Expose-MyIT.Server.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "publish",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"publish",
|
||||
"${workspaceFolder}/Expose-MyIT.Server.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "watch",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"watch",
|
||||
"run",
|
||||
"--project",
|
||||
"${workspaceFolder}/Expose-MyIT.Server.csproj"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
30
Server/Controllers/AppSettingsController.cs
Normal file
30
Server/Controllers/AppSettingsController.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Expose.MyIT.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class AppSettingsController : ControllerBase, IAppSettingsController
|
||||
{
|
||||
|
||||
private readonly Models.AppSettings _AppSettings;
|
||||
|
||||
public AppSettingsController(Models.AppSettings appSettings) => _AppSettings = appSettings;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[HttpGet]
|
||||
public string[] GetAppSettings()
|
||||
{
|
||||
List<string> results = new();
|
||||
string json = JsonSerializer.Serialize(_AppSettings);
|
||||
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
|
||||
JsonProperty[] jsonProperties = jsonElement.EnumerateObject().ToArray();
|
||||
foreach (JsonProperty jsonProperty in jsonProperties)
|
||||
results.Add(jsonProperty.Value.ToString());
|
||||
if (!_AppSettings.IsDevelopment)
|
||||
throw new Exception("Shouldn't expose!");
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
}
|
40
Server/Controllers/ClientSettingsController.cs
Normal file
40
Server/Controllers/ClientSettingsController.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Expose.MyIT.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class ClientSettingsController : ControllerBase, IClientSettingsController
|
||||
{
|
||||
|
||||
private readonly Models.AppSettings _AppSettings;
|
||||
|
||||
public ClientSettingsController(Models.AppSettings appSettings) => _AppSettings = appSettings;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[HttpGet]
|
||||
public string[] GetClientSettings()
|
||||
{
|
||||
List<string> results = new();
|
||||
string? remoteIpAddress = Request.HttpContext.Connection?.RemoteIpAddress?.ToString();
|
||||
if (!string.IsNullOrEmpty(remoteIpAddress))
|
||||
results.Add(remoteIpAddress);
|
||||
else
|
||||
results.Add(nameof(remoteIpAddress));
|
||||
if (!_AppSettings.IsDevelopment)
|
||||
throw new Exception("Shouldn't expose!");
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
[Route("api/[controller]/IpAddress")]
|
||||
[HttpGet]
|
||||
public string GetIpAddress()
|
||||
{
|
||||
string? result;
|
||||
result = Request.HttpContext.Connection?.RemoteIpAddress?.ToString();
|
||||
if (string.IsNullOrEmpty(result))
|
||||
result = string.Empty;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
56
Server/Controllers/ServiceShopOrderController.cs
Normal file
56
Server/Controllers/ServiceShopOrderController.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using Expose.MyIT.Shared.Models.Methods;
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Expose.MyIT.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class ServiceShopOrderController : ControllerBase, IServiceShopOrderController
|
||||
{
|
||||
|
||||
private readonly IServiceShopOrderController _ServiceShopOrderController;
|
||||
private readonly IServiceShopOrderRepository _ServiceShopOrderRepository;
|
||||
|
||||
public ServiceShopOrderController(IServiceShopOrderRepository ServiceShopOrderRepository)
|
||||
{
|
||||
_ServiceShopOrderController = this;
|
||||
_ServiceShopOrderRepository = ServiceShopOrderRepository;
|
||||
}
|
||||
|
||||
async Task<Shared.ViewModels.ServiceShopOrder[]> IServiceShopOrderController.GetAllServiceShopOrders() => await _ServiceShopOrderRepository.GetAllServiceShopOrders();
|
||||
|
||||
async Task<Shared.ViewModels.ServiceShopOrder[]> IServiceShopOrderController.GetServiceShopOrders(string id) => await _ServiceShopOrderRepository.GetServiceShopOrders(id);
|
||||
|
||||
[HttpGet(nameof(Shared.Models.Stateless.IServiceShopOrderController.Action.All))]
|
||||
public async Task<ActionResult> GetAllServiceShopOrders()
|
||||
{
|
||||
try
|
||||
{
|
||||
Shared.ViewModels.ServiceShopOrder[] results = await _ServiceShopOrderController.GetAllServiceShopOrders();
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError,
|
||||
"Error retrieving data from the database");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<ActionResult> GetServiceShopOrders(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
Shared.ViewModels.ServiceShopOrder[] results = await _ServiceShopOrderController.GetServiceShopOrders(id);
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError,
|
||||
"Error retrieving data from the database");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
56
Server/Controllers/SsaOrderController.cs
Normal file
56
Server/Controllers/SsaOrderController.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using Expose.MyIT.Shared.Models.Methods;
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Expose.MyIT.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class SsaOrderController : ControllerBase, ISsaOrderController
|
||||
{
|
||||
|
||||
private readonly ISsaOrderController _SsaOrderController;
|
||||
private readonly ISsaOrderRepository _SsaOrderRepository;
|
||||
|
||||
public SsaOrderController(ISsaOrderRepository SsaOrderRepository)
|
||||
{
|
||||
_SsaOrderController = this;
|
||||
_SsaOrderRepository = SsaOrderRepository;
|
||||
}
|
||||
|
||||
async Task<Shared.ViewModels.SsaOrder[]> ISsaOrderController.GetAllSsaOrders() => await _SsaOrderRepository.GetAllSsaOrders();
|
||||
|
||||
async Task<Shared.ViewModels.SsaOrder[]> ISsaOrderController.GetSsaOrders(string id) => await _SsaOrderRepository.GetSsaOrders(id);
|
||||
|
||||
[HttpGet(nameof(Shared.Models.Stateless.ISsaOrderController.Action.All))]
|
||||
public async Task<ActionResult> GetAllSsaOrders()
|
||||
{
|
||||
try
|
||||
{
|
||||
Shared.ViewModels.SsaOrder[] results = await _SsaOrderController.GetAllSsaOrders();
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError,
|
||||
"Error retrieving data from the database");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<ActionResult> GetSsaOrders(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
Shared.ViewModels.SsaOrder[] results = await _SsaOrderController.GetSsaOrders(id);
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError,
|
||||
"Error retrieving data from the database");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
36
Server/Controllers/WeatherForecastController.cs
Normal file
36
Server/Controllers/WeatherForecastController.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Expose.MyIT.Shared.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Expose.MyIT.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
[Route("api/[controller]")]
|
||||
public class WeatherForecastController : ControllerBase, IWeatherForecastController
|
||||
{
|
||||
private static readonly string[] _Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _Logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger) => _Logger = logger;
|
||||
|
||||
Task<WeatherForecast[]> IWeatherForecastController.Get() => throw new NotImplementedException();
|
||||
|
||||
[HttpGet]
|
||||
public WeatherForecast[] Get()
|
||||
{
|
||||
_Logger.LogDebug("I was here :)");
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast(new Shared.Models.WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = _Summaries[Random.Shared.Next(_Summaries.Length)]
|
||||
}))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
}
|
8035
Server/Data/Mike/service-shop.json
Normal file
8035
Server/Data/Mike/service-shop.json
Normal file
File diff suppressed because it is too large
Load Diff
5214
Server/Data/Mike/ssa.json
Normal file
5214
Server/Data/Mike/ssa.json
Normal file
File diff suppressed because it is too large
Load Diff
41
Server/Expose-MyIT.Server.csproj
Normal file
41
Server/Expose-MyIT.Server.csproj
Normal file
@ -0,0 +1,41 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>Expose-MyIT.Server</RootNamespace>
|
||||
<AssemblyName>$(AssemblyName.Replace(' ', '_'))</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00032" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="6.1.0" />
|
||||
<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="System.Data.SqlClient" Version="4.8.5" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\Expose-MyIT.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="appsettings.Staging.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="appsettings.Development.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Data\Mike\ssa.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Data\Mike\service-shop.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
50
Server/Models/AppSettings.cs
Normal file
50
Server/Models/AppSettings.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Expose.MyIT.Server.Models;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
public string BuildNumber { init; get; }
|
||||
public string Company { init; get; }
|
||||
public string ConnectionString { init; get; }
|
||||
public string GitCommitSeven { init; get; }
|
||||
public bool IsDevelopment { init; get; }
|
||||
public bool IsStaging { init; get; }
|
||||
public string MonAResource { init; get; }
|
||||
public string MonASite { init; get; }
|
||||
public string URLs { init; get; }
|
||||
public string WorkingDirectoryName { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string buildNumber,
|
||||
string company,
|
||||
string connectionString,
|
||||
string gitCommitSeven,
|
||||
bool isDevelopment,
|
||||
bool isStaging,
|
||||
string monAResource,
|
||||
string monASite,
|
||||
string urls,
|
||||
string workingDirectoryName)
|
||||
{
|
||||
BuildNumber = buildNumber;
|
||||
Company = company;
|
||||
ConnectionString = connectionString;
|
||||
GitCommitSeven = gitCommitSeven;
|
||||
IsDevelopment = isDevelopment;
|
||||
IsStaging = isStaging;
|
||||
MonAResource = monAResource;
|
||||
MonASite = monASite;
|
||||
URLs = urls;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
77
Server/Models/Binder/AppSettings.cs
Normal file
77
Server/Models/Binder/AppSettings.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Expose.MyIT.Server.Models.Binder;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
#nullable disable
|
||||
|
||||
[Display(Name = "Build Number"), Required] public string BuildNumber { get; set; }
|
||||
[Display(Name = "Company"), Required] public string Company { get; set; }
|
||||
[Display(Name = "Connection String"), Required] public string ConnectionString { get; set; }
|
||||
[Display(Name = "Git Commit Seven"), Required] public string GitCommitSeven { get; set; }
|
||||
[Display(Name = "Is Development"), Required] public bool? IsDevelopment { get; set; }
|
||||
[Display(Name = "Is Staging"), Required] public bool? IsStaging { get; set; }
|
||||
[Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; }
|
||||
[Display(Name = "MonA Site"), Required] public string MonASite { get; set; }
|
||||
[Display(Name = "URLs"), Required] public string URLs { get; set; }
|
||||
[Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; }
|
||||
|
||||
#nullable restore
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
if (appSettings is null)
|
||||
throw new NullReferenceException(nameof(appSettings));
|
||||
if (appSettings.BuildNumber is null)
|
||||
throw new NullReferenceException(nameof(BuildNumber));
|
||||
if (appSettings.Company is null)
|
||||
throw new NullReferenceException(nameof(Company));
|
||||
if (appSettings.ConnectionString is null)
|
||||
throw new NullReferenceException(nameof(ConnectionString));
|
||||
if (appSettings.GitCommitSeven is null)
|
||||
throw new NullReferenceException(nameof(GitCommitSeven));
|
||||
if (appSettings.MonAResource is null)
|
||||
throw new NullReferenceException(nameof(MonAResource));
|
||||
if (appSettings.IsDevelopment is null)
|
||||
throw new NullReferenceException(nameof(IsDevelopment));
|
||||
if (appSettings.IsStaging is null)
|
||||
throw new NullReferenceException(nameof(IsStaging));
|
||||
if (appSettings.MonASite is null)
|
||||
throw new NullReferenceException(nameof(MonASite));
|
||||
if (appSettings.URLs is null)
|
||||
throw new NullReferenceException(nameof(URLs));
|
||||
if (appSettings.WorkingDirectoryName is null)
|
||||
throw new NullReferenceException(nameof(WorkingDirectoryName));
|
||||
result = new(
|
||||
appSettings.BuildNumber,
|
||||
appSettings.Company,
|
||||
appSettings.ConnectionString,
|
||||
appSettings.GitCommitSeven,
|
||||
appSettings.IsDevelopment.Value,
|
||||
appSettings.IsStaging.Value,
|
||||
appSettings.MonAResource,
|
||||
appSettings.MonASite,
|
||||
appSettings.URLs,
|
||||
appSettings.WorkingDirectoryName);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||
result = Get(appSettings);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
51
Server/Models/ServiceShopOrderRepository.cs
Normal file
51
Server/Models/ServiceShopOrderRepository.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using Expose.MyIT.Shared.Models.Methods;
|
||||
using Expose.MyIT.Shared.ViewModels;
|
||||
using Serilog.Context;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Expose.MyIT.Server.Models;
|
||||
|
||||
public class ServiceShopOrderRepository : IServiceShopOrderRepository
|
||||
{
|
||||
|
||||
private readonly Serilog.ILogger _Log;
|
||||
|
||||
public ServiceShopOrderRepository() => _Log = Serilog.Log.ForContext<ServiceShopOrderRepository>();
|
||||
|
||||
private static ServiceShopOrder[] GetServiceShopOrders(Shared.Models.ServiceShop? ServiceShop)
|
||||
{
|
||||
ServiceShopOrder[] result = Shared.Models.Stateless.Methods.IServiceShopOrder.GetServiceShopOrders(ServiceShop);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Shared.Models.ServiceShop? GetServiceShopOrders()
|
||||
{
|
||||
Shared.Models.ServiceShop? result;
|
||||
string jsonFile = Path.Combine(AppContext.BaseDirectory, "service-shop.json");
|
||||
string json = File.ReadAllText(jsonFile);
|
||||
result = JsonSerializer.Deserialize<Shared.Models.ServiceShop>(json);
|
||||
return result;
|
||||
}
|
||||
|
||||
async Task<ServiceShopOrder[]> IServiceShopOrderRepository.GetAllServiceShopOrders()
|
||||
{
|
||||
ServiceShopOrder[] results;
|
||||
string? methodName = Shared.Models.Stateless.Methods.IMethodName.GetActualAsyncMethodName();
|
||||
using (LogContext.PushProperty("MethodName", methodName))
|
||||
{
|
||||
_Log.Debug("() => ...");
|
||||
Shared.Models.ServiceShop? ServiceShop = await Task.Run(GetServiceShopOrders);
|
||||
results = GetServiceShopOrders(ServiceShop);
|
||||
}
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
async Task<ServiceShopOrder[]> IServiceShopOrderRepository.GetServiceShopOrders(string id)
|
||||
{
|
||||
ServiceShopOrder[] results;
|
||||
Shared.Models.ServiceShop? ServiceShop = await Task.Run(GetServiceShopOrders);
|
||||
results = GetServiceShopOrders(ServiceShop).Where(l => l.Id == id).ToArray();
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
51
Server/Models/SsaOrderRepository.cs
Normal file
51
Server/Models/SsaOrderRepository.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using Expose.MyIT.Shared.Models.Methods;
|
||||
using Expose.MyIT.Shared.ViewModels;
|
||||
using Serilog.Context;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Expose.MyIT.Server.Models;
|
||||
|
||||
public class SsaOrderRepository : ISsaOrderRepository
|
||||
{
|
||||
|
||||
private readonly Serilog.ILogger _Log;
|
||||
|
||||
public SsaOrderRepository() => _Log = Serilog.Log.ForContext<SsaOrderRepository>();
|
||||
|
||||
private static SsaOrder[] GetSsaOrders(Shared.Models.SSA? ssa)
|
||||
{
|
||||
SsaOrder[] result = Shared.Models.Stateless.Methods.ISsaOrder.GetSsaOrders(ssa);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Shared.Models.SSA? GetSsaOrders()
|
||||
{
|
||||
Shared.Models.SSA? result;
|
||||
string jsonFile = Path.Combine(AppContext.BaseDirectory, "ssa.json");
|
||||
string json = File.ReadAllText(jsonFile);
|
||||
result = JsonSerializer.Deserialize<Shared.Models.SSA>(json);
|
||||
return result;
|
||||
}
|
||||
|
||||
async Task<SsaOrder[]> ISsaOrderRepository.GetAllSsaOrders()
|
||||
{
|
||||
SsaOrder[] results;
|
||||
string? methodName = Shared.Models.Stateless.Methods.IMethodName.GetActualAsyncMethodName();
|
||||
using (LogContext.PushProperty("MethodName", methodName))
|
||||
{
|
||||
_Log.Debug("() => ...");
|
||||
Shared.Models.SSA? ssa = await Task.Run(GetSsaOrders);
|
||||
results = GetSsaOrders(ssa);
|
||||
}
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
async Task<SsaOrder[]> ISsaOrderRepository.GetSsaOrders(string id)
|
||||
{
|
||||
SsaOrder[] results;
|
||||
Shared.Models.SSA? ssa = await Task.Run(GetSsaOrders);
|
||||
results = GetSsaOrders(ssa).Where(l => l.Id == id).ToArray();
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
42
Server/Pages/Error.cshtml
Normal file
42
Server/Pages/Error.cshtml
Normal file
@ -0,0 +1,42 @@
|
||||
@page
|
||||
@model Expose.MyIT.Server.Pages.ErrorModel
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<title>Error</title>
|
||||
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
|
||||
<link href="~/css/app.css" rel="stylesheet" asp-append-version="true" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="main">
|
||||
<div class="content px-4">
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
|
||||
@if (Model.ShowRequestId)
|
||||
{
|
||||
<p>
|
||||
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||
</p>
|
||||
}
|
||||
|
||||
<h3>Development Mode</h3>
|
||||
<p>
|
||||
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
|
||||
</p>
|
||||
<p>
|
||||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||
It can result in displaying sensitive information from exceptions to end users.
|
||||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||
and restarting the app.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
16
Server/Pages/Error.cshtml.cs
Normal file
16
Server/Pages/Error.cshtml.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Expose.MyIT.Server.Pages;
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
[IgnoreAntiforgeryToken]
|
||||
public class ErrorModel : PageModel
|
||||
{
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
|
||||
public void OnGet() => RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
||||
}
|
79
Server/Program.cs
Normal file
79
Server/Program.cs
Normal file
@ -0,0 +1,79 @@
|
||||
using Expose.MyIT.Server.Models;
|
||||
using Expose.MyIT.Shared.Models.Methods;
|
||||
using Serilog;
|
||||
|
||||
namespace Expose.MyIT.Server;
|
||||
|
||||
public class Program
|
||||
{
|
||||
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
LoggerConfiguration loggerConfiguration = new();
|
||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||
_ = builder.Configuration.AddUserSecrets<Program>();
|
||||
AppSettings appSettings = Models.Binder.AppSettings.Get(builder.Configuration);
|
||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||
throw new Exception("Working directory name must have a value!");
|
||||
Environment.SetEnvironmentVariable("workingDirectory", $"D:/Tmp/{appSettings.WorkingDirectoryName}");
|
||||
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, builder.Configuration);
|
||||
_ = SerilogHostBuilderExtensions.UseSerilog(builder.Host);
|
||||
Log.Logger = loggerConfiguration.CreateLogger();
|
||||
Serilog.ILogger log = Log.ForContext<Program>();
|
||||
try
|
||||
{
|
||||
// Add services to the container.
|
||||
|
||||
_ = builder.Services.AddSingleton<AppSettings, AppSettings>(_ => appSettings);
|
||||
_ = builder.Services.AddSingleton<ISsaOrderRepository, SsaOrderRepository>();
|
||||
_ = builder.Services.AddSingleton<IServiceShopOrderRepository, ServiceShopOrderRepository>();
|
||||
_ = builder.Services.AddControllersWithViews();
|
||||
_ = builder.Services.AddRazorPages();
|
||||
|
||||
WebApplication app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseWebAssemblyDebugging();
|
||||
_ = app.UseCors(corsPolicyBuilder => corsPolicyBuilder.AllowAnyOrigin());
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = app.UseCors(corsPolicyBuilder => corsPolicyBuilder.WithOrigins("https://localhost:7130", "http://localhost:5055"));
|
||||
_ = app.UseExceptionHandler("/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
_ = app.UseHsts();
|
||||
}
|
||||
_ = app.Lifetime.ApplicationStopped.Register(Log.CloseAndFlush);
|
||||
_ = ApplicationBuilderSerilogClientExtensions.UseSerilogIngestion(app);
|
||||
_ = SerilogApplicationBuilderExtensions.UseSerilogRequestLogging(app);
|
||||
|
||||
_ = app.UseHttpsRedirection();
|
||||
|
||||
_ = app.UseBlazorFrameworkFiles();
|
||||
_ = app.UseStaticFiles();
|
||||
|
||||
_ = app.UseRouting();
|
||||
|
||||
_ = app.MapRazorPages();
|
||||
_ = app.MapControllers();
|
||||
_ = app.MapFallbackToFile("index.html");
|
||||
|
||||
log.Information("Starting Web Application");
|
||||
app.Run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Fatal(ex, "Host terminated unexpectedly");
|
||||
return 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
48
Server/Sample-Data/metrology-records.json
Normal file
48
Server/Sample-Data/metrology-records.json
Normal file
@ -0,0 +1,48 @@
|
||||
[
|
||||
{
|
||||
"Id": {
|
||||
"Value": 21474836471
|
||||
},
|
||||
"MaxInsertDate": {
|
||||
"Value": "1980-01-17T00:00:00"
|
||||
},
|
||||
"RunDataSheet": {
|
||||
"Value": "123456"
|
||||
},
|
||||
"ProductSpecificationNumber": {
|
||||
"Value": "1234"
|
||||
},
|
||||
"Reactor": {
|
||||
"Value": "12"
|
||||
},
|
||||
"Equipment": {
|
||||
"Value": "TENCOR1"
|
||||
},
|
||||
"Recipe": {
|
||||
"Value": "Bla bla bla"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Id": {
|
||||
"Value": 21474836472
|
||||
},
|
||||
"MaxInsertDate": {
|
||||
"Value": "2022-04-28T16:03:46"
|
||||
},
|
||||
"RunDataSheet": {
|
||||
"Value": "521920"
|
||||
},
|
||||
"ProductSpecificationNumber": {
|
||||
"Value": "2660"
|
||||
},
|
||||
"Reactor": {
|
||||
"Value": "59"
|
||||
},
|
||||
"Equipment": {
|
||||
"Value": "PROBE 1"
|
||||
},
|
||||
"Recipe": {
|
||||
"Value": "6IN4_10"
|
||||
}
|
||||
}
|
||||
]
|
15
Server/appsettings.Development.json
Normal file
15
Server/appsettings.Development.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"ConnectionString": "Data Source=asdf;",
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Debug",
|
||||
"Microsoft": "Warning",
|
||||
"Log4netProvider": "Debug",
|
||||
"Microsoft.Hosting.Lifetime": "Debug"
|
||||
}
|
||||
},
|
||||
"IsDevelopment": true,
|
||||
"IsStaging": false,
|
||||
"MonAResource": "Asdf_Asdf_IFX",
|
||||
"URLs": "https://localhost:7130;http://localhost:5126"
|
||||
}
|
15
Server/appsettings.Staging.json
Normal file
15
Server/appsettings.Staging.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"ConnectionString": "Data Source=asdf;",
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Log4netProvider": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"IsDevelopment": true,
|
||||
"IsStaging": false,
|
||||
"MonAResource": "Asdf_Asdf_EC",
|
||||
"URLs": "https://localhost:5003"
|
||||
}
|
59
Server/appsettings.json
Normal file
59
Server/appsettings.json
Normal file
@ -0,0 +1,59 @@
|
||||
{
|
||||
"AllowedHosts": "*",
|
||||
"BuildNumber": "1",
|
||||
"Company": "Infineon Technologies Americas Corp.",
|
||||
"ConnectionString": "Data Source=MESSV01EC.EC.LOCAL\\PROD1,53959;Integrated Security=True;Initial Catalog=Metrology;",
|
||||
"GitCommitSeven": "1234567",
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Log4netProvider": "Debug",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"InboundApiAllowedIPList": "",
|
||||
"IsDevelopment": false,
|
||||
"IsStaging": false,
|
||||
"MonAResource": "Asdf_Asdf_EC",
|
||||
"MonASite": "auc",
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
"Serilog.Sinks.Console",
|
||||
"Serilog.Sinks.File"
|
||||
],
|
||||
"MinimumLevel": "Debug",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "Debug",
|
||||
"Args": {
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "Console",
|
||||
"Args": {
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "%workingDirectory% - Log/log-.txt",
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}",
|
||||
"rollingInterval": "Hour"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": [
|
||||
"FromLogContext",
|
||||
"WithMachineName",
|
||||
"WithThreadId"
|
||||
],
|
||||
"Properties": {
|
||||
"Application": "Sample"
|
||||
}
|
||||
},
|
||||
"URLs": "http://localhost:5002;",
|
||||
"WorkingDirectoryName": "IFXApps"
|
||||
}
|
Reference in New Issue
Block a user