Skip to content

Commit b81aac3

Browse files
committed
Initial commit
1 parent 7e54ac7 commit b81aac3

22 files changed

+6638
-0
lines changed

README.md

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# WorkflowGen and Microsoft Graph integration samples
2+
3+
## Overview
4+
5+
You can use [Microsoft Graph API](https://developer.microsoft.com/en-us/graph/docs/concepts/v1-overview) to create some integration points between WorkflowGen and Office 365 applications such Outlook, Excel, Teams, OneDrive, SharePoint and Azure.
6+
7+
This repository includes the `Advantys.Workflow.Applications.MicrosoftGraph.dll` assembly and the associated Visual Studio project.
8+
This assembly exposes multiples methods that can be used as WorkflowGen applications for each integration feature.
9+
10+
## Content
11+
12+
`docs`: Workflow applications documentation.
13+
14+
`processes`: Process definition file examples.
15+
16+
`src`: Visual Studio solution.
17+
18+
## Prerequisites
19+
20+
- Office 365 licences (one license for each user that will be accessing Office applications)
21+
22+
- Access to an Azure portal: https://portal.azure.com/
23+
24+
- Service account with an Office 365 licence (such as `workflowgen@YOUR_DOMAIN.com`)
25+
26+
- Workflowgen.My.dll 4.2.0 (WorkflowGen 7.10 or later)
27+
28+
29+
## Installation
30+
31+
### Application registration
32+
33+
1. Create an application on the https://apps.dev.microsoft.com/ site, such as `WorkflowGen`.
34+
35+
2. In **Application Secret** section, generate a new password and save the secret.
36+
37+
3. In **Platforms** section, click **Add platform** and choose **Web**.
38+
39+
4. Check **Allow implicit Flow** and add `https://login.microsoftonline.com` to the **Redirect URLs**.
40+
41+
5. Each [workflow application](#Workflow-applications-installation) requires specific permissions, so select these in **Application Permissions**, then save the application.
42+
43+
6. To activate permissions, go to the `https://login.microsoftonline.com/YOUR_TENANT_ID/adminconsent?client_id=YOUR_CLIENT_ID&redirect_uri=https://login.microsoftonline.com` URL (replacing `YOUR_TENANT_ID` and `YOUR_CLIENT_ID` with your tenant and client IDs, respectively), and connect using an Administrator account.
44+
45+
### Librairies installation on the WorkflowGen Server
46+
47+
The following components will be installed in the WorkflowGen `/bin` folders (`/wfgen/bin`, `/wfgen/ws/bin`, `../Program Files/Advantys/WorkflowGen/Service/bin`):
48+
- `Advantys.Workflow.Applications.MicrosoftGraph.dll`
49+
- `Microsoft.Graph.dll`
50+
- `Microsoft.Graph.Core.dll`
51+
- `Microsoft.Identity.Client.dll`
52+
53+
#### Quick Start
54+
55+
1. Download the last release pack on your WorkflowGen server.
56+
57+
2. Edit the `config.json`, replacing `WebAppPath` and `ServiceAppPath` with your own path (the default values are already specified).
58+
59+
3. Execute the `Install.ps1` script in PowerShell.
60+
61+
#### Custom installation
62+
63+
1. Clone the repository.
64+
65+
2. Open the Visual Studio Solution : `WorkflowGenMicrosoftGraph.sln`.
66+
67+
3. Compile the Solution and copy the `Advantys.Workflow.Applications.MicrosoftGraph.dll` generated to the `src/Install` folder.
68+
69+
4. Edit the `config.json`, replacing `WebAppPath` and `ServiceAppPath` with your own path (the default values are already specified).
70+
71+
5. Execute the `Install.ps1` script in PowerShell.
72+
73+
### WorkflowGen configuration
74+
75+
Add the following settings to the WorkflowGen `/wfgen/web.config` with your own values:
76+
77+
```xml
78+
<add key="MicrosoftGraphTenant" value="TENANT_ID" />
79+
<add key="MicrosoftGraphClientId" value="CLIENT_ID" />
80+
<add key="MicrosoftGraphClientSecret" value="CLIENT_SECRET" />
81+
<add key="MicrosoftGraphServiceAccountId" value="SERVICE_ACCOUNT_ID" />
82+
<add key="MicrosoftGraphServiceLogPath" value="LOG_PATH" />
83+
```
84+
85+
Where:
86+
* **TENANT_ID**: Your tenant ID, which you can can find in the Azure AD (Directory ID)
87+
88+
* **CLIENT_ID**: The application ID you created earlier
89+
90+
* **CLIENT_SECRET** : The secret password you generated earlier
91+
92+
* **SERVICE_ACCOUNT_ID** : Your service account ID, which you can find in the Azure AD account profile (`object id`)
93+
94+
* **LOG_PATH** : The path where the logs will be saved
95+
96+
## Workflow applications installation
97+
98+
All required components are installed, you can now deploy WorkflowGen applications for each desired integration.
99+
100+
### [Outlook](https://github.com/advantys/workflowgen-microsoft-graph/tree/master/docs/Outlook)
101+
102+
- Send mail
103+
- Schedule meetings
104+
105+
### [Azure AD](https://github.com/advantys/workflowgen-microsoft-graph/tree/master/docs/Azure%20AD)
106+
107+
- Add user
108+
109+
### [OneDrive](https://github.com/advantys/workflowgen-microsoft-graph/tree/master/docs/OneDrive)
110+
111+
- Upload a file

docs/Azure AD/README.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Azure
2+
3+
- [Add user](#add-user)
4+
5+
## Add user
6+
7+
### Permissions required for your MSGraph Apps
8+
9+
To allow workflowGen to create user, you need to enable the following permissions:
10+
11+
- `User.ReadWrite.All`
12+
13+
- `Directory.ReadWrite.All`
14+
15+
### Create the GRAPH_CREATE_USER_OFFICE application
16+
17+
First, you need to create an application in WorkflowGen with a configuration like the following:
18+
19+
- **Name**: `GRAPH_CREATE_USER_OFFICE`
20+
21+
- **Description**: `Create office 365 user with MsGraph`
22+
23+
- **Type**: `assembly`
24+
25+
- **Assembly full name or path**: `Advantys.Workflow.Applications.MicrosoftGraph`
26+
27+
- **Class full name**: `Advantys.Workflow.Applications.MicrosoftGraph.Graph`
28+
29+
- **Method**: `CreateOfficeUser`
30+
31+
You can import the following configuration to create the application automatically (make sure your username is included in `ProcessesRuntimeWebServiceAllowedUsers` in the `web.config`).
32+
33+
1. Go to `http://[YOUR_SITE]/wfgen/ws/processesruntime.asmx?op=CreateWorkflowApplication`
34+
35+
2. Copy and paste the following configuration to `applicationDefinition`:
36+
37+
```xml
38+
<Application xmlStructureRevisision="1.0"> <Name>GRAPH_CREATE_USER_OFFICE</Name> <Description>Create office 365 user with MsGraph</Description> <Type>ASSEMBLY</Type> <Method>CreateOfficeUser</Method> <Active>Y</Active> <Assembly>Advantys.Workflow.Applications.MicrosoftGraph</Assembly> <Class>Advantys.Workflow.Applications.MicrosoftGraph.Graph</Class> <Parameters> <Parameter> <Name>lastName</Name> <Description>lastName</Description> <DataType>TEXT</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>firstName</Name> <Description>firstName</Description> <DataType>TEXT</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>password</Name> <Description>password</Description> <DataType>TEXT</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>email</Name> <Description>email</Description> <DataType>TEXT</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>mobilePhone</Name> <Description>mobilePhone</Description> <DataType>TEXT</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>country</Name> <Description>country</Description> <DataType>TEXT</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>city</Name> <Description>city</Description> <DataType>TEXT</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>department</Name> <Description>department</Description> <DataType>TEXT</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>postalCode</Name> <Description>postalCode</Description> <DataType>TEXT</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>jobTitle</Name> <Description>jobTitle</Description> <DataType>TEXT</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>officeLocation</Name> <Description>officeLocation</Description> <DataType>TEXT</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>RETURN_VALUE</Name> <Description>RETURN_VALUE</Description> <DataType>TEXT</DataType> <Direction>OUT</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> </Parameters></Application>
39+
```
40+
41+
### Parameters
42+
| Name | Description | Type |
43+
| --- | --- |---|
44+
| `lastname` | User's lastname | Required |
45+
| `firstname` | User's firstname | Required |
46+
| `password` | User's password, at his first connection he needs to change it (ex P@ssw0rd) | Required |
47+
| `email` | User's email (e.g firstname.lastname@YOUR_DOMAIN.com). Your domain needs to be associate with your office 365 subscription | Required |
48+
| `mobilePhone` | User's mobile phone | Optional |
49+
| `country` | User's country | Optional |
50+
| `city` | User's city | Optional |
51+
| `postalCode` | User's postal code | Optional |
52+
| `department` | User's department | Optional |
53+
| `jobTitle` | User's job title | Optional |
54+
| `officeLocation` | User office's location | Optional |
55+
56+
### Example
57+
58+
You can use the [`CREATE_OFFICE365_USER`](https://github.com/advantys/workflowgen-microsoft-graph/blob/develop/processes/OneDrive/ARCHIVING_PROCESS_FILEv1.xml) process as an example.

docs/OneDrive/README.md

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# OneDrive
2+
3+
- [Upload a file](#upload-a-file)
4+
5+
## Upload a file
6+
7+
### Permissions required for your MSGraph Apps
8+
9+
To allow WorkflowGen to upload files, you have to enable the following permissions:
10+
11+
- `Group.ReadWrite.All`
12+
13+
- `File.ReadWrite.All`
14+
15+
- `Sites.ReadWrite.All`
16+
17+
### Create the GRAPH_UPLOAD_FILE_ONEDRIVE application
18+
19+
First, you need to create an application in WorkflowGen with a configuration like the following:
20+
21+
- **Name**: `GRAPH_UPLOAD_FILE_ONEDRIVE`
22+
23+
- **Description**: `Upload file to OneDrive group's folder`
24+
25+
- **Type**: `assembly`
26+
27+
- **Assembly full name or path**: `Advantys.Workflow.Applications.MicrosoftGraph`
28+
29+
- **Class full name**: `Advantys.Workflow.Applications.MicrosoftGraph.Graph`
30+
31+
- **Method**: `UploadFileOneDrive`
32+
33+
You can import the following configuration to create the application automatically (make sure your username is included in `ProcessesRuntimeWebServiceAllowedUsers` in the `web.config` file).
34+
35+
1. Go to `http://[YOUR_SITE]/wfgen/ws/processesruntime.asmx?op=CreateWorkflowApplication`.
36+
37+
2. Copy and paste the following configuration to `applicationDefinition`:
38+
39+
```xml
40+
<Application xmlStructureRevisision="1.0"> <Name>GRAPH_UPLOAD_FILE_ONEDRIVE</Name> <Description>Upload file to onedrive group&amp;#39;s folder</Description> <Type>ASSEMBLY</Type> <Method>UploadFileOneDrive</Method> <Active>Y</Active> <Assembly>Advantys.Workflow.Applications.MicrosoftGraph</Assembly> <Class>Advantys.Workflow.Applications.MicrosoftGraph.Graph</Class> <Parameters> <Parameter> <Name>groupId</Name> <Description>groupId</Description> <DataType>TEXT</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>folderId</Name> <Description>folderId</Description> <DataType>TEXT</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>requestNumber</Name> <Description>requestNumber</Description> <DataType>NUMERIC</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>file</Name> <Description>file</Description> <DataType>FILE</DataType> <Direction>IN</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> <Parameter> <Name>RETURN_VALUE</Name> <Description>RETURN_VALUE</Description> <DataType>TEXT</DataType> <Direction>OUT</Direction> <Required>Y</Required> <Default>N</Default> </Parameter> </Parameters> </Application>
41+
```
42+
43+
### Parameters
44+
| Name | Description | Type |
45+
| --- | --- |---|
46+
|`file`|File to upload | Required|
47+
|`folderId`|Destination folder ID|Required|
48+
|`groupId`|Destination OneDrive group ID| Required |
49+
|`requestNumber`|Request number (`CURRENT_REQUEST`)| Required |
50+
51+
### Example
52+
53+
You can use the [`ARCHIVING_FILE_ONEDRIVE`](https://github.com/advantys/workflowgen-microsoft-graph/blob/master/processes/OneDrive/ARCHIVING_PROCESS_FILEv1.xml) process as an example. You'll need to use the `BU_ONEDRIVE` global list and create various groups and folders in your OneDrive.
54+
55+
In our example, we have three Business Units represented by groups in OneDrive; in each Business Unit, we have three domains represented by folders.
56+
57+
```
58+
|-- Aerospace
59+
|-- Aviation
60+
|-- Defense
61+
|-- Space
62+
|-- Telecom
63+
|-- IoT
64+
|-- Metering
65+
|-- Telecom
66+
|-- Transport
67+
|-- Marine
68+
|-- Racing
69+
|-- Rail
70+
```
71+
72+
If you want to use the process example, perform the following steps.
73+
74+
1. Go to your Office portal `https://www.office.com` and connect with an Office 365 Administrator account.
75+
76+
2. Go to OneDrive.
77+
78+
3. Under `Recycle bin` you'll see your domain name. Click on `+` to create a group and repeat this as many times as you need.
79+
80+
4. Create folders in your OneDrive groups.
81+
82+
5. In the `BU_ONEDRIVE` global list, update the `IdBuGroup` and `IdDomainFolder` columns.
83+
84+
6. Go to `https://developer.microsoft.com/en-us/graph/graph-explore`.
85+
86+
7. To get `IdBuGroup`, execute the following query as a `GET` request.
87+
```
88+
https://graph.microsoft.com/v1.0/groups
89+
```
90+
8. Copy and paste the ID returned in the `IdBuGroup` column
91+
92+
9. To get `IdDomainFolder`, execute the following query as `GET` request:
93+
```
94+
https://graph.microsoft.com/v1.0/groups/[ID_GROUP}/drive/root/children
95+
```
96+
97+
10. Copy and paste the ID returned in the `IdDomainFolder` column
98+
99+
100+
101+
102+
103+

0 commit comments

Comments
 (0)