public ActionResult Check(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            if (!profile.ForwardToFurtherProfile.Enabled)
            {
                return(new ActionResult());
            }

            _logger.Debug("Check ForwardToFurtherProfileAction");

            var forwardGuid = profile.ForwardToFurtherProfile.ProfileGuid;

            if (forwardGuid.Equals(profile.Guid))
            {
                _logger.Error("The forward to further profile action forwards to itself.");
                return(new ActionResult(ErrorCode.ForwardToFurtherProfile_ForwardToItself));
            }

            var forwardProfile = _settingsProvider.Settings.GetProfileByGuid(forwardGuid);

            if (forwardProfile == null)
            {
                _logger.Error($"The forward to further profile action forwards to an unknown profile (Guid: {forwardGuid}.");
                return(new ActionResult(ErrorCode.ForwardToFurtherProfile_UnknownProfile));
            }

            if (HasCircularDependency(profile))
            {
                return(new ActionResult(ErrorCode.ForwardToFurtherProfile_CircularDependency));
            }

            return(new ActionResult());
        }
Пример #2
0
        private ActionResult CheckFileNameTemplate(ConversionProfile profile, CheckLevel checkLevel)
        {
            if (checkLevel == CheckLevel.Job)
            {
                return(new ActionResult()); //Job uses Job.OutputFileTemplate
            }
            if (profile.AutoSave.Enabled)
            {
                if (string.IsNullOrEmpty(profile.FileNameTemplate))
                {
                    _logger.Error("Automatic saving without filename template.");
                    return(new ActionResult(ErrorCode.AutoSave_NoFilenameTemplate));
                }
            }

            if (TokenIdentifier.ContainsTokens(profile.FileNameTemplate))
            {
                return(new ActionResult());
            }

            if (!_pathUtil.IsValidFilename(profile.FileNameTemplate))
            {
                return(new ActionResult(ErrorCode.FilenameTemplate_IllegalCharacters));
            }

            return(new ActionResult());
        }
Пример #3
0
        public ActionResult Check(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            if (!IsEnabled(profile))
            {
                return(new ActionResult());
            }

            var isJobLevelCheck = checkLevel == CheckLevel.Job;

            var account = accounts.GetDropboxAccount(profile);

            if (account == null)
            {
                return(new ActionResult(ErrorCode.Dropbox_AccountNotSpecified));
            }

            var accessToken = account.AccessToken;

            if (string.IsNullOrEmpty(accessToken))
            {
                return(new ActionResult(ErrorCode.Dropbox_AccessTokenNotSpecified));
            }

            if (!isJobLevelCheck && TokenIdentifier.ContainsTokens(profile.DropboxSettings.SharedFolder))
            {
                return(new ActionResult());
            }

            if (!ValidName.IsValidDropboxFolder(profile.DropboxSettings.SharedFolder))
            {
                return(new ActionResult(ErrorCode.Dropbox_InvalidFolderName));
            }

            return(new ActionResult());
        }
Пример #4
0
        private ActionResult CheckTargetDirectory(ConversionProfile profile, CheckLevel checkLevel)
        {
            if (checkLevel == CheckLevel.Job)
                return new ActionResult(); //Job uses Job.OutputFilenameTemplate

            if (!profile.AutoSave.Enabled && string.IsNullOrWhiteSpace(profile.TargetDirectory))
                return new ActionResult(); // Valid LastSaveDirectory-Trigger

            if (profile.AutoSave.Enabled && string.IsNullOrWhiteSpace(profile.TargetDirectory))
                return new ActionResult(ErrorCode.TargetDirectory_NotSetForAutoSave);

            if (TokenIdentifier.ContainsTokens(profile.TargetDirectory))
                return new ActionResult();

            var pathUtilStatus = _pathUtil.IsValidRootedPathWithResponse(profile.TargetDirectory);

            switch (pathUtilStatus)
            {
                case PathUtilStatus.InvalidRootedPath:
                    return new ActionResult(ErrorCode.TargetDirectory_InvalidRootedPath);

                case PathUtilStatus.PathTooLongEx:
                    return new ActionResult(ErrorCode.TargetDirectory_TooLong);

                case PathUtilStatus.NotSupportedEx:
                    return new ActionResult(ErrorCode.TargetDirectory_InvalidRootedPath);

                case PathUtilStatus.ArgumentEx:
                    return new ActionResult(ErrorCode.TargetDirectory_IllegalCharacters);
            }

            return new ActionResult();
        }
 /// <summary>
 /// Constructor
 /// </summary>
 public LocalDirectorySource(string basePath, IProgressing progress, bool wideDisplay, CheckLevel checkLevel, bool ignoreCleaning)
 {
     _path           = basePath ?? throw new ArgumentNullException("basePath");
     _pathNoTail     = _path.RemoveTail();
     _progress       = progress ?? throw new ArgumentNullException("progress");
     _wideDisplay    = wideDisplay;
     _checkLevel     = checkLevel;
     _ignoreCleaning = ignoreCleaning;
 }
Пример #6
0
    public static bool isSucceced = false;//记录Check是否成功
    /*id 用来传递要使用的技能*/
    public void ShowCheckPanel(int id, DiceHander hander, CheckLevel level)
    {
        Skill s = SkillManager.Instance.GetSkillDataById(id);

        CheckPanel.s_Check          = s;
        CheckPanel.hander           = hander;
        CheckPanel.level_CheckPanel = level;
        GUIManager.ShowView("CheckPanel");
    }
Пример #7
0
        private ActionResult CheckAttachmentPageSettings(ConversionProfile profile, CheckLevel checkLevel)
        {
            if (!profile.AttachmentPage.Enabled)
            {
                return(new ActionResult());
            }

            var isJobLevelCheck = checkLevel == CheckLevel.Job;

            if (string.IsNullOrEmpty(profile.AttachmentPage.File))
            {
                _logger.Error("No attachment file is specified.");
                return(new ActionResult(ErrorCode.Attachment_NoFileSpecified));
            }

            if (!isJobLevelCheck && TokenIdentifier.ContainsTokens(profile.AttachmentPage.File))
            {
                return(new ActionResult());
            }

            if (!profile.AttachmentPage.File.EndsWith(".pdf", StringComparison.InvariantCultureIgnoreCase))
            {
                _logger.Error("The attachment file \"" + profile.CoverPage.File + "\" is no pdf file.");
                return(new ActionResult(ErrorCode.Attachment_NoPdf));
            }

            var pathUtilStatus = _pathUtil.IsValidRootedPathWithResponse(profile.AttachmentPage.File);

            switch (pathUtilStatus)
            {
            case PathUtilStatus.InvalidRootedPath:
                return(new ActionResult(ErrorCode.AttachmentPage_InvalidRootedPath));

            case PathUtilStatus.PathTooLongEx:
                return(new ActionResult(ErrorCode.AttachmentPage_TooLong));

            case PathUtilStatus.NotSupportedEx:
                return(new ActionResult(ErrorCode.AttachmentPage_InvalidRootedPath));

            case PathUtilStatus.ArgumentEx:
                return(new ActionResult(ErrorCode.AttachmentPage_IllegalCharacters));
            }

            if (!isJobLevelCheck && profile.AttachmentPage.File.StartsWith(@"\\"))
            {
                return(new ActionResult());
            }

            if (!_file.Exists(profile.AttachmentPage.File))
            {
                _logger.Error("The attachment file \"" + profile.AttachmentPage.File + "\" does not exist.");
                return(new ActionResult(ErrorCode.Attachment_FileDoesNotExist));
            }

            return(new ActionResult());
        }
        public ActionResult Check(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            if (!profile.CustomScript.Enabled)
            {
                return(new ActionResult());
            }

            var loadResult = _customScriptLoader.LoadScriptWithValidation(profile.CustomScript.ScriptFilename);

            return(loadResult.Result);
        }
Пример #9
0
        public void SetupGroup(string groupName, AlertLevel alertlevel, CheckLevel checkLevel)
        {
            groupName = groupName.ToLower();
            if (!_groups.TryGetValue(groupName, out var group))
            {
                group = RegisterGroup(groupName, true);
            }

            group.alertLevel = alertlevel;
            group.checkLevel = checkLevel;
        }
Пример #10
0
        /// <summary>
        ///     Check for valid profile
        /// </summary>
        /// <param name="profile"></param>
        /// <param name="accounts">accounts are not used here, but are required for common ICheckable</param>
        /// <param name="checkLevel"></param>
        /// <returns>ActionResult</returns>
        public ActionResult Check(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            if (!IsEnabled(profile))
            {
                return(new ActionResult());
            }

            var isJobLevelCheck = checkLevel == CheckLevel.Job;

            if (string.IsNullOrWhiteSpace(profile.Scripting.ScriptFile))
            {
                return(new ActionResult(ErrorCode.Script_NoScriptFileSpecified));
            }

            //Skip further check for tokens
            if (!isJobLevelCheck &&
                TokenIdentifier.ContainsTokens(profile.Scripting.ScriptFile))
            {
                return(new ActionResult());
            }

            var pathUtilStatus = _pathUtil.IsValidRootedPathWithResponse(profile.Scripting.ScriptFile);

            switch (pathUtilStatus)
            {
            case PathUtilStatus.InvalidRootedPath:
                return(new ActionResult(ErrorCode.Script_InvalidRootedPath));

            case PathUtilStatus.PathTooLongEx:
                return(new ActionResult(ErrorCode.Script_PathTooLong));

            case PathUtilStatus.NotSupportedEx:
                return(new ActionResult(ErrorCode.Script_InvalidRootedPath));

            case PathUtilStatus.ArgumentEx:
                return(new ActionResult(ErrorCode.Script_IllegalCharacters));
            }

            //Skip check for network path
            if (!isJobLevelCheck && profile.Scripting.ScriptFile.StartsWith(@"\\"))
            {
                return(new ActionResult());
            }

            if (!_file.Exists(profile.Scripting.ScriptFile))
            {
                _logger.Error("The script file \"" + profile.Scripting.ScriptFile + "\" does not exist.");
                return(new ActionResult(ErrorCode.Script_FileDoesNotExist));
            }

            return(new ActionResult());
        }
Пример #11
0
        public ActionResult Check(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            if (!profile.AttachmentPage.Enabled)
            {
                return(new ActionResult());
            }
            ActionResult totalResult = new ActionResult();

            foreach (var file in profile.AttachmentPage.Files.DefaultIfEmpty())
            {
                totalResult.Add(CheckFile(file, checkLevel));
            }

            return(totalResult);
        }
Пример #12
0
        public static string GetName(this CheckLevel level)
        {
            switch (level)
            {
            case CheckLevel.Any:
                return("<Any>");

            case CheckLevel.Success:
                return("<Success>");

            case CheckLevel.Fail:
                return("<Fail>");

            default:
                return("<silence>");
            }
        }
Пример #13
0
 private void Filter(CheckLevel checkLevel)
 {
     foreach (TreeNode dateNode in trvLogDateAndSellerAccount.Nodes)
     {
         foreach (TreeNode subNode in dateNode.Nodes)
         {
             var level = subNode.Text.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries)[1];
             if (level == "Error")
             {
                 subNode.TreeView.Visible = true;
             }
             else
             {
                 subNode.TreeView.Visible = false;
             }
         }
     }
 }
Пример #14
0
        public ActionResult Check(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            var actionResult = new ActionResult();

            if (profile.Stamping.Enabled)
            {
                if (string.IsNullOrEmpty(profile.Stamping.StampText))
                {
                    _logger.Error("No stamp text is specified.");
                    actionResult.Add(ErrorCode.Stamp_NoText);
                }

                if (checkLevel == CheckLevel.Job)
                {
                    actionResult.Add(_fontPathHelper.GetFontPath(profile));
                }
            }
            return(actionResult);
        }
Пример #15
0
        public ActionResult Check(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            var result = new ActionResult();

            if (!IsEnabled(profile))
            {
                return(result);
            }

            var security = profile.PdfSettings.Security;

            if (profile.AutoSave.Enabled)
            {
                if (string.IsNullOrEmpty(security.OwnerPassword))
                {
                    _logger.Error("No saved owner password for security in automatic saving.");
                    result.Add(ErrorCode.AutoSave_NoOwnerPassword);
                }

                if (security.RequireUserPassword)
                {
                    if (string.IsNullOrEmpty(security.UserPassword))
                    {
                        _logger.Error("No saved user password for security in automatic saving.");
                        result.Add(ErrorCode.AutoSave_NoUserPassword);
                    }
                }
            }

            if (checkLevel == CheckLevel.Profile)
            {
                return(result);
            }

            return(result);
        }
Пример #16
0
        public ActionResult Check(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            var result = new ActionResult();

            if (_emailClientFactory.CreateEmailClient() == null)
            {
                result.Add(ErrorCode.MailClient_NoCompatibleEmailClientInstalled);
            }

            if (checkLevel == CheckLevel.Job)
            {
                foreach (var attachmentFile in profile.EmailClientSettings.AdditionalAttachments)
                {
                    if (!_file.Exists(attachmentFile))
                    {
                        Logger.Error("Can't find client mail attachment " + attachmentFile + ".");
                        result.Add(ErrorCode.MailClient_InvalidAttachmentFiles);
                        break;
                    }
                }
            }

            return(result);
        }
Пример #17
0
        /// <summary>
        ///     Check if the profile is configured properly for this action
        /// </summary>
        /// <param name="profile">The profile to check</param>
        /// <param name="accounts">Current accounts</param>
        /// <param name="checkLevel"></param>
        /// <returns>ActionResult with configuration problems</returns>
        public override ActionResult Check(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            var actionResult = new ActionResult();

            if (!IsEnabled(profile))
            {
                return(actionResult);
            }

            var httpAccount = accounts.GetHttpAccount(profile);

            if (httpAccount == null)
            {
                actionResult.Add(ErrorCode.HTTP_NoAccount);
                return(actionResult);
            }

            Uri isValidUrl;

            if (!Uri.TryCreate(httpAccount.Url, UriKind.Absolute, out isValidUrl))
            {
                actionResult.Add(ErrorCode.HTTP_NoUrl);
            }
            else if (isValidUrl.Scheme != Uri.UriSchemeHttp && isValidUrl.Scheme != Uri.UriSchemeHttps)
            {
                actionResult.Add(ErrorCode.HTTP_MustStartWithHttp);
            }

            if (httpAccount.IsBasicAuthentication)
            {
                if (string.IsNullOrWhiteSpace(httpAccount.UserName))
                {
                    actionResult.Add(ErrorCode.HTTP_NoUserNameForAuth);
                }

                if (profile.AutoSave.Enabled && string.IsNullOrWhiteSpace(httpAccount.Password))
                {
                    actionResult.Add(ErrorCode.HTTP_NoPasswordForAuthWithAutoSave);
                }
            }

            return(actionResult);
        }
Пример #18
0
        private ActionResult ProfileCheck(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            var actionResult = new ActionResult();

            actionResult.AddRange(CheckTargetDirectory(profile, checkLevel));
            actionResult.AddRange(CheckFileNameTemplate(profile, checkLevel));
            actionResult.AddRange(CheckCoverPageSettings(profile, checkLevel));
            actionResult.AddRange(CheckAttachmentPageSettings(profile, checkLevel));
            actionResult.AddRange(CheckBackgroundPageSettings(profile, checkLevel));
            actionResult.AddRange(CheckStampingSettings(profile));
            actionResult.AddRange(CheckEncryptionSettings(profile));
            actionResult.AddRange(CheckSignatureSettings(profile, accounts, checkLevel));

            foreach (var actionCheck in _actionChecks)
            {
                var result = actionCheck.Check(profile, accounts, checkLevel);
                actionResult.AddRange(result);
            }

            return(actionResult);
        }
Пример #19
0
        public override ActionResult Check(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            var actionResult = new ActionResult();

            if (!IsEnabled(profile))
            {
                return(actionResult);
            }

            var smtpAccount = accounts.GetSmtpAccount(profile);

            if (smtpAccount == null)
            {
                Logger.Error($"The specified SMTP account with ID \"{profile.EmailSmtpSettings.AccountId}\" is not configured.");
                actionResult.Add(ErrorCode.Smtp_NoAccount);
                return(actionResult);
            }

            if (string.IsNullOrWhiteSpace(smtpAccount.Address))
            {
                Logger.Error("No SMTP email address is specified.");
                actionResult.Add(ErrorCode.Smtp_NoEmailAddress);
            }

            if (string.IsNullOrWhiteSpace(smtpAccount.Server))
            {
                Logger.Error("No SMTP host is specified.");
                actionResult.Add(ErrorCode.Smtp_NoServerSpecified);
            }

            if (smtpAccount.Port < 0)
            {
                Logger.Error("Invalid SMTP port.");
                actionResult.Add(ErrorCode.Smtp_InvalidPort);
            }

            if (string.IsNullOrWhiteSpace(smtpAccount.UserName))
            {
                Logger.Error("No SMTP UserName is specified.");
                actionResult.Add(ErrorCode.Smtp_NoUserSpecified);
            }

            if (string.IsNullOrWhiteSpace(profile.EmailSmtpSettings.Recipients))
            {
                Logger.Error("No SMTP email recipients are specified.");
                actionResult.Add(ErrorCode.Smtp_NoRecipients);
            }

            if (profile.AutoSave.Enabled)
            {
                if (string.IsNullOrWhiteSpace(smtpAccount.Password))
                {
                    Logger.Error("No SMTP password for automatic saving.");
                    actionResult.Add(ErrorCode.Smtp_NoPasswordSpecified);
                }
            }

            return(actionResult);
        }
Пример #20
0
    public void ShowDicePanel(int diceType, float rate, DiceHander hander, int diceCount, CheckLevel level)
    {
        int[] DiceNumerArray = new int[diceType];
        if (diceType == 6)
        {
            DiceNumerArray = GetIndexRandomNum(1, 6);
        }
        else if (diceType == 10)
        {
            DiceNumerArray = GetIndexRandomNum(0, 9);
        }

        else if (diceType == 4)
        {
            DiceNumerArray = GetIndexRandomNum(1, 4);
        }
        DicePanel.DiceNumerArray     = DiceNumerArray;
        DicePanel.rate               = rate;
        DicePanel.OnDiceRotateFished = hander;
        DicePanel.isPlural           = true;
        DicePanel.diceNumber_Plural  = diceCount;
        DicePanel.level              = level;
        GUIManager.ShowView("DicePanel");
    }
Пример #21
0
        private ActionResult CheckSignatureSettings(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            var result = new ActionResult();

            var signature = profile.PdfSettings.Signature;

            if (!signature.Enabled)
            {
                return(result);
            }

            if (!profile.OutputFormat.IsPdf())
            {
                return(result);
            }

            var isJobLevelCheck = checkLevel == CheckLevel.Job;

            if (profile.AutoSave.Enabled)
            {
                if (string.IsNullOrEmpty(signature.SignaturePassword))
                {
                    _logger.Error("Automatic saving without certificate password.");
                    result.Add(ErrorCode.Signature_AutoSaveWithoutCertificatePassword);
                }
            }

            var timeServerAccount = accounts.GetTimeServerAccount(profile);

            if (timeServerAccount == null)
            {
                _logger.Error("The specified time server account for signing is not configured.");
                result.Add(ErrorCode.Signature_NoTimeServerAccount);
            }
            else
            {
                if (timeServerAccount.IsSecured)
                {
                    if (string.IsNullOrEmpty(timeServerAccount.UserName))
                    {
                        _logger.Error("Secured Time Server without Login Name.");
                        result.Add(ErrorCode.Signature_SecuredTimeServerWithoutUsername);
                    }
                    if (string.IsNullOrEmpty(timeServerAccount.Password))
                    {
                        _logger.Error("Secured Time Server without Password.");
                        result.Add(ErrorCode.Signature_SecuredTimeServerWithoutPassword);
                    }
                }
            }

            var certificateFile = profile.PdfSettings.Signature.CertificateFile;

            if (string.IsNullOrEmpty(certificateFile))
            {
                _logger.Error("Error in signing. Missing certification file.");
                result.Add(ErrorCode.ProfileCheck_NoCertificationFile);
                return(result);
            }

            if (!isJobLevelCheck && TokenIdentifier.ContainsTokens(certificateFile))
            {
                return(result);
            }

            var pathUtilStatus = _pathUtil.IsValidRootedPathWithResponse(profile.PdfSettings.Signature.CertificateFile);

            switch (pathUtilStatus)
            {
            case PathUtilStatus.InvalidRootedPath:
                result.Add(ErrorCode.CertificateFile_InvalidRootedPath);
                return(result);

            case PathUtilStatus.PathTooLongEx:
                result.Add(ErrorCode.CertificateFile_TooLong);
                return(result);

            case PathUtilStatus.NotSupportedEx:
                result.Add(ErrorCode.CertificateFile_InvalidRootedPath);
                return(result);

            case PathUtilStatus.ArgumentEx:
                result.Add(ErrorCode.CertificateFile_IllegalCharacters);
                return(result);
            }

            if (!isJobLevelCheck && certificateFile.StartsWith(@"\\"))
            {
                return(result);
            }

            if (!_file.Exists(certificateFile))
            {
                _logger.Error("Error in signing. The certification file '" + certificateFile +
                              "' doesn't exist.");
                result.Add(ErrorCode.CertificateFile_CertificateFileDoesNotExist);
            }

            return(result);
        }
Пример #22
0
        public ActionResult ProfileCheck(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            var actionResult = new ActionResult();

            actionResult.AddRange(CheckTargetDirectory(profile, checkLevel));
            actionResult.AddRange(CheckFileNameTemplate(profile, checkLevel));

            foreach (var action in _actions)
            {
                if (!(action is ICheckable checkable))
                {
                    continue;
                }
                var result = checkable.Check(profile, accounts, checkLevel);
                actionResult.AddRange(result);
            }

            return(actionResult);
        }
Пример #23
0
        public override ActionResult Check(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            var actionResult = new ActionResult();

            if (!IsEnabled(profile))
            {
                return(actionResult);
            }

            var isFinal = checkLevel == CheckLevel.Job;

            var ftpAccount = accounts.GetFtpAccount(profile);

            if (ftpAccount == null)
            {
                Logger.Error($"The specified FTP account with ID '{profile.Ftp.AccountId}' is not configured.");
                actionResult.Add(ErrorCode.Ftp_NoAccount);

                return(actionResult);
            }

            if (string.IsNullOrEmpty(ftpAccount.Server))
            {
                Logger.Error("No FTP server specified.");
                actionResult.Add(ErrorCode.Ftp_NoServer);
            }

            if (string.IsNullOrEmpty(ftpAccount.UserName))
            {
                Logger.Error("No FTP username specified.");
                actionResult.Add(ErrorCode.Ftp_NoUser);
            }

            if (profile.AutoSave.Enabled && string.IsNullOrEmpty(ftpAccount.Password))
            {
                Logger.Error("Automatic saving without ftp password.");
                actionResult.Add(ErrorCode.Ftp_AutoSaveWithoutPassword);
            }

            if (!isFinal && TokenIdentifier.ContainsTokens(profile.Ftp.Directory))
            {
                return(actionResult);
            }

            if (!ValidName.IsValidFtpPath(profile.Ftp.Directory))
            {
                actionResult.Add(ErrorCode.FtpDirectory_InvalidFtpPath);
            }

            return(actionResult);
        }
Пример #24
0
 /// <summary>
 /// Constructor of <see cref="CheckWithLastConstraintFilterable"/> class>
 /// </summary>
 /// <param name="level">Check level</param>
 /// <param name="description">Check description</param>
 /// <param name="constraints">Constraints to run</param>
 /// <param name="creationFunc">Creation function</param>
 public CheckWithLastConstraintFilterable(CheckLevel level, string description,
                                          IEnumerable <IConstraint> constraints, Func <Option <string>, IConstraint> creationFunc)
     : base(level, description, constraints) =>
Пример #25
0
        public override ActionResult Check(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel)
        {
            var actionResult = new ActionResult();

            if (!IsEnabled(profile))
            {
                return(actionResult);
            }

            var isFinal = checkLevel == CheckLevel.Job;

            var ftpAccount = accounts.GetFtpAccount(profile);

            if (ftpAccount == null)
            {
                Logger.Error($"The specified FTP account with ID '{profile.Ftp.AccountId}' is not configured.");
                actionResult.Add(ErrorCode.Ftp_NoAccount);

                return(actionResult);
            }

            if (string.IsNullOrEmpty(ftpAccount.Server))
            {
                Logger.Error("No FTP server specified.");
                actionResult.Add(ErrorCode.Ftp_NoServer);
            }

            if (string.IsNullOrEmpty(ftpAccount.UserName))
            {
                Logger.Error("No FTP username specified.");
                actionResult.Add(ErrorCode.Ftp_NoUser);
            }

            if (ftpAccount.AuthenticationType == AuthenticationType.KeyFileAuthentication)
            {
                var pathUtilStatus = _pathUtil.IsValidRootedPathWithResponse(ftpAccount.PrivateKeyFile);
                switch (pathUtilStatus)
                {
                case PathUtilStatus.InvalidRootedPath:
                    return(new ActionResult(ErrorCode.FtpKeyFilePath_InvalidRootedPath));

                case PathUtilStatus.PathTooLongEx:
                    return(new ActionResult(ErrorCode.FtpKeyFilePath_PathTooLong));

                case PathUtilStatus.NotSupportedEx:
                    return(new ActionResult(ErrorCode.FtpKeyFilePath_InvalidRootedPath));

                case PathUtilStatus.ArgumentEx:
                    return(new ActionResult(ErrorCode.FtpKeyFilePath_IllegalCharacters));
                }

                if (!isFinal && ftpAccount.PrivateKeyFile.StartsWith(@"\\"))
                {
                    return(new ActionResult());
                }

                if (!_file.Exists(ftpAccount.PrivateKeyFile))
                {
                    Logger.Error("The private key file \"" + ftpAccount.PrivateKeyFile + "\" does not exist.");
                    return(new ActionResult(ErrorCode.FtpKeyFilePath_FileDoesNotExist));
                }
            }

            if (profile.AutoSave.Enabled && string.IsNullOrEmpty(ftpAccount.Password) || KeyFilePasswordIsRequired(ftpAccount))
            {
                Logger.Error("Automatic saving without ftp password.");
                actionResult.Add(ErrorCode.Ftp_AutoSaveWithoutPassword);
            }

            if (!isFinal && TokenIdentifier.ContainsTokens(profile.Ftp.Directory))
            {
                return(actionResult);
            }

            if (!ValidName.IsValidFtpPath(profile.Ftp.Directory))
            {
                actionResult.Add(ErrorCode.FtpDirectory_InvalidFtpPath);
            }

            return(actionResult);
        }
 public abstract ActionResult Check(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel);