v1.3.0 Restructure Saxonite workspace and upgrade to .NET 10 (#1)
Move Saxonite’s projects into a dedicated `Workspace` folder and align the solution with .NET 10 and the current Common workspace. Update encryption integration, test project structure and coverage, and repository guidance and upgrade notes. - Relocate application and library projects while retaining Git rename history. - Split tests into Admin, Online, and Shared projects; add representative behavioral and serialization tests. - Update Common integration, application version, and repository documentation. Application version: 1.3.0 Reviewed-on: #1 Co-authored-by: andy <andy@sarand.com>
This commit was merged in pull request #1.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "8.0.4",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using Saxonite.Net.Core.Web.Base.App;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Web.Api.App;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
{
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
SaxSystem_Web.InitComputerName();
|
||||
builder.Environment.EnvironmentName = SaxSystem.GetEnvironment().ToString();
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddControllers().AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
|
||||
});
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(options =>
|
||||
{
|
||||
// Ref. https://stackoverflow.com/questions/46071513/swagger-error-conflicting-schemaids-duplicate-schemaids-detected-for-types-a-a
|
||||
options.CustomSchemaIds(type => type?.ToString().Replace("+", "."));
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Saxonite API application.
|
||||
var application = new SaxApplication_Api(app);
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
//app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Helpers;
|
||||
using Sarand.Net.Standard.Base.IO;
|
||||
using Sarand.Net.Standard.Base.Net;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Core.Web.Base.App;
|
||||
using Saxonite.Net.Core.Web.Base.Helpers;
|
||||
using Saxonite.Net.Core.Web.Base.Procs;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus.Reference;
|
||||
using Saxonite.Net.Standard.Base.Consoles;
|
||||
using Saxonite.Net.Standard.Base.Helpers;
|
||||
using Saxonite.Web.Api.Consoles;
|
||||
using System.Net;
|
||||
using System.Net.Security;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text.RegularExpressions;
|
||||
using static Saxonite.Net.Core.Web.Base.App.SaxAppConfig;
|
||||
|
||||
namespace Saxonite.Web.Api.App
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxApplication_Api : SaxApplication_Web
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Dictionary<String, SaxAppConfig> appConfigs = new Dictionary<string, SaxAppConfig>();
|
||||
private Dictionary<String, SaxEmailConfig> emailConfigs = new Dictionary<string, SaxEmailConfig>();
|
||||
// Session contexts.
|
||||
private class SessionContextData_Api : SessionContextData_Web
|
||||
{
|
||||
public SessionContextData_Api(SaxSessionContext_Web sessionContext) : base(sessionContext) { }
|
||||
}
|
||||
private readonly Dictionary<int, SessionContextData_Api> sessionContexts = new Dictionary<int, SessionContextData_Api>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SaxApplication_Api(WebApplication app) : base(Sax.Application.Api)
|
||||
{
|
||||
InitialiseTemporaryLoggingFolder();
|
||||
try
|
||||
{
|
||||
AppInstance = this;
|
||||
ConsoleHelper_Api = new SaxConsoleHelper_Api(this);
|
||||
|
||||
// Application configuration.
|
||||
InitEnvironment(app.Environment, "Sax-Web-Api");
|
||||
LoadConfiguration();
|
||||
|
||||
// Test API calls.
|
||||
Timer? timer = null;
|
||||
timer =
|
||||
new Timer((obj) =>
|
||||
{
|
||||
new Thread(new ThreadStart(() => { TestApi(); })).Start();
|
||||
if (timer != null) timer.Dispose();
|
||||
},
|
||||
null, 1000, Timeout.Infinite);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error($"GetType().Name.CTR {ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public static SaxApplication_Api? AppInstance { get; private set; }
|
||||
public override SaxConsoleHelper ConsoleHelper { get { return ConsoleHelper_Api; } }
|
||||
public SaxConsoleHelper_Api ConsoleHelper_Api { get; private set; }
|
||||
// Database.
|
||||
public override ISacsDatabase? GetDatabase(SaxSessionContext sessionContext, Sax.Database databaseType)
|
||||
{
|
||||
return sessionContexts.GetValue(sessionContext.Index, null)?.Databases.GetValue(databaseType, null);
|
||||
}
|
||||
// Configuration.
|
||||
public override SaxAppConfig AppConfig { get { return appConfigs.Values.ToList().getConfigForApplication(); } }
|
||||
public override SaxEmailConfig EmailConfig { get { return emailConfigs.Values.ToList().getConfigForSession(AppConfig); } }
|
||||
public override String SessionCookieName { get { return Sax.Config.Api.Session.Cookie.Name; } }
|
||||
// Startup messages - for debugging. See Admin.Views._Layout.
|
||||
public List<String> Messages { get; } = new List<String>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
|
||||
private void LoadConfiguration()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Application configuration.
|
||||
appConfigs = SaxAppConfigHelper.ExtractAppConfigs(SaxConfiguration.GetSection("AppConfigs"));
|
||||
emailConfigs = SaxEmailConfigHelper.ExtractEmailConfigs(SaxConfiguration.GetSection("EmailConfigs"));
|
||||
|
||||
// Ensure root log folder ends with 'Api' folder.
|
||||
LoggingRootFolder = AppConfig.Logging.RootFolder;
|
||||
if (!StringUtil.IsBlank(LoggingRootFolder) && !Regex.IsMatch(LoggingRootFolder, "[\\\\/]Api$", RegexOptions.IgnoreCase))
|
||||
LoggingRootFolder = StringUtil.CombineFilePath(LoggingRootFolder, "Api");
|
||||
|
||||
// Application instance.
|
||||
if (AppConfig.Instance.EqualsCI("Dev")) instanceType = Sax.InstanceType.Dev;
|
||||
else if (AppConfig.Instance.ContainsCI("Q")) instanceType = Sax.InstanceType.QC;
|
||||
else if (AppConfig.Instance.ContainsCI("UAT")) instanceType = Sax.InstanceType.UAT;
|
||||
else if (AppConfig.Instance.EqualsCI("PreProd")) instanceType = Sax.InstanceType.UAT;
|
||||
|
||||
// Initialise hard-coded logging path.
|
||||
if (StringUtil.IsBlank(LoggingRootFolder))
|
||||
{
|
||||
if (SaxSystem.ComputerName.EqualsCI("WIN-BPCLM1QUOMT"))
|
||||
LoggingRootFolder = @"D:\Saxonite\Logs\" + (Development ? "Dev" : "Test");
|
||||
}
|
||||
if (DirectoryUtil.DirectoryExists(LoggingRootFolder))
|
||||
SaLogger.LogFolder = LoggingRootFolder;
|
||||
LogApplicationStart(SysUtil.Fn);
|
||||
|
||||
// Session context - only one context available/necessary (for now).
|
||||
SessionContextData_Api sessionContextData = new SessionContextData_Api(new SaxSessionContext_Web(100, ApplicationType));
|
||||
ConfigureDatabaseConnection(sessionContextData, Sax.Database.Core);
|
||||
ConfigureDatabaseConnection(sessionContextData, Sax.Database.Reference);
|
||||
ConfigureDatabaseConnection(sessionContextData, Sax.Database.Support);
|
||||
sessionContexts.Add(sessionContextData.SessionContext.Index, sessionContextData);
|
||||
SessionContext = sessionContextData.SessionContext;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn(SysUtil.Fn + " " + ExceptionUtil.GetLogMessage(exc, "loading application configuration", 8));
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void TestApi()
|
||||
{
|
||||
#pragma warning disable CS0162
|
||||
// Allows you to bypass "AuthenticationException: The remote certificate is invalid according to the validation procedure." error. Don't to do this in production code...
|
||||
//ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
|
||||
|
||||
if (false)
|
||||
{
|
||||
CancellationToken cancelToken = new CancellationToken();
|
||||
SacsHttpClientHelper.RequestData request = new SacsHttpClientHelper.RequestData(cancelToken);
|
||||
request.UriBuilder.ConfigureSslUriBuilder("api.sportierre.com", "System/Version");
|
||||
request.ContentHeaders.Add(SacsHttpClientHelper.HeaderName_ContentType, "application/json");
|
||||
request.PostData = "{}";
|
||||
//request.ForcePost = true;
|
||||
request.Debug = true;
|
||||
SacsHttpClientHelper.ResponseData response = SacsHttpClientHelper.DoRequest(request).Result;
|
||||
String responseData = response.Data;
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
CancellationToken cancelToken = new CancellationToken();
|
||||
SacsHttpRequestData request = new SacsHttpRequestData(cancelToken);
|
||||
request.Url = "https://api.sportierre.com/System/Version";
|
||||
request.PostData = "{}";
|
||||
request.ContentHeaders.Add(SacsHttpClient.HeaderName_ContentType, "application/json");
|
||||
//request.ForcePost = true;
|
||||
request.Debug = true;
|
||||
SacsHttpResponseData response = SacsHttpClient.DoRequest(request).Result;
|
||||
String data = response.Data;
|
||||
}
|
||||
|
||||
DbUpdateInfo dbUpdateInfo = new DbUpdateInfo(new SysId(), "ApiApp", SacsSystem.ComputerName);
|
||||
|
||||
if (false)
|
||||
{
|
||||
// Cleanse USGA Courses and Markers.
|
||||
SaxGolfUsgaDataLookup.Config courseLookupConfig = new SaxGolfUsgaDataLookup.Config(SessionContext, dbUpdateInfo);
|
||||
courseLookupConfig.Tasks.Add(SaxGolfUsgaDataLookup.Task.CleanseCourses);
|
||||
courseLookupConfig.Tasks.Add(SaxGolfUsgaDataLookup.Task.CleanseMarkers);
|
||||
SaxGolfUsgaDataLookup courseLookup = new SaxGolfUsgaDataLookup(courseLookupConfig);
|
||||
courseLookup.RunAsync();
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
// USGA Countries.
|
||||
SaxGolfUsgaDataLookup.Config courseLookupConfig = new SaxGolfUsgaDataLookup.Config(SessionContext, dbUpdateInfo);
|
||||
SaxGolfUsgaDataLookup courseLookup = new SaxGolfUsgaDataLookup(courseLookupConfig);
|
||||
List<SaxGolfUsgaDataLookup.CountryData> countries = courseLookup.LookupUsgaCountries();
|
||||
SaLogger.Warn($"{SysUtil.Fn} Country lookup - found: {countries.Count}");
|
||||
if (courseLookup.HasErrorMessage())
|
||||
SaLogger.Warn($"{SysUtil.Fn} Country lookup error: {courseLookup.GetErrorMessage()}");
|
||||
foreach (SaxGolfUsgaDataLookup.CountryData country in countries)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
// USGA Provinces.
|
||||
SaxGolfUsgaDataLookup.Config courseLookupConfig = new SaxGolfUsgaDataLookup.Config(SessionContext, dbUpdateInfo);
|
||||
SaxGolfUsgaDataLookup courseLookup = new SaxGolfUsgaDataLookup(courseLookupConfig);
|
||||
List<SaxGolfUsgaDataLookup.ProvinceData> provinces = courseLookup.LookupUsgaProvincesForCountry("AUS");
|
||||
SaLogger.Warn($"{SysUtil.Fn} Province lookup - found: {provinces.Count}");
|
||||
if (courseLookup.HasErrorMessage())
|
||||
SaLogger.Warn($"{SysUtil.Fn} Province lookup error: {courseLookup.GetErrorMessage()}");
|
||||
foreach (SaxGolfUsgaDataLookup.ProvinceData province in provinces)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
// USGA Courses.
|
||||
SaxGolfUsgaDataLookup.Config courseLookupConfig = new SaxGolfUsgaDataLookup.Config(SessionContext, dbUpdateInfo);
|
||||
SaxGolfUsgaDataLookup courseLookup = new SaxGolfUsgaDataLookup(courseLookupConfig);
|
||||
List<SaxGolfUsgaDataLookup.CourseData> courses = courseLookup.LookupUsgaCoursesForCountryAndProvince("AUS", "AU-VIC");
|
||||
SaLogger.Warn($"{SysUtil.Fn} Course lookup - found: {courses.Count}");
|
||||
if (courseLookup.HasErrorMessage())
|
||||
SaLogger.Warn($"{SysUtil.Fn} Course lookup error: {courseLookup.GetErrorMessage()}");
|
||||
foreach (SaxGolfUsgaDataLookup.CourseData course in courses)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
// USGA Markers.
|
||||
SaxGolfUsgaDataLookup.Config courseLookupConfig = new SaxGolfUsgaDataLookup.Config(SessionContext, dbUpdateInfo);
|
||||
SaxGolfUsgaDataLookup courseLookup = new SaxGolfUsgaDataLookup(courseLookupConfig);
|
||||
List<SaxGolfUsgaDataLookup.MarkerData> markers = courseLookup.LookupUsgaMarkersForCourse(new SysId(18226));
|
||||
SaLogger.Warn($"{SysUtil.Fn} Marker lookup - found: {markers.Count}");
|
||||
if (courseLookup.HasErrorMessage())
|
||||
SaLogger.Warn($"{SysUtil.Fn} Marker lookup error: {courseLookup.GetErrorMessage()}");
|
||||
foreach (SaxGolfUsgaDataLookup.MarkerData marker in markers)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Core.Web.Base.Consoles;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
|
||||
namespace Saxonite.Web.Api.Consoles
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxActivityConsole_Api : SaxActivityConsole_Web
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public SaxActivityConsole_Api(SaxSessionContext sessionContext) :
|
||||
base(sessionContext)
|
||||
{
|
||||
SaLogger.Info(SysUtil.Fn + "");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Core.Web.Base.Consoles;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Consoles;
|
||||
using Saxonite.Web.Api.App;
|
||||
|
||||
namespace Saxonite.Web.Api.Consoles
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxConsoleHelper_Api : SaxConsoleHelper_Web
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members:
|
||||
private readonly SaxApplication_Api app;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SaxConsoleHelper_Api(SaxApplication_Api app)
|
||||
{
|
||||
this.app = app;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// Clear process consoles.
|
||||
foreach (SaxProcessConsole_Api? processConsole in processConsoles.Values)
|
||||
{
|
||||
if (processConsole != null)
|
||||
processConsole.Dispose();
|
||||
}
|
||||
processConsoles.Clear();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data cache console.
|
||||
public override SaxDataCacheConsole? GetDataCacheConsole(SaxSessionContext sessionContext)
|
||||
{
|
||||
//throw new NotSupportedException(fn + " Data Cache Console not supported in API app.");
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Session data console.
|
||||
public override SaxSessionDataConsole? GetSessionDataConsole(SaxSessionContext sessionContext)
|
||||
{
|
||||
// Method is called by Base Controller on ValidUserSession and must return null for Admin app.
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Process console.
|
||||
private Dictionary<ushort, SaxProcessConsole_Api?> processConsoles { get; } = new Dictionary<ushort, SaxProcessConsole_Api?>();
|
||||
public SaxProcessConsole GetProcessConsole(SaxSessionContext sessionContext)
|
||||
{
|
||||
if (sessionContext == null) throw new NotSupportedException($"{SysUtil.Fn} Session Context must be specified.");
|
||||
SaxProcessConsole_Api? processConsole = processConsoles.GetValueOrDefault(sessionContext.Index, null);
|
||||
if (processConsole == null)
|
||||
{
|
||||
processConsole = processConsoles[sessionContext.Index] = new SaxProcessConsole_Api(sessionContext);
|
||||
}
|
||||
return processConsole;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Activity console.
|
||||
public override SaxActivityConsole CreateActivityConsole(SaxSessionContext sessionContext)
|
||||
{
|
||||
return new SaxActivityConsole_Api(sessionContext);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Email console.
|
||||
public override SaxEmailConsole CreateEmailConsole(SaxSessionContext sessionContext)
|
||||
{
|
||||
SaxEmailConsole emailConsole = new SaxEmailConsole_Web(app.EmailConfig);
|
||||
return emailConsole;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using Sarand.Net.Standard.Base.Procs;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Consoles;
|
||||
using Saxonite.Web.Api.Procs;
|
||||
|
||||
namespace Saxonite.Web.Api.Consoles
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxProcessConsole_Api : SaxProcessConsole
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
public enum ProcessType
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Process cache - to sustain processes outside of request/response timescales.
|
||||
internal class ProcessData
|
||||
{
|
||||
public ProcessData(SaxProcess_Api process)
|
||||
{
|
||||
this.Process = process;
|
||||
|
||||
}
|
||||
public SaxProcess_Api Process { get; }
|
||||
}
|
||||
// Cache.
|
||||
private Dictionary<ProcessType, ProcessData> processes { get; } = new Dictionary<ProcessType, ProcessData>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SaxInternals? internals = null;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SaxProcessConsole_Api(SaxSessionContext sessionContext) : base(sessionContext)
|
||||
{
|
||||
}
|
||||
protected async override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// Clear processes.
|
||||
foreach (ProcessData processData in processes.Values)
|
||||
{
|
||||
await processData.Process.StopProcessAsync();
|
||||
processData.Process.Dispose();
|
||||
}
|
||||
processes.Clear();
|
||||
// Internals.
|
||||
if (internals != null)
|
||||
{
|
||||
internals.Dispose();
|
||||
internals = null;
|
||||
}
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Priority.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Processes.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
public SaxProcess_Api? GetProcess(ProcessType processType)
|
||||
{
|
||||
return DictionaryUtil.GetValue<ProcessType, ProcessData>(processes,processType, null)?.Process;
|
||||
}
|
||||
|
||||
public bool IsProcessing(ProcessType processType)
|
||||
{
|
||||
SaxProcess_Api? process = GetProcess(processType);
|
||||
if (process != null)
|
||||
if (process.Processing) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the process from the cache.
|
||||
/// </summary>
|
||||
/// <param name="processType"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="InProgressException"></exception>
|
||||
public bool ClearProcess(ProcessType processType)
|
||||
{
|
||||
SaxProcess_Api? process = GetProcess(processType);
|
||||
if (process != null)
|
||||
{
|
||||
if (process.Processing)
|
||||
throw new SaProcess_Base.InProgressException();
|
||||
process.Dispose();
|
||||
}
|
||||
return processes.Remove(processType);
|
||||
}
|
||||
|
||||
public void SetProcess(ProcessType processType, SaxProcess_Api process)
|
||||
{
|
||||
ClearProcess(processType);
|
||||
processes.Add(processType, new ProcessData(process));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Specific processes.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus.Reference;
|
||||
using Saxonite.Net.Standard.Base.Mgr.Reference;
|
||||
using Saxonite.Web.Api.App;
|
||||
using static Sarand.Net.Standard.Base.Helpers.SacsHttpClientHelper;
|
||||
using static Saxonite.Net.Standard.Base.App.Sax.Config.Online;
|
||||
|
||||
namespace Saxonite.Web.Api.Controllers
|
||||
{
|
||||
//=======================================================================
|
||||
[ApiController]
|
||||
public class GolfController : SwapiControllerBase
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public GolfController()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// USGA Countries.
|
||||
|
||||
public class RequestData_UsgaCountries
|
||||
{
|
||||
public String? Search { get; set; }
|
||||
public SaxGolfUsgaCountry.StatusCat? Status { get; set; } = SaxGolfUsgaCountry.StatusCat.ActiveOnly;
|
||||
}
|
||||
public class ResponseData_UsgaCountries : ApiResponse_Data
|
||||
{
|
||||
public class UsgaCountriesData
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
public String? Code { get; set; }
|
||||
public String? Name { get; set; }
|
||||
}
|
||||
public List<UsgaCountriesData> UsgaCountries { get; } = new List<UsgaCountriesData>();
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("[controller]/UsgaCountries")]
|
||||
public ResponseData_UsgaCountries GetUsgaCountries_Post(RequestData_UsgaCountries requestData)
|
||||
{
|
||||
ResponseData_UsgaCountries responseData = new ResponseData_UsgaCountries();
|
||||
|
||||
SaxGolfUsgaCountry.Params prmCountries = new SaxGolfUsgaCountry.Params();
|
||||
prmCountries.CountryFilter = requestData.Search;
|
||||
prmCountries.StatusCat = requestData.Status ?? SaxGolfUsgaCountry.StatusCat.NotDeleted;
|
||||
foreach (SaxGolfUsgaCountry usgaCountry in ReferenceGolfMgr.GetUsgaCountryList(prmCountries))
|
||||
{
|
||||
ResponseData_UsgaCountries.UsgaCountriesData countryData = new ResponseData_UsgaCountries.UsgaCountriesData();
|
||||
countryData.Id = SysId.ToLong(usgaCountry.Id);
|
||||
if (!StringUtil.IsBlank(usgaCountry.CountryCode))
|
||||
countryData.Code = usgaCountry.CountryCode;
|
||||
if (!StringUtil.IsBlank(usgaCountry.CountryName))
|
||||
countryData.Name = usgaCountry.CountryName;
|
||||
responseData.UsgaCountries.Add(countryData);
|
||||
}
|
||||
|
||||
return responseData;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// USGA Provinces.
|
||||
|
||||
public class RequestData_UsgaProvinces
|
||||
{
|
||||
public String? CountryId { get; set; }
|
||||
public String? Search { get; set; }
|
||||
public SaxGolfUsgaProvince.StatusCat? Status { get; set; } = SaxGolfUsgaProvince.StatusCat.ActiveOnly;
|
||||
}
|
||||
public class ResponseData_UsgaProvinces : ApiResponse_Data
|
||||
{
|
||||
public class UsgaProvinceData
|
||||
{
|
||||
public String? Id { get; set; }
|
||||
public String? Code { get; set; }
|
||||
public String? Name { get; set; }
|
||||
}
|
||||
public List<UsgaProvinceData> UsgaProvinces { get; } = new List<UsgaProvinceData>();
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("[controller]/UsgaProvinces")]
|
||||
public ResponseData_UsgaProvinces GetUsgaProvinces_Post(RequestData_UsgaProvinces requestData)
|
||||
{
|
||||
ResponseData_UsgaProvinces responseData = new ResponseData_UsgaProvinces();
|
||||
|
||||
SysId countryId = SysId.ToSysId(requestData.CountryId);
|
||||
if (SysId.IsValid(countryId))
|
||||
{
|
||||
SaxGolfUsgaProvince.Params prmProvinces = new SaxGolfUsgaProvince.Params();
|
||||
prmProvinces.CountryIdsIncluded.Add(countryId);
|
||||
prmProvinces.ProvinceFilter = requestData.Search;
|
||||
prmProvinces.StatusCat = requestData.Status ?? SaxGolfUsgaProvince.StatusCat.NotDeleted;
|
||||
foreach (SaxGolfUsgaProvince usgaProvince in ReferenceGolfMgr.GetUsgaProvinceList(prmProvinces))
|
||||
{
|
||||
ResponseData_UsgaProvinces.UsgaProvinceData provinceData = new ResponseData_UsgaProvinces.UsgaProvinceData();
|
||||
provinceData.Id = SysId.ToString(usgaProvince.Id);
|
||||
if (!StringUtil.IsBlank(usgaProvince.ProvinceCode))
|
||||
provinceData.Code = usgaProvince.ProvinceCode;
|
||||
if (!StringUtil.IsBlank(usgaProvince.ProvinceName))
|
||||
provinceData.Name = usgaProvince.ProvinceName;
|
||||
responseData.UsgaProvinces.Add(provinceData);
|
||||
}
|
||||
}
|
||||
|
||||
return responseData;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// USGA Courses.
|
||||
|
||||
public class RequestData_UsgaCourses
|
||||
{
|
||||
public String? ProvinceId { get; set; }
|
||||
public String? Search { get; set; }
|
||||
public SaxGolfUsgaCourse.StatusCat? Status { get; set; } = SaxGolfUsgaCourse.StatusCat.ActiveOnly;
|
||||
}
|
||||
public class ResponseData_UsgaCourses : ApiResponse_Data
|
||||
{
|
||||
public class UsgaCourseData
|
||||
{
|
||||
public String? Id { get; set; }
|
||||
public String? Caption { get; set; }
|
||||
public String? CourseName { get; set; }
|
||||
public String? FullName { get; set; }
|
||||
public String? Address1 { get; set; }
|
||||
public String? Address2 { get; set; }
|
||||
public String? City { get; set; }
|
||||
}
|
||||
public List<UsgaCourseData> UsgaCourses { get; } = new List<UsgaCourseData>();
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("[controller]/UsgaCourses")]
|
||||
public ResponseData_UsgaCourses GetUsgaCourses_Post(RequestData_UsgaCourses requestData)
|
||||
{
|
||||
ResponseData_UsgaCourses responseData = new ResponseData_UsgaCourses();
|
||||
|
||||
SysId provinceId = SysId.ToSysId(requestData.ProvinceId);
|
||||
if (SysId.IsValid(provinceId))
|
||||
{
|
||||
SaxGolfUsgaCourse.Params prmCourses = new SaxGolfUsgaCourse.Params();
|
||||
prmCourses.ProvinceIdsIncluded.Add(provinceId);
|
||||
prmCourses.CourseFilter = requestData.Search;
|
||||
prmCourses.StatusCat = requestData.Status ?? SaxGolfUsgaCourse.StatusCat.NotDeleted;
|
||||
foreach (SaxGolfUsgaCourse usgaCourse in ReferenceGolfMgr.GetUsgaCourseList(prmCourses))
|
||||
{
|
||||
ResponseData_UsgaCourses.UsgaCourseData provinceData = new ResponseData_UsgaCourses.UsgaCourseData();
|
||||
provinceData.Id = SysId.ToString(usgaCourse.Id);
|
||||
if (!StringUtil.IsBlank(usgaCourse.Caption))
|
||||
provinceData.Caption = usgaCourse.Caption;
|
||||
if (!StringUtil.IsBlank(usgaCourse.CourseName))
|
||||
provinceData.CourseName = usgaCourse.CourseName;
|
||||
if (!StringUtil.IsBlank(usgaCourse.FullName))
|
||||
provinceData.FullName = usgaCourse.FullName;
|
||||
if (!StringUtil.IsBlank(usgaCourse.Address1))
|
||||
provinceData.Address1 = usgaCourse.Address1;
|
||||
if (!StringUtil.IsBlank(usgaCourse.Address2))
|
||||
provinceData.Address2 = usgaCourse.Address2;
|
||||
if (!StringUtil.IsBlank(usgaCourse.City))
|
||||
provinceData.City = usgaCourse.City;
|
||||
responseData.UsgaCourses.Add(provinceData);
|
||||
}
|
||||
}
|
||||
|
||||
return responseData;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// USGA Markers.
|
||||
|
||||
public class RequestData_UsgaMarkers
|
||||
{
|
||||
public String? CourseId { get; set; }
|
||||
public String? Search { get; set; }
|
||||
public SaxGolfUsgaMarker.StatusCat? Status { get; set; } = SaxGolfUsgaMarker.StatusCat.ActiveOnly;
|
||||
}
|
||||
public class ResponseData_UsgaMarkers : ApiResponse_Data
|
||||
{
|
||||
public class UsgaMarkerData
|
||||
{
|
||||
public String? CourseId { get; set; }
|
||||
public String? MarkerId { get; set; }
|
||||
public String? Caption { get; set; }
|
||||
public short? Holes { get; set; }
|
||||
public String? HolesCaption { get; set; }
|
||||
public String? Tee { get; set; }
|
||||
public String? Gender { get; set; }
|
||||
public short? SlopeRating { get; set; }
|
||||
public short? Par { get; set; }
|
||||
public decimal? CourseRating { get; set; }
|
||||
public decimal? BogeyRating { get; set; }
|
||||
public short? Length { get; set; }
|
||||
}
|
||||
public List<UsgaMarkerData> UsgaMarkers { get; } = new List<UsgaMarkerData>();
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("[controller]/UsgaMarkers")]
|
||||
public ResponseData_UsgaMarkers GetUsgaMarkers_Post(RequestData_UsgaMarkers requestData)
|
||||
{
|
||||
ResponseData_UsgaMarkers responseData = new ResponseData_UsgaMarkers();
|
||||
|
||||
SysId courseId = SysId.ToSysId(requestData.CourseId);
|
||||
if (SysId.IsValid(courseId))
|
||||
{
|
||||
SaxGolfUsgaMarker.Params prmMarkers = new SaxGolfUsgaMarker.Params();
|
||||
prmMarkers.CourseIdsIncluded.Add(courseId);
|
||||
prmMarkers.MarkerFilter = requestData.Search;
|
||||
prmMarkers.StatusCat = requestData.Status ?? SaxGolfUsgaMarker.StatusCat.NotDeleted;
|
||||
foreach (SaxGolfUsgaMarker usgaMarker in ReferenceGolfMgr.GetUsgaMarkerList(prmMarkers))
|
||||
{
|
||||
ResponseData_UsgaMarkers.UsgaMarkerData provinceData = new ResponseData_UsgaMarkers.UsgaMarkerData();
|
||||
provinceData.CourseId = SysId.ToString(usgaMarker.CourseId);
|
||||
provinceData.MarkerId = SysId.ToString(usgaMarker.Id);
|
||||
if (!StringUtil.IsBlank(usgaMarker.Caption))
|
||||
provinceData.Caption = usgaMarker.Caption;
|
||||
if (usgaMarker.Holes > 0)
|
||||
provinceData.Holes = usgaMarker.Holes;
|
||||
if (!StringUtil.IsBlank(usgaMarker.HolesCaption))
|
||||
provinceData.HolesCaption = usgaMarker.HolesCaption;
|
||||
if (!StringUtil.IsBlank(usgaMarker.Tee))
|
||||
provinceData.Tee = usgaMarker.Tee;
|
||||
if (!StringUtil.IsBlank(usgaMarker.Gender))
|
||||
provinceData.Gender = usgaMarker.Gender;
|
||||
if (usgaMarker.SlopeRating > 0)
|
||||
provinceData.SlopeRating = usgaMarker.SlopeRating;
|
||||
if (usgaMarker.Par > 0)
|
||||
provinceData.Par = usgaMarker.Par;
|
||||
if (usgaMarker.CourseRating > 0)
|
||||
provinceData.CourseRating = usgaMarker.CourseRating;
|
||||
if (usgaMarker.BogeyRating > 0)
|
||||
provinceData.BogeyRating = usgaMarker.BogeyRating;
|
||||
if (usgaMarker.Length > 0)
|
||||
provinceData.Length = usgaMarker.Length;
|
||||
responseData.UsgaMarkers.Add(provinceData);
|
||||
}
|
||||
}
|
||||
|
||||
return responseData;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Saxonite.Web.Api.Controllers
|
||||
{
|
||||
//=======================================================================
|
||||
[ApiController]
|
||||
//[Route("[controller]")]
|
||||
public class SecurityController : SwapiControllerBase
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SecurityController()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Start session.
|
||||
|
||||
public class RequestData_StartSession
|
||||
{
|
||||
public String userCode { get; set; } = "";
|
||||
}
|
||||
public class ResponseData_StartSession : ApiResponse_Data
|
||||
{
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("[controller]/StartSession")]
|
||||
public ResponseData_StartSession StartSession_Get(RequestData_StartSession requestData)
|
||||
{
|
||||
ResponseData_StartSession responseData = new ResponseData_StartSession();
|
||||
responseData.SetMessage("Security",$"User: {requestData.userCode}.");
|
||||
|
||||
return responseData;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Sacs.Web.Components;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Core.Web.Base.Controllers;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
|
||||
namespace Saxonite.Web.Api.Controllers
|
||||
{
|
||||
//=======================================================================
|
||||
public class SwapiControllerBase : SaxController_Base
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Response data.
|
||||
// Null values are ignored by JSON serialisation.
|
||||
// - See Saxonite.Net.Core.Web.Base.App.SaxStartup.ConfigureServices()
|
||||
// - Ref. config.services.AddMvc(...).AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; });
|
||||
//-------------------------------------------------------------------
|
||||
// Base response data - for simple responses.
|
||||
public class ApiResponse_Base
|
||||
{
|
||||
// Response status.
|
||||
public bool? Success { get; set; } = null;
|
||||
public bool? Error { get; set; } = null;
|
||||
public bool? SessionExpired { get; protected set; } = null;
|
||||
public ApiResponse_Base SetSessionExpired(String title, String text)
|
||||
{
|
||||
SessionExpired = true;
|
||||
return SetMessage(title, text);
|
||||
}
|
||||
// Message - displays alert popup.
|
||||
public class MessageData
|
||||
{
|
||||
public MessageData(String title, String text)
|
||||
{
|
||||
this.Title = title;
|
||||
this.Text = text;
|
||||
}
|
||||
public String Title { get; }
|
||||
public String Text { get; }
|
||||
}
|
||||
public MessageData? Message { get; private set; }
|
||||
public ApiResponse_Base SetMessage(String title, String text)
|
||||
{
|
||||
if (!StringUtil.IsBlank(text))
|
||||
Message = new MessageData(title, text);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public class ApiResponse_Data : ApiResponse_Base
|
||||
{
|
||||
//---------------------------------------------------------------
|
||||
// Construction.
|
||||
protected ApiResponse_Data()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
/// <summary>Item data - Common properties for data items.</summary>
|
||||
public class ItemData_Base
|
||||
{
|
||||
// Common item properties.
|
||||
public String? Id { get; set; }
|
||||
public String? Notes { get; set; }
|
||||
public String? StatusCode { get; set; }
|
||||
public String? StatusDesc { get; set; }
|
||||
// Flags for common status values.
|
||||
// Return true or null so that property is not serialised when false.
|
||||
public bool? Awaiting { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Awaiting)) ? true : (bool?)null; } }
|
||||
public bool? Active { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Active)) ? true : (bool?)null; } }
|
||||
public bool? Inactive { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Inactive)) ? true : (bool?)null; } }
|
||||
public bool? Deleted { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Deleted)) ? true : (bool?)null; } }
|
||||
/// <summary>Created on date - YYYYMMDD</summary>
|
||||
public String? CreatedOn { get; set; }
|
||||
/// <summary>Created on date - formatted per locale</summary>
|
||||
public String? CreatedOnFmt { get; set; }
|
||||
/// <summary>Updated on date - YYYYMMDD</summary>
|
||||
public String? UpdatedOn { get; set; }
|
||||
/// <summary>Updated on date - formatted per locale</summary>
|
||||
public String? UpdatedOnFmt { get; set; }
|
||||
}
|
||||
/// <summary>Contact Method properties.</summary>
|
||||
public class ContactMethodData
|
||||
{
|
||||
public String? Method { get; set; }
|
||||
public String? MethodCaption { get; set; }
|
||||
public String? Value { get; set; }
|
||||
}
|
||||
/// <summary>Address properties.</summary>
|
||||
public class AddressData : ItemData_Base
|
||||
{
|
||||
public String? Line1 { get; set; }
|
||||
public String? Line2 { get; set; }
|
||||
public String? Line3 { get; set; }
|
||||
public String? Town { get; set; }
|
||||
public String? RegionIdProvince { get; set; }
|
||||
public String? RegionNameProvince { get; set; }
|
||||
public String? RegionIdCountry { get; set; }
|
||||
public String? RegionNameCountry { get; set; }
|
||||
public String? PostalCode { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Item data with label and value.
|
||||
/// </summary>
|
||||
public class ItemLabelValue
|
||||
{
|
||||
public String? Label { get; set; }
|
||||
public String? Value { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Item data with just Id and name.
|
||||
/// <para>- Id is String to allow for obfuscated values.</para>
|
||||
/// </summary>
|
||||
public class ItemIdName
|
||||
{
|
||||
public String? Id { get; set; }
|
||||
public String? Name { get; set; }
|
||||
}
|
||||
/// <summary>Item code and desc values.</summary>
|
||||
public class ItemCodeDesc
|
||||
{
|
||||
public String? Code { get; set; }
|
||||
public String? Desc { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SwapiControllerBase() : base(null)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Web.Api.App;
|
||||
using static Sarand.Net.Standard.Base.Helpers.SacsHttpClientHelper;
|
||||
|
||||
namespace Saxonite.Web.Api.Controllers
|
||||
{
|
||||
//=======================================================================
|
||||
[ApiController]
|
||||
public class SystemController : SwapiControllerBase
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SystemController()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Version.
|
||||
|
||||
public class RequestData_Version
|
||||
{
|
||||
}
|
||||
public class ResponseData_Version : ApiResponse_Data
|
||||
{
|
||||
public String? Version { get; set; }
|
||||
}
|
||||
[HttpGet]
|
||||
[Route("[controller]/Version")]
|
||||
public ResponseData_Version GetVersion_Get()
|
||||
{
|
||||
return GetVersion_Post(new RequestData_Version());
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("[controller]/Version")]
|
||||
public ResponseData_Version GetVersion_Post(RequestData_Version requestData)
|
||||
{
|
||||
ResponseData_Version responseData = new ResponseData_Version();
|
||||
responseData.Version = Sax.Version.GetFullVersion();
|
||||
return responseData;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Config.
|
||||
|
||||
public class RequestData_Config
|
||||
{
|
||||
}
|
||||
public class ResponseData_Config : ApiResponse_Data
|
||||
{
|
||||
public class ConfigData
|
||||
{
|
||||
public String? Environment { get; set; }
|
||||
public String? Instance { get; set; }
|
||||
public String? Version { get; set; }
|
||||
public String? Host{ get; set; }
|
||||
public String? ConfigLogFolder { get; set; }
|
||||
public String? LogFolder { get; set; }
|
||||
public String? EmailContext { get; set; }
|
||||
}
|
||||
public ConfigData Config { get; } = new ConfigData();
|
||||
}
|
||||
[HttpGet]
|
||||
[Route("[controller]/Config")]
|
||||
public ResponseData_Config GetConfig_Get()
|
||||
{
|
||||
return GetConfig_Post(new RequestData_Config());
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("[controller]/Config")]
|
||||
public ResponseData_Config GetConfig_Post(RequestData_Config requestData)
|
||||
{
|
||||
ResponseData_Config responseData = new ResponseData_Config();
|
||||
responseData.Config.Environment = SaxApplication_Api.AppInstance?.EnvironmentName;
|
||||
responseData.Config.Instance = SaxApplication_Api.AppInstance?.InstanceType.ToString();
|
||||
responseData.Config.Version = Sax.Version.GetFullVersion();
|
||||
if (DebugMode)
|
||||
{
|
||||
// Just for testing - do not expose in production.
|
||||
responseData.Config.Host = SaxSystem.ComputerName;
|
||||
responseData.Config.ConfigLogFolder = SaxApplication_Api.AppInstance?.AppConfig.Logging.RootFolder;
|
||||
responseData.Config.LogFolder = SaLogger.LogFolder;
|
||||
responseData.Config.EmailContext = SaxApplication_Api.AppInstance?.EmailConfig.Context;
|
||||
}
|
||||
return responseData;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Proc.Excel;
|
||||
using Saxonite.Net.Core.Web.Base.Procs;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Procs;
|
||||
|
||||
namespace Saxonite.Web.Api.Procs
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SaxProcess_Api : SaxProcess_Web
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
public new class Config : SaxProcess_Web.Config
|
||||
{
|
||||
protected Config(SaxSessionContext sessionContext, DbUpdateInfo dbUpdateInfo) : base(sessionContext, dbUpdateInfo)
|
||||
{ }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SaxProcess_Api(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:52385",
|
||||
"sslPort": 44304
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"SaxoniteWebApi": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7048;http://localhost:5193",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<AssemblyName>Saxonite.Web</AssemblyName>
|
||||
<RootNamespace>Saxonite.Web</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Api\Base\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\Common-VS\Workspace\SacsCoreWeb\SacsCoreWeb.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\Common-VS\Workspace\SacsStandardBase\SacsStandardBase.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\Common-VS\Workspace\SacsStandardDbas\SacsStandardDbas.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\Common-VS\Workspace\SacsStandardProc\SacsStandardProc.csproj" />
|
||||
<ProjectReference Include="..\SaxoniteCoreWeb\SaxoniteCoreWeb.csproj" />
|
||||
<ProjectReference Include="..\SaxoniteStandardBase\SaxoniteStandardBase.csproj" />
|
||||
<ProjectReference Include="..\SaxoniteStandardDbas\SaxoniteStandardDbas.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user