BasicPlugin

This Plugin implements the most common functions for handling processes, parameters, etc.

The BasicPlugin main actions, conditions, rules and API

Table of contents

  1. Installation and setting
  2. Cases
    1. SendEmail
    2. HTTPRequest
    3. Predefined actors
    4. Update document state
    5. Parallel approval without branches

Installation and setting

Table of contents

Add the following namespaces to the section of the using statements:

using OptimaJet.Workflow.Plugins;

Create a plugin object and specify the necessary settings:

var basicPlugin = new BasicPlugin();

// Here are your settings

// basicPlugin.Setting_Mailserver = "smtp.yourserver.com";
// basicPlugin.Setting_MailserverPort = 25;
// basicPlugin.Setting_MailserverFrom = "from@yourserver.com";
// basicPlugin.Setting_MailserverLogin = "login@yourserver.com";
// basicPlugin.Setting_MailserverPassword = "password";
// basicPlugin.Setting_MailserverSsl = true;
// basicPlugin.Setting_MailserverSsl = true;
// basicPlugin.RequestHeaders.add("MyHeader", "headerValue");
// basicPlugin.UsersInRoleAsync += MyUsersInRoleAsync;
// basicPlugin.CheckPredefinedActorAsync += CheckMyPredefinedActorAsync;
// basicPlugin.GetPredefinedIdentitiesAsync += GetMyPredefinedIdentitiesAsync;
// basicPlugin.ApproversInStageAsync += MyApproversInStageAsync;
// basicPlugin.UpdateDocumentStateAsync += UpdateMyDocumentStateAsync;

Connect the plugin to WorkflowRuntime:

var runtime = new WorkflowRuntime()...

runtime.WithPlugin(approvalPlugin);

Read about Settings.

Cases

SendEmail

Table of contents

To send an email, use action: SendEmail.

You should specify the server and the port associated with your email address account in the parameters or settings.

For example, the following options are available:

Gmail: Server: smtp.gmail.com; Port: 587

iCloud: Server: smtp.mail.me.com; Port: 587

Yahoo: Server: smtp.mail.yahoo.com; Port: 465

HTTPRequest

Table of contents

To send an HTTP request, use action: HTTPRequest.

PredefinedActors

Table of contents

Actors are created on the server with the WithActor/WithActors methods. Those actors have rule = Predefined.

By way of the CheckAsync method, the delegate CheckPredefinedActorAsync are used.

By way of the GetIdentitiesAsync method, the delegate GetPredefinedIdentitiesAsync are used.

To get a list of the predefined actors, the appropriate flag should be enabled in the actors panel in the designer.

CheckPredefinedActorAsync

A delegate, your function should return: true - if the user meets the specified rule; false - if the user doesn't meet the specified rule.

Handler syntax:

async Task<bool> CheckMyPredefinedActorAsync(ProcessInstance processInstance, WorkflowRuntime runtime, string parameter, string identityId)
{

  //Example: check if the user with the specified Id is a manager
  if (parameter == "Manager")
  {
      if (identityId == myManagerId)
          return true;
      else
          return false;
  }

  return false;
}

GetPredefinedIdentitiesAsync

A delegate, your function should return all of the users with the specified rule. Using this function, your can impelement the rules both for the secutiry system and for the given document. For example: document author, document manager, controller.

Handler syntax:

async Task<IEnumerable<string>> GetMyPredefinedIdentitiesAsync(ProcessInstance processInstance, WorkflowRuntime runtime, string parameter)
{
  //Example: return id for all of the users who are managers
  if (parameter == "Manager")
  {
      return new List<string>() {myManagerId1, myManagerId2};
  }

  return new List<string>();
}

WithActor

basicPlugin.WithActor("Manager");

WithActors

basicPlugin.WithActors(new List<string>() {"Manager", "Director"});

Update document state

Table of contents

To update the document state, use the delegate UpdateDocumentStateAsync in the settings.

UpdateDocumentStateAsync

Table of contents

The delegate that fires the ProcessStatusChanged event in WorkflowRuntime.

Handler syntax:

public static async Task UpdateMyDocumentStateAsync(ProcessInstance processInstance, string stateName, string  localizedStateName)
{
  //here you can update your document state
  myDoc.State = stateName;
}

Parallel approval without branches

Table of contents

Implements a parallel approval when a document state can be approved by several users from the list, and all the users from this list must approve a document in this state.

1

1, 4: Fill approvers

Activity with action from the list:

The lists are filled with users or roles, whose approval is necessary at the current stage.

2, 5: Approve

Transitions with Command trigger.

You can limit the list of users, able to run the command, using the Restrictions.

Adding restrictions with the parameters Actor: Approver; Type: Allow

2

Read about manage roles

3, 6: Is approved

Transitions with condition from the list:

The transition is performed after the specified users or roles have completed the approval.

7: Approval finished

Activity to be executed after the approval.

Table of contents

Top