Example #1
0
        /// <summary>
        /// Collecct and Submit JetAdvantageLink MemoryMonitoring.
        /// </summary>
        protected override void CollectJetAdvantagelinkMemoryMonitoring(IDeviceInfo deviceInfo)
        {
            if (deviceInfo == null)
            {
                throw new ArgumentNullException(nameof(deviceInfo));
            }

            try
            {
                if (_clio != null)
                {
                    JetAdvantageLinkMemoryMonitoring jalMem = new JetAdvantageLinkMemoryMonitoring(_clio.LinkUI, _clio.ClioAppsPackageName, ExecutionData, deviceInfo);
                    jalMem.CollectMemoryMonitoringData();
                    jalMem.Submit();
                }
                else
                {
                    UpdateStatus("Device is null - can not submit the JetAdvantageLink memory.");
                }
            }
            catch (Exception)
            {
                UpdateStatus($"JetAdvantageMemoryMonitoring failed - cannot submit the JetAdvantageLink memory.");
            }
        }
 /// <summary>
 /// JetAdvantageLinkMemoryMonitoring
 /// </summary>
 /// <param name="linkUI">Link UI</param>
 /// <param name="targetPackage">Target Android Package name</param>
 /// <param name="pluginExecutionData">PluginExecution Data</param>
 /// <param name="deviceInfo">deviceInfo</param>
 public JetAdvantageLinkMemoryMonitoring(JetAdvantageLinkUI linkUI, string targetPackage, PluginExecutionData pluginExecutionData, IDeviceInfo deviceInfo)
 {
     _linkUI              = linkUI;
     _targetPackage       = targetPackage;
     _pluginExecutionData = pluginExecutionData;
     _deviceInfo          = deviceInfo;
 }
Example #3
0
        /// <summary>
        /// Sets the device.
        /// </summary>
        /// <param name="deviceAsset">The device asset.</param>
        /// <returns></returns>
        private IDevice SetDevice(IDeviceInfo deviceAsset)
        {
            // Select a device
            IDevice device = DeviceConstructor.Create(deviceAsset);

            UpdateStatus(string.Format("Using device {0} ({1})", deviceAsset.AssetId, deviceAsset.Address));

            return(device);
        }
        private void ConfigureDevice(IDeviceInfo deviceInfo)
        {
            // If this is a Jedi simulator, load documents into the ADF
            DeviceSimulatorInfo simulatorInfo = deviceInfo as DeviceSimulatorInfo;

            if (simulatorInfo?.SimulatorType == "Jedi" && ScanOptions.UseAdf)
            {
                LoadAdf(deviceInfo.Address, ScanOptions.PageCount);
            }
        }
Example #5
0
        /// <summary>
        /// Collecct and Submit JetAdvantageLink MemoryMonitoring.
        /// </summary>
        protected override void CollectJetAdvantagelinkMemoryMonitoring(IDeviceInfo deviceInfo)
        {
            if (deviceInfo == null)
            {
                throw new ArgumentNullException(nameof(deviceInfo));
            }

            JetAdvantageLinkMemoryMonitoring jalMem = new JetAdvantageLinkMemoryMonitoring(_regusKioskApp.LinkUI, _regusKioskApp.KioskPackageName, ExecutionData, deviceInfo);

            jalMem.CollectMemoryMonitoringData();
            jalMem.Submit();
        }
Example #6
0
        /// <summary>
        /// Launches the application.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="deviceAsset">The device asset.</param>
        /// <returns>PluginExecutionResult</returns>
        private PluginExecutionResult LaunchApp(IDevice device, IDeviceInfo deviceAsset)
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Passed);
            string buttonText            = _activityData.InitiationButton;

            try
            {
                _workflowLogger.RecordEvent(DeviceWorkflowMarker.ActivityBegin);

                AuthenticationInitMethod aim = GetAuthenticationInitMethod(_activityData.InitiationButton);
                DeviceSignOutMethod      deviceUnauthMethod = SignOutMethod.GetSignOutMethod(_activityData.UnAuthenticateMethod);
                IAuthenticator           auth = GetAuthenticator(device, deviceAsset);

                // retrieve the Authentication solution, plugin.
                IAuthenticationDriver app = GetApp(device);

                UpdateStatus("Launching authentication for " + buttonText + ".");
                if (!aim.Equals(AuthenticationInitMethod.DoNotSignIn))
                {
                    app.Launch(auth, aim);
                }
                else
                {
                    UpdateStatus("Skip Sign In :: Do not Sign In");
                }

                UpdateStatus("Logging out of device " + deviceAsset.AssetId + " - " + deviceAsset.Address + " by " + _activityData.UnAuthenticateMethod);
                if (deviceUnauthMethod.Equals(DeviceSignOutMethod.DoNotSignOut))
                {
                    UpdateStatus("Skip Sign Out :: Do Not Sign Out");
                }
                else
                {
                    app.SignOut(deviceUnauthMethod, device);
                }

                _workflowLogger.RecordEvent(DeviceWorkflowMarker.ActivityEnd);
            }
            catch (DeviceCommunicationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device communication error.");
            }
            catch (DeviceInvalidOperationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device automation error.");
            }
            catch (DeviceWorkflowException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error.");
            }

            return(result);
        }
Example #7
0
        protected override PluginExecutionResult ExecuteScan(IDevice device, IDeviceInfo deviceInfo)
        {
            //var result = new PluginExecutionResult(PluginResult.Passed);
            var result = new PluginExecutionResult(PluginResult.Failed, "Automation Failure", "Device workflow error.");

            try
            {
                _collectMemoryManager = new CollectMemoryManager(device, deviceInfo);
                result = base.ExecuteScan(device, deviceInfo);
            }
            finally
            {
                _collectMemoryManager.CollectDeviceMemoryProfile(_activityData.DeviceMemoryProfilerConfig, "ScanToHpcr");
            }
            return(result);
        }
Example #8
0
        /// <summary>
        /// Executes the scan job using the specified device.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="deviceInfo">The device information.</param>
        /// <returns>
        /// The result of execution.
        /// </returns>
        protected override PluginExecutionResult ExecuteScan(IDevice device, IDeviceInfo deviceInfo)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Automation Failure", "Device workflow error.");

            ScanLog.JobEndStatus = "Failed";
            try
            {
                _collectMemoryManager = new CollectMemoryManager(device, deviceInfo);
                result = base.ExecuteScan(device, deviceInfo);
            }
            finally
            {
                SetJobEndStatus(result);
                //collectMemoryManager.CollectDeviceMemoryProfile(_activityData.DeviceMemoryProfilerConfig, "AutoStore");
            }
            return(result);
        }
        /// <summary>
        /// Collecct and Submit JetAdvantageLink MemoryMonitoring.
        /// </summary>
        protected override void CollectJetAdvantagelinkMemoryMonitoring(IDeviceInfo deviceInfo)
        {
            try
            {
                if (deviceInfo == null)
                {
                    throw new ArgumentNullException(nameof(deviceInfo));
                }

                JetAdvantageLinkMemoryMonitoring jalMem = new JetAdvantageLinkMemoryMonitoring(_imanage.LinkUI, _imanage.iManageAppsPackageName, ExecutionData, deviceInfo);
                jalMem.CollectMemoryMonitoringData();
                jalMem.Submit();
            }
            catch
            {
                UpdateStatus($"JetAdvantageMemoryMonitoring failed - cannot submit the JetAdvantageLink memory.");
            }
        }
Example #10
0
        /// <summary>
        /// Gets the authenticator for the given device and requested solution.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="deviceInfo">Device information</param>
        /// <returns>IAuthenticator</returns>
        private IAuthenticator GetAuthenticator(IDevice device, IDeviceInfo deviceInfo)
        {
            AuthenticationCredential authCredential = null;

            if (_activityData.AuthProvider == AuthenticationProvider.Card || _activityData.AuthMethod.GetDescription().Contains("Badge"))
            {
                authCredential = new AuthenticationCredential(_executionData, deviceInfo.AssetId, deviceInfo.Address);
            }
            else
            {
                authCredential = new AuthenticationCredential(_executionData.Credential);
            }

            IAuthenticator auth = AuthenticatorFactory.Create(device, authCredential, _activityData.AuthProvider);

            auth.WorkflowLogger = _workflowLogger;
            return(auth);
        }
Example #11
0
        /// <summary>
        /// Entrypoint for the Plugin Task Execution for TwainDriverConfiguration Plugin
        /// </summary>
        /// <param name="executionData"></param>
        /// <returns></returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Passed);
            var acquireTimeout           = TimeSpan.FromMinutes(5);
            var holdTimeout = TimeSpan.FromMinutes(5);

            _executionData = executionData;
            _deviceAssets  = executionData.Assets.OfType <IDeviceInfo>().ToList();
            try
            {
                _workflowLogger = new DeviceWorkflowLogger(executionData);
                UpdateStatus("Starting task engine");
                List <AssetLockToken> tokens = _deviceAssets.Select(n => new AssetLockToken(n, acquireTimeout, holdTimeout)).ToList();
                _workflowLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockBegin);
                ExecutionServices.CriticalSection.Run(tokens, selectedToken =>
                {
                    IDeviceInfo deviceInfo = (selectedToken as AssetLockToken).AssetInfo as IDeviceInfo;

                    UpdateStatus($"Using device {deviceInfo.AssetId} ({deviceInfo.Address})");
                    using (IDevice device = DeviceConstructor.Create(deviceInfo))
                    {
                        var retryManager = new PluginRetryManager(executionData, UpdateStatus);
                        result           = retryManager.Run(() => RunTwain(device, executionData));
                    }
                });

                _workflowLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockEnd);
            }
            catch (DeviceCommunicationException ex)
            {
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device communication error."));
            }
            catch (DeviceInvalidOperationException ex)
            {
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device automation error."));
            }
            catch (DeviceWorkflowException ex)
            {
                return(new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error."));
            }

            return(result);
        }
        private static IDevice CreateAutomationDevice(IDeviceInfo deviceInfo)
        {
            // Jedi simulators stop working if TLS 1.1 or 1.2 are allowed.  Exact cause is unknown, but could be because
            // Windows supports those protocols and the simulator does not.  The negotiation with Windows establishes that
            // one of those should be used, but then the simulator closes the connection because it can't use the selected protocol.
            if (deviceInfo is DeviceSimulatorInfo)
            {
                NetworkConfiguration.SecurityProtocolOverrideValue = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
            }
            else
            {
                NetworkConfiguration.SecurityProtocolOverrideValue = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
            }

            IDevice device = null;

            try
            {
                device = DeviceConstructor.Create(deviceInfo);
                return(device);
            }
            catch (Exception ex)
            {
                // Make sure the device is disposed, if necessary
                if (device != null)
                {
                    device.Dispose();
                    device = null;
                }

                // Log the error and post the exception back to the dispatcher
                LogError($"Error creating device: {ex.Message}");
                ExecutionServices.SessionRuntime.ReportAssetError(deviceInfo);

                throw;
            }
        }
        /// <summary>
        /// Executes the scan job using the specified device.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="deviceInfo">The device information.</param>
        /// <returns>
        /// The result of execution.
        /// </returns>
        protected override PluginExecutionResult ExecuteScan(IDevice device, IDeviceInfo deviceInfo)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Automation Failure", "Device workflow error.");

            try
            {
                _geniusBytesApp = GeniusBytesAppFactory.Create(device);
                var devicePrepManager = new GeniusBytesPreparationManager((JediOmniDevice)device, _geniusBytesApp);
                devicePrepManager.WorkflowLogger = WorkflowLogger;
                devicePrepManager.InitializeDevice(false);

                // Configure the device (apply settings, load simulator ADF, etc.)
                UpdateStatus("Configuring device...");
                ConfigureDevice(deviceInfo);
                ScanLog.PageCount = (short)ScanOptions.PageCount;
                ScanLog.Sender    = ExecutionData.Credential.UserName;

                // Set up the job (enter parameters, etc.)
                RecordEvent(DeviceWorkflowMarker.ActivityBegin);
                UpdateStatus("Setting up job...");
                SetupJob(device);
                UpdateStatus("Job setup complete.");

                // Finish the job (apply job build options, press start, wait for finish)
                UpdateStatus("Finishing job...");
                result = FinishJob(device);
                UpdateStatus("Job finished.");

                try
                {
                    SignOut();
                    RecordEvent(DeviceWorkflowMarker.ActivityEnd);
                }
                catch (Exception ex) when(ex is DeviceCommunicationException || ex is DeviceInvalidOperationException)
                {
                    // Don't fail the activity if there is an exception here.
                    UpdateStatus("Device could not return to home screen.");
                    //GatherTriageData(device, $"Device could not return to home screen: {ex.ToString()}");
                }

                // SignOut will be developed
                UpdateStatus("Activity finished.");
            }
            catch (DeviceCommunicationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, "Device communication error.");
                GatherTriageData(device, ex.ToString());
            }
            catch (DeviceInvalidOperationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, "Device automation error.");
                GatherTriageData(device, ex.ToString());
            }
            catch (DeviceWorkflowException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error.");
                GatherTriageData(device, ex.ToString());
            }
            catch (Exception ex)
            {
                GatherTriageData(device, $"Unexpected exception, gathering triage data: {ex.ToString()}");
                throw;
            }
            return(result);
        }
Example #14
0
        /// <summary>
        /// Logs the device.
        /// </summary>
        private void LogDevice(IDeviceInfo deviceAsset)
        {
            ActivityExecutionAssetUsageLog assetLog = new ActivityExecutionAssetUsageLog(_executionData, deviceAsset);

            ExecutionServices.DataLogger.Submit(assetLog);
        }
Example #15
0
        /// <summary>
        /// Executes this plugin's workflow using the specified <see cref="T:HP.ScalableTest.Framework.Plugin.PluginExecutionData" />.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <returns>A <see cref="T:HP.ScalableTest.Framework.Plugin.PluginExecutionResult" /> indicating the outcome of the execution.</returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Passed);

            _executionData = executionData;

            _deviceAssets = executionData.Assets.OfType <IDeviceInfo>().ToList();
            ExecutionServices.SystemTrace.LogDebug($"# of assets in ExecutionData: {executionData.Assets.Count}");

            try
            {
                UpdateStatus("Starting activity...");
                _activityData = executionData.GetMetadata <AuthenticationData>(ConverterProvider.GetMetadataConverters());

                _workflowLogger = new DeviceWorkflowLogger(executionData);
                TimeSpan acquireTimeout = _activityData.LockTimeouts.AcquireTimeout;
                TimeSpan holdTimeout    = _activityData.LockTimeouts.HoldTimeout;

                string msg = string.Empty;

                List <AssetLockToken> tokens = _deviceAssets.Select(n => new AssetLockToken(n, acquireTimeout, holdTimeout)).ToList();
                _workflowLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockBegin);
                ExecutionServices.CriticalSection.Run(tokens, selectedToken =>
                {
                    IDeviceInfo deviceInfo = (selectedToken as AssetLockToken).AssetInfo as IDeviceInfo;
                    LogDevice(deviceInfo);

                    using (IDevice device = SetDevice(deviceInfo))
                    {
                        var retryManager = new PluginRetryManager(executionData, UpdateStatus);
                        result           = retryManager.Run(() => LaunchApp(device, deviceInfo));
                    }
                });

                _workflowLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockEnd);
            }
            catch (DeviceCommunicationException ex)
            {
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device communication error."));
            }
            catch (DeviceInvalidOperationException ex)
            {
                return(new PluginExecutionResult(PluginResult.Failed, ex.Message, "Device automation error."));
            }
            catch (DeviceWorkflowException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error.");
            }
            catch (AcquireLockTimeoutException)
            {
                return(new PluginExecutionResult(PluginResult.Skipped, "Could not obtain lock on specified devices(s).", "Device unavailable."));
            }
            catch (HoldLockTimeoutException)
            {
                return(new PluginExecutionResult(PluginResult.Error, $"Automation did not complete within {_activityData.LockTimeouts.HoldTimeout}.", "Automation timeout exceeded."));
            }
            finally
            {
                UpdateStatus("Finished activity");
            }
            return(result);
        }
        /// <summary>
        /// Runs the scan activity.
        /// </summary>
        /// <returns>The result of the activity.</returns>
        public PluginExecutionResult RunLinkPrintActivity()
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed, "Automation Execution Failure", "Device workflow error.");

            try
            {
                var devices     = ExecutionData.Assets.OfType <IDeviceInfo>();
                var assetTokens = devices.Select(n => new AssetLockToken(n, _lockTimeoutData));

                RecordEvent(DeviceWorkflowMarker.DeviceLockBegin);
                ExecutionServices.CriticalSection.Run(assetTokens, selectedToken =>
                {
                    IDeviceInfo deviceInfo = (selectedToken as AssetLockToken).AssetInfo as IDeviceInfo;
                    DeviceSelected?.Invoke(this, new StatusChangedEventArgs(deviceInfo.AssetId));

                    if (_linkPrintOptions != null)
                    {
                        AppNameSelected?.Invoke(this, new StatusChangedEventArgs(_linkPrintOptions.AppName));
                    }
                    else
                    {
                        AppNameSelected?.Invoke(this, new StatusChangedEventArgs(LinkJobType));
                    }

                    ConnectorLog.DeviceId = deviceInfo.AssetId;

                    ExecutionServices.DataLogger.Submit(new ActivityExecutionAssetUsageLog(ExecutionData, deviceInfo));

                    if (_serverName != null)
                    {
                        ExecutionServices.DataLogger.Submit(new ActivityExecutionServerUsageLog(ExecutionData, _serverName));
                    }

                    using (IDevice device = CreateAutomationDevice(deviceInfo))
                    {
                        var retryManager = new PluginRetryManager(ExecutionData, this.UpdateStatus);
                        result           = retryManager.Run(() => ExecuteLinkPrint(device, deviceInfo));
                    }
                }
                                                      );

                RecordEvent(DeviceWorkflowMarker.DeviceLockEnd);
            }
            catch (ArgumentException ex)
            {
                result = new PluginExecutionResult(PluginResult.Skipped, ex.Message, "Device automation error.");
            }
            catch (InvalidOperationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Skipped, ex.Message, "Device automation error.");
            }
            catch (AcquireLockTimeoutException)
            {
                result = new PluginExecutionResult(PluginResult.Skipped, "Could not obtain lock on specified device(s).", "Device unavailable.");
            }
            catch (HoldLockTimeoutException)
            {
                result = new PluginExecutionResult(PluginResult.Error, $"Automation did not complete within {_lockTimeoutData.HoldTimeout}.", "Automation timeout exceeded.");
            }
            LogDebug($"Print activity complete. Result is {result.Result.ToString()}: {result.Message}");

            return(result);
        }
 /// <summary>
 /// Collecct Android MemoryMonitoring.
 /// </summary>
 protected abstract void CollectJetAdvantagelinkMemoryMonitoring(IDeviceInfo deviceInfo);
Example #18
0
        /// <summary>
        /// Executes the scan job using the specified device.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="deviceInfo">The device information.</param>
        /// <returns>The result of execution.</returns>
        protected override PluginExecutionResult ExecuteLinkPrint(IDevice device, IDeviceInfo deviceInfo)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Automation Failure", "Device workflow error.");

            try
            {
                // Make sure the device is in a good state
                var devicePrepManager = DevicePreparationManagerFactory.Create(device);
                devicePrepManager.WorkflowLogger = WorkflowLogger;
                //devicePrepManager.InitializeDevice();

                // Set up the job (enter parameters, etc.)
                RecordEvent(DeviceWorkflowMarker.ActivityBegin);
                UpdateStatus("Setting up job...");

                _regusKioskApp = new RegusKioskApp(device);
                _regusKioskApp.WorkflowLogger = WorkflowLogger;
                _regusKioskApp.DeviceInfo     = deviceInfo;

                SetupJob(device);
                UpdateStatus("Job setup complete.");

                // Finish the job (apply job build options, press start, wait for finish)
                UpdateStatus("Finishing job...");
                result = FinishJob(device);
                UpdateStatus("Job finished.");

                // Clean up
                try
                {
                    UpdateStatus("SignOut Start");
                    SignOut();
                    UpdateStatus("SignOut finished");

                    RecordEvent(DeviceWorkflowMarker.ActivityEnd);

                    try
                    {
                        CollectJetAdvantagelinkMemoryMonitoring(deviceInfo);
                    }
                    catch (Exception ex)
                    {
                        UpdateStatus(ex.ToString());

                        SubmitConnectorLog(result.Result.ToString());
                        return(result);
                    }
                }
                catch (Exception ex) when(ex is DeviceCommunicationException || ex is DeviceInvalidOperationException)
                {
                    // Don't fail the activity if there is an exception here.
                    UpdateStatus("Device could not return to home screen.");
                    GatherTriageData(device, $"Device could not return to home screen: {ex.ToString()}");
                }
                UpdateStatus("Activity finished.");
            }
            catch (DeviceCommunicationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, "Device communication error.");
            }
            catch (DeviceInvalidOperationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, "Device automation error.");
            }
            catch (DeviceWorkflowException ex)
            {
                if (ex.Data.Contains(_exceptionCategoryData))
                {
                    result = new PluginExecutionResult(PluginResult.Failed, ex, ex.Data[_exceptionCategoryData].ToString());
                }
                else
                {
                    result = new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error.");
                }

                GatherTriageData(device, ex.ToString());
            }
            catch (Exception ex)
            {
                GatherTriageData(device, $"Unexpected exception, gathering triage data: {ex.ToString()}");
                throw;
            }
            SubmitConnectorLog(result.Result.ToString());
            return(result);
        }
        protected override PluginExecutionResult ExecuteLinkScan(IDevice device, IDeviceInfo deviceInfo)
        {
            var result = new PluginExecutionResult(PluginResult.Failed, "Automation Failure", "Device workflow error.");

            try
            {
                // Make sure the device is in a good state
                var devicePrepManager = DevicePreparationManagerFactory.Create(device);
                devicePrepManager.WorkflowLogger = WorkflowLogger;
                devicePrepManager.InitializeDevice(false);

                if (_data.SIO.Equals(SIOMethod.NoneSIO))
                {
                    devicePrepManager.Reset();
                }

                // Set up the job (enter parameters, etc.)
                RecordEvent(DeviceWorkflowMarker.ActivityBegin);
                UpdateStatus("Setting up job...");
                SetupJob(device);
                UpdateStatus("Job setup complete.");

                // Finish the job (apply job build options, press start, wait for finish)
                UpdateStatus("Finishing job...");
                result = FinishJob(device);
                UpdateStatus("Job finished.");

                // Clean up
                try
                {
                    SignOut();
                    //NavigateHome();
                    RecordEvent(DeviceWorkflowMarker.ActivityEnd);

                    try
                    {
                        CollectJetAdvantagelinkMemoryMonitoring(deviceInfo);
                    }
                    catch (Exception ex)
                    {
                        SubmitConnectorLog(result.Result.ToString());
                        return(result);
                    }
                }
                catch (Exception ex) when(ex is DeviceCommunicationException || ex is DeviceInvalidOperationException)
                {
                    // Don't fail the activity if there is an exception here.
                    GatherTriageData(device, $"Device could not return to home screen: {ex.ToString()}");
                }
                UpdateStatus("Activity finished.");
            }
            catch (DeviceCommunicationException ex)
            {
                if (ex.Data.Contains(_exceptionCategoryData) && ex.Data[_exceptionCategoryData].Equals(ConnectorExceptionCategory.EnvironmentError.GetDescription()))
                {
                    result = new PluginExecutionResult(PluginResult.Error, ex, $"Webview communication error - You need check \"Debuggable option enable\" to hpk file: {ex.Message}");
                }
                else
                {
                    result = new PluginExecutionResult(PluginResult.Failed, ex, $"Device communication error: {ex.Message}");
                }
            }
            catch (DeviceInvalidOperationException ex)
            {
                result = new PluginExecutionResult(PluginResult.Failed, ex, $"Device automation error: {ex.Message}");
            }
            catch (DeviceWorkflowException ex)
            {
                if (ex.Data.Contains(_exceptionCategoryData))
                {
                    result = new PluginExecutionResult(PluginResult.Failed, ex, ex.Data[_exceptionCategoryData].ToString());
                }
                else
                {
                    result = new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error.");
                }

                GatherTriageData(device, ex.ToString());
            }
            catch (Exception ex)
            {
                GatherTriageData(device, $"Unexpected exception, gathering triage data: {ex.ToString()}");
                throw;
            }
            SubmitConnectorLog(result.Result.ToString());
            return(result);
        }
Example #20
0
        /// <summary>
        /// Sets the badge box.
        /// </summary>
        /// <param name="availableAssets">The available assets.</param>
        /// <param name="deviceAsset">The device asset.</param>
        /// <returns></returns>
        private BadgeBoxInfo SetBadgeBox(Framework.Assets.AssetInfoCollection availableAssets, IDeviceInfo deviceAsset)
        {
            ExecutionServices.SystemTrace.LogDebug($"Number of assets: {availableAssets.Count.ToString()}");
            BadgeBoxInfo badgeBoxAsset = null;

            if (availableAssets.OfType <BadgeBoxInfo>().Any())
            {
                ExecutionServices.SystemTrace.LogDebug($"Printer ID of badge box:");
                ExecutionServices.SystemTrace.LogDebug(availableAssets.OfType <BadgeBoxInfo>().FirstOrDefault().PrinterId);
                ExecutionServices.SystemTrace.LogDebug($"Device Asset: " + deviceAsset.AssetId);

                badgeBoxAsset = availableAssets.OfType <BadgeBoxInfo>().FirstOrDefault(n => n.PrinterId == deviceAsset.AssetId);
            }
            if (badgeBoxAsset == null)
            {
                throw new Exception($"No Badge Box associated with device {deviceAsset.AssetId}, {deviceAsset.Address}");
            }
            return(badgeBoxAsset);
        }
        /// <summary>
        /// Performs the pull print.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <param name="result">The result.</param>
        /// <param name="device">The device.</param>
        /// <param name="proxy">The proxy.</param>
        /// <returns>HP.ScalableTest.Framework.Plugin.PluginExecutionResult.</returns>
        private PluginExecutionResult PerformPullPrint(PluginExecutionData executionData, PluginExecutionResult result, HP.ScalableTest.Framework.Assets.IDeviceInfo device, IDeviceProxy proxy)
        {
            try
            {
                // Log the device being used
                ExecutionServices.DataLogger.Submit(new ActivityExecutionAssetUsageLog(executionData, device));
                UpdateStatus($"Executing as user [{executionData?.Credential?.UserName}]");

                // Reset and make sure we're on home screen
                proxy.DeviceUI.PressKey(KeyCode.ResetKey);
                proxy.DeviceUI.WaitForHomeScreen(TimeSpan.FromSeconds(15));

                // Press the PullPrint example solution button
                var solutionButton = _data.TopLevelButtonName;
                UpdateStatus($"Pressing button [{solutionButton}]");
                proxy.DeviceUI.NavigateToSolution(solutionButton);
                proxy.BrowserUI.WaitForIdle(TimeSpan.FromSeconds(15));

                // Get the list of documents available to print
                UpdateStatus("Checking for available documents");
                Dictionary <string, string>[] checkboxes = proxy.BrowserUI.GetElements("span[class='checkbox']");
                UpdateStatus($"{checkboxes.Length} documents found");

                // Set result to skip if no documents found
                if (checkboxes.Length <= 0)
                {
                    result = new PluginExecutionResult(PluginResult.Skipped, "No documents found to print");
                }
                else
                {
                    UpdateStatus("Checking the the first checkbox");
                    // click the first item in the list to check the checkbox
                    proxy.BrowserUI.ClickElement(checkboxes[0]["id"]);

                    // press the print button
                    UpdateStatus("Clicking the print button");
                    proxy.BrowserUI.ClickElement("printButton");

                    // wait for idle for the job to finish
                    proxy.DeviceProperties.WaitForIdle(TimeSpan.FromSeconds(30));
                    result = new PluginExecutionResult(PluginResult.Passed);
                }
            }
            finally
            {
                try
                {
                    // Navigate through device sign out procedure (if applicable) and return to home screen
                    proxy.DeviceUI.NavigateSignOut();
                    proxy.DeviceUI.WaitForHomeScreen(TimeSpan.FromSeconds(10));
                }
                catch { }

                UpdateStatus("Execution complete");
                UpdateStatus("Result = " + result.Result.ToString());
            }

            return(result);
        }