Create Code-Based Sets
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. You create code-based Sets in Workflow Studio.
This article demonstrates how to create a code-based set by creating one that returns all people with the title of “Helpdesk Technician.”
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.
In the Workspace tree, right-click the folder of your choice and select New Extension or Library > Class Library (.NET Framework).
Select the Properties tab located to the right of the C# Editor and click the Supports button (…).
Select SetRuntime and then click OK.
In the toolbar just above the C# Editor, click the Save button.
Name the class something that represents its purpose and click Save.
In the C# Editor, do the following:
Set the base class for the class to ISetRuntime.
Stub a method for the GetResults() method of the TheDotNetFactory.Framework.People.Components.SetCompilation class and add code to the method 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 class looks like:public class HelpDeskTechniciansSetRuntime :ISetRuntime { public E.TList<SetCompilation> GetResults() { 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; } }
Save your changes and close the CS file.
Publish the code-based Set
On the source control tree, double-click the class library file to open it in Visual Studio.
If this is the first time opening a class library file in this way, you will be prompted to select the default app with which to open the file. Select Visual Studio.In Visual Studio, build the Set Runtime solution.
After Visual Studio builds the solution, you should see a .pub file for the project in the WFS > _PublishedItems folder on your local file system. You publish this file to your system to make the Set Runtime available to EmpowerID as a manageable object that can be used in delegation.Log in to the EmpowerID web application as a user with the appropriate access to run the PublishWorkflowStudioItem workflow and navigate to the URL for the workflow. The URL should be
https://YourEmpowerIDWebServer.com/UI/#w/PublishWorkflowStudioItem
.Click Choose File, navigate to the _PublishedItems folder and select the pub file for the Set Runtime.
Click Submit.
Next, create a SetGroup for the Set.
Create a SetGroup for the Set
On the navbar, expand Role Management and select Query-Based Collections (SetGroup).
Select the Actions tab and then select Create a Query-Based Collection (SetGroup).
Enter the following information in the Create Query-Based Collection form:
Name – Name of the collection
Display Name – Display name of the collection
Description – Description of the collection
Is a collection of person objects – Select if the collection contains persons
Location – Creation location
When ready, click Submit and then click OK to close the Operation Execution Summary.
Search for and select the Set Runtime you just published.