Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UIExerciser" /> class.
 /// </summary>
 /// <param name="device">The <see cref="JediDevice" /> object.</param>
 internal UIExerciser(DirtyDeviceManager owner, JediOmniDevice device, JediOmniPreparationManager preparationManager)
 {
     _owner              = owner;
     _device             = device;
     _preparationManager = preparationManager;
     _controlPanel       = device.ControlPanel;
 }
Пример #2
0
        private void InitializeDevice()
        {
            try
            {
                OnUpdateStatus(this, "Initializing device.");
                _device             = (JediOmniDevice)DeviceConstructor.Create(_deviceInfo);
                _preparationManager = new JediOmniPreparationManager(_device);

                _digitalSendExerciser = new DigitalSendExerciser(this, _device, _preparationManager);
                _ewsExerciser         = new EwsExerciserViaSeleniumWebDriver(this, _device);
                _printExerciser       = new PrintExerciser(this, _device);
                _snmpExerciser        = new SnmpExerciser(this, _device);
                _uiExerciser          = new UIExerciser(this, _device, _preparationManager);
                _webServicesExerciser = new WebServicesExerciser(this, _device);

                _preparationManager.InitializeDevice(true);
            }
            catch (Exception ex)
            {
                OnUpdateStatus(this, ex.ToString());
                OnUpdateStatus(this, "Cleaning up.");

                _device?.Dispose();

                // Log the error and re-throw.
                ExecutionServices.SystemTrace.LogError(ex);
                throw;
            }
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DigitalSendExerciser" /> class.
 /// </summary>
 /// <param name="device">The <see cref="JediDevice" /> object.</param>
 internal DigitalSendExerciser(DirtyDeviceManager owner, JediOmniDevice deviceDat, JediOmniPreparationManager preparationManager)
 {
     _owner                 = owner;
     _deviceDat             = deviceDat;
     _preparationManager    = preparationManager;
     _webServices           = _deviceDat.WebServices;
     DateTimeStampForNaming = DateTime.Now.ToString($"yyyyMMdd_HHmmss");
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="JediOmniTraySettingsApp" /> class.
        /// </summary>
        /// <param name="device">The device.</param>
        public JediOmniTraySettingsApp(JediOmniDevice device)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            _device             = device;
            _controlPanel       = _device.ControlPanel;
            _preparationManager = new JediOmniPreparationManager(device);
            Pacekeeper          = new Pacekeeper(TimeSpan.Zero);
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JediOmniContactsApp" /> class.
        /// </summary>
        /// <param name="device">The device.</param>
        public JediOmniContactsApp(JediOmniDevice device)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            _device       = device;
            _controlPanel = _device.ControlPanel;
            // _optionsManager = new JediOmniFaxJobOptions(device);
            _preparationManager = new JediOmniPreparationManager(device);
            Pacekeeper          = new Pacekeeper(TimeSpan.Zero);
        }
Пример #6
0
        private void AuthenticateOmni(string deviceIP, string userName)
        {
            IDevice device = DeviceFactory.Create(deviceIP, "!QAZ2wsx");
            //AuthenticationCredential credential = new AuthenticationCredential(userName, "1qaz2wsx", "etl.boi.rd.hpicorp.net");
            AuthenticationCredential credential = new AuthenticationCredential("03000");

            JediOmniPreparationManager prepMgr = new JediOmniPreparationManager(((JediOmniDevice)device));
            JediOmniLaunchHelper       helper  = new JediOmniLaunchHelper((JediOmniDevice)device);

            // Set up the device for Authentication
            prepMgr.Reset();
            helper.PressSignInButton();

            IAuthenticator authenticator = AuthenticatorFactory.Create(device, credential, AuthenticationProvider.Auto);

            authenticator.Authenticate();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OmniAuthenticatorDriver"/> class.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="solutionButton">The solution button.</param>
        public OmniAuthenticatorDriver(JediOmniDevice device, string solutionButton, DeviceWorkflowLogger workflowLogger)
        {
            _omniDevice   = device;
            _controlPanel = device.ControlPanel;
            _launchHelper = new JediOmniLaunchHelper(device);
            _launchHelper.WorkflowLogger = workflowLogger;

            _preparationManager = new JediOmniPreparationManager(_omniDevice);
            _preparationManager.WorkflowLogger = workflowLogger;

            _solutionButton = solutionButton;
            _workflowLogger = workflowLogger;

            _initMethod = AuthInitMethod.GetInitiationMethod(solutionButton);

            PrepareDevice();
        }
Пример #8
0
        //public static void PUTCDM(string url)
        //{
        //    string final = $@"https://{url}/hp/network/ioConfig/v1/networkInterfaces/wired1/snmpv1v2Config";
        //    string jsonContent = @"{""snmpv1v2Enabled"": ""true"",""accessOption"": ""readWrite"",""readOnlyPublicAllowed"": ""true"",""readOnlyCommunityNameSet"": ""false"",""writeOnlyCommunitryNameSet"": ""false""}";
        //    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(final);
        //    request.Method = "PUT";
        //    request.ContentType = "access-control-allow-headers";
        //    request.Proxy = null;
        //    request.Credentials = new NetworkCredential("admin", "!QAZ2wsx");

        //    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
        //    ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
        //    UTF8Encoding encoding = new System.Text.UTF8Encoding();
        //    Byte[] byteArray = encoding.GetBytes(jsonContent);

        //    request.ContentLength = byteArray.Length;
        //    request.ContentType = @"application/json";

        //    using (Stream dataStream = request.GetRequestStream())
        //    {
        //        dataStream.Write(byteArray, 0, byteArray.Length);
        //    }
        //    long length = 0;
        //    try
        //    {
        //        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
        //        {
        //            Stream receiveStream = response.GetResponseStream();
        //            length = response.ContentLength;
        //            Console.WriteLine(response.StatusCode);

        //        }
        //    }
        //    catch (WebException ex)
        //    {
        //        throw ex;
        //        // Log exception and throw as for GET example above
        //    }
        //}
        #endregion


        private PluginExecutionResult UpgradeFirmware(IDeviceInfo deviceInfo)
        {
            TimeSpan              waitTimeSpan = TimeSpan.FromSeconds(4);
            Pacekeeper            pacekeeper   = new Pacekeeper(TimeSpan.FromSeconds(7));
            PluginExecutionResult result       = new PluginExecutionResult(PluginResult.Passed);

            IDevice device     = DeviceConstructor.Create(deviceInfo);
            var     omniDevice = device as JediOmniDevice;

            _preparationManager = new JediOmniPreparationManager(omniDevice);

            if (omniDevice == null)
            {
                result = new PluginExecutionResult(PluginResult.Failed, "This plugin supports only Jedi Omni devices");
                throw new DeviceWorkflowException("This plugin supports only Jedi Omni devices");
            }

            device_textBox.InvokeIfRequired(x => x.Text          = device.Address);
            currentRevision_textBox.InvokeIfRequired(x => x.Text = device.GetDeviceInfo().FirmwareRevision);
            _activityExecutionDetailLog = new ActivityExecutionDetailLog(_executionData, "FirmwareFlashMethod", "USB");
            ExecutionServices.DataLogger.Submit(_activityExecutionDetailLog);
            //_activityExecutionDetailLog = new ActivityExecutionDetailLog(_executionData, "FirmwareFlashUpgrade", _activityData.IsDowngrade ? "false" : "true");
            //ExecutionServices.DataLogger.Submit(_activityExecutionDetailLog);

            UpdateProgressBar(0);

            _preparationManager.InitializeDevice(true);
            omniDevice.ControlPanel.ScrollPressWait("#hpid-supportTools-homescreen-button",
                                                    "#hpid-supporttools-app-screen", waitTimeSpan);
            pacekeeper.Pause();



            #region handle maintanance popup
            JediOmniPopupManager popupManager = new JediOmniPopupManager(omniDevice);
            bool maintananceWindowNotSolved   = false;
            int  maintananceretries           = 0;
            while (!maintananceWindowNotSolved && maintananceretries < 2)
            {
                if (omniDevice.ControlPanel.WaitForAvailable("#hpid-tree-node-listitem-maintenance", TimeSpan.FromSeconds(5)))
                {
                    Thread.Sleep(5);

                    omniDevice.ControlPanel.PressWait("#hpid-tree-node-listitem-maintenance", "#hpid-settings-app-menu-panel", waitTimeSpan);
                }

                if (omniDevice.ControlPanel.CheckState("#hpid-maintenancemode-failed-feedback-popup", OmniElementState.VisibleCompletely)) // TimeSpan.FromSeconds(4)))
                {
                    popupManager.HandleMaintananceUnavailablePopUp();
                    maintananceWindowNotSolved = true;
                }

                maintananceretries++;
            }

            if (maintananceWindowNotSolved)
            {
                if (omniDevice.ControlPanel.WaitForAvailable("#hpid-tree-node-listitem-maintenance", TimeSpan.FromSeconds(5)))
                {
                    omniDevice.ControlPanel.PressWait("#hpid-tree-node-listitem-maintenance", "#hpid-settings-app-menu-panel", waitTimeSpan);
                }
            }
            #endregion

            if (omniDevice.ControlPanel.WaitForState("#hpid-tree-node-listitem-usbfirmwareupgrade", OmniElementState.Exists, waitTimeSpan))
            {
                omniDevice.ControlPanel.ScrollPressWait("#hpid-tree-node-listitem-usbfirmwareupgrade", "#hpid-usb-firmware-upgrade-screen", waitTimeSpan);
            }
            //var items = omniDevice.ControlPanel.GetIds("div", OmniIdCollectionType.Children);
            //foreach (var item in items)
            //{
            //    ExecutionServices.SystemTrace.LogInfo(item.ToString());
            //}

            pacekeeper.Pause();
            if (omniDevice.ControlPanel.WaitForAvailable("#hpid-firmware-bundles-list", waitTimeSpan))
            {
                //Verify USB firmware?--Lets find out
                if (omniDevice.ControlPanel.CheckState(".hp-listitem-text:contains(_)", OmniElementState.Exists))
                {
                    omniDevice.ControlPanel.ScrollPress(".hp-listitem-text:contains(_)");
                }
                else
                {
                    result = new PluginExecutionResult(PluginResult.Skipped, "Specified firmware bundle not found on USB media");
                    // throw new DeviceWorkflowException("Specified firmware bundle not found on USB media");
                }

                if (omniDevice.ControlPanel.WaitForState("#hpid-setting-install-button", OmniElementState.Enabled,
                                                         waitTimeSpan))
                {
                    omniDevice.ControlPanel.Press("#hpid-setting-install-button");
                    pacekeeper.Pause();
                }
                else
                {
                    result = new PluginExecutionResult(PluginResult.Failed, "Unable to install firmware");
                    //throw new DeviceWorkflowException("Unable to install firmware");
                }

                bool   popUpFound    = false;
                var    popUpWaitTime = DateTime.Now + TimeSpan.FromSeconds(6);
                string buttonPress   = @"";
                while (DateTime.Now < popUpWaitTime)
                {
                    popUpFound = omniDevice.ControlPanel.WaitForState("#hpid-reinstall-button", OmniElementState.Enabled, TimeSpan.FromSeconds(.5));
                    if (popUpFound)
                    {
                        buttonPress = "#hpid-reinstall-button";
                        break;
                    }
                    popUpFound = omniDevice.ControlPanel.WaitForAvailable("#hpid-upgrade-message", TimeSpan.FromSeconds(.5));
                    if (popUpFound)
                    {
                        buttonPress = "#hpid-upgrade-button";
                        break;
                    }
                    popUpFound = omniDevice.ControlPanel.WaitForState("#hpid-rollback-button", OmniElementState.Enabled, TimeSpan.FromSeconds(.5));
                    if (popUpFound)
                    {
                        buttonPress = "#hpid-rollback-button";
                        break;
                    }
                }
                switch (buttonPress)
                {
                case "#hpid-reinstall-button":
                    return(new PluginExecutionResult(PluginResult.Skipped, "This version of firmware is already installed."));

                    //omniDevice.ControlPanel.Press("#hpid-reinstall-button");
                    //pacekeeper.Pause();
                    break;

                case "#hpid-upgrade-button":
                    if (omniDevice.ControlPanel.WaitForAvailable("#hpid-upgrade-button", waitTimeSpan))
                    {
                        omniDevice.ControlPanel.Press("#hpid-upgrade-button");
                        pacekeeper.Pause();
                    }
                    break;

                case "#hpid-rollback-button":
                    result = new PluginExecutionResult(PluginResult.Skipped, "Firmware rollback not officially supported, please check that you have the right firmware");
                    return(result);

                    break;

                default:
                    result = new PluginExecutionResult(PluginResult.Failed, "Failed to find upgrade button to press");
                    return(result);
                }


                _performanceLogger.RecordEvent(DeviceWorkflowMarker.FirmwareUpdateBegin);
                UpdateProgressBar(20);
                while (omniDevice.ControlPanel.WaitForState("#hpid-firmware-install-progress-popup", OmniElementState.VisibleCompletely, waitTimeSpan))
                {
                    //do nothing
                    Application.DoEvents();

                    //let's not spam the device with check messages
                    Thread.Sleep(waitTimeSpan);
                }
                if (omniDevice.ControlPanel.WaitForAvailable("#hpid-usbfirmwareupgrade-error-msg-popup",
                                                             waitTimeSpan))
                {
                    var errorMessage = omniDevice.ControlPanel.GetValue(".hp-popup-content", "textContent",
                                                                        OmniPropertyType.Property);
                    omniDevice.ControlPanel.Press("#hpid-usbfirmwareupgrade-error-popup-button-ok");
                    result = new PluginExecutionResult(PluginResult.Failed, errorMessage);
                    throw new DeviceWorkflowException(errorMessage);
                }
                //_performanceLogger.RecordEvent(DeviceWorkflowMarker.FirmwareUpdateEnd);
                UpdateProgressBar(100);
            }
            else
            {
                var upgradeMessage = omniDevice.ControlPanel.GetValue("#hpid-usb-firmware-upgrade-message", "innerText",
                                                                      OmniPropertyType.Property);
                result = new PluginExecutionResult(PluginResult.Failed, upgradeMessage);
//                throw new DeviceWorkflowException(upgradeMessage);
            }

            return(result);
        }