/// <summary>
        /// Executes this plugin's workflow using the specified <see cref="PluginExecutionData" />.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <returns>A <see cref="PluginExecutionResult" /> indicating the outcome of the execution.</returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            GeniusBytesPullPrintingActivityData data = executionData.GetMetadata <GeniusBytesPullPrintingActivityData>();

            GeniusBytesPullPrintManager manager = new GeniusBytesPullPrintManager(executionData, data, executionData.Environment);

            if (_documentCollectionIterator == null)
            {
                CollectionSelectorMode mode = data.ShuffleDocuments ? CollectionSelectorMode.ShuffledRoundRobin : CollectionSelectorMode.RoundRobin;
                _documentCollectionIterator = new DocumentCollectionIterator(mode);
            }
            manager.StatusUpdate           += UpdateStatus;
            manager.DeviceSelected         += UpdateDevice;
            manager.DocumentActionSelected += UpdateDocumentAction;
            manager.TimeStatusUpdate       += PullPrintManager_TimeStatusUpdate;
            manager.SessionIdUpdate        += UpdateSessionId;

            if (executionData.PrintQueues.Any() && executionData.Documents.Any())
            {
                try
                {
                    // Thread the print task so that any issues don't crash the user main thread.
                    Task printTask = Task.Factory.StartNew(() => manager.ExecutePrintJob(_documentCollectionIterator, data.UsePrintServerNotification, data.DelayAfterPrint));
                    printTask.Wait();
                }
                catch (AggregateException ex)
                {
                    ExecutionServices.SystemTrace.LogError(ex);
                    return(new PluginExecutionResult(PluginResult.Failed, ex, "Print Process Aborted."));
                }
            }
            return(manager.ExecutePullPrintOperation());
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GeniusBytesPullPrintManager"/> class.
 /// </summary>
 /// <param name="pluginExecutionData">The plugin execution data.</param>
 /// <param name="activityData">The activity data.</param>
 public GeniusBytesPullPrintManager(PluginExecutionData pluginExecutionData, GeniusBytesPullPrintingActivityData activityData, PluginEnvironment environment) : base(pluginExecutionData)
 {
     _activityData     = activityData;
     PullPrintSolution = "Genius Bytes Pull Printing";
     _environment      = environment;
     this.LockTimeouts = _activityData.LockTimeouts;
     this.AuthProvider = _activityData.AuthProvider;
 }
 /// <summary>
 /// Initializes this configuration control to default values.
 /// </summary>
 /// <param name="environment">Information about the plugin environment.</param>
 public void Initialize(PluginEnvironment environment)
 {
     _environment  = environment;
     _activityData = new GeniusBytesPullPrintingActivityData();
     assetSelectionControl.Initialize(_deviceAttributes);
     printingConfigurationControl.Initialize();
     lockTimeoutControl.Initialize(_activityData.LockTimeouts);
     SetPullPrintAction();
 }
        /// <summary>
        /// Initializes this configuration control with the specified <see cref="PluginConfigurationData" />.
        /// </summary>
        /// <param name="configuration">The configuration data.</param>
        /// <param name="environment">Information about the plugin environment.</param>
        public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
        {
            _activityData            = configuration.GetMetadata <GeniusBytesPullPrintingActivityData>();
            _pluginConfigurationData = configuration;
            _environment             = environment;

            assetSelectionControl.Initialize(_pluginConfigurationData.Assets, _deviceAttributes);
            printingConfigurationControl.Initialize(_pluginConfigurationData.Documents, _pluginConfigurationData.PrintQueues, _activityData.DelayAfterPrint, _activityData.ShuffleDocuments, _activityData.UsePrintServerNotification);
            lockTimeoutControl.Initialize(_activityData.LockTimeouts);
            SetConfiguration();
        }