/// <summary>
 /// Initializes a new instance of the <see cref="JediOmniHpRoamApp"/> class.
 /// </summary>
 /// <param name="device">The device.</param>
 public JediOmniHpRoamApp(JediOmniDevice device)
     : base(device.Snmp, device.ControlPanel)
 {
     _controlPanel         = device.ControlPanel;
     _launchHelper         = new JediOmniLaunchHelper(device);
     _jediOmniPopupManager = new JediOmniPopupManager(_controlPanel);
     _masthead             = new JediOmniMasthead(device);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="JediOmniAppAuthenticatorBase" /> class.
        /// </summary>
        /// <param name="controlPanel">The <see cref="JediOmniControlPanel"/> object.</param>
        /// <param name="credential">The <see cref="AuthenticationCredential"/> object.</param>
        /// <param name="pacekeeper">The <see cref="Pacekeeper"/> object.</param>
        protected JediOmniAppAuthenticatorBase(JediOmniControlPanel controlPanel, AuthenticationCredential credential, Pacekeeper pacekeeper)
        {
            ControlPanel = controlPanel;
            Credential = credential;
            Pacekeeper = pacekeeper;
            _popupManager = new JediOmniPopupManager(controlPanel);

            _oxpdEngine = new Lazy<OxpdBrowserEngine>(() => new OxpdBrowserEngine(controlPanel));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="JediOmniNetworkFolderApp" /> class.
        /// </summary>
        /// <param name="device">The device.</param>
        public JediOmniNetworkFolderApp(JediOmniDevice device)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            _device           = device;
            _controlPanel     = _device.ControlPanel;
            _optionsManager   = new JediOmniNetworkFolderJobOptions(device);
            _executionManager = new JediOmniJobExecutionManager(device);
            _popupManager     = new JediOmniPopupManager(device);
            _launchHelper     = new JediOmniLaunchHelper(device);
            Pacekeeper        = new Pacekeeper(TimeSpan.Zero);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="JediOmniDssWorkflowApp" /> class.
        /// </summary>
        /// <param name="device">The device.</param>
        public JediOmniDssWorkflowApp(JediOmniDevice device)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            _device              = device;
            _controlPanel        = _device.ControlPanel;
            _masthead            = new JediOmniMasthead(device);
            _launchHelper        = new JediOmniLaunchHelper(device);
            _notificationPanel   = new JediOmniNotificationPanel(device);
            _enhancedWorkflowApp = new DssEnhancedWorkflowApp(_controlPanel);
            _idleTimeoutOffset   = device.PowerManagement.GetInactivityTimeout().Subtract(TimeSpan.FromSeconds(10));
            _popupManager        = new JediOmniPopupManager(device);
            _engine              = new OxpdBrowserEngine(_device.ControlPanel, DssWorkflowResource.DssWorkflowJavaScript);

            Pacekeeper = new Pacekeeper(TimeSpan.Zero);
        }
示例#5
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);
        }