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>
114 lines
3.2 KiB
C#
114 lines
3.2 KiB
C#
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.
|
|
//-------------------------------------------------------------------
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|