SubstitutePlaceholders() публичный Метод

public SubstitutePlaceholders ( string fileNameWithPath, System.DateTime dateTime, bool incrementIfExists = true, int numberSkip, int autoNumberDigits ) : string
fileNameWithPath string
dateTime System.DateTime
incrementIfExists bool
numberSkip int
autoNumberDigits int
Результат string
Пример #1
0
        private bool SaveOneFile(AutoSaveSettings settings, DateTime now, int i, List <ScannedImage> images, ISaveNotify notify, ref string firstFileSaved)
        {
            if (images.Count == 0)
            {
                return(true);
            }
            var    form    = formFactory.Create <FProgress>();
            string subPath = fileNamePlaceholders.SubstitutePlaceholders(settings.FilePath, now, true, i);

            if (settings.PromptForFilePath)
            {
                if (dialogHelper.PromptToSavePdfOrImage(subPath, out string newPath))
                {
                    subPath = fileNamePlaceholders.SubstitutePlaceholders(newPath, now, true, i);
                }
            }
            var extension = Path.GetExtension(subPath);

            if (extension != null && extension.Equals(".pdf", StringComparison.InvariantCultureIgnoreCase))
            {
                if (File.Exists(subPath))
                {
                    subPath = fileNamePlaceholders.SubstitutePlaceholders(subPath, now, true, 0, 1);
                }
                var op = operationFactory.Create <SavePdfOperation>();
                form.Operation = op;
                var ocrLanguageCode = userConfigManager.Config.EnableOcr ? userConfigManager.Config.OcrLanguageCode : null;
                if (op.Start(subPath, now, images, pdfSettingsContainer.PdfSettings, ocrLanguageCode, false))
                {
                    form.ShowDialog();
                }
                if (op.Status.Success && firstFileSaved == null)
                {
                    firstFileSaved = subPath;
                }
                if (op.Status.Success)
                {
                    notify?.PdfSaved(subPath);
                }
                return(op.Status.Success);
            }
            else
            {
                var op = operationFactory.Create <SaveImagesOperation>();
                form.Operation = op;
                if (op.Start(subPath, now, images))
                {
                    form.ShowDialog();
                }
                if (op.Status.Success && firstFileSaved == null)
                {
                    firstFileSaved = op.FirstFileSaved;
                }
                if (op.Status.Success)
                {
                    notify?.ImagesSaved(images.Count, op.FirstFileSaved);
                }
                return(op.Status.Success);
            }
        }
Пример #2
0
        private async Task <(bool, string)> SaveOneFile(AutoSaveSettings settings, DateTime now, int i, List <ScannedImage> images, ISaveNotify notify)
        {
            if (images.Count == 0)
            {
                return(true, null);
            }
            string subPath = fileNamePlaceholders.SubstitutePlaceholders(settings.FilePath, now, true, i);

            if (settings.PromptForFilePath)
            {
                if (dialogHelper.PromptToSavePdfOrImage(subPath, out string newPath))
                {
                    subPath = fileNamePlaceholders.SubstitutePlaceholders(newPath, now, true, i);
                }
                else
                {
                    return(false, null);
                }
            }
            var extension = Path.GetExtension(subPath);

            if (extension != null && extension.Equals(".pdf", StringComparison.InvariantCultureIgnoreCase))
            {
                if (File.Exists(subPath))
                {
                    subPath = fileNamePlaceholders.SubstitutePlaceholders(subPath, now, true, 0, 1);
                }
                var op = operationFactory.Create <SavePdfOperation>();
                if (op.Start(subPath, now, images, pdfSettingsContainer.PdfSettings, ocrManager.DefaultParams, false, null))
                {
                    operationProgress.ShowProgress(op);
                }
                bool success = await op.Success;
                if (success)
                {
                    notify?.PdfSaved(subPath);
                }
                return(success, subPath);
            }
            else
            {
                var op = operationFactory.Create <SaveImagesOperation>();
                if (op.Start(subPath, now, images))
                {
                    operationProgress.ShowProgress(op);
                }
                bool success = await op.Success;
                if (success)
                {
                    notify?.ImagesSaved(images.Count, op.FirstFileSaved);
                }
                return(success, subPath);
            }
        }