Exemplo n.º 1
0
 private IResultCollection <IFileDataSourceServer> CreateProcessingDocument(IDocumentLibrary documentLibrary, FilePathCollection filePathCollection,
                                                                            IConvertingSettings convertingSettings, ColorPrintType colorPrintType) =>
 documentLibrary.
 Void(_ => _messagingService.ShowMessage("Обработка штампов...")).
 GetStampContainer(convertingSettings.ToApplication()).
 Map(stampContainer => StampContainerProcessing(stampContainer, documentLibrary, filePathCollection,
                                                convertingSettings, colorPrintType));
 /// <summary>
 /// Запустить конвертацию. Инициировать начальные значения
 /// </summary>
 private IFileDataServer ConvertingFile(IFileDataServer fileDataServer, IConvertingSettings convertingSettings) =>
 LoadAndSaveDocument(fileDataServer).
 ResultValueOkBind(document =>
                   MakeConvertingFileActions(document, fileDataServer, convertingSettings).
                   Map(filesData => CloseFile(document, fileDataServer).
                       Map(closeResult => filesData.ConcatErrors(closeResult.Errors)).
                       ToResultCollection())).
 Map(result => new FileDataServer(fileDataServer, StatusProcessing.ConvertingComplete, result.Value, result.Errors));
 /// <summary>
 /// Экспортировать в другие форматы и добавить в список обработанных файлов
 /// </summary>
 private IResultCollection <IFileDataSourceServer> ExportFileToSaveResult(IResultCollection <IFileDataSourceServer> saveResult,
                                                                          IDocumentLibrary documentLibrary, IFilePath filePath,
                                                                          IConvertingSettings convertingSettings) =>
 documentLibrary.GetStampContainer(convertingSettings.ToApplication()).
 WhereContinue(stampContainer => ConvertingModeChoice.IsDwgConvertingNeed(convertingSettings.ConvertingModeTypes) &&
               (stampContainer.StampDocumentType == StampDocumentType.Specification ||
                stampContainer.StampDocumentType == StampDocumentType.Drawing),
               okFunc: stampContainer => saveResult.ConcatResultValue(ExportFile(documentLibrary, filePath, stampContainer.StampDocumentType)),
               badFunc: _ => saveResult);
 /// <summary>
 /// Создать PDF
 /// </summary>
 private IResultCollection <IFileDataSourceServer> CreateProcessingFile(IDocumentLibrary documentLibrary, IFileDataServer fileDataServer,
                                                                        IConvertingSettings convertingSettings) =>
 new ResultError().
 ResultVoidOk(_ => _messagingService.ShowMessage("Создание файлов PDF и печать")).
 ResultVoidOk(_ => _loggerService.LogByObject(LoggerLevel.Info, LoggerAction.Operation, ReflectionInfo.GetMethodBase(this), fileDataServer.FileNameServer)).
 ResultValueOkBind(_ =>
                   _applicationConverting.
                   CreateProcessingFile(documentLibrary, ConvertingFilePath.GetFilePathCollection(fileDataServer, _fileSystemOperations),
                                        convertingSettings, fileDataServer.ColorPrintType)).
 Void(result => _messagingService.ShowAndLogErrors(result.Errors)).
 ToResultCollection();
Exemplo n.º 5
0
 /// <summary>
 /// Обработать штампы и начать печать
 /// </summary>
 private IResultCollection <IFileDataSourceServer> StampContainerProcessing(IStampContainer stampContainer, IDocumentLibrary documentLibrary,
                                                                            FilePathCollection filePathCollection,
                                                                            IConvertingSettings convertingSettings, ColorPrintType colorPrintType) =>
 stampContainer.
 Void(_ => _messagingService.ShowMessage("Подключение дополнительных элементов...")).
 Void(_ => documentLibrary.AttachAdditional()).
 Void(_ => _messagingService.ShowMessage("Форматирование полей...")).
 CompressFieldsRanges().
 Void(_ => _loggerService.LogByObject(LoggerLevel.Debug, LoggerAction.Operation, ReflectionInfo.GetMethodBase(this), nameof(stampContainer.CompressFieldsRanges))).
 Map(_ => GetSavedFileDataSource(documentLibrary, filePathCollection.FilePathMain)).
 WhereContinue(_ => ConvertingModeChoice.IsPdfConvertingNeed(convertingSettings.ConvertingModeTypes),
               filesDataSource => StampContainerCreatePdf(stampContainer, documentLibrary, filePathCollection.FilePathPdf,
                                                          convertingSettings, ConvertingModeType.Pdf, colorPrintType).
               Map(filesDataSource.ConcatResult),
               filesDataSource => filesDataSource).
 WhereContinue(_ => ConvertingModeChoice.IsPrintConvertingNeed(convertingSettings.ConvertingModeTypes),
               filesDataSource => StampContainerPrint(stampContainer, documentLibrary, filePathCollection.FilePathPrint,
                                                      convertingSettings, ConvertingModeType.Print, colorPrintType).
               Map(filesDataSource.ConcatResult),
               filesDataSource => filesDataSource).
 Void(_ => documentLibrary.DetachAdditional());
 /// <summary>
 /// Преобразовать параметры конвертации в класс модуля конвертирования
 /// </summary>
 public static ConvertingSettingsApp ToApplication(this IConvertingSettings convertingSettings) =>
 ConverterSettingsApplication.ToConvertingSettingsApplication(convertingSettings);
 /// <summary>
 /// Конвертировать файл до превышения лимита
 /// </summary>
 private IFileDataServer ConvertingByCountLimit(IFileDataServer fileDataServer, IConvertingSettings convertingSettings) =>
 fileDataServer.
 Void(_ => _loggerService.LogByObject(LoggerLevel.Info, LoggerAction.Operation, ReflectionInfo.GetMethodBase(this), fileDataServer.FileNameServer)).
 WhereOk(fileData => !fileData.IsCompleted,
         okFunc: fileData =>
         ExecuteBindResultValue(() => _convertingFileData.Converting(fileData, convertingSettings)).
         ResultValueBad(errors => fileData.IsValidByAttemptingCount
                                          ? fileData.SetAttemptingCount(fileData.AttemptingConvertCount + 1).
                        Void(_ => _convertingFileData.CloseApplication()).
                        Map(fileDataUncompleted => ConvertingByCountLimit(fileDataUncompleted, convertingSettings))
                                          : new FileDataServer(fileData, StatusProcessing.ConvertingComplete, errors)).
         Value);
 /// <summary>
 /// Печать и экспорт файла
 /// </summary>
 private IResultCollection <IFileDataSourceServer> MakeConvertingFileActions(IDocumentLibrary documentLibrary, IFileDataServer fileDataServer,
                                                                             IConvertingSettings convertingSettings) =>
 CreateProcessingFile(documentLibrary, fileDataServer, convertingSettings).
 Map(saveResultPdf => ExportFileToSaveResult(saveResultPdf, documentLibrary, fileDataServer, convertingSettings)).
 Map(CheckDataSourceExistence);
 /// <summary>
 /// Конвертировать файл
 /// </summary>
 public IFileDataServer Converting(IFileDataServer fileDataServer, IConvertingSettings convertingSettings) =>
 fileDataServer.
 Void(fileData => _messagingService.ShowMessage($"Конвертация файла {fileDataServer.FileNameClient}")).
 Void(fileData => _loggerService.LogByObject(LoggerLevel.Info, LoggerAction.Operation, ReflectionInfo.GetMethodBase(this), fileDataServer.FileNameServer)).
 Map(fileData => ConvertingFile(fileData, convertingSettings));
Exemplo n.º 10
0
 /// <summary>
 /// Конвертер пакета информации о файле из локальной модели в трансферную
 /// </summary>
 public async Task <IResultValue <PackageDataRequestClient> > ToPackageDataRequest(IPackageData packageData,
                                                                                   IConvertingSettings convertingSetting) =>
 await packageData.FilesData.Select(ToFileDataRequest).
 Map(Task.WhenAll).
 MapAsync(filesRequest =>
          filesRequest.ToResultCollection().
          ResultValueOk(requests => new PackageDataRequestClient(packageData.GenerateId(),
                                                                 ToConvertingSettingsRequest(convertingSetting),
                                                                 requests.ToList())));
Exemplo n.º 11
0
 /// <summary>
 /// Произвести печать PDF
 /// </summary>
 private IResultCollection <IFileDataSourceServer> StampContainerCreatePdf(IStampContainer stampContainer, IDocumentLibrary documentLibrary,
                                                                           IFilePath filePath, IConvertingSettings convertingSettings,
                                                                           ConvertingModeType convertingModeType, ColorPrintType colorPrintType) =>
 stampContainer.
 Void(_ => _messagingService.ShowMessage("Вставка подписей...")).
 Map(_ => stampContainer.InsertSignatures().ToResultCollectionFromApplication()).
 ResultVoidOk(signatures => _loggerService.LogByObjects(LoggerLevel.Debug, LoggerAction.Operation, ReflectionInfo.GetMethodBase(this),
                                                        signatures.Select(signature => signature.SignatureLibrary.PersonInformation.FullName))).
 ResultValueOkBind(signatures => StampContainerPrinting(stampContainer.GetStampsToPrint().ToResultCollectionFromApplication(),
                                                        documentLibrary, filePath, convertingSettings, convertingModeType, colorPrintType).
                   Void(_ => _messagingService.ShowMessage("Удаление подписей...")).
                   Void(_ => stampContainer.DeleteSignatures(signatures)).
                   Void(_ => _loggerService.LogByObject(LoggerLevel.Debug, LoggerAction.Operation,
                                                        ReflectionInfo.GetMethodBase(this), nameof(stampContainer.DeleteSignatures)))).
 ToResultCollection();
Exemplo n.º 12
0
 private IResultCollection <IFileDataSourceServer> StampContainerPrinting(IResultCollection <IStamp> stampsToPrint, IDocumentLibrary documentLibrary,
                                                                          IFilePath filePath, IConvertingSettings convertingSettings,
                                                                          ConvertingModeType convertingModeType, ColorPrintType colorPrintType) =>
 stampsToPrint.
 ResultValueOkBind(stamps => StampFilePath.GetFileNamesByNamingType(stamps, filePath.FileNameWithoutExtensionClient, convertingSettings.PdfNamingType).
Exemplo n.º 13
0
 /// <summary>
 /// Произвести печать
 /// </summary>
 private IResultCollection <IFileDataSourceServer> StampContainerPrint(IStampContainer stampContainer, IDocumentLibrary documentLibrary,
                                                                       IFilePath filePath, IConvertingSettings convertingSettings,
                                                                       ConvertingModeType convertingModeType, ColorPrintType colorPrintType) =>
 stampContainer.GetStampsToPrint().ToResultCollectionFromApplication().
 ResultValueOkBind(signatures => StampContainerPrinting(stampContainer.GetStampsToPrint().ToResultCollectionFromApplication(),
                                                        documentLibrary, filePath, convertingSettings, convertingModeType,
                                                        colorPrintType)).
 ToResultCollection();
Exemplo n.º 14
0
 /// <summary>
 /// Преобразовать параметры конвертации в трансферную модель
 /// </summary>
 private static ConvertingSettingsRequest ToConvertingSettingsRequest(IConvertingSettings convertingSetting) =>
 new ConvertingSettingsRequest(convertingSetting.PersonSignature.PersonId ?? String.Empty,
                               convertingSetting.PdfNamingType, convertingSetting.ConvertingModesUsed.ToList(),
                               convertingSetting.UseDefaultSignature);
Exemplo n.º 15
0
 public ProjectSettings(IConvertingSettings convertingSettings)
 {
     ConvertingSettings = convertingSettings ?? throw new ArgumentNullException(nameof(convertingSettings));
 }
 public IResultCollection <IFileDataSourceServer> CreateProcessingFile(IDocumentLibrary documentLibrary, FilePathCollection filePathCollection,
                                                                       IConvertingSettings convertingSettings, ColorPrintType colorPrintType) =>
 ExecuteBindResultValue(() => CreateProcessingDocument(documentLibrary, filePathCollection, convertingSettings, colorPrintType),
                        new ErrorCommon(ErrorConvertingType.PdfPrintingError,
                                        $"Ошибка обработки файла {filePathCollection.FilePathMain.FileNameClient}")).
 ToResultCollection();
 /// <summary>
 /// Преобразовать параметры конвертации в класс модуля конвертирования
 /// </summary>
 public static ConvertingSettingsApp ToConvertingSettingsApplication(IConvertingSettings convertingSettings) =>
 new ConvertingSettingsApp(convertingSettings.PersonId,
                           ToPdfNamingTypeApplication(convertingSettings.PdfNamingType),
                           convertingSettings.UseDefaultSignature);