Exemple #1
0
        /// <summary>
        /// File Name and Folder Path Setting
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="emailInfo"></param>
        public void EmailJobSetting(string fileName, ScanToEmailInfo emailInfo)
        {
            UpdateStatus($"Starting Email Job Setting");
            UpdateStatus($"from : {emailInfo.From}, to : {emailInfo.To}, cc : {emailInfo.Cc}, bcc : {emailInfo.Bcc}, subject : {emailInfo.Subject}, filename : {fileName}, message : {emailInfo.Message}");

            ////////////////////////From
            if (!String.IsNullOrEmpty(emailInfo.From) && LinkUI.Controller.DoesScreenContains(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/tagsEditTextFrom")))
            {
                ClickTextbox("tagsEditTextFrom");
                if (!LinkUI.Controller.SetText(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/tagsEditTextFrom"), emailInfo.From))
                {
                    throw new DeviceWorkflowException($"Fail to set the From field: {emailInfo.From}");
                }
                PressBackKey();
            }
            ////////////////////////

            ////////////////////////To
            if (!String.IsNullOrEmpty(emailInfo.To) && LinkUI.Controller.DoesScreenContains(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/tagsEditTextTo")))
            {
                ClickTextbox("tagsEditTextTo");
                if (!LinkUI.Controller.SetText(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/tagsEditTextTo"), emailInfo.To))
                {
                    throw new DeviceWorkflowException($"Fail to set the To field: {emailInfo.To}");
                }
                PressBackKey();
            }
            ////////////////////////

            ////////////////////////Cc
            if (!String.IsNullOrEmpty(emailInfo.Cc) && LinkUI.Controller.DoesScreenContains(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/tagsEditTextCc")))
            {
                ClickTextbox("tagsEditTextCc");
                if (!LinkUI.Controller.SetText(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/tagsEditTextCc"), emailInfo.Cc))
                {
                    throw new DeviceWorkflowException($"Fail to set the Cc field: {emailInfo.Cc}");
                }
                PressBackKey();
            }
            ////////////////////////

            ////////////////////////Bcc
            if (!String.IsNullOrEmpty(emailInfo.Bcc) && LinkUI.Controller.DoesScreenContains(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/tagsEditTextBcc")))
            {
                ClickTextbox("tagsEditTextBcc");
                if (!LinkUI.Controller.SetText(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/tagsEditTextBcc"), emailInfo.Bcc))
                {
                    throw new DeviceWorkflowException($"Fail to set the Bcc field: {emailInfo.Bcc}");
                }
                PressBackKey();
            }
            ////////////////////////

            ////////////////////////Subject
            if (!String.IsNullOrEmpty(emailInfo.Subject) && LinkUI.Controller.DoesScreenContains(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/editTextSubject")))
            {
                ClickTextbox("editTextSubject");
                if (!LinkUI.Controller.SetText(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/editTextSubject"), emailInfo.Subject))
                {
                    throw new DeviceWorkflowException($"Fail to set the Subject field: {emailInfo.Subject}");
                }
                PressBackKey();
            }
            ////////////////////////

            ////////////////////////File Name
            LinkUI.Controller.Swipe(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/fileNameTextViewMessage"), To.Up);
            if (!String.IsNullOrEmpty(fileName) && LinkUI.Controller.DoesScreenContains(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/editTextDescription")))
            {
                ClickTextbox("editTextDescription");
                if (!LinkUI.Controller.SetText(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/editTextDescription"), fileName))
                {
                    throw new DeviceWorkflowException($"Fail to set the Filename filed: {fileName}");
                }
                PressBackKey();
            }
            ////////////////////////

            ///////////////////////Message
            LinkUI.Controller.Swipe(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/fileNameTextViewMessage"), To.Up);
            if (!String.IsNullOrEmpty(emailInfo.Message) && LinkUI.Controller.DoesScreenContains(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/editTextMessage")))
            {
                ClickTextbox("editTextMessage");
                if (!LinkUI.Controller.SetText(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/editTextMessage"), emailInfo.Message))
                {
                    throw new DeviceWorkflowException($"Fail to set the Message field: {emailInfo.Message}");
                }
                PressBackKey();
            }
            ////////////////////////
        }
        /// <summary>
        /// Sets up the LinkScanApps scan job.
        /// </summary>
        /// <param name="device">The de vice.</param>
        protected override void SetupJob(IDevice device)
        {
            if (device == null)
            {
                throw new ArgumentNullException("device");
            }

            _device = device;

            _linkScanApp = new LinkScanApp(_data.ScanDestination, device);
            _linkScanApp.WorkflowLogger         = WorkflowLogger;
            _linkScanApp.ActivityStatusChanged += LinkAppsActivityStatusChanged;

            UpdateStatus($"Starting App Launch :: {EnumUtil.GetDescription(_data.ScanDestination)}");
            _linkScanApp.Launch();

            UpdateStatus($"Starting navigate to destination :: {EnumUtil.GetDescription(_data.ScanDestination)}");

            if (!_data.FileNameIsChecked)
            {
                _data.FileName = FilePrefix.ToString();
            }
            if (!_data.SubjectIsChecked)
            {
                _data.Subject = FilePrefix.ToString();
            }
            if (!_data.MessageIsChecked)
            {
                _data.Message = "";
            }
            try
            {
                switch (_data.ScanDestination)
                {
                case LinkScanDestination.Email:
                    UpdateStatus($"Starting Email Job Setting");
                    ScanToEmailInfo emailInfo = new ScanToEmailInfo()
                    {
                        From    = _data.From,
                        To      = _data.To,
                        Cc      = _data.Cc,
                        Bcc     = _data.Bcc,
                        Subject = _data.Subject,
                        Message = _data.Message
                    };
                    _linkScanApp.EmailJobSetting(_data.FileName, emailInfo);
                    break;

                case LinkScanDestination.FTP:
                    UpdateStatus($"Starting FTP Job Setting");
                    ScanToSMBFTPInfo ftpInfo = new ScanToSMBFTPInfo()
                    {
                        Server     = _data.Server,
                        UserName   = _data.UserName,
                        Password   = _data.Password,
                        DomainPort = _data.DomainPort,
                        FolderPath = _data.FolderPath
                    };
                    _linkScanApp.FileNameFolderPathSetting(_data.FileName, ftpInfo);
                    break;

                case LinkScanDestination.SMB:
                    UpdateStatus($"Starting SMB Job Setting");
                    ScanToSMBFTPInfo smbInfo = new ScanToSMBFTPInfo()
                    {
                        Server     = _data.Server,
                        UserName   = _data.UserName,
                        Password   = _data.Password,
                        DomainPort = _data.DomainPort
                    };
                    _linkScanApp.FileNameFolderPathSetting(_data.FileName, smbInfo);
                    break;

                default:
                    throw new DeviceWorkflowException($"Scan destination is not valid: {EnumUtil.GetDescription(_data.ScanDestination)}");
                }

                UpdateStatus($"Starting selection options :: {EnumUtil.GetDescription(_data.ScanDestination)}");

                SetOptions(_linkScanApp.ScanOptionManager, _data.ScanOptions);
            }
            catch (DeviceWorkflowException ex)
            {
                if (ex.Data.Contains(_exceptionCategoryData))
                {
                    throw;
                }

                DeviceWorkflowException e = new DeviceWorkflowException(ex.Message + $" :: {EnumUtil.GetDescription(_data.ScanDestination)}", ex);
                e.Data.Add(_exceptionCategoryData, ConnectorExceptionCategory.SelectOptions.GetDescription());
                throw e;
            }
        }