Пример #1
0
        /// <summary>
        /// File Name and Folder Path Setting
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="smbftpInfo"></param>
        public void FileNameFolderPathSetting(string fileName, ScanToSMBFTPInfo smbftpInfo)
        {
            string launchAppname = GetLaunchAppId();

            if (!String.IsNullOrEmpty(fileName))
            {
                if (!LinkUI.Controller.SetText(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/etFileName"), fileName))
                {
                    throw new DeviceWorkflowException($"Fail to set the file name field: {fileName}");
                }
            }

            if (!LinkUI.Controller.Click(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/ivAddBtn")))
            {
                throw new DeviceWorkflowException($"Fail to click the Add button");
            }

            if (!LinkUI.Controller.SetText(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/et_folderPaths"), smbftpInfo.Server))
            {
                throw new DeviceWorkflowException($"Fail to set the folder path: {smbftpInfo.FolderPath}");
            }

            if (!LinkUI.Controller.Click(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/bt_done")))
            {
                throw new DeviceWorkflowException($"Fail to click the Save button");
            }

            if (!String.IsNullOrEmpty(smbftpInfo.UserName))
            {
                LinkUI.Controller.Click(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/et_username"));
                if (!LinkUI.Controller.SetText(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/et_username"), smbftpInfo.UserName))
                {
                    throw new DeviceWorkflowException($"Fail to set the User Name: {smbftpInfo.UserName}");
                }
            }

            if (!String.IsNullOrEmpty(smbftpInfo.Password))
            {
                LinkUI.Controller.Click(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/et_password"));
                if (!LinkUI.Controller.SetText(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/et_password"), smbftpInfo.Password))
                {
                    throw new DeviceWorkflowException($"Fail to set the Password: {smbftpInfo.Password}");
                }
            }

            if (!String.IsNullOrEmpty(smbftpInfo.FolderPath))
            {
                LinkUI.Controller.Click(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/et_folder_path"));
                if (!LinkUI.Controller.SetText(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/et_folder_path"), smbftpInfo.FolderPath))
                {
                    throw new DeviceWorkflowException($"Fail to set the FTP Folder Path: {smbftpInfo.FolderPath}");
                }
            }

            if (!String.IsNullOrEmpty(smbftpInfo.DomainPort))
            {
                string resourceid = null;
                if (Destination == LinkScanDestination.FTP)
                {
                    resourceid = "et_port";
                }
                else if (Destination == LinkScanDestination.SMB)
                {
                    resourceid = "et_domain";
                }

                LinkUI.Controller.Click(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/{resourceid}"));
                if (!LinkUI.Controller.SetText(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/{resourceid}"), smbftpInfo.DomainPort))
                {
                    throw new DeviceWorkflowException($"Fail to set the Domain: {smbftpInfo.DomainPort}");
                }
            }

            LinkUI.Controller.PressKey(4);

            if (!LinkUI.Controller.Click(new UiSelector().ResourceId($"{LinkScanAppsPackageName}:id/bt_ok")))
            {
                throw new DeviceWorkflowException($"Fail to click the OK button");
            }
        }
        /// <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;
            }
        }