public void Initialize(PluginEnvironment environment)
 {
     // Initialize the activity data with a default value
     _activityData = new ePrintAdminActivityData();
     ePrintServer_ComboBox.Initialize("ePrint");
     hpacServer_ComboBox.Initialize();
 }
        public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
        {
            _activityData      = configuration.GetMetadata <ePrintAdminActivityData>();
            _selectedAssetList = ConfigurationServices.AssetInventory.GetAssets(configuration.Assets.SelectedAssets);
            if (_selectedAssetList != null && _selectedAssetList.Any())
            {
                deviceId_TextBox.Text = _selectedAssetList.First().AssetId;
            }
            _selectedServer = configuration.Servers.SelectedServers.FirstOrDefault();
            ePrintServer_ComboBox.Initialize(_selectedServer, "ePrint");

            adminUser_textBox.Text     = _activityData.ePrintAdminUser;
            adminPassword_textBox.Text = _activityData.ePrintAdminPassword;

            tasks_dataGridView.DataSource = _activityData.ePrintAdminTasks;
        }
Example #3
0
        /// <summary>
        /// Sets up the scan job.
        /// </summary>
        /// <param name="device">The device.</param>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            bool          activityFailed = false;
            StringBuilder failedMessages = new StringBuilder();

            _activityData = executionData.GetMetadata <ePrintAdminActivityData>();
            _credential   = executionData.Credential;

            PrintDeviceInfo printDeviceInfo = (PrintDeviceInfo)executionData.Assets.First();

            _device = DeviceConstructor.Create(printDeviceInfo);

            _userDnsName    = executionData.Environment.UserDnsDomain;
            _ePrintServerIp = executionData.Servers.First().Address;
            CookieCollection loginCookie = new CookieCollection();

            if (Login(loginCookie).Result == PluginResult.Failed)
            {
                return(new PluginExecutionResult(PluginResult.Failed, "Unable to login to eprint server"));
            }

            foreach (var eprintTask in _activityData.ePrintAdminTasks)
            {
                activityStatus_dataGridView.DataSource = null;
                try
                {
                    switch (eprintTask.Operation)
                    {
                    case EprintAdminToolOperation.AddPrinteripv4:
                    case EprintAdminToolOperation.AddPrinterHpac:
                    case EprintAdminToolOperation.AddPrinterPJL:
                    {
                        ePrintAddPrinter(eprintTask, loginCookie);
                    }
                    break;

                    case EprintAdminToolOperation.DeletePrinter:
                    {
                        ePrintDeletePrinter(eprintTask, loginCookie);
                    }
                    break;

                    case EprintAdminToolOperation.ImportPrinter:
                    {
                        ePrintImportPrinter(eprintTask, loginCookie);
                    }
                    break;

                    case EprintAdminToolOperation.RegularUser:
                    case EprintAdminToolOperation.GuestUser:
                    {
                        AddUser(eprintTask, loginCookie);
                    }
                    break;

                    case EprintAdminToolOperation.SendPrintJob:
                    {
                        ePrintSendPrintJob(eprintTask, loginCookie);
                    }
                    break;
                    }

                    activityStatus_dataGridView.Visible = false;

                    activityStatus_dataGridView.DataSource = _activityData.ePrintAdminTasks;
                    activityStatus_dataGridView.Visible    = true;
                }
                catch (Exception ex)
                {
                    failedMessages.AppendLine($"Failed for ActivityTask:{eprintTask.Operation} with Exception: {ex.Message}");
                    activityFailed = true;
                }
            }
            return(activityFailed ? new PluginExecutionResult(PluginResult.Failed, string.Join(",", failedMessages)) : new PluginExecutionResult(PluginResult.Passed, "All test cases passed"));
        }