mirror of
https://github.com/hanzoai/jube-fork.git
synced 2026-10-30 18:33:33 +00:00
* Pushed Case Workflow Display HTML rendering logic down into a controller for improved security and consistent tokenisation of the Jube token format against context. Included a migration to update the default demo entry to use proper tokenisation. Updated the repository to support fetching CaseWorkflowDisplay with appropriate security. * Implemented improved tokenisation of the EntityAnalysisModelInstanceEntryPayload model via a common extension method on EntityAnalysisModelInstanceEntryPayload, used consistently across the system for serialisation and storage. * Included a migration to update the tokenisation format for full CaseWorkflowDisplay support. * Fixed an issue where CaseWorkflowFilter was incorrectly filtering on CaseWorkflowStatus.Guid instead of CaseWorkflowStatus.Name, causing the GUID to be returned rather than the display name on the template/demo model. (The remainder was fixed in GitHub issue #6.) Included a migration with a corrective SQL statement. * Fixed an issue where tokens were not being stored alongside CaseWorkflowFilter definition configuration. It now behaves identically to CaseSearch. Note: migrating missing tokens is not feasible as it requires JS-side parsing via JQueryBuilder. * Reduced the size of the CaseWorkflowForm invocation to include only the required fields given the new POST body context being rendered server side. Improved API serialisation by using a dictionary for form payload keys and values. * Consolidated JSON serialisation settings into DI and updated usages throughout. * Updated EntityAnalysisModelInstanceEntryPayload write serialisers to handle deserialisation, which is required to support tokenisation of new Case Automation POST bodies. * Created an extension method on the EntityAnalysisModelInstanceEntryPayload to centralise tokenisation of strings across Activation and Case Automation on a consistent basis. Simplified Case Notification and Case HTTP dispatch by removing tokenisation logic from those classes. * Removed a redundant field from the CaseWorkflowFormEntry POCO (database left unchanged for now). * Fixed a bug in Case session SQL rebuilding where the rebuild date was not being correctly checked for null or default value, which caused a failure in the last migration. * Made minor modifications to the Create Case process and method signature to skip serialisation when the payload object required for tokenisation is already available on the thread (e.g. during synchronous reprocessing). * Updated Case Workflow Macro processing to fetch the archive payload for the case from the database, improving security of that invocation endpoint. * Removed what appeared to be a duplicate EntityAnalysisModelInstanceEntryPayload model introduced during refactoring. * Fixed a but in Case Worfkflow Display Role assigment owing to volatile Guid in its update.
167 lines
9.8 KiB
C#
167 lines
9.8 KiB
C#
/* Copyright (C) 2022-present Jube Holdings Limited.
|
|
*
|
|
* This file is part of Jube™ software.
|
|
*
|
|
* Jube™ is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License
|
|
* as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
* Jube™ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU Affero General Public License along with Jube™. If not,
|
|
* see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
namespace Jube.Engine.EntityAnalysisModelInvoke.Context.Extensions.ActivationRules
|
|
{
|
|
using System;
|
|
using EntityAnalysisModelManager.EntityAnalysisModel.Models.Models;
|
|
using Models.Payload.EntityAnalysisModelInstanceEntryPayload;
|
|
|
|
public static class ActivationRuleResponseElevationExtensions
|
|
{
|
|
public static void ProcessResponseElevation(this Context context,
|
|
EntityAnalysisModelActivationRule evaluateActivationRule, ref double responseElevationHighWaterMark,
|
|
bool suppressed)
|
|
{
|
|
if (context.Log.IsInfoEnabled)
|
|
{
|
|
context.Log.Info(
|
|
$"Entity Invoke: GUID {context.EntityAnalysisModelInstanceEntryPayload.EntityAnalysisModelInstanceEntryGuid} " +
|
|
$"and model {context.EntityAnalysisModel.Instance.Id} will begin processing of response elevation for activation " +
|
|
$"rule {evaluateActivationRule.Id}. " +
|
|
$"Current high water mark on response elevation is {responseElevationHighWaterMark}.");
|
|
}
|
|
|
|
if (suppressed || !evaluateActivationRule.EnableResponseElevation)
|
|
{
|
|
if (context.Log.IsInfoEnabled)
|
|
{
|
|
context.Log.Info(
|
|
$"Entity Invoke: GUID {context.EntityAnalysisModelInstanceEntryPayload.EntityAnalysisModelInstanceEntryGuid} and model {context.EntityAnalysisModel.Instance.Id} response elevation for activation rule {evaluateActivationRule.Id} is suppressed or disabled and will not be evaluated.");
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
if (responseElevationHighWaterMark > evaluateActivationRule.ResponseElevation)
|
|
{
|
|
if (context.Log.IsInfoEnabled)
|
|
{
|
|
context.Log.Info(
|
|
$"Entity Invoke: GUID {context.EntityAnalysisModelInstanceEntryPayload.EntityAnalysisModelInstanceEntryGuid} and model {context.EntityAnalysisModel.Instance.Id} response elevation for activation rule {evaluateActivationRule.Id} is less than the current largest Response Elevation {context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation} which is {responseElevationHighWaterMark} and will not be processed.");
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
responseElevationHighWaterMark = evaluateActivationRule.ResponseElevation;
|
|
|
|
if (context.Log.IsInfoEnabled)
|
|
{
|
|
context.Log.Info(
|
|
$"Entity Invoke: GUID {context.EntityAnalysisModelInstanceEntryPayload.EntityAnalysisModelInstanceEntryGuid} and model {context.EntityAnalysisModel.Instance.Id} response elevation for activation rule {evaluateActivationRule.Id} is the current largest Response Elevation {context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation} but is less than the new value of {responseElevationHighWaterMark} so it will be elevated. Will be tested against certain other model constraints.");
|
|
}
|
|
|
|
if (responseElevationHighWaterMark > context.EntityAnalysisModel.Counters.MaxResponseElevation)
|
|
{
|
|
context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation.Value =
|
|
context.EntityAnalysisModel.Counters.MaxResponseElevation;
|
|
|
|
context.EntityAnalysisModel.Counters.ResponseElevationValueLimitCounter += 1;
|
|
|
|
if (context.Log.IsInfoEnabled)
|
|
{
|
|
context.Log.Info(
|
|
$"Entity Invoke: GUID {context.EntityAnalysisModelInstanceEntryPayload.EntityAnalysisModelInstanceEntryGuid} and model {context.EntityAnalysisModel.Instance.Id} the response elevation exceeds the maximum allowed in the model of {context.EntityAnalysisModel.Counters.MaxResponseElevation}, so has been truncated to {context.EntityAnalysisModel.Counters.MaxResponseElevation} and the Response Elevation Value Limit Counter incremented.");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (responseElevationHighWaterMark > context.EntityAnalysisModelInstanceEntryPayload.ResponseElevationLimit)
|
|
{
|
|
context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation.Value =
|
|
context.EntityAnalysisModelInstanceEntryPayload.ResponseElevationLimit;
|
|
|
|
context.EntityAnalysisModel.Counters.ResponseElevationValueGatewayLimitCounter += 1;
|
|
|
|
if (context.Log.IsInfoEnabled)
|
|
{
|
|
context.Log.Info(
|
|
$"Entity Invoke: GUID {context.EntityAnalysisModelInstanceEntryPayload.EntityAnalysisModelInstanceEntryGuid} and model {context.EntityAnalysisModel.Instance.Id} the response elevation exceeds the maximum allowed in the gateway rule of {context.EntityAnalysisModelInstanceEntryPayload.ResponseElevationLimit}, so has been truncated and the Response Elevation Value Gateway Limit counter incremented.");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation.Value =
|
|
responseElevationHighWaterMark;
|
|
|
|
if (context.Log.IsInfoEnabled)
|
|
{
|
|
context.Log.Info(
|
|
$"Entity Invoke: GUID {context.EntityAnalysisModelInstanceEntryPayload.EntityAnalysisModelInstanceEntryGuid} and model {context.EntityAnalysisModel.Instance.Id} the response elevation has tested the limits and the response elevation is being carried forward as {responseElevationHighWaterMark}.");
|
|
}
|
|
}
|
|
}
|
|
|
|
if (context.Log.IsInfoEnabled)
|
|
{
|
|
context.Log.Info(
|
|
$"Entity Invoke: GUID {context.EntityAnalysisModelInstanceEntryPayload.EntityAnalysisModelInstanceEntryGuid} and model {context.EntityAnalysisModel.Instance.Id} response elevation for activation rule {evaluateActivationRule.Id} is being tested against the current limits and cap to zero if exceeded.");
|
|
}
|
|
|
|
context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation.Content =
|
|
evaluateActivationRule.ResponseElevationContent;
|
|
|
|
context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation.Redirect =
|
|
evaluateActivationRule.ResponseElevationRedirect;
|
|
|
|
context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation.BackColor =
|
|
evaluateActivationRule.ResponseElevationBackColor;
|
|
|
|
context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation.ForeColor =
|
|
evaluateActivationRule.ResponseElevationForeColor;
|
|
|
|
context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation.Content =
|
|
evaluateActivationRule.ResponseElevationContent;
|
|
|
|
context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation.Redirect =
|
|
evaluateActivationRule.ResponseElevationRedirect;
|
|
|
|
context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation.ForeColor =
|
|
evaluateActivationRule.ResponseElevationForeColor;
|
|
|
|
context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation.BackColor =
|
|
evaluateActivationRule.ResponseElevationBackColor;
|
|
|
|
if (context.Log.IsInfoEnabled)
|
|
{
|
|
context.Log.Info(
|
|
$"Entity Invoke: GUID {context.EntityAnalysisModelInstanceEntryPayload.EntityAnalysisModelInstanceEntryGuid} and model {context.EntityAnalysisModel.Instance.Id} response elevation for activation rule {evaluateActivationRule.Id} updated the response elevation to {context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation}.");
|
|
}
|
|
|
|
if (context.EntityAnalysisModel.Flags.EnableResponseElevationLimit)
|
|
{
|
|
context.EntityAnalysisModel.ConcurrentQueues.BillingResponseElevationBalanceEntries.Enqueue(new ResponseElevation
|
|
{
|
|
CreatedDate = DateTime.Now,
|
|
Value = context.EntityAnalysisModelInstanceEntryPayload.ResponseElevation.Value
|
|
});
|
|
|
|
if (context.Log.IsInfoEnabled)
|
|
{
|
|
context.Log.Info(
|
|
$"Entity Invoke: GUID {context.EntityAnalysisModelInstanceEntryPayload.EntityAnalysisModelInstanceEntryGuid} and model {context.EntityAnalysisModel.Instance.Id} has noted the response elevation date on the counter queue. There are {context.EntityAnalysisModel.ConcurrentQueues.ActivationWatcherCountJournal.Count} in queue.");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (context.Log.IsInfoEnabled)
|
|
{
|
|
context.Log.Info(
|
|
$"Entity Invoke: GUID {context.EntityAnalysisModelInstanceEntryPayload.EntityAnalysisModelInstanceEntryGuid} and model {context.EntityAnalysisModel.Instance.Id} does not have response elevation limit enabled, so has not noted the response elevation date.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|