private void EnterFileName() { string fileName = FilePrefix.ToString().ToLowerInvariant(); _emailApp.EnterSubject(fileName); _emailApp.EnterFileName(fileName); }
/// <summary> /// Performs ScanToEmail job on Control Panel /// </summary> /// <param name="device"></param> /// <param name="emailScanData"></param> /// <returns></returns> private PluginExecutionResult ExecuteEmailActivity(IDevice device, ScanActivityData emailScanData, IAuthenticator authenticator) { var result = new PluginExecutionResult(PluginResult.Failed); // Make sure the device is in a good state UpdateStatus($"Setting up device at address {device.Address} for user {ExecutionData.Credential.UserName}"); var devicePrepManager = DevicePreparationManagerFactory.Create(device); devicePrepManager.WorkflowLogger = WorkflowLogger; devicePrepManager.InitializeDevice(true); // Load the email application IEmailApp contentionEmailApp = EmailAppFactory.Create(device); //Launch the Scan to Email application UpdateStatus("ScanToEmail Activity: Launching the Scan To Email application..."); contentionEmailApp.Launch(authenticator, AuthenticationMode.Lazy); //Enter subject and file name ScanFilePrefix FilePrefix = new ScanFilePrefix(ExecutionData.SessionId, ExecutionData.Credential.UserName, "Email"); string fileName = FilePrefix.ToString().ToLowerInvariant(); contentionEmailApp.EnterSubject(fileName); UpdateStatus("ScanToEmail Activity: Email subject entered..."); contentionEmailApp.EnterFileName(fileName); UpdateStatus("ScanToEmail Activity: File name entered..."); List <string> emailList = new List <string>(); emailList.Add(emailScanData.EmailAddress); //Enter email address contentionEmailApp.EnterToAddress(emailList); UpdateStatus("ScanToEmail Activity: Email address entered..."); try { ScanExecutionOptions options = new ScanExecutionOptions(); options.ValidateJobExecution = false; if (emailScanData.PageCount > 1) { options.JobBuildSegments = emailScanData.PageCount; } //Finish the job UpdateStatus("ScanToEmail Activity: Finishing the activity..."); if (contentionEmailApp.ExecuteJob(options)) { result = new PluginExecutionResult(PluginResult.Passed); } // Clean up try { devicePrepManager.NavigateHome(); if (devicePrepManager.SignOutRequired()) { UpdateStatus("ScanToEmail Activity: Signing Out..."); devicePrepManager.SignOut(); } UpdateStatus("ScanToEmail Activity: Activity finished"); } catch (Exception ex) when(ex is DeviceCommunicationException || ex is DeviceInvalidOperationException) { // Don't fail the activity if there is an exception here. ExecutionServices.SystemTrace.LogWarn($"Device could not return to home screen: {ex.ToString()}"); } } finally { // End of ScanToEmail activity ExecutionServices.SystemTrace.LogDebug("ScanToEmail activity completed"); } return(result); }