Beispiel #1
0
 public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
 {
     _data = configuration.GetMetadata <PrintFromJobStorageActivityData>();
     jobStorage_AssetSelectionControl.Initialize(configuration.Assets, _deviceAttributes);
     folderName_TextBox.Text              = _data.FolderName;
     pin_TextBox.Text                     = _data.Pin;
     printAll_CheckBox.Checked            = _data.PrintAll;
     deleteJobAfterPrint_Checkbox.Checked = _data.DeleteJobAfterPrint;
     pinRequired_CheckBox.Checked         = _data.IsPinRequired;
     Copies_NumericUpDown.Value           = _data.NumberOfCopies < 1 ? 1 : _data.NumberOfCopies;
     ConfigureControls(_data);
 }
Beispiel #2
0
 public void ConfigureControls(PrintFromJobStorageActivityData data)
 {
     comboBox_AuthProvider.SelectedValue = _data.AuthProvider;
     if (_data.ApplicationAuthentication)
     {
         radioButton_PrintFromJobStprage.Checked = true;
     }
     else
     {
         radioButton_SignInButton.Checked = true;
     }
 }
        /// <summary>
        /// Validates the given metadata against the PrintFromJobStorage Activity data.
        /// </summary>
        /// <param name="configurationData">The configuration data.</param>
        /// <returns>true if valid</returns>
        public bool ValidateMetadata(ref PluginConfigurationData configurationData)
        {
            bool validData = true;
            PrintFromJobStorageActivityData activityData = null;

            try
            {
                activityData = configurationData.GetMetadata <PrintFromJobStorageActivityData>();
            }
            catch
            {
                activityData = new PrintFromJobStorageActivityData();
                validData    = false;
            }

            configurationData = new PluginConfigurationData(activityData, PrintFromJobStorageConfigControl.Version);

            return(validData);
        }
Beispiel #4
0
 /// <summary>
 /// Initializes this configuration control to default values.
 /// </summary>
 /// <param name="environment">Information about the plugin environment.</param>
 public void Initialize(PluginEnvironment environment)
 {
     _data = new PrintFromJobStorageActivityData();
     jobStorage_AssetSelectionControl.Initialize(_deviceAttributes);
     ConfigureControls(_data);
 }
Beispiel #5
0
        private PluginExecutionResult RunApp(IDevice device)
        {
            try
            {
                PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed);

                _activityData = _executionData.GetMetadata <PrintFromJobStorageActivityData>();

                IJobStoragePrintApp jobStorageApp = JobStoragePrintAppFactory.Create(device);
                IAuthenticator      authenticator = GetAuthenticator(_activityData.AuthProvider, device);

                AuthenticationMode am = (_activityData.ApplicationAuthentication == false) ? AuthenticationMode.Eager : AuthenticationMode.Lazy;

                var preparationManager = DevicePreparationManagerFactory.Create(device);
                preparationManager.InitializeDevice(true);

                jobStorageApp.Pacekeeper = authenticator.Pacekeeper = new Pacekeeper(TimeSpan.FromSeconds(2));
                jobStorageApp.Launch(authenticator, am);
                UpdateStatus("The Print From Job Storage app is launched");

                jobStorageApp.SelectFolder(_activityData.FolderName);
                UpdateStatus($"The Selected Folder: '{_activityData.FolderName}'");

                if (_activityData.PrintAll)
                {
                    bool allJobsSelected;
                    allJobsSelected = jobStorageApp.SelectAllJobs(_activityData.Pin, _activityData.FolderName);
                    if (allJobsSelected)
                    {
                        jobStorageApp.ExecutePrintJob();
                        UpdateStatus("All jobs are selected and printed");
                        if (_activityData.DeleteJobAfterPrint)
                        {
                            try
                            {
                                jobStorageApp.DeletePrintedJob();
                                UpdateStatus("All Selected Jobs were deleted");
                            }
                            catch (JobStorageDeleteJobExeception ex)
                            {
                                string message = $"The selected Job was not deleted. {ex.ToString()}";
                                LogDebug(message);
                                UpdateStatus(message);
                            }
                        }
                        result = new PluginExecutionResult(PluginResult.Passed);
                    }
                }
                else
                {
                    jobStorageApp.SelectFirstJob(_activityData.Pin, _activityData.NumberOfCopies, _activityData.FolderName);
                    UpdateStatus("The first job is selected");
                    jobStorageApp.ExecutePrintJob();
                    UpdateStatus("The first job is printed");
                    if (_activityData.DeleteJobAfterPrint)
                    {
                        try
                        {
                            jobStorageApp.DeletePrintedJob();
                            UpdateStatus("The Selected job was deleted");
                        }
                        catch (JobStorageDeleteJobExeception ex)
                        {
                            string message = $"The selected Job was not deleted. {ex.ToString()}";
                            LogDebug(message);
                            UpdateStatus(message);
                        }
                    }
                    result = new PluginExecutionResult(PluginResult.Passed);
                }
                preparationManager.Reset();
                return(result);
            }
            catch (DeviceCommunicationException ex)
            {
                GatherTriageData(device, ex.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device communication error."));
            }
            catch (DeviceInvalidOperationException ex)
            {
                GatherTriageData(device, ex.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device automation error."));
            }
            catch (DeviceWorkflowException ex)
            {
                GatherTriageData(device, ex.ToString());
                return(new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error."));
            }
            catch (Exception ex)
            {
                GatherTriageData(device, ex.ToString());
                throw;
            }
        }