WorkflowEngine v4.1 Release Notes

    • ๐Ÿ‘Œ Support for multi-tenant applications.

      • TenantId has been added to processes. When creating a process, one can specify TenantId and use its value when working with the process. TenantId is stored in the WorkflowProcessInstance table in the TenantId column. Passing TenantId to a process:
      var createInstanceParams = new CreateInstanceParams(schemeCode, processId) { TenantId = "tenantId" };
      workflowRuntime.CreateInstance(createInstanceParams);
      

      After creating a process with TenantId indicated, the access to it inside Actions, Conditions and Rules can be arranged as follows.

      string tenantId = processInstance.TenantId;
      
      • For schemes one can specify tags, and then, search for schemes where these tags are indicated. Tags are set in the scheme designer by clicking on the Process Info button. Tags are stored in the WorkflowScheme table in the Tags column. A list of codes for the schemes where the corresponding tags are indicated can be received using the following code:
       List<string> schemeCodes =  workflowRuntime.Builder.SearchSchemesByTags(new List<string> {"Tag1","Tag2"});
      

    The search is performed using an OR expression.

    • ๐Ÿ”Œ Plugin System and the Basic Plugin. The plugin for WorkflowEngine.NET is a class that is necessary to implement the IWorkflowPlugin interface, and optional to implement the IWorkflowActionProvider, IWorkflowRuleProvider, IDesignerParameterFormatProvider, IDesignerAutocompleteProvider interfaces (in any combination). In fact, the plugin is a class that adds functionality to be used when creating process schemes. The plugin connects to WorkflowEngine.NET when configuring WorkflowRuntime.
      WorkflowRuntime workflowRuntime = workflowRuntime.WithPlugin(new BasicPlugin());
    

    Simultaneously, any number of plugins can be connected to WorkflowEngine.NET. The Basic Plugin OptimaJet.Workflow.Core.Plugins.BasicPlugin has been added to the WorkflowEngine.NET package; it implements the following basic functions:

    • Actions:
      • SendEmail - sending email.
      • CreateProcess - creating a process from a process.
      • HTTPRequest - sending a request to a third-party web service.
      • SetParameter - setting a process parameter.
    • Conditions:
      • IsProcessFinalized - checking the finalization of the current process or a process with the Id specified.
      • CheckAllSubprocessesCompleted - checking the finalization (completion) of all the subprocesses.
      • CheckParameter - checking if the parameter is consistent to the given value (so far, only strings are supported).
      • IsArrovedByUsers - checking if the specified process was processed by all of the listed users.
      • IsArrovedByRoles - checking if the specified process was processed by all of the listed roles.
      • CheckHTTPRequest - conditional transition based on the result of a request to a third-party web service.
    • Authorization Rules (Security):

      • CheckRole - checking access to the command for a specific role. Warning: to perform operations related to the roles checking, BasicPlugin must have the delegate handler basicPlugin.UsersInRoleAsync installed.
      • Now, implicit (that is, not explicitly specified in the scheme) parameters passed when creating a process, executing a command, or setting a new state to a process can be persistent.
    • When creating a process, use the following code:

      var createInstanceParams = new CreateInstanceParams(schemeCode, processId)
        .AddPersistentParameter("Parameter1Name", 100)
        .AddPersistentParameter("ParameterName2", parameterValue);
      workflowRuntime.CreateInstance(createInstanceParams);
      
    • When passing parameters with a command, use the following code:

      WorkflowCommand command = ...
      command.SetParameter("ParameterName", parameterValue, persist: true);
      workflowRuntime.ExecuteCommand(command, ... );
      
    • When passing a parameter with a command, use the following code:

      var setStateParams = new SetStateParams(processId,"StateName")
        .AddPersistentParameter("Parameter1Name", 100)
        .AddPersistentParameter("ParameterName2", parameterValue);
      workflowRuntime.SetState(setStateParams);
      
      • ๐Ÿ‘Œ Support for dynamic parameters has been added. To perform the task, the DynamicParameter class, which can be cast into dynamic, has been developed. For example:

    Creating a parameter:

      var dynamicParameter = new
      {
        Name = "Dynamic",
        ObjectValue = new
        {
            Name = "Object",
            Value = 100
        },
        ListValue = new List<object> {
            new {Id = 1, Name = "ObjectInList1"},
            new {Id = 2, Name = "ObjectInList2"}
        }
      }
      processInstance.SetParameter("Dynamic", dynamicParameter, ParameterPurpose.Persistence);
    

    Getting a parameter:

      var dynamicParameter = processInstance.GetParameter<DynamicParameter>("Dynamic") as dynamic;
      string name = dynamicParameter.Name;
      string objectValueName = dynamicParameter.ObjectValue.Name;
      string firstItemName = (dynamicParameter.ListValue as List<dynamic>).First().Name;
    
    • The following aggregating providers are available: AggregatingActionProvider, AggregatingRuleProvider, AggregatingDesignerAutocompleteProvider, AggregatingDesignerParameterFormatProvider. An aggregating provider is a provider to which other providers can be added.
    • ๐Ÿ”’ IWorkflowRuleProvider - supports asynchronous authorization (security) rules.
    • The scheme code is passed to all methods of all providers. Here are these methods
      • IWorkflowActionProvider.GetActions
      • IWorkflowActionProvider.GetConditions
      • IWorkflowActionProvider.IsActionAsync
      • IWorkflowActionProvider.IsConditionAsync
      • IWorkflowRuleProvider.GetRules
      • IWorkflowRuleProvider.IsCheckAsync
      • IWorkflowRuleProvider.IsGetIdentitiesAsync
      • IDesignerParameterFormatProvider.GetFormat
      • IDesignerAutocompleteProvider.GetAutocompleteSuggestions

    string schemeCode has been added as the last parameter to all these methods.

    • A unified and correct error output when accessing the Designer API has been added.
    • Intellisense has been added in the Code Actions (code in schemes) editor.
    • A new type TextArea has been added to the forms where parameter (for Actions, Conditions or rules) values are edited.
    • In any of the persistence providers, one can optionally turn off the history of transitions and set the history of subprocesses to be written in the history of the main process. For example:
      var provider = new MSSQLProvider(connectionString, writeToHistory:false);
      var provider = new MSSQLProvider(connectionString, writeSubProcessToRoot:true);
    

    โฌ†๏ธ The following additional actions must be taken to upgrade to Workflow Engine 4.1:

    • Run the SQL script update_2_7_to_2_8.sql for all relative databases.
    • โšก๏ธ Update all files related to the Designer. They are available here.
    • โšก๏ธ Update packages or dll to version 4.1.
    • If the IWorkflowActionProvider interface is implemented in your project, the last parameterstring schemeCode shall be added to the following methods:
      • IWorkflowActionProvider.GetActions
      • IWorkflowActionProvider.GetConditions
      • IWorkflowActionProvider.IsActionAsync
      • IWorkflowActionProvider.IsConditionAsync
    • If the IWorkflowRuleProvider interface is implemented in your project, the following methods shall be added to your provider:
      public Task<bool> CheckAsync(ProcessInstance processInstance, WorkflowRuntime runtime, string identityId, string ruleName,string parameter, CancellationToken token)
      {
          throw new NotImplementedException();
      }
    
      public Task<IEnumerable<string>> GetIdentitiesAsync(ProcessInstance processInstance, WorkflowRuntime runtime, string ruleName, string parameter, CancellationToken token)
      {
          throw new NotImplementedException();
      }
    
      public bool IsCheckAsync(string ruleName, string schemeCode)
      {
          return false;
      }
    
      public bool IsGetIdentitiesAsync(string ruleName, string schemeCode)
      {
          return false;
      }
    

    The last parameter string schemeCode shall be also added to the following method:

    • IWorkflowRuleProvider.GetRules

      • If the IDesignerParameterFormatProvider interface is implemented in your project, the last parameter string schemeCode shall be added to the following method:
    • IDesignerParameterFormatProvider.GetFormat

      • If the IDesignerAutocompleteProvider interface is implemented in your project, the last parameter string schemeCode shall be added to the following method:
    • IDesignerAutocompleteProvider.GetAutocompleteSuggestions

      • ๐Ÿ”€ IMPORTANT! Incorrect behavior was fixed when the subprocess was merged in the parent process via the set state of the parent process mechanism. Previously, the parent process parameters were OVERWRITTEN. Now, the parent process parameters won't be changed. Only new parameters from the subprocess will be written to the parent process automatically. The same way the merge via calculating conditions always works. If you consciously exploited this behavior, then the best way to get parameters from the subprocess is to use a property processInstance.MergedSubprocessParameters when merge occurs.
      • IMPORTANT! If in your project the Action Provider has changed (after the first initialization) using the method workflowRuntime.WithActionProvider(...) replace this code with the following call workflowRuntime.ClearActionProvider().WithActionProvider(...)
      • IMPORTANT! If in your project the Rule Provider has changed (after the first initialization) using the method workflowRuntime.WithRuleProvider(...) replace this code with the following call workflowRuntime.ClearRuleProvider().WithRuleProvider(...)
      • IMPORTANT! If in your project the Designer Autocomplete Provider has changed (after the first initialization) using the method workflowRuntime.WithDesignerAutocompleteProvider(...) replace this code with the following call workflowRuntime.ClearDesignerAutocompleteProvider().WithDesignerAutocompleteProvider(...)
      • IMPORTANT! If in your project the Designer Parameter Format Provider has changed (after the first initialization) using the method workflowRuntime.WithDesignerParameterFormatProvider(...) replace this code with the following call workflowRuntime.ClearDesignerParameterFormatProvider().WithDesignerParameterFormatProvider(...)
      • It is not necessary but suggested to change the Designer Controller the following way
      public ActionResult API()
      {
        ...
        var res = WorkflowInit.Runtime.DesignerAPI(pars, out bool hasError, filestream, true);
        var operation = pars["operation"].ToLower();
    
        if (operation == "downloadscheme" && !hasError)
          return File(Encoding.UTF8.GetBytes(res), "text/xml", "scheme.xml");
        else if (operation == "downloadschemebpmn" &&  !hasError)
          return File(UTF8Encoding.UTF8.GetBytes(res), "text/xml", "scheme.bpmn");
    
        return Content(res);
      }
    

    See complete controller code

      wfdesigner.create(schemecode);
    

    See complete view code