Attaching elements

Step 12 – Implementing IActionExecutor Interface

The MyUrlActionExecutor implements the IActionExecutor interface.

public sealed class MyUrlActionExecutor : IActionExecutor
{
  public FlowToken Execute(
     EntityToken entityToken, 
     ActionToken actionToken, 
     FlowControllerServicesContainer flowControllerServicesContainer)
  {
    string currentConsoleId = flowControllerServicesContainer.
       GetService<IManagementConsoleMessageService>().CurrentConsoleId;
    DataEntityToken dataEntityToken = entityToken as DataEntityToken;
    IPage page = dataEntityToken.Data as IPage;
    string url = string.Format("/MyUrlAction.aspx?pageId={0}", page.Id);
    ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem 
    {
       Url = url, 
       ViewId = Guid.NewGuid().ToString(), 
       ViewType = ViewType.Main, 
       Label = "My URL Action" 
    }, currentConsoleId);
    return null;
  }
}

And it only contains one method: Execute. We know that pages under our children are only going to have this action, so it’s pretty safe to get the page from the passed-on entity token. Then we enqueue a new message on the message queue and tell the client to open the given URL in a new document tab. We pass on the Id of the page to this aspx page in the query string.