# Advanced Configuration

## File storage

### Overview <a href="#file-storage-overview" id="file-storage-overview"></a>

WorkflowGen stores files (such as attachments to a request) in a folder tree structure. By default these files are stored on the web server in the folder specified in the `ApplicationDataPath` parameter in the configuration file (`web.config`), e.g. `<add key="ApplicationDataPath" value="\\SERVER\SHARE" />`.

The default value is empty and thus will point to the physical directory `DRIVE:\Inetpub\wwwroot\wfgen\App_Data`. The default is to keep all the files on the web server.

You might need to move this storage folder location to a dedicated file server for the following reasons:

* High volume (large attachments, document archiving, high usage level)<br>
* Web Farm architecture implementation (see [Web Farm architecture](#web-farm-architecture))

Basic configuration allows you to easily move these files but with a low security level.

### Basic configuration

The following steps must be followed to configure your web server:

1. Create the storage folder on the file server `DRIVE:\FOLDER` (e.g. `D:\filepub`).<br>
2. Re-create the folder tree structure relative to the file storage location:
   * `DRIVE:\FOLDER\wfgen\App_Data`
   * `DRIVE:\FOLDER\wfgen\App_Data\Files\API`
   * `DRIVE:\FOLDER\wfgen\App_Data\Files\DataSet`
   * `DRIVE:\FOLDER\wfgen\App_Data\Files\EFormASPX`
   * `DRIVE:\FOLDER\wfgen\App_Data\Files\MergeForm`
   * `DRIVE:\FOLDER\wfgen\App_Data\Files\RemoteApproval`
   * `DRIVE:\FOLDER\wfgen\App_Data\Files\RestApiClient`
   * `DRIVE:\FOLDER\wfgen\App_Data\Files\XmlToDatabase`
   * `DRIVE:\FOLDER\wfgen\App_Data\Files\XmlTrans`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\auth`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\CancelRequest`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\CompleteAction`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\CopyData`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\Dir`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\Engine`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\GetFormData`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\GetProcessData`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\GetUsersFromDir`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\MergeForm`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\Notifications`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\Portal`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\RaiseException`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\RemoteApproval`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\RestApiClient`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\SendHttpPost`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\SendMessage`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\StartProcess`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\UpdateProcessData`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\XmlToDatabase`
   * `DRIVE:\FOLDER\wfgen\App_Data\LogFiles\XmlTrans` <br>
3. Copy the existing files and folders from their original locations to the new locations, which should still follow the same structure.<br>
4. Create a share on the folder `DRIVE:\FOLDER`. This folder should then be accessible by a `\SERVER\SHARE$` type UNC name.<br>
5. Give NTFS modify permissions on the share as well as all of its folders and sub-folders for all users of WorkflowGen.<br>
6. Edit the `ApplicationDataPath` parameter in `DRIVE:\Inetpub\wwwroot\wfgen\web.config` to `<add key="ApplicationDataPath" value="\\SERVER\SHARE$\wfgen\App_Data" />`. This is because WorkflowGen will use the specified path in `ApplicationDataPath` to store the `\Files`, `\LogFiles`, and `\Templates` folders.

## Database authentication

### Using Windows Authentication instead of SQL Server Authentication

You can set up your SQL Server connection to use Windows Authentication (SSPI) instead of SQL Server Authentication for the WorkflowGen back-end database and other external databases. This SQL authentication mode provides additional security, since no credentials are stored in the `web.config` file.

To configure Windows Authentication, use one of the following connection strings in the WorkflowGen `web.config` file, located in the `DRIVE:\Inetpub\wwwroot\wfgen` folder:

```
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI; 
```

**OR**

```
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
```

You'll also need to modify the WorkflowGen application pool identity for a service account. To do this:

1. In **IIS Manager**, right-click on the **WorkflowGen** application pool, then select **Advanced Settings**.<br>

2. In the **Process Model** section, select **Identity**, then click the `...` button.<br>

3. Select **Custom Account**, then click **Set...**<br>

4. Enter your credentials, then click **OK**.<br>

5. Make sure the application pools for the other WorkflowGen web applications (`auth`, `graphql`, `hooks`, `scim`,`ws`, and `webforms`) match the `wfgen` application pool.

6. Make sure the custom account has read/write and modify permissions for the WorkflowGen SQL database and the WorkflowGen files and folders.<br>

7. Use the same account as the application identity to run the WorkflowGen engine and directory synchronization services.

For more information on SQL Server connection strings, see <https://www.connectionstrings.com/sql-server/>.

## Web Farm architecture

### Overview <a href="#web-farm-architecture-overview" id="web-farm-architecture-overview"></a>

To allow higher availability and scalability of the application, you can install WorkflowGen in a Web Farm architecture. The application is therefore installed on several servers, but the database and file storage directory are centralized on one dedicated server.

User requests are automatically routed to different servers depending on their load and availability. You can choose between different methods of load balancing such as DNS Round Robin or setup a hardware load balancer.

### Configuration

#### Prerequisites

* WorkflowGen on all web servers<br>
* File storage centralized in one location<br>
* Common `WebForms` folder for all web servers<br>
* Identical configuration on all WorkflowGen servers

#### File storage location

Apply the basic configuration explained in the [Basic configuration](#basic-configuration) section before modifying the WorkflowGen configuration.

#### Setting up a common WebForms folder

If you have configured multiple instances of WorkflowGen on different web servers in a Web Farm setup, you must share the same `WebForms` folder for all servers. To do this:

1. Share your `WebForms` folder. This can be either your primary WorkflowGen site’s local `WebForms` folder, or a `WebForms` folder on a network file server.<br>
2. If you are using a network file server and you have content in your primary WorkflowGen site’s local `WebForms` folder, we suggest copying the content of this folder to the shared `WebForms` folder.<br>
3. Once you have shared the folder, copy the UNC path.<br>
4. Do the following **for each instance** of WorkflowGen:<br>
   1. In IIS, navigate to the `WebForms` application folder.<br>
   2. Right-click on the folder, then choose **Manage Application / Advanced Settings**.<br>
   3. Replace the physical path with the UNC path you copied in step 3.<br>
   4. Add the `<add key="ApplicationWebFormsPath" value="" />` parameter with the UNC path as the value to the `web.config` file.<br>

      ✏️ **Note:** This parameter is currently only used by the SOAP Web Service API to manage processes and requests with the built-in form designer enabled.<br>
5. Ensure that the required permissions (modify, read and execute, list folder contents, read, write) are correctly applied to the shared `WebForms` folder for the IIS application pool used by the `WebForms` application.

#### WorkflowGen configuration

Verify that all web servers have the same configuration for the WorkflowGen application and for all workflow applications. The `\wfgen\web.config` files must be identical.

The WorkflowGen engine service is a Windows Service that is installed with WorkflowGen and should only be run from one web server. The other servers should only run this service as a backup if the main service fails to run.

Data and application backup is done in the same way except that it only affects the file server (for file type data) and one web server since they have identical configurations (with regards to the applications).

## Database file storage mode

### Overview <a href="#database-file-storage-mode-overview" id="database-file-storage-mode-overview"></a>

This feature allows process file data (including attachments) to be stored in the database. It allows you to perform WorkflowGen data backup without interrupting service, so that WorkflowGen can still be used during the backup.

### Setup and configuration <a href="#database-file-storage-mode-setup-and-configuration" id="database-file-storage-mode-setup-and-configuration"></a>

#### WorkflowGen web configuration

Set the `ApplicationDefaultProcessDataFileStorageMethod` parameter to `File` to store process data files in the file system, or set it to `Database` to store process data files in the database.

This parameter will define the default process data file storage method when creating a new process or importing a process XPDL of previous version.

### Usage

Each process version can have the process data file storage method set independently. This will allow different processes using the file system or database storage method.

#### New process

On the **Process information** tab:

* Check the **Process data storage** option **Store file content in database** to enable the database file storage method.<br>
* Uncheck the **Process data storage** option to disable the database file storage method. This will then use the file system storage method.

#### Existing process

On the **Process information** tab:

* Uncheck the **Process data storage** option to disable the database file storage method. This will then use the file system storage method.

When changing process data storage method, the following rules must be applied:

* There should be no existing requests using the previous process data storage method. You can either delete existing requests or create a new version of the process.<br>
* There should be no existing `FILE` type process data with the default file value using the previous process data storage method. You can delete all default file values, change the process data storage method, and re-upload the default file values into the process data.

### Additional information

#### Temporary files

For a Web Farm architecture, file storage must be centralized in a common shared storage path. The settings in the [File storage](#file-storage) section must be applied for temporary files.

In the database file storage method, WorkflowGen will still create temporary files in the `\wfgen\App_Data` folder (`ApplicationDataPath`) to be used by requests and actions at runtime.

These temporary files will be automatically deleted when the requests or actions are completed.

#### Custom asynchronous system action

To ensure data integrity and 24-hour / 7-days-a-week operation time in database file storage method, your custom asynchronous system action that uses `FILE` IN parameters must also save the file content in your custom application database when the file is referenced later by your action.

This will ensure that the file will still exist and can be used later by your asynchronous system action, since only the WorkflowGen database and your custom application database are backed up.

## Configuring multiple instances of WorkflowGen

### Overview <a href="#configuring-multiple-instances-of-workflowgen-overview" id="configuring-multiple-instances-of-workflowgen-overview"></a>

This section describes how to configure multiple instances of WorkflowGen on the **same** web server. Each instance of WorkflowGen also requires a dedicated license. This section assumes that you have already installed separate instances of WorkflowGen as described in the [Setup](https://docs.workflowgen.com/tech/8.0/setup) section.

{% hint style="info" %}
For instructions on how to configure multiple instances of WorkflowGen on **different** servers in a Web Farm setup, see the [Web Farm architecture](#web-farm-architecture) section.
{% endhint %}

### Setup and configuration <a href="#configuring-multiple-instances-of-workflowgen-setup-and-configuration" id="configuring-multiple-instances-of-workflowgen-setup-and-configuration"></a>

To configure multiple instances of WorkflowGen on a single server, perform the steps outlined below. While more than two installations are possible, the following steps assume only two instances are installed.

Before modifying the service, it must be uninstalled using the `winsvc-uninstall.cmd` file found in the `\bin` folder of the application installation (for example, `DRIVE:\Program Files\Advantys\WorkflowGen\Services\bin\winsvc-uninstall.cmd`). Be sure to run it as the administrator of the server.

#### WorkflowGen directory synchronization service

For both instances of WorkflowGen, edit the parameter name in the `WfgDirectoriesSyncService.exe.config` WorkflowGen directory synchronization service configuration file as shown in the following examples.

* **Instance 1:** Edit the `DRIVE:\Program Files\Advantys\WorkflowGen1\Services\bin\WfgDirectoriesSyncService.exe.config` file as follows:

  ```markup
  <add key="ServiceName" value="WorkflowGenDirSyncService1" />
  ```
* **Instance 2:** Edit the `DRIVE:\Program Files\Advantys\WorkflowGen2\Services\bin\WfgDirectoriesSyncService.exe.config` file as follows:

  ```markup
  <add key="ServiceName" value="WorkflowGenDirSyncService2" />
  ```

#### WorkflowGen engine service

For both instances of WorkflowGen, edit the parameter name in the `WfgWorkflowEngineService.exe.config` WorkflowGen engine service configuration file.

* **Instance 1:** Edit the `DRIVE:\Program Files\Advantys\WorkflowGen1\Services\bin\WfgWorkflowEngineService exe.config` file as follows:

  ```markup
  <add key="ServiceName" value="WorkflowGenEngineService1" />
  ```
* **Instance 2:** Edit the `DRIVE:\Program Files\Advantys\WorkflowGen2\Services\bin\WfgWorkflowEngineService exe.config file` as follows:

  ```markup
  <add key="ServiceName" value="WorkflowGenEngineService2" />
  ```

#### Windows command scripts (install and uninstall of services)

For both instances of WorkflowGen you need to modify the Windows shell scripts that are used to install and uninstall the `WfgDirectoriesSyncService` and `WfgWorkflowEngineService` Windows services as described above.

**Instance 1:**

* Install script: `DRIVE:\Program Files\Advantys\WorkflowGen1\Services\bin\winsvc-install.cmd`\
  \
  Based on the value given for the `ServiceName` parameter defined in the WorkflowGen directory synchronization service section above, your `winsvc-install.cmd` file should appear as follows:

  ```
  %windir%\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /i "C:\Program Files\Advantys\WorkflowGen1\Services\bin\WfgDirectoriesSyncService.exe"
  net start WorkflowGenDirSyncService1

  %windir%\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /i "C:\Program Files\Advantys\WorkflowGen1\Services\bin\WfgWorkflowEngineService.exe"
  net start WorkflowGenEngineService1

  pause
  ```
* Uninstall script: `DRIVE:\Program Files\Advantys\WorkflowGen1\Services\bin\winsvc-uninstall.cmd`\
  \
  Based on the value given for the `ServiceName` parameter defined in the WorkflowGen directory synchronization service section above, your `winsvc-uninstall.cmd` file should appear as follows:

  ```
  %windir%\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /u "C:\Program Files\Advantys\WorkflowGen1\Services\bin\WfgDirectoriesSyncService.exe" /LogFile=

  %windir%\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /u "C:\Program Files\Advantys\WorkflowGen1\Services\bin\WfgWorkflowEngineService.exe" /LogFile=

  pause
  ```

**Instance 2:**

* Install script: `DRIVE:\Program Files\Advantys\WorkflowGen2\Services\bin\winsvc-install.cmd`\
  \
  Based on the value given for the `ServiceName` parameter defined in the WorkflowGen directory synchronization service section above, your `winsvc-install.cmd` file should appear as follows:

  ```
  %windir%\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /i "C:\Program Files\Advantys\WorkflowGen2\Services\bin\WfgDirectoriesSyncService.exe"
  net start WorkflowGenDirSyncService2

  %windir%\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /i "C:\Program Files\Advantys\WorkflowGen2\Services\bin\WfgWorkflowEngineService.exe"
  net start WorkflowGenEngineService2

  pause
  ```
* Uninstall script: `DRIVE:\Program Files\Advantys\WorkflowGen2\Services\bin\winsvc-uninstall.cmd`\
  \
  Based on the value given for the `ServiceName` parameter defined in the WorkflowGen directory synchronization service section above, your `winsvc-uninstall.cmd` file should appear as follows:

  ```
  %windir%\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /u "C:\Program Files\Advantys\WorkflowGen2\Services\bin\WfgDirectoriesSyncService.exe" /LogFile=

  %windir%\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /u "C:\Program Files\Advantys\WorkflowGen2\Services\bin\WfgWorkflowEngineService.exe" /LogFile=

  pause
  ```

#### Install the Windows Services

For both instances, you must run the install scripts that have been modified as described above using administrator permissions.

* **Instance 1:** `DRIVE:\Program Files\Advantys\WorkflowGen1\Services\bin\winsvc-install.cmd`<br>
* **Instance 2:** `DRIVE:\Program Files\Advantys\WorkflowGen2\Services\bin\winsvc-install.cmd`

## Database scaling

### Overview <a href="#database-scaling-overview" id="database-scaling-overview"></a>

The database scaling feature allows for the addition of database servers in order to dramatically improve server performance and response times. The additional read-only replica database servers will be used as dedicated read-only servers (SELECT SQL queries). The read-only database servers are replicated from the existing primary database using the SQL Server Replication service.

{% hint style="info" %}
This feature is only supported in MS SQL Server.
{% endhint %}

### Requirements

#### Overview

* SQL Server 2012 or later for all database servers<br>
* SQL Server Replication feature must be installed on all SQL Server instances<br>
* SQL Server Agent must be installed and configured on all SQL Server instances

### Setup and configuration <a href="#database-scaling-setup-and-configuration" id="database-scaling-setup-and-configuration"></a>

#### Overview

This section provides a general procedure for configuring the SQL Server Replication service on all the SQL Server instances and enabling the WorkflowGen web server in database scaling mode. This procedure is an example based on one WorkflowGen instance and two database server instances architecture.

If your current architecture differs from this example, you can adapt the procedure and some specific configuration options according to your needs.

Your current WorkflowGen environment must meet the following prerequisites:

* The initial WorkflowGen database is already installed on the primary database instance.<br>
* The read-only database instance does not contain an existing WorkflowGen database.<br>
* The WorkflowGen web server is fully configured and allows access to the Administration Module with a WorkflowGen administrator account.

#### SQL Server configuration options

It is mandatory to update the SQL Server's `max text repl size` configuration option with a higher value in order for the database replication to function properly. We recommend setting this to the maximum value of `2147483647` instead of the default value of `65536`.

Run the following SQL statements in the source (primary) and destination (read-only) SQL Server database instances (this example uses SQL Server 2008):

```
EXEC sp_configure "max text repl size", 2147483647;
GO
RECONFIGURE;
GO
```

For more information, see <http://msdn.microsoft.com/en-us/library/ms186225.aspx> and select your version of SQL Server from the drop-down menu.

#### SQL Server replication services

To set up a publication on the primary database:

1. Open SQL Server Management Studio.<br>
2. Connect to the primary database instance.<br>
3. Open the **Replication** node.<br>
4. Right-click on **Local Publications** and choose **New Publication**. The **New Publication Wizard** will open. Click **Next**.<br>
5. Select `WFGEN` in the **Publication Database** list. Click **Next**.<br>
6. Select **Transactional publication** in the **Publication type** list. Click **Next**.<br>
7. Check all **Tables** and **Views** (optional if the WorkflowGen Reporting Module is installed in the current database instance) in the **Articles** list. Click **Next**.<br>
8. The **Article Issues** dialog box will open if you selected **Views** in the previous step. Click **Next**.<br>
9. The **Filter Table Rows** dialog box will open. There is no need to filter the data in the publication. Click **Next**.<br>
10. The **Snapshot Agent** dialog box will open. Check **Create a snapshot immediately and keep the snapshot available to initialize subscriptions**. Click **Next**.<br>
11. In **Snapshot Agent Security**, provide valid service or administrator credentials for the Windows account. Click **Next**.<br>
12. Check **Create the publication**. Click **Next**.<br>
13. Enter the **Publication name** `WFGEN_PUB`.<br>
14. Click **Finish**. If all is successful, close the **New Publication Wizard**.

To set up a subscription on the read-only database:

1. Open SQL Server Management Studio.<br>
2. Connect to the read-only database instance.<br>
3. Open the **Replication** node.<br>
4. Right-click on **Local Subscriptions** and choose **New Subscription**. The **New Subscription Wizard** will open. Click **Next**.<br>
5. Select `<Find SQL Server Publisher...>`.<br>
6. Connect to the primary database instance.<br>
7. Select `WFGEN_PUB` in the **Databases and publications** list. Click **Next**.<br>
8. Select **Run each agent at its Subscriber (pull subscriptions)**. Click **Next**.<br>
9. In the **Subscription Database** column, select `<New database...>`.<br>
10. Enter the `WFGEN` as the **Database name** and click **OK**. Click **Next**.<br>
11. In **Distribution Agent Security**, provide valid service or administrator credentials for the Windows account. Click **Next**.<br>
12. In **Synchronization Schedule**, select **Run continuously**. Click **Next**.<br>
13. In **Initialize Subscriptions**, select **Immediately**. Click **Next**.<br>
14. Select **Create the subscription(s)**. Click **Next**.<br>
15. Click **Finish**. If all is successful, close the New Subscription Wizard.<br>
16. Create and add the SQL user `WFGEN_USER` to the `WFGEN` read-only database security with `db_datareader` and `db_datawriter` permissions.

{% hint style="info" %}
The `WFGEN_USER` account will be used in the connection string for the `WFGEN` read-only database in WorkflowGen.
{% endhint %}

### Database scaling in WorkflowGen

#### Enable the multi-database mode in WorkflowGen:

1. In the WorkflowGen **Administration Module**, open the **Configuration Panel** and select the **General** tab.<br>
2. In the **Read-only database connection string field**, enter the WorkflowGen connection string of the read-only database instance.<br>
3. Check **Enable** on **Multi-database** to turn on the database scaling feature.<br>
4. Check each of the specific **Portal** pages and **Modules**:
   * If unchecked, it will use the primary database.
   * If checked, it will use the read-only replica database.<br>
5. Save and close.

### References <a href="#database-scaling-in-workflowgen-references" id="database-scaling-in-workflowgen-references"></a>

* For more information on SQL Server replication, see <http://msdn.microsoft.com/en-us/library/ms151198.aspx> and select your version of SQL Server from the drop-down menu.<br>
* For more information on the SQL Server `max text repl size` option, see <http://msdn.microsoft.com/en-us/library/ms186225.aspx> and select your version of SQL Server from the drop-down menu.

## Custom language support and layout

### Overview <a href="#custom-language-support-and-layout-overview" id="custom-language-support-and-layout-overview"></a>

You can customize WorkflowGen according to your language and, if applicable, the required language layout.

### Customizing the resource files

To customize the resource files for your language, first make copies of the `.resx` files in the following folders:

* `\wfgen\App_GlobalResources`
* `\wfgen\WfApps\WebForms\App_GlobalResources`
* `\wfgen\ws\App_GlobalResources`

Append the file name with the language code and, if needed, a hyphen followed by the country code; for example, `.ar-AE` for Arabic and United Arab Emirates. Then, customize the resource files as needed.

### Customizing the CSS files

If the custom language requires a different layout, such as right-to-left text, customize the CSS files as needed using the method in the previous section.
