Persistence Provider Initialization

First, it is necessary to determine whether you need an SQL or NoSQL database and download the necessary provider from the downloads page or via NuGet. You will find provider's source code in the downloaded archive or in our GitHub repository.

If you use an RDMS such as MS SQL Server, PostgreSQL, Oracle or MySql you have to run the CreatePersistenceObjects.sql script, that creates the following tables in the database:

  • WorkflowProcessScheme — all process schemes are kept here. The Scheme column contains a serialized XML scheme, the SchemeCode column has the scheme name (code). DefiningParameters and DefiningParametersHash columns contain the parameters passed to the scheme generator (feel free to explore our the Scheme Generation section to learn how to use them). IsObsolete indicates the scheme's relevance: if it's relevant, new processes will rest on it (read the Schemes Update section). Other columns contain data for creating subprocesses (read about parallel branches in the Parallel Branches section);
  • WorkflowProcessInstance — contains process data, such as the current activity and state, previous activities, etc. There is also IDs of parent and root processes here;
  • WorkflowProcessInstancePersistence — this table keeps process parameters. Parameter values are serialized in JSON and shown in the Value column;
  • WorkflowProcessTransitionHistory — contains information about successful process transitions.The table is used for process tracking;
  • WorkflowProcessInstanceStatus — the Status field indicates current process status: 0 - Initialized, 1 - Running, 2 - Idled, 3 - Finalized;
  • WorkflowProcessTimer — contains trigger actuation times for different processes;
  • WorkflowGlobalParameter — global Code Actions and subprocess trees are stored here;
  • WorkflowScheme — this table is used by the scheme generator by default. The scheme from designer is saved here; if WorkflowRuntime can't find a relevant scheme in the WorkflowProcessScheme table, it grabs the scheme from here;;
  • WorkflowInbox — doesn't belong to Workflow Engine but is used in our examples as the inbox folder.

If you use Oracle, the tables will have different names:

  • WORKFLOWPROCESSTRANSITIONH instead of WorkflowProcessTransitionHistory;
  • WORKFLOWPROCESSINSTANCEP instead of WorkflowProcessInstancePersistence;
  • WORKFLOWPROCESSINSTANCES instead of WorkflowProcessInstanceStatus;

With MongoDB, RavenDB or GridGain, all data are kept in structurally similar objects. In Redis the data are stored in key-value storage;

Take a look at the example of persistence provider initialization that you will need in the next section. The code for relational databaes is quite similar.

  • for MS SQL
// Get a DB connection string
var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; 
// Initiate a provider 
var dbProvider = new MSSQLProvider(connectionString);
  • for PostgreSQL

    // Get a DB connection string
    var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; 
    // Initiate a provider 
    var dbProvider = new PostgreSQLProvider(connectionString);
  • for Oracle

    // Get a DB connection string
    var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; 
    // Initiate a provider 
    var dbProvider = new OracleProvider(connectionString);
  • for MySQL
    // Get a DB connection string
    var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; 
    // Create a provider 
    var dbProvider = new MySQLProvider(connectionString);

For NoSQL databases, the code will be different.

  • for MongoDB

    // Get DB's URL and name from config
    var url = ConfigurationManager.AppSettings["Url"];
    var databaseName = ConfigurationManager.AppSettings["DatabaseName"];
    // Create a MongoDatabase object
    var mongoDatabase = new MongoClient(url).GetServer().GetDatabase(databaseName);
    // Create a provider 
    var dbProvider = new MongoDBProvider(mongoDatabase);
  • for Redis

    // Get Redis server URL from config
    var url = ConfigurationManager.AppSettings["Url"];
    // Create a ConnectionMultiplexer object
    var multiplexer = ConnectionMultiplexer.Connect(url);
    // Create a provider 
    var dbProvider = new RedisProvider(multiplexer);
  • for RavenDb

    // Get DB's URL and name from config
    var url = ConfigurationManager.AppSettings["Url"];
    var databaseName = ConfigurationManager.AppSettings["DatabaseName"];
    //Создаем объект DocumentStore
    var documentStore = new DocumentStore()
    {
        Url = url,
        DefaultDatabase = databaseName
    };
    // Create a provider 
    var dbProvider = new RavenDBProvider(documentStore);
  • for GridGain
    // Create an Ignite object
    Ignition.ClientMode = true;
    var store = Ignition.TryGetIgnite() ?? Ignition.Start(IgniteProvider.GetDefaultIgniteConfiguration());
    // Create a provider 
    var dbProvider = new IgniteProvider(store);

The next section outlines WorkflowRuntime object initialization and creation.

Top