Esempio n. 1
0
        public static ActionResult CheckBackgroundpageSettings(ConversionProfile profile)
        {
            const int actionId = 17;

            var actionResult = new ActionResult();

            if (profile.OutputFormat != OutputFormat.Pdf && profile.OutputFormat != OutputFormat.PdfA1B &&
                profile.OutputFormat != OutputFormat.PdfA2B &&
                profile.OutputFormat != OutputFormat.PdfX)
            {
                return(actionResult);
            }

            if (profile.BackgroundPage.Enabled)
            {
                if (string.IsNullOrEmpty(profile.BackgroundPage.File))
                {
                    Logger.Error("No background file is specified.");
                    actionResult.Add(actionId, 100);
                }
                //Skip check for network path
                else if (!profile.BackgroundPage.File.StartsWith(@"\\") && !File.Exists(profile.BackgroundPage.File))
                {
                    Logger.Error("The background file \"" + profile.BackgroundPage.File + "\" does not exist.");
                    actionResult.Add(actionId, 101);
                }
                else if (!profile.BackgroundPage.File.EndsWith(".pdf", StringComparison.InvariantCultureIgnoreCase))
                {
                    Logger.Error("The background file \"" + profile.BackgroundPage.File + "\" is no pdf file.");
                    actionResult.Add(actionId, 102);
                }
            }

            return(actionResult);
        }
Esempio n. 2
0
        private static ActionResult CheckAttachmentPageSettings(ConversionProfile profile)
        {
            const int actionId = 23;

            var actionResult = new ActionResult();

            if (profile.AttachmentPage.Enabled)
            {
                if (string.IsNullOrEmpty(profile.AttachmentPage.File))
                {
                    Logger.Error("No attachment file is specified.");
                    actionResult.Add(actionId, 100);
                }
                //Skip check for network path
                else if (!profile.AttachmentPage.File.StartsWith(@"\\") && !File.Exists(profile.AttachmentPage.File))
                {
                    Logger.Error("The attachment file \"" + profile.AttachmentPage.File + "\" does not exist.");
                    actionResult.Add(actionId, 101);
                }
                else if (!profile.AttachmentPage.File.EndsWith(".pdf", StringComparison.InvariantCultureIgnoreCase))
                {
                    Logger.Error("The attachment file \"" + profile.CoverPage.File + "\" is no pdf file.");
                    actionResult.Add(actionId, 102);
                }
            }

            return(actionResult);
        }
Esempio n. 3
0
        public ActionResult CheckEncryptionSettings(ConversionProfile profile)
        {
            var actionResult = new ActionResult();

            var security = profile.PdfSettings.Security;

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

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

            return(actionResult);
        }
Esempio n. 4
0
        private ActionResult HttpUpload(Job job)
        {
            var result = new ActionResult();

            // setup and send request
            var uploadFileViaHttp = UploadFileViaHttp(job);

            // wait for the result
            var httpResponse = uploadFileViaHttp;

            if (httpResponse.IsSuccessStatusCode == false)
            {
                switch (httpResponse.StatusCode)
                {
                case HttpStatusCode.Unauthorized:
                    result.Add(ErrorCode.PasswordAction_Login_Error);
                    break;

                default:
                    result.Add(ErrorCode.HTTP_Generic_Error);
                    break;
                }
            }
            return(result);
        }
Esempio n. 5
0
        private ActionResult CheckAttachmentPageSettings(ConversionProfile profile)
        {
            var actionResult = new ActionResult();

            if (profile.AttachmentPage.Enabled)
            {
                if (string.IsNullOrEmpty(profile.AttachmentPage.File))
                {
                    _logger.Error("No attachment file is specified.");
                    actionResult.Add(ErrorCode.Attachment_NoFileSpecified);
                }
                //Skip check for network path
                else if (!profile.AttachmentPage.File.StartsWith(@"\\") && !_file.Exists(profile.AttachmentPage.File))
                {
                    _logger.Error("The attachment file \"" + profile.AttachmentPage.File + "\" does not exist.");
                    actionResult.Add(ErrorCode.Attachment_FileDoesNotExist);
                }
                else if (!profile.AttachmentPage.File.EndsWith(".pdf", StringComparison.InvariantCultureIgnoreCase))
                {
                    _logger.Error("The attachment file \"" + profile.CoverPage.File + "\" is no pdf file.");
                    actionResult.Add(ErrorCode.Attachment_NoPdf);
                }
            }
            return(actionResult);
        }
Esempio n. 6
0
        private void AddNotExistingFileError(ActionResult result, OutputFormat format)
        {
            if (_outputFormatHelper.IsPdfFormat(format))
            {
                result.Add(ErrorCode.DefaultViewer_FileDoesNotExist_For_Pdf);
            }

            switch (format)
            {
            case OutputFormat.Jpeg:
                result.Add(ErrorCode.DefaultViewer_FileDoesNotExist_For_Jpeg);
                break;

            case OutputFormat.Png:
                result.Add(ErrorCode.DefaultViewer_FileDoesNotExist_For_Png);
                break;

            case OutputFormat.Tif:
                result.Add(ErrorCode.DefaultViewer_FileDoesNotExist_For_Tif);
                break;

            case OutputFormat.Txt:
                result.Add(ErrorCode.DefaultViewer_FileDoesNotExist_For_Txt);
                break;

            default:
                break;
            }
        }
Esempio n. 7
0
        private ActionResult CheckEncryptionSettings(ConversionProfile profile)
        {
            var result = new ActionResult();

            var security = profile.PdfSettings.Security;

            if (!security.Enabled)
                return result;

            if (!_outputFormatHelper.IsPdfFormat(profile.OutputFormat))
                return result;

            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);
                    }
                }
            }

            return result;
        }
Esempio n. 8
0
        public ActionResult CheckBackgroundpageSettings(ConversionProfile profile)
        {
            var actionResult = new ActionResult();

            if ((profile.OutputFormat != OutputFormat.Pdf) && (profile.OutputFormat != OutputFormat.PdfA1B) &&
                (profile.OutputFormat != OutputFormat.PdfA2B) && (profile.OutputFormat != OutputFormat.PdfX))
            {
                return(actionResult);
            }

            if (profile.BackgroundPage.Enabled)
            {
                if (string.IsNullOrEmpty(profile.BackgroundPage.File))
                {
                    _logger.Error("No background file is specified.");
                    actionResult.Add(ErrorCode.Background_NoFileSpecified);
                }
                //Skip check for network path
                else if (!profile.BackgroundPage.File.StartsWith(@"\\") && !_file.Exists(profile.BackgroundPage.File))
                {
                    _logger.Error("The background file \"" + profile.BackgroundPage.File + "\" does not exist.");
                    actionResult.Add(ErrorCode.Background_FileDoesNotExist);
                }
                else if (!profile.BackgroundPage.File.EndsWith(".pdf", StringComparison.InvariantCultureIgnoreCase))
                {
                    _logger.Error("The background file \"" + profile.BackgroundPage.File + "\" is no pdf file.");
                    actionResult.Add(ErrorCode.Background_NoPdf);
                }
            }
            return(actionResult);
        }
Esempio n. 9
0
        private void AddMissingPathError(ActionResult result, OutputFormat format)
        {
            if (_outputFormatHelper.IsPdfFormat(format))
            {
                result.Add(ErrorCode.DefaultViewer_PathIsEmpty_for_Pdf);
            }
            switch (format)
            {
            case OutputFormat.Jpeg:
                result.Add(ErrorCode.DefaultViewer_PathIsEmpty_for_Jpeg);
                break;

            case OutputFormat.Png:
                result.Add(ErrorCode.DefaultViewer_PathIsEmpty_for_Png);
                break;

            case OutputFormat.Tif:
                result.Add(ErrorCode.DefaultViewer_PathIsEmpty_for_Tif);
                break;

            case OutputFormat.Txt:
                result.Add(ErrorCode.DefaultViewer_PathIsEmpty_for_Txt);
                break;

            default:
                break;
            }
        }
        /// <summary>
        ///     Check if the profile is configured properly for this action
        /// </summary>
        /// <param name="profile">The profile to check</param>
        /// <returns>ActionResult with configuration problems</returns>
        public ActionResult Check(ConversionProfile profile, Accounts accounts)
        {
            var actionResult = new ActionResult();

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

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

                if (profile.AutoSave.Enabled)
                {
                    if (string.IsNullOrEmpty(profile.Ftp.Password))
                    {
                        Logger.Error("Automatic saving without ftp password.");
                        actionResult.Add(ErrorCode.Ftp_AutoSaveWithoutPassword);
                    }
                }
            }
            return(actionResult);
        }
Esempio n. 11
0
        public void NewActionResult_WithOneFailAndOneSuccess_IsUnsuccessful()
        {
            var result = new ActionResult();

            result.Add(ErrorCode.Attachment_NoPdf);
            result.Add(ErrorCode.Script_GenericError);

            Assert.IsFalse(result.IsSuccess);
        }
Esempio n. 12
0
        public void NewActionResult_WithOneFailAndOneSuccess_IsUnsuccessful()
        {
            var result = new ActionResult();

            result.Add(10, 123);
            result.Add(11, 456);

            Assert.IsFalse(result.Success);
        }
Esempio n. 13
0
        public void NewActionResult_WithTwoAddErrorCodeCall_HasBothErrorCodes()
        {
            var result = new ActionResult();

            result.Add(ErrorCode.Encryption_Error);
            result.Add(ErrorCode.Conversion_UnknownError);

            Assert.Contains(ErrorCode.Encryption_Error, result);
            Assert.Contains(ErrorCode.Conversion_UnknownError, result);
        }
Esempio n. 14
0
        public void NewActionResult_WithTwoAddErrorCodeCall_HasBothErrorCodes()
        {
            var result = new ActionResult();

            result.Add(10, 123);
            result.Add(11, 456);

            Assert.Contains(10123, result);
            Assert.Contains(11456, result);
        }
Esempio n. 15
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);
        }
Esempio n. 16
0
        public static ActionResult CheckSignatureSettings(ConversionProfile profile)
        {
            const int actionId = 12;

            var actionResult = new ActionResult();

            var sign = profile.PdfSettings.Signature;

            if (sign.Enabled)
            {
                if (string.IsNullOrEmpty(sign.CertificateFile))
                {
                    Logger.Error("Error in signing. Missing certification file.");
                    actionResult.Add(actionId, 100);
                }
                //Skip check for network path
                else if (!sign.CertificateFile.StartsWith(@"\\") && !File.Exists(sign.CertificateFile))
                {
                    Logger.Error("Error in signing. The certification file '" + sign.CertificateFile +
                                 "' doesn't exist.");
                    actionResult.Add(actionId, 101);
                }

                if (profile.AutoSave.Enabled)
                {
                    if (string.IsNullOrEmpty(sign.SignaturePassword))
                    {
                        Logger.Error("Automatic saving without certificate password.");
                        actionResult.Add(actionId, 102);
                    }
                }

                if (sign.TimeServerIsSecured)
                {
                    if (string.IsNullOrEmpty(sign.TimeServerLoginName))
                    {
                        Logger.Error("Secured Time Server without Login Name.");
                        actionResult.Add(actionId, 103);
                    }

                    if (string.IsNullOrEmpty(sign.TimeServerPassword))
                    {
                        Logger.Error("Secured Time Server without Password.");
                        actionResult.Add(actionId, 104);
                    }
                }
            }

            return(actionResult);
        }
        public void CopyToClipBoard_CopyToClipboardisCalledWithCorrectText()
        {
            var actionResultDict     = new ActionResultDict();
            var excpetedError        = _errorCodeInterpreter.GetErrorText(ErrorCode.Attachment_NoPdf, false);
            var oneErrorActionResult = new ActionResult(ErrorCode.Attachment_NoPdf);

            actionResultDict.Add("RegionWithOneError", oneErrorActionResult);
            var twoErrorsActionResult = new ActionResult(ErrorCode.Attachment_NoPdf);

            twoErrorsActionResult.Add(ErrorCode.Attachment_NoPdf);
            actionResultDict.Add("RegionWithTwoErrors", twoErrorsActionResult);
            var interaction = new MessageInteraction("text", "title", MessageOptions.OK, MessageIcon.Info, actionResultDict, "second text");

            _viewModel.SetInteraction(interaction);

            var receivedText = "";

            _clipboardService.SetDataObject(Arg.Do <object>(o => receivedText = o as string));

            _viewModel.CopyToClipboard_CommandBinding(null, null);

            var expectedText = new StringBuilder()
                               .AppendLine("text")
                               .AppendLine("RegionWithOneError")
                               .AppendLine("- " + excpetedError)
                               .AppendLine("RegionWithTwoErrors")
                               .AppendLine("- " + excpetedError)
                               .AppendLine("- " + excpetedError)
                               .AppendLine("second text")
                               .ToString();

            Assert.AreEqual(receivedText, expectedText);
        }
        public void SetInteractionWithActionResultDict_ErrorListVisibiltyIsVisible_ErrorListIsBuild_RaisesPropertyChanged()
        {
            var actionResultDict     = new ActionResultDict();
            var excpetedError        = _errorCodeInterpreter.GetErrorText(ErrorCode.Attachment_NoPdf, false);
            var oneErrorActionResult = new ActionResult(ErrorCode.Attachment_NoPdf);

            actionResultDict.Add("RegionWithOneError", oneErrorActionResult);
            var twoErrorsActionResult = new ActionResult(ErrorCode.Attachment_NoPdf);

            twoErrorsActionResult.Add(ErrorCode.Attachment_NoPdf);
            actionResultDict.Add("RegionWithTwoErrors", twoErrorsActionResult);
            var interaction = new MessageInteraction("", "", MessageOptions.OK, MessageIcon.Info, actionResultDict);

            var propertyChangedList = new List <string>();

            _viewModel.PropertyChanged += (sender, args) => propertyChangedList.Add(args.PropertyName);

            _viewModel.SetInteraction(interaction);

            Assert.AreEqual("RegionWithOneError", _viewModel.ErrorList[0].Region);
            Assert.AreEqual(excpetedError, _viewModel.ErrorList[0].Error);
            Assert.AreEqual("RegionWithTwoErrors", _viewModel.ErrorList[1].Region);
            Assert.AreEqual(excpetedError, _viewModel.ErrorList[1].Error);
            Assert.AreEqual("RegionWithTwoErrors", _viewModel.ErrorList[2].Region);
            Assert.AreEqual(excpetedError, _viewModel.ErrorList[2].Error);

            Assert.AreEqual(Visibility.Visible, _viewModel.ErrorListVisibility);
            Assert.Contains(nameof(_viewModel.ErrorListVisibility), propertyChangedList);
        }
        public ActionResult CheckSignatureSettings(ConversionProfile profile)
        {
            var actionResult = new ActionResult();

            var sign = profile.PdfSettings.Signature;

            if (sign.Enabled)
            {
                if (string.IsNullOrEmpty(sign.CertificateFile))
                {
                    _logger.Error("Error in signing. Missing certification file.");
                    actionResult.Add(ErrorCode.ProfileCheck_NoCertificationFileSpecified);
                }
                //Skip check for network path
                else if (!sign.CertificateFile.StartsWith(@"\\") && !_file.Exists(sign.CertificateFile))
                {
                    _logger.Error("Error in signing. The certification file '" + sign.CertificateFile +
                                  "' doesn't exist.");
                    actionResult.Add(ErrorCode.ProfileCheck_CertificateFileDoesNotExist);
                }

                if (profile.AutoSave.Enabled)
                {
                    if (string.IsNullOrEmpty(sign.SignaturePassword))
                    {
                        _logger.Error("Automatic saving without certificate password.");
                        actionResult.Add(ErrorCode.ProfileCheck_AutoSaveWithoutCertificatePassword);
                    }
                }

                if (sign.TimeServerIsSecured)
                {
                    if (string.IsNullOrEmpty(sign.TimeServerLoginName))
                    {
                        _logger.Error("Secured Time Server without Login Name.");
                        actionResult.Add(ErrorCode.ProfileCheck_SecureTimeServerWithoutUsername);
                    }
                    if (string.IsNullOrEmpty(sign.TimeServerPassword))
                    {
                        _logger.Error("Secured Time Server without Password.");
                        actionResult.Add(ErrorCode.ProfileCheck_SecureTimeServerWithoutPassword);
                    }
                }
            }

            return(actionResult);
        }
Esempio n. 20
0
        public void NewActionResult_WithAddErrorCodeCall_HasThisErrorCode()
        {
            var result = new ActionResult();

            result.Add(10, 123);

            Assert.Contains(10123, result);
        }
Esempio n. 21
0
        public void NewActionResult_WithAddErrorCodeCall_HasThisErrorCode()
        {
            var result = new ActionResult();

            result.Add(ErrorCode.Attachment_NoPdf);

            Assert.Contains(ErrorCode.Attachment_NoPdf, result);
        }
Esempio n. 22
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);
        }
Esempio n. 23
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);
        }
Esempio n. 24
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);
        }
Esempio n. 25
0
        private ActionResult CheckStampingSettings(ConversionProfile profile)
        {
            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 (string.IsNullOrEmpty(profile.Stamping.FontName))
                {
                    _logger.Error("No stamp font is specified.");
                    actionResult.Add(ErrorCode.Stamp_NoFont);
                }
            }
            return(actionResult);
        }
Esempio n. 26
0
        public LoadScriptResult LoadScriptWithValidation(string scriptFilename)
        {
            var actionResult = new ActionResult();

            if (string.IsNullOrWhiteSpace(scriptFilename))
            {
                actionResult.Add(ErrorCode.CustomScript_NoScriptFileSpecified);
                return(new LoadScriptResult(actionResult, null, ""));
            }

            var scriptFile = PathSafe.Combine(ScriptFolder, scriptFilename);

            if (!_file.Exists(scriptFile))
            {
                actionResult.Add(ErrorCode.CustomScript_FileDoesNotExistInScriptFolder);
                return(new LoadScriptResult(actionResult, null, ""));
            }

            return(LoadScript(scriptFile));
        }
Esempio n. 27
0
        private ActionResult CheckAutosaveSettings(ConversionProfile profile)
        {
            var actionResult = new ActionResult();

            if (profile.AutoSave.Enabled)
            {
                if (string.IsNullOrEmpty(profile.TargetDirectory))
                {
                    _logger.Error("Automatic saving without target directory.");
                    actionResult.Add(ErrorCode.AutoSave_NoTargetDirectory);
                }
                if (string.IsNullOrEmpty(profile.FileNameTemplate))
                {
                    _logger.Error("Automatic saving without filename template.");
                    actionResult.Add(ErrorCode.AutoSave_NoFilenameTemplate);
                }
            }

            return(actionResult);
        }
Esempio n. 28
0
        public ActionResult Check(ConversionProfile profile, Accounts accounts)
        {
            var actionResult = new ActionResult();

            if (!profile.Scripting.Enabled)
            {
                return(actionResult);
            }

            var tokenReplacer = new TokenReplacer();

            tokenReplacer.AddToken(new EnvironmentToken());

            var validName = new ValidName();

            var scriptFile = ComposeScriptPath(profile.Scripting.ScriptFile, tokenReplacer);

            if (string.IsNullOrEmpty(scriptFile))
            {
                _logger.Error("Missing script file.");
                actionResult.Add(ErrorCode.Script_NoScriptFileSpecified);
                return(actionResult);
            }

            if (!validName.IsValidFilename(scriptFile))
            {
                _logger.Error("The script file \"" + scriptFile + "\" contains illegal characters.");
                actionResult.Add(ErrorCode.Script_IllegalCharacters);
                return(actionResult);
            }

            //Skip check for network path
            if (!scriptFile.StartsWith(@"\\") && !_file.Exists(scriptFile))
            {
                _logger.Error("The script file \"" + scriptFile + "\" does not exist.");
                actionResult.Add(ErrorCode.Script_FileDoesNotExist);
                return(actionResult);
            }

            return(actionResult);
        }
Esempio n. 29
0
        private static ActionResult CheckStampingSettings(ConversionProfile profile)
        {
            const int actionId = 24;

            var actionResult = new ActionResult();

            if (profile.Stamping.Enabled)
            {
                if (string.IsNullOrEmpty(profile.Stamping.StampText))
                {
                    Logger.Error("No stamp text is specified.");
                    actionResult.Add(actionId, 100);
                }
                if (string.IsNullOrEmpty(profile.Stamping.FontName))
                {
                    Logger.Error("No stamp font is specified.");
                    actionResult.Add(actionId, 101);
                }
            }
            return(actionResult);
        }
Esempio n. 30
0
        public override ActionResult Check(ConversionProfile profile, Accounts accounts)
        {
            var actionResult = new ActionResult();

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

            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);
            }

            return(actionResult);
        }