1.2.11.5
This commit is contained in:
@@ -61,7 +61,7 @@ namespace Saxonite.Web.Api.App
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error(GetType().Name + ".CTR " + ExceptionUtil.GetErrorStateMessage(exc));
|
||||
SaLogger.Error($"GetType().Name.CTR {ExceptionUtil.GetErrorStateMessage(exc)}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -137,6 +137,7 @@ namespace Saxonite.Web.Api.App
|
||||
//-------------------------------------------------------------------
|
||||
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; };
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Saxonite.Net.Core.Web.Base.Consoles;
|
||||
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;
|
||||
@@ -23,9 +25,10 @@ namespace Saxonite.Web.Api.Consoles
|
||||
if (disposing)
|
||||
{
|
||||
// Clear process consoles.
|
||||
foreach (SaxProcessConsole_Api processConsole in processConsoles.Values)
|
||||
foreach (SaxProcessConsole_Api? processConsole in processConsoles.Values)
|
||||
{
|
||||
processConsole.Dispose();
|
||||
if (processConsole != null)
|
||||
processConsole.Dispose();
|
||||
}
|
||||
processConsoles.Clear();
|
||||
}
|
||||
@@ -51,11 +54,11 @@ namespace Saxonite.Web.Api.Consoles
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Process console.
|
||||
private Dictionary<ushort, SaxProcessConsole_Api> processConsoles { get; } = new Dictionary<ushort, SaxProcessConsole_Api>();
|
||||
private Dictionary<ushort, SaxProcessConsole_Api?> processConsoles { get; } = new Dictionary<ushort, SaxProcessConsole_Api?>();
|
||||
public SaxProcessConsole GetProcessConsole(SaxSessionContext sessionContext)
|
||||
{
|
||||
if (sessionContext == null) throw new NotSupportedException(GetType().Name + ".GetProcessConsole Session Context must be specified");
|
||||
SaxProcessConsole_Api processConsole = processConsoles.GetValueOrDefault(sessionContext.Index, null);
|
||||
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);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
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;
|
||||
@@ -55,14 +56,14 @@ namespace Saxonite.Web.Api.Consoles
|
||||
// Processes.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
public SaxProcess_Api GetProcess(ProcessType processType)
|
||||
public SaxProcess_Api? GetProcess(ProcessType processType)
|
||||
{
|
||||
return processes.GetValueOrDefault(processType, null)?.Process;
|
||||
return DictionaryUtil.GetValue<ProcessType, ProcessData>(processes,processType, null)?.Process;
|
||||
}
|
||||
|
||||
public bool IsProcessing(ProcessType processType)
|
||||
{
|
||||
SaxProcess_Api process = GetProcess(processType);
|
||||
SaxProcess_Api? process = GetProcess(processType);
|
||||
if (process != null)
|
||||
if (process.Processing) return true;
|
||||
return false;
|
||||
@@ -76,7 +77,7 @@ namespace Saxonite.Web.Api.Consoles
|
||||
/// <exception cref="InProgressException"></exception>
|
||||
public bool ClearProcess(ProcessType processType)
|
||||
{
|
||||
SaxProcess_Api process = GetProcess(processType);
|
||||
SaxProcess_Api? process = GetProcess(processType);
|
||||
if (process != null)
|
||||
{
|
||||
if (process.Processing)
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
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; }
|
||||
}
|
||||
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; }
|
||||
}
|
||||
public class ResponseData_UsgaProvinces : ApiResponse_Data
|
||||
{
|
||||
public class UsgaProvincesData
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
public String? Code { get; set; }
|
||||
public String? Name { get; set; }
|
||||
}
|
||||
public List<UsgaProvincesData> UsgaProvinces { get; } = new List<UsgaProvincesData>();
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("[controller]/UsgaProvinces")]
|
||||
public ResponseData_UsgaProvinces GetUsgaProvinces_Post(RequestData_UsgaProvinces requestData)
|
||||
{
|
||||
ResponseData_UsgaProvinces responseData = new ResponseData_UsgaProvinces();
|
||||
|
||||
SysId countryId = StringUtil.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.UsgaProvincesData provinceData = new ResponseData_UsgaProvinces.UsgaProvincesData();
|
||||
provinceData.Id = SysId.ToLong(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;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
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 : ControllerBase
|
||||
public class SwapiControllerBase : SaxController_Base
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
@@ -130,7 +133,7 @@ namespace Saxonite.Web.Api.Controllers
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SwapiControllerBase()
|
||||
protected SwapiControllerBase() : base(null)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
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
|
||||
@@ -15,7 +17,7 @@ namespace Saxonite.Web.Api.Controllers
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Start session.
|
||||
// Version.
|
||||
|
||||
public class RequestData_Version
|
||||
{
|
||||
@@ -39,6 +41,41 @@ namespace Saxonite.Web.Api.Controllers
|
||||
return responseData;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Config.
|
||||
|
||||
public class RequestData_Config
|
||||
{
|
||||
}
|
||||
public class ResponseData_Config : ApiResponse_Data
|
||||
{
|
||||
public class ConfigData
|
||||
{
|
||||
public String? Version { get; set; }
|
||||
public String? Environment { 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.Version = Sax.Version.GetFullVersion();
|
||||
responseData.Config.Environment = SaxApplication_Api.AppInstance?.EnvironmentName;
|
||||
responseData.Config.LogFolder = SaLogger.LogFolder;
|
||||
responseData.Config.EmailContext = SaxApplication_Api.AppInstance?.EmailConfig.Context;
|
||||
return responseData;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
@@ -14,7 +14,11 @@ using System.Text.Json.Serialization;
|
||||
});
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user