Question
What is the easiest way to retrieve an array of all Adapter objects in a Pega Robotic Automation Studio solution?
What is the easiest way to retrieve an array of all Adapter objects in a Pega Robotic Automation Studio solution?
For example, the StartMyDayController component has the method GetStartupApplications(), which returns an array of <StartMyDayApplication> objects, from which each represented adapter and its properties are available. However, this method only returns adapters whose StartMyDay property is set to Manual or Automatic. I am looking for something similar, except it must return ALL adapters in the solution.
The ASOManager component has a GetAllApplications() method, but this method only returns an array containing the string Name of each adapter in the solution, so this will not work for me.
The issue we are trying to solve for is not straighforward, but I will describe it as best I can below:
1. Chrome adapters remove themselves from the SMDController's ShowStartDialog UI after being started until either the specific adapter's Stop() method is called, or ALL Chrome windows are closed. Our solution is an RDA, so we decided it best to not try to go down the path of determining when each adapter's Stop() method should be called. This was an issue for our use case because we needed our agents to be able to re-open applications they closed (accidentally or otherwise) without having to close EVERY chrome window first.
2. Our workaround for this issue was to include a 'dummy' adapter for each Chrome adapter. The dummy adapters use StartMyDay: manual, while the 'real' adapters use StartMyDay: none. This causes the dummy adapters to show up in the SMDController ShowStartDialog UI while the real adapters do not. The dummy adapters start the real adapters when StartMyDay() is called. Because the dummy adapters are never started, they remain in the list, and each Chrome adapter contains the necessary logic to prevent more than one instance of the application from starting.
3. Unfortunately, this workaround led to another issue: we can no longer use the SMDController to allow our agents to save/restore the size and position of Chrome apps, because the Chrome apps that are 'open' are not technically the same ones that are in the SMDController.
4. The solution we are looking at for this issue is using a persistent preferences file stored inside the project folder to save size/position data for all adapters. We plan to feed the name/size/position data to the SMDController's OrganizeApplication() method (Or each adapter's MoveAndResizeWindow() method), but the initially described issue is a roadblock to this.
As I see it, to solve this current issue, we'll need to do one of the following:
- Prevent Chrome apps from removing themselves from the ShowStartDialog UI after being opened
- Grab an array of all adapter objects in the solution, not just the SMD Adapters
Any input is appreciated.
Hello Matthew,
I am not sure how and what behavior leads to ShowStartDialog UI. But the best way to get the list of all the adapter object loaded in the solution would be a C# script to go through the loaded project and the design component of each project and find the adapters component.
This script should do the trick.
public List<Adapter> GetAdapters()
{
List<Adapter> allAdapters = new List<Adapter>();
foreach (RuntimeProject loadedProject in (IEnumerable<IRuntimeProject>)RuntimeHost.LoadedProjects)
{
RuntimeProject runtimeProject;
foreach (IDesignComponent designComponent in (IEnumerable<IDesignComponent>)((IRuntimeProject)(runtimeProject = loadedProject)).DesignComponents)
{
if (designComponent is Adapter)
{
Adapter currentComponent = (Adapter)designComponent;
allAdapters.Add(currentComponent);
}
}
}
return allAdapters;
}
Note: I am typecasting all the adapter components as the base adapter type, so you be exposed to Process, Method and Event that would be available for all adapter type. If you need to use Universal Web Adapter, Web Adapter and/or Windows Adapter specific PMEs, then another type case later in the flow or in the script logic will be necessary.
Thank you