/// <summary> /// Creates and returns a <see cref="PluginConfigurationData" /> instance containing the /// configuration data from this control. /// </summary> /// <returns>The configuration data.</returns> public PluginConfigurationData GetConfiguration() { _data = new TwainDriverActivityData { TwainOperation = _selectedOperation }; if (_selectedOperation == TwainOperation.Install) { _data.SetupFileName = setupPath_TextBox.Text; } else if (_selectedOperation == TwainOperation.ScanConfiguration) { _data.TwainConfigurations = _selectedconfiguration; _data.ItemType = EnumUtil.GetByDescription <ItemType>(itemType_ComboBox.SelectedItem.ToString()); _data.PageSides = EnumUtil.GetByDescription <PageSides>(pageSides_ComboBox.SelectedItem.ToString()); _data.PageSize = EnumUtil.GetByDescription <PageSize>(pageSize_ComboBox.SelectedItem.ToString()); _data.Source = EnumUtil.GetByDescription <Source>(source_ComboBox.SelectedItem.ToString()); _data.ColorMode = EnumUtil.GetByDescription <ColorMode>(colorMode_ComboBox.SelectedItem.ToString()); _data.FileType = EnumUtil.GetByDescription <FileType>(fileType_ComboBox.SelectedItem.ToString()); _data.SendTo = EnumUtil.GetByDescription <SendTo>(sendTo_ComboBox.SelectedItem.ToString()); _data.ShortcutSettings = EnumUtil.GetByDescription <ShortcutSettings>(shortcutSettings_ComboBox.SelectedItem.ToString()); _data.SharedFolderPath = saveToFolderPath_TextBox.Text; _data.EmailAddress = emailAddress_TextBox.Text; _data.IsPinRequired = pinRequired_CheckBox.Checked; _data.IsReservation = enableReservation_CheckBox.Checked; _data.Pin = pin_TextBox.Text; } return(new PluginConfigurationData(_data, "1.0") { Assets = assetSelectionControl.AssetSelectionData, }); }
private PluginExecutionResult RunTwain(IDevice device, PluginExecutionData executionData) { PluginExecutionResult result = new PluginExecutionResult(PluginResult.Passed); _activityData = _executionData.GetMetadata <TwainDriverActivityData>(); var preparationManager = DevicePreparationManagerFactory.Create(device); preparationManager.InitializeDevice(true); TopCatUIAutomation.Initialize(); if (_activityData.TwainOperation == TwainOperation.Install) { InstallTwainDriver(device); } else if (_activityData.TwainOperation == TwainOperation.DeviceAddition) { DeviceAddition(device); } else { ConfigureSettings(device, executionData.SessionId, executionData.Credential.UserName); } preparationManager.Reset(); return(result); }
private static void JobReservationSettings(TwainDriverActivityData twainDriver) { _hpscanConfiguration.Button1903Button.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); string machineName = Environment.MachineName; JobReservation jobReservation = new JobReservation(_modelName, machineName); if (twainDriver.IsReservation) { if (!jobReservation.UsePINButton190CheckBox.IsEnabled()) { jobReservation.EnableReservatiCheckBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); } if (twainDriver.IsPinRequired) { if (!jobReservation.JobNameHOLLAEdiEdit.IsEnabled()) { jobReservation.UsePINButton190CheckBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); } jobReservation.JobNameHOLLAEdiEdit.PerformHumanAction(x => x.EnterText(twainDriver.Pin, WindowsTimeout)); } else { if (jobReservation.JobNameHOLLAEdiEdit.IsEnabled()) { jobReservation.UsePINButton190CheckBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); } } } else { if (jobReservation.UsePINButton190CheckBox.IsEnabled()) { jobReservation.EnableReservatiCheckBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); } } jobReservation.OKButton1156Button.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); }
public static void ScanOperation(TwainDriverActivityData twainDriver, string sessionId, string userName) { if ((twainDriver.TwainConfigurations.ToString() == TwainConfiguration.SavesAsPdf.ToString()) || (twainDriver.TwainConfigurations.ToString() == TwainConfiguration.SaveAsJpeg.ToString())) { SaveToFolder(twainDriver.SharedFolderPath, sessionId, userName); } else if ((twainDriver.TwainConfigurations.ToString() == TwainConfiguration.EmailAsPdf.ToString()) || (twainDriver.TwainConfigurations.ToString() == TwainConfiguration.EmailAsJpeg.ToString())) { SendToEmail(twainDriver.EmailAddress, twainDriver.TwainConfigurations.ToString()); } else { if (twainDriver.SendTo.ToString() == SendTo.LocalorNetworkfolder.ToString()) { SaveToFolder(twainDriver.SharedFolderPath, sessionId, userName); } else { SendToEmail(twainDriver.EmailAddress, twainDriver.TwainConfigurations.ToString()); } } }
/// <summary> /// Device side operation for Twain Scan /// </summary> /// <param name="twainDriver"></param> /// <param name="deviceDetails"></param> public static void ExecuteJob(IDevice deviceDetails, TwainDriverActivityData twainDriver) { JediOmniDevice device = (JediOmniDevice)deviceDetails; IDevicePreparationManager preparationManager = DevicePreparationManagerFactory.Create(device); preparationManager.WakeDevice(); //Checking For Home Screen if (!device.ControlPanel.WaitForState("#hpid-homescreen-logo-icon", OmniElementState.VisibleCompletely, TimeSpan.FromSeconds(1))) { preparationManager.NavigateHome(); } device.ControlPanel.ScrollPress("#hpid-scan-homescreen-button"); if (device.ControlPanel.WaitForState("#hpid-remoteScanRequest-homescreen-button", OmniElementState.Exists)) { device.ControlPanel.ScrollToItem("#hpid-remoteScanRequest-homescreen-button"); device.ControlPanel.PressWait("#hpid-remoteScanRequest-homescreen-button", "#hpid-remote-scan-request-landing-page"); if (device.ControlPanel.WaitForState("#hpid-remote-scan-request-job-list-item", OmniElementState.Exists)) { if (device.ControlPanel.WaitForState("#hpid-remote-scan-request-job-list-item", OmniElementState.Useable, ScreenWaitTimeout)) { device.ControlPanel.Press("#hpid-remote-scan-request-job-list-item:first"); } else { device.ControlPanel.Press("#hpid-remote-scan-request-unlock-private-jobs:first"); if (device.ControlPanel.CheckState("#undefined", OmniElementState.Exists)) { device.ControlPanel.PressWait("#hpid-pin-to-unlock-job-textbox", "#hpid-keyboard", ShortScreenWaitTimeout); device.ControlPanel.TypeOnVirtualKeyboard(twainDriver.Pin); //Check for 4.3 inch control panel where the keypad/keyboard hides the 'OK' button after entering the Pin/Password. //Close the numeric keypad after PIN is entered if (device.ControlPanel.CheckState("#hpid-keypad-key-close", OmniElementState.Exists)) { device.ControlPanel.Press("#hpid-keypad-key-close"); } //Close the virtual keyboard after PIN/Password is entered else if (device.ControlPanel.CheckState("#hpid-keyboard-key-done", OmniElementState.Exists)) { device.ControlPanel.Press("#hpid-keyboard-key-done"); } device.ControlPanel.Press("#hpid-button-ok"); //Automatic selection of job was not happening when reservation was enabled and a password is set for Remote Scan Request using Twain driver in the previous device firmware.Now the issue is fixed in device firmware 2458466 and above //Hence commenting the below line of code //device.ControlPanel.Press("#hpid-remote-scan-request-job-list-item:first"); if (device.ControlPanel.CheckState(".hp-popup-modal-overlay", OmniElementState.Exists)) { throw new DeviceWorkflowException("Invalid Pin/Pin Not Entered"); } } } if (device.ControlPanel.WaitForState("#hpid-button-remote-scan-request-start", OmniElementState.Useable, ScreenWaitTimeout)) { device.ControlPanel.Press("#hpid-button-remote-scan-request-start"); if (device.ControlPanel.WaitForState("#hpid-button-ok", OmniElementState.Exists, ShortScreenWaitTimeout)) { device.ControlPanel.Press("#hpid-button-ok"); device.ControlPanel.Press("#hpid-button-remote-scan-request-start"); } } } else { throw new DeviceWorkflowException("No Remote scan jobs found."); } } else { throw new DeviceWorkflowException("Remote Scan Request was not found in the scan folder."); } if (device.ControlPanel.WaitForState("#hpid-message-center-screen", OmniElementState.Exists, ShortScreenWaitTimeout)) { throw new DeviceWorkflowException("There is an error displayed on the device, Please check the device and try again"); } }
/// <summary> /// Configuration Settings for Twain Scan /// </summary> /// <param name="twainDriver"></param> /// <param name="deviceDetails"></param> public static bool ConfigureSettings(IDevice deviceDetails, TwainDriverActivityData twainDriver) { // Get the common desktop directory var shortcut = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory), "HP Scan Twain.lnk"); if (File.Exists(shortcut)) { ProcessStartInfo processInfo = new ProcessStartInfo(shortcut) { UseShellExecute = true, Verb = "runas" }; Process.Start(processInfo); } else { throw new Exception("Desktop shortcut not found"); } _modelName = deviceDetails.GetDeviceInfo().ModelName; _hpscanConfiguration = new HPScanTwain(UIAFramework.ManagedUIA); _saveOperations = new SaveOperations(_modelName); CommunicationError communicationError = new CommunicationError(_modelName); try { Retry.WhileThrowing(() => _hpscanConfiguration.SaveasPDFListItem.IsAvailable(), 15, TimeSpan.FromSeconds(3), new List <Type>() { typeof(Exception) }); //Selecting the Configuration switch (twainDriver.TwainConfigurations) { case TwainConfiguration.SavesAsPdf: _hpscanConfiguration.SaveasPDFListItem.Select(WindowsTimeout); _hpscanConfiguration.SaveasPDFListItem.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); break; case TwainConfiguration.SaveAsJpeg: _hpscanConfiguration.SaveasJPEGListItem.Select(WindowsTimeout); _hpscanConfiguration.SaveasJPEGListItem.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); break; case TwainConfiguration.EmailAsPdf: _hpscanConfiguration.EmailasPDFListItem.Select(WindowsTimeout); _hpscanConfiguration.EmailasPDFListItem.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); break; case TwainConfiguration.EmailAsJpeg: _hpscanConfiguration.EmailasJPEGListItem.Select(WindowsTimeout); _hpscanConfiguration.EmailasJPEGListItem.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); break; case TwainConfiguration.EveryDayScan: _hpscanConfiguration.EverydayScanListItem.Select(WindowsTimeout); _hpscanConfiguration.EverydayScanListItem.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); break; case TwainConfiguration.NewScanShortCut: _hpscanConfiguration.CreateNewScanShButton.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); break; } //Creating Shortcut if (twainDriver.TwainConfigurations.ToString() == TwainConfiguration.NewScanShortCut.ToString()) { //Creating Scan Shortcut Button CreateShortcut createShortcut = new CreateShortcut(_modelName); Thread.Sleep(ShortWaitWindowsTimeout); createShortcut.EnterthenameoftEdit.PerformHumanAction(x => x.ClickWithMouse(WindowsTimeout)); switch (twainDriver.ShortcutSettings) { case ShortcutSettings.SavesAsPdf: createShortcut.EnterthenameoftEdit.PerformHumanAction(x => x.EnterText("SaveAsPDF_shortcut", WindowsTimeout)); createShortcut.NewScanShortcutComboBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); createShortcut.SaveasPDFDup0ListItem.Select(WindowsTimeout); break; case ShortcutSettings.SaveAsJpeg: createShortcut.EnterthenameoftEdit.PerformHumanAction(x => x.EnterText("SaveAsJPEG_shortcut", WindowsTimeout)); createShortcut.NewScanShortcutComboBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); createShortcut.SaveasJPEGDup0ListItem.Select(WindowsTimeout); break; case ShortcutSettings.EmailAsPdf: createShortcut.EnterthenameoftEdit.PerformHumanAction(x => x.EnterText("EmailAsPDF_shortcut", WindowsTimeout)); createShortcut.NewScanShortcutComboBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); createShortcut.EmailasPDFDup0ListItem.Select(WindowsTimeout); break; case ShortcutSettings.EmailAsJpeg: createShortcut.EnterthenameoftEdit.PerformHumanAction(x => x.EnterText("EmailAsJPEG_shortcut", WindowsTimeout)); createShortcut.NewScanShortcutComboBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); createShortcut.EmailasJPEGDup0ListItem.Select(WindowsTimeout); break; } createShortcut.CreateButton1Button.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); if (createShortcut.OKButton1Button.IsAvailable()) { createShortcut.OKButton1Button.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); throw new Exception("Shortcut already exists"); } _hpscanConfiguration.ExitButton1007Button.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); } else { //Enabling or disabling Reservation JobReservationSettings(twainDriver); //Selecting the Item Type _hpscanConfiguration.ItemTypeComboBoComboBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); switch (twainDriver.ItemType) { case ItemType.Document: _hpscanConfiguration.DocumentListItem.Select(WindowsTimeout); break; case ItemType.Photo: _hpscanConfiguration.PhotoListItem.Select(WindowsTimeout); break; } //Selecting the Page Size _hpscanConfiguration.PageSizeComboBoComboBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); switch (twainDriver.PageSize) { case PageSize.DetectContentOnPage: if (twainDriver.ItemType.ToString() == ItemType.Document.ToString()) { _hpscanConfiguration.DetectContentonListItem.Select(WindowsTimeout); break; } else { _hpscanConfiguration.DetectPhotosListItem.Select(WindowsTimeout); break; } case PageSize.EntireScanArea: _hpscanConfiguration.EntireScanAreaListItem.Select(WindowsTimeout); break; case PageSize.Letter11Inches: _hpscanConfiguration.Letter85x11inchListItem.Select(WindowsTimeout); break; case PageSize.Legal14Inches: _hpscanConfiguration.Legal85x14incheListItem.Select(WindowsTimeout); break; case PageSize.A4: _hpscanConfiguration.A4210x297mmListItem.Select(WindowsTimeout); break; case PageSize.TwentyCrossTwentyFive: _hpscanConfiguration.A8x10in20x25cmListItem.Select(WindowsTimeout); break; } //Selecting the Source _hpscanConfiguration.SourceComboBox1ComboBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); switch (twainDriver.Source) { case Source.DocumentFeederifloaded: if (twainDriver.IsReservation) { _hpscanConfiguration.AutomaticDocumeListItem.Select(WindowsTimeout); break; } else { _hpscanConfiguration.DocumentFeederiListItem.Select(WindowsTimeout); break; } case Source.Flatbed: _hpscanConfiguration.FlatbedListItem.Select(WindowsTimeout); break; } //Selecting the Page Sides _hpscanConfiguration.PageSidesComboBComboBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); switch (twainDriver.PageSides) { case PageSides.OneSided: _hpscanConfiguration.A1sidedListItem.Select(WindowsTimeout); break; case PageSides.TwoSidedBook: _hpscanConfiguration.A2sidedbookListItem.Select(WindowsTimeout); break; case PageSides.TwoSidedTablet: _hpscanConfiguration.A2sidedtabletListItem.Select(WindowsTimeout); break; } //Selecting the ColorMode _hpscanConfiguration.ColorModeComboBComboBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); switch (twainDriver.ColorMode) { case ColorMode.BlackWhite: _hpscanConfiguration.BlackWhiteListItem.Select(WindowsTimeout); break; case ColorMode.Gray: _hpscanConfiguration.GrayListItem.Select(WindowsTimeout); break; case ColorMode.Halftone: _hpscanConfiguration.HalftoneListItem.Select(WindowsTimeout); break; case ColorMode.Color: _hpscanConfiguration.ColorListItem.Select(WindowsTimeout); break; case ColorMode.AutoDetectColor: _hpscanConfiguration.AutoDetectColorListItem.Select(WindowsTimeout); break; } //Selecting the Filetype and SendTo if the selected configuration is EveryDayScan if (twainDriver.TwainConfigurations.ToString() == TwainConfiguration.EveryDayScan.ToString()) { _hpscanConfiguration.FileTypeComboBoComboBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); switch (twainDriver.FileType) { case FileType.Bmp: _hpscanConfiguration.BMPListItem.Select(WindowsTimeout); break; case FileType.Jpeg: _hpscanConfiguration.JPEGListItem.Select(WindowsTimeout); break; case FileType.Pdf: _hpscanConfiguration.PDFListItem.Select(WindowsTimeout); break; case FileType.Png: _hpscanConfiguration.PNGListItem.Select(WindowsTimeout); break; case FileType.Tif: _hpscanConfiguration.TIFListItem.Select(WindowsTimeout); break; } //Ensure the FileType is selected Thread.Sleep(ShortWaitWindowsTimeout); _hpscanConfiguration.SendToComboBox1ComboBox.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); switch (twainDriver.SendTo) { case SendTo.Email: _hpscanConfiguration.EmailListItem.Select(WindowsTimeout); break; case SendTo.LocalorNetworkfolder: _hpscanConfiguration.LocalorNetworkfListItem.Select(WindowsTimeout); break; } } _hpscanConfiguration.ScanButton1012Button.PerformHumanAction(x => x.ClickWithMouse(MouseButton.Left, WindowsTimeout)); if (communicationError.OKButton1Button.IsAvailable(WindowsTimeout)) { throw new Exception( "Scanner Communication cannot be established/Communication with the device ended prematurely"); } } return(_hpscanConfiguration.PreparingtoscanText.IsAvailable()); } catch (Exception ex) { throw new DeviceWorkflowException(ex.Message); } }
private void ConfigureControls(TwainDriverActivityData data) { switch (data.TwainOperation) { case TwainOperation.Install: install_RadioButton.Checked = true; break; case TwainOperation.DeviceAddition: deviceAddition_RadioButton.Checked = true; break; case TwainOperation.ScanConfiguration: scanConfiguration_RadioButton.Checked = true; break; } if (data.TwainOperation == TwainOperation.Install) { setupPath_TextBox.Text = data.SetupFileName; } else if (data.TwainOperation == TwainOperation.ScanConfiguration) { switch (data.TwainConfigurations) { case TwainConfiguration.SavesAsPdf: saveAsPDF_RadioButton.Checked = true; break; case TwainConfiguration.SaveAsJpeg: saveAsJPEG_RadioButton.Checked = true; break; case TwainConfiguration.EmailAsPdf: emailAsPDF_RadioButton.Checked = true; break; case TwainConfiguration.EmailAsJpeg: emailAsJPEG_RadioButton.Checked = true; break; case TwainConfiguration.EveryDayScan: everyDayScan_RadioButton.Checked = true; break; case TwainConfiguration.NewScanShortCut: shortcut_RadioButton.Checked = true; break; } itemType_ComboBox.Text = data.ItemType.GetDescription(); pageSides_ComboBox.Text = data.PageSides.GetDescription(); pageSize_ComboBox.Text = data.PageSize.GetDescription(); source_ComboBox.Text = data.Source.GetDescription(); colorMode_ComboBox.Text = data.ColorMode.GetDescription(); fileType_ComboBox.Text = data.FileType.GetDescription(); sendTo_ComboBox.Text = data.SendTo.GetDescription(); shortcutSettings_ComboBox.Text = data.ShortcutSettings.GetDescription(); saveToFolderPath_TextBox.Text = data.SharedFolderPath; emailAddress_TextBox.Text = data.EmailAddress; enableReservation_CheckBox.Checked = data.IsReservation; pinRequired_CheckBox.Checked = data.IsPinRequired; pin_TextBox.Text = data.Pin; scanConfiguration_RadioButton_CheckedChanged(null, null); } }