コード例 #1
0
 /// <summary>
 /// Configuring the Controls during Initialization Call to Plugin
 /// </summary>
 /// <param name="data"></param>
 private void ConfigureControls(HpEasyStartActivityData data)
 {
     textBoxInstallerPath.Text  = data.HpEasyStartInstallerPath;
     checkBoxTestPage.Checked   = data.PrintTestPage;
     checkBoxSetDefault.Checked = data.SetAsDefaultDriver;
     webPackInstallation_RadioButton.Checked = data.IsWebPackInstallation;
 }
コード例 #2
0
        /// <summary>
        /// Get Configuration function to pass back the PluginActivityData to Framework
        /// </summary>
        /// <returns></returns>
        public PluginConfigurationData GetConfiguration()
        {
            HpEasyStartActivityData data = new HpEasyStartActivityData()
            {
                HpEasyStartInstallerPath = textBoxInstallerPath.Text,
                PrintTestPage            = checkBoxTestPage.Checked,
                SetAsDefaultDriver       = checkBoxSetDefault.Checked,
                IsWebPackInstallation    = webPackInstallation_RadioButton.Checked
            };

            return(new PluginConfigurationData(data, "1.0")
            {
                Assets = assetSelectionControl.AssetSelectionData,
            });
        }
コード例 #3
0
        /// <summary>
        /// Execute call for HP Easy Start Execution Engine
        /// </summary>
        /// <param name="executionData"></param>
        /// <returns></returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            _activityData = executionData.GetMetadata <HpEasyStartActivityData>();
            UpdateStatus("Retrieving the Printer Information");

            //Retrieving the printer Randomly from the Selected Assets List
            Framework.Assets.IDeviceInfo printer = executionData.Assets.GetRandom <Framework.Assets.IDeviceInfo>();
            IDevice device    = DeviceConstructor.Create(printer);
            string  modelName = device.GetDeviceInfo().ModelName;

            UpdateStatus(_activityData.IsWebPackInstallation ? "Retrieving the Full Web Pack Installer Information" : "Retrieving the HP Easy Start Installer Information");
            if (!File.Exists(_activityData.HpEasyStartInstallerPath))
            {
                return(new PluginExecutionResult(PluginResult.Failed, "Could not find the HP Easy Start Installer file/Web Pack file"));
            }

            TopCatUIAutomation.Initialize();
            UpdateStatus(_activityData.IsWebPackInstallation ? "Copying Full Web Pack Installer to Local Temp Path" : "Copying HP Easy Start Installer to Local Temp Path");
            string localSetupFile = Path.Combine(Path.GetTempPath(), Path.GetFileName(_activityData.HpEasyStartInstallerPath));

            if (!File.Exists(localSetupFile))
            {
                File.Copy(_activityData.HpEasyStartInstallerPath, localSetupFile);
            }

            UpdateStatus(_activityData.IsWebPackInstallation ? "Launching the Full Web Pack Installer" : "Launching the HP Easy Start Installer");
            ProcessStartInfo pStartInfo = new ProcessStartInfo(localSetupFile)
            {
                UseShellExecute = true,
                Verb            = "runas"
            };

            Process.Start(pStartInfo);

            //Collate all the UI Maps to the TopCat Related Activity
            List <UIMaps.UIMap> installScreenList = new List <UIMaps.UIMap>
            {
                new HpEasyStartInstall("HP Easy Start Driver Download", printer.Address),
                new HpEasyDriverInstall("HP Easy Start Driver Installation", printer.Address, modelName, _activityData.PrintTestPage, _activityData.SetAsDefaultDriver)
            };

            for (int i = 0; i < installScreenList.Count; i++)
            {
                if (_activityData.IsWebPackInstallation && i == 0)
                {
                    continue;
                }
                else
                {
                    try
                    {
                        var result = installScreenList.ElementAt(i).PerformAction();
                        if (result.Result != PluginResult.Passed)
                        {
                            return(result);
                        }
                        Thread.Sleep(20);
                    }
                    catch (Exception)
                    {
                        return(new PluginExecutionResult(PluginResult.Error, $"Failed to proceed beyond {installScreenList.ElementAt(i).ScreenName}"));
                    }
                }
            }
            return(new PluginExecutionResult(PluginResult.Passed));
        }