Creating Code-Based Sets
- Universal Importer for Confluence
- Phillip Hanegan
- Kim Landis (Unlicensed)
Code-based Sets are queries that can result in collections of people or collections of other resource types protected by EmpowerID. Each code-based Set requires a Set Runtime, which is a custom implementation of the EmpowerID API that allows C# code to be used to return a collection of EmpowerID object types. This topic walks you through the process.
To create a code-based Set
- Log into Workflow Studio.
- From Solution Explorer (located to the left of the Workflow Studio IDE), select the Workspace node.
The Workspace tree appears, displaying the packages and package items in your personal Workspace. - In the Workspace tree, right-click the Package node of your choice and select Add New Item, then EmpowerID Set Runtime.
- In the Add New Set Runtime window that appears, in the Name text field, enter "Helpdesk Technicians" and click OK.
Workflow Studio does the following:- Creates a Set Runtime folder inside the selected package node.
- Adds a Helpdesk Technicians package item to the new folder.
Opens the C# Editor stubbed for the new Set Runtime in the Document Space, ready for you to add custom code.
Adds the HelpdeskTechnicians.cs class file to the Classes folder in the Code Tree (in the Toolbox to the right).
All Set Runtime objects you create in Workflow Studio use the GetResults() method of the ISetRuntime interface in the TheDotNetFactory.Framework.People.Components namespace.
The following image shows the new Helpdesk Technicians Set Runtime in Workflow Studio.Â
- In the C# Editor, in the body of the GetResults() method, delete throw new NotImplementedException();Â and replace it with code that does the following:
- Creates a new instance of the TheDotNetFactory.Framework.People.Components.Person class, using the Find() method to find EmpowerID Person objects with a title of "Helpdesk Technician."
- Creates a new instance of the TheDotNetFactory.Framework.People.Components.SetCompilation class.
- Loops through the new instance of the Person class,
adding each person returned by the Find() method to the new instance of the SetCompilation class, and
writing the PersonGUID DisplayName of the SetCompilation class to the FriendlyName property for each person. - Returns the results of the collection.
Here is what the code for the GetResults() method looks like:int totalCount = -1; E.TList<Person> people = Person.Find ("Title = Helpdesk Technician", 0, int.MaxValue, out totalCount); E.TList<SetCompilation> results = new E.TList<SetCompilation>(); foreach (Person p in people) { results.Add(new SetCompilation(){SystemIdentifier = p.PersonGUID.ToString(),DisplayName = p.FriendlyName}); } return results;
If you use LINQ to return results, the SELECT statement cannot contain any characters that XML does not escape:
<
>
"
'
&
- In the toolbar just above the C# Editor, click the Compile button. Compiling the Set Runtime allows you to verify that your code contains no syntax errors.
If successful, the Operations Log shows a message stating that the HelpdeskTechnicians.dll compiled successfully.
If unsuccessful, details of the problem appear in the Error Message box at the bottom of the log. - Click the Close button to close the Operations Log.
To compile and publish your code-based Set
- In the toolbar just above the C# Editor, click the Compile and Publish button to publish it.
Publishing the Set Runtime to the Workflow Server(s) makes it available to EmpowerID as a manageable object that you can use in delegation. - In the Set Runtime Publishing wizard that appears, click the Next button.
- Select the Enterprise Workflow Server to which you want to publish it and click Next.
- Click Next and follow the wizard to complete the publishing process.
- In the Set dialog that appears, click Yes. This lets you create a code-based Set to associate with the Set Runtime.
- In the Add Set dialog that appears, do the following:
- Enter HelpdeskTechniciansSet in the Name field.
- Enter Helpdesk Technicians in the Friendly Name and Description fields.
- Select EmpowerID Person from the Object Type drop-down.
- Select both Is Enabled and Compile Now.
Enter the desired parameters for the compilation schedule and then click OK.
At this point, the Add Set dialog looks similar to this.
- When prompted to restart one or more services, click Yes.
- In the Active Services window that appears, select the EmpowerID services and click Restart.
 Â