Files
jube-fork/Jube.Migrations/Branches/GitHubIssueBranch108.cs
richard-churchman bc66cd80e3 Expanded Inline Script Invocation Coverage and Implemented Activation Rule Chaining
* Updated documentation to include Inline Script events and Activation Rule Chaining concepts.
* Included Activation Rules in Activation Completions to make them available.
* Modified activation rule signatures to include match keys for facilitation.
* Updated Gateway Rule Priority to support double type, including changes in migrations and POCOs.
* Updated tree to ensure entities are listed by Priority when Priority exists in the entity.
* Included Priority in Activation Rule user interface, POCOs, and migrations; ensured invocation and synchronization preserve order for evaluation sequence to support rule chaining.
* Updated completions to support Activation Rules and Activation Rule chaining.
* Improved delegate compilation to avoid reflection during invocation; delegates are now compiled during synchronization, eliminating reflection usage during invocation for real-time processing.
* Created event attributes to direct matching of Inline Scripts, including matching properties given event context (to restrict to a single Activation Rule, for example).
* Separated ExecuteAsync attributes from property attributes in the solution for better organization.
* Mapped Inline Script property and method attributes during synchronization to avoid reflection during invocation.
* Removed parallel for loops and locks in Activation Rule processing to support chaining.
* Modified reflection wrapper for Inline Scripts to eliminate reflection by compiling delegates during synchronization.
* Minor refactoring and variable renaming.
* Updated Inline Script interface to mandate bool return value in ExecuteAsync method.
* Updated rule parser to support evaluation of exists activation rule match for chaining support.
* Updated sandbox code for new Inline Script format.
* Corrected some spelling in documentation.
2026-02-12 12:51:52 +02:00

97 lines
4.0 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.Migrations.Branches
{
using FluentMigrator;
[Migration(20260209125900)]
public class GitHubIssueBranch108 : Migration
{
public override void Up()
{
AddPriorityToEntityAnalysisModelActivationRule();
ChangeDataTypeForEntityAnalysisModelGatewayRulePriority();
UpdateVbInlineScript();
}
private void UpdateVbInlineScript()
{
const string code = """
Imports System
Imports System.Net.Http
Imports System.Threading
Imports System.Threading.Tasks
Imports Newtonsoft.Json.Linq
Imports Jube.Engine.Attributes
Imports Jube.Engine.Attributes.Events
Imports Jube.Engine.Attributes.Properties
Imports Jube.Engine.EntityAnalysisModelInvoke.Context
Imports Jube.Engine.Interfaces
Public Class IssueOTP
Implements IInlineScript
Public Property OTP As String
<PayloadEvent>
Public Async Function ExecuteAsync(context As Context) As Task(Of Boolean) Implements IInlineScript.ExecuteAsync
OTP = RandomDigits(6)
Return True
End Function
Private Function RandomDigits(ByVal length As Integer) As String
Dim random = New Random()
Dim s As String = String.Empty
For i As Integer = 0 To length - 1
s = String.Concat(s, random.[Next](10).ToString())
Next
Return s
End Function
End Class
""";
Update.Table("EntityAnalysisInlineScript").Set(new
{
Code = code
}).Where(new
{
Id = 1
});
}
private void AddPriorityToEntityAnalysisModelActivationRule()
{
Alter.Table("EntityAnalysisModelActivationRule").AddColumn("Priority").AsDouble().Nullable();
Alter.Table("EntityAnalysisModelActivationRuleVersion").AddColumn("Priority").AsDouble().Nullable();
Update.Table("EntityAnalysisModelActivationRule").Set(new {Priority = 0}).AllRows();
Update.Table("EntityAnalysisModelActivationRuleVersion").Set(new {Priority = 0}).AllRows();
}
private void ChangeDataTypeForEntityAnalysisModelGatewayRulePriority()
{
Alter.Table("EntityAnalysisModelGatewayRule").AlterColumn("Priority").AsDouble();
Alter.Table("EntityAnalysisModelGatewayRuleVersion").AlterColumn("Priority").AsDouble();
}
public override void Down()
{
}
}
}