示例#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));
示例#2
0
 internal DocumentViewListToolbar(IDocumentLibrary documentLibrary, UriFlags libraryType, bool isRootFolder) : base("divTBL")
 {
     this.documentLibrary = documentLibrary;
     this.libraryType     = libraryType;
     this.isRootFolder    = isRootFolder;
     this.contextMenu     = new DocumentBreadcrumbBarContextMenu(base.UserContext);
 }
 /// <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>
 /// Экспортировать в другие форматы
 /// </summary>
 private IResultValue <IFileDataSourceServer> ExportFile(IDocumentLibrary documentLibrary, IFilePath filePath, StampDocumentType stampDocumentType) =>
 new ResultError().
 ResultVoidOk(_ => _messagingService.ShowMessage("Экспорт файла")).
 ResultVoidOk(_ => _loggerService.LogByObject(LoggerLevel.Info, LoggerAction.Operation, ReflectionInfo.GetMethodBase(this), filePath.FileNameServer)).
 ResultValueOk(_ => ConvertingFilePath.CreateSavingPath(filePath.FilePathServer,
                                                        _applicationConverting.GetExportFileExtension(filePath.FileExtensionType),
                                                        _fileSystemOperations)).
 ResultValueOkBind(fileExportPath => _applicationConverting.CreateExportFile(documentLibrary, filePath.ChangeServerPath(fileExportPath),
                                                                             stampDocumentType)).
 Void(result => _messagingService.ShowErrors(result.Errors));
 /// <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();
示例#6
0
 /// <summary>
 /// Печать
 /// </summary>
 private IResultValue <IFileDataSourceServer> CreatePrintingService(IDocumentLibrary documentLibrary, IStamp stamp, IFilePath filePath,
                                                                    ConvertingModeType convertingModeType, ColorPrintType colorPrintType,
                                                                    IResultValue <IPrinterInformation> printerInformation) =>
 printerInformation.
 ResultVoidOk(printer => _messagingService.ShowMessage($"Установка принтера {printer.Name}")).
 ResultVoidOk(printer => SetDefaultPrinter(printer.Name)).
 ResultVoidOk(printer => _messagingService.ShowMessage($"Печать файла {filePath.FileNameClient}")).
 ResultValueOkBind(_ => PrintCommand(documentLibrary, stamp, filePath.FilePathServer, convertingModeType, colorPrintType,
                                     printerInformation.Value.PrefixSearchPaperSize)).
 ResultVoidOk(_ => _loggerService.LogByObject(LoggerLevel.Debug, LoggerAction.Operation, ReflectionInfo.GetMethodBase(this), filePath.FilePathServer)).
 ResultValueOk(_ => new FileDataSourceServer(filePath.FilePathServer, filePath.FilePathClient, convertingModeType,
                                             stamp.PaperSize, printerInformation.Value.Name));
 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();
 public IResultValue <IFileDataSourceServer> SaveDocument(IDocumentLibrary documentLibrary, IFilePath filePath) =>
 ExecuteAndHandleError(() => documentLibrary.SaveAs(filePath.FilePathServer),
                       errorMessage: new ErrorCommon(ErrorConvertingType.PdfPrintingError, $"Ошибка сохранения файла {filePath.FileNameClient}")).
 ResultValueOk(_ => new FileDataSourceServer(filePath.FilePathServer, filePath.FilePathClient, ConvertingModeType.Main));
示例#9
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).
示例#10
0
        // Token: 0x06000741 RID: 1857 RVA: 0x00026D8C File Offset: 0x00024F8C
        public void Execute()
        {
            Uri uri = null;

            try
            {
                uri = new Uri(this.linkId);
            }
            catch (UriFormatException innerException)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, string.Format(CultureInfo.InvariantCulture, "DocumentLibrarySearchProvider: Bad Uri {0} was specified!", new object[]
                {
                    this.linkId
                }));
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "BadLinkInDocSearch");
                throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, innerException, false);
            }
            AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "Processing Search command with Uri {0}.", uri.AbsoluteUri);
            if (!DocumentLibraryUtility.IsTrustedProtocol(uri.Scheme))
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, string.Format(CultureInfo.InvariantCulture, "ItemOperationsFetchProvider: untrusted protocol: {0}!", new object[]
                {
                    uri.Scheme
                }));
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "BadProtocolInDocSearch");
                throw new AirSyncPermanentException(StatusCode.Sync_InvalidParameters, false);
            }
            if (!DocumentLibraryUtility.IsInternalUri(uri))
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, string.Format(CultureInfo.InvariantCulture, "ItemOperationsFetchProvider: Uri must be internal: {0}!", new object[]
                {
                    uri.Host
                }));
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ExternalProtocolInDocSearch");
                throw new AirSyncPermanentException(StatusCode.Sync_InvalidParameters, false);
            }
            AuthenticationContext authenticationContext = new AuthenticationContext();

            try
            {
                IPrincipal principal;
                if (this.userPassword == null)
                {
                    principal = this.user.WindowsPrincipal;
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "DocumentLibrarySearchProvider: Created IPrincipal object from IAirSyncUser .");
                    if (principal == null)
                    {
                        if (GlobalSettings.EnableCredentialRequest && this.user.Context.Request.Version >= 121)
                        {
                            this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NeedPromptForCredsToProxy2");
                            throw new AirSyncPermanentException(StatusCode.Sync_InvalidWaitTime, false);
                        }
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NeedCredsToProxy2");
                        throw new AirSyncPermanentException(HttpStatusCode.Forbidden, StatusCode.AccessDenied, null, false);
                    }
                }
                else
                {
                    SecurityStatus securityStatus = authenticationContext.LogonUser(this.userName, this.userPassword);
                    this.userPassword.Dispose();
                    this.userPassword = null;
                    if (securityStatus != SecurityStatus.OK)
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, string.Format(CultureInfo.InvariantCulture, "DocumentLibrarySearchProvider: Authentication failed with status {0}.", new object[]
                        {
                            securityStatus
                        }));
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, string.Format(CultureInfo.InvariantCulture, "AuthenticationErrorStatus{0}", new object[]
                        {
                            securityStatus
                        }));
                        throw new AirSyncPermanentException(HttpStatusCode.OK, StatusCode.Sync_ServerError, null, false);
                    }
                    principal = new WindowsPrincipal(authenticationContext.Identity);
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "DocumentLibrarySearchProvider: Created IPrincipal using AuthenticationContext LogonUser method.");
                }
                ClassifyResult classifyResult = LinkClassifier.ClassifyLinks(principal, new Uri[]
                {
                    uri
                })[0];
                if (classifyResult.Error != ClassificationError.None)
                {
                    AirSyncDiagnostics.TraceDebug <string, ClassificationError>(ExTraceGlobals.RequestsTracer, this, "The LinkClassifier failed to classify the link {0}, returned {1}", this.linkId, classifyResult.Error);
                    switch (classifyResult.Error)
                    {
                    case ClassificationError.ConnectionFailed:
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "LinkClassConnFailedInDocSearch");
                        throw new AirSyncPermanentException(HttpStatusCode.OK, StatusCode.Sync_Conflict, null, false);

                    case ClassificationError.AccessDenied:
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "LinkClassDeniedInDocSearch");
                        throw new AirSyncPermanentException(HttpStatusCode.OK, StatusCode.Sync_ServerError, null, false);

                    case ClassificationError.ObjectNotFound:
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "LinkClassNotFoundInDocSearch");
                        throw new AirSyncPermanentException(HttpStatusCode.OK, StatusCode.Sync_ClientServerConversion, null, false);

                    case ClassificationError.UriTypeNotSupported:
                    case ClassificationError.InvalidUri:
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "LinkClassBadUriInDocSearch");
                        throw new AirSyncPermanentException(HttpStatusCode.OK, StatusCode.Sync_ProtocolError, null, false);
                    }
                    this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "LinkClassFailureInDocSearch");
                    throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, false);
                }
                AirSyncDiagnostics.TraceDebug <UriFlags>(ExTraceGlobals.RequestsTracer, this, "Search command document type is {0}.", classifyResult.UriFlags);
                SharepointSession      sharepointSession     = null;
                UncSession             uncSession            = null;
                IDocumentLibraryItem   documentLibraryItem   = null;
                IDocumentLibrary       documentLibrary       = null;
                IDocumentLibraryFolder documentLibraryFolder = null;
                if ((classifyResult.UriFlags & UriFlags.Unc) == UriFlags.Unc)
                {
                    if (!DocumentLibraryUtility.IsUncAccessEnabled(this.user))
                    {
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "AccessDeniedInDocSearch");
                        throw new AirSyncPermanentException(StatusCode.Sync_InvalidParameters, false);
                    }
                    if (DocumentLibraryUtility.IsBlockedHostName(uri.Host))
                    {
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "HostBlockedInDocSearch");
                        throw new AirSyncPermanentException(StatusCode.Sync_InvalidParameters, false);
                    }
                    uncSession = UncSession.Open(classifyResult.ObjectId, principal);
                }
                else
                {
                    if ((classifyResult.UriFlags & UriFlags.Sharepoint) != UriFlags.Sharepoint)
                    {
                        AirSyncDiagnostics.TraceDebug <string, UriFlags>(ExTraceGlobals.RequestsTracer, this, "The Uri {0} of type {1} is not supported for Search", this.linkId, classifyResult.UriFlags);
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "BadLinkInDocSearch2");
                        throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, false);
                    }
                    if (!DocumentLibraryUtility.IsWssAccessEnabled(this.user))
                    {
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "WssDeniedInDocSearch");
                        throw new AirSyncPermanentException(StatusCode.Sync_InvalidParameters, false);
                    }
                    if (DocumentLibraryUtility.IsBlockedHostName(uri.Host))
                    {
                        this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "HostBlockedInDocSearch2");
                        throw new AirSyncPermanentException(StatusCode.Sync_InvalidParameters, false);
                    }
                    sharepointSession = SharepointSession.Open(classifyResult.ObjectId, principal);
                }
                UriFlags uriFlags = classifyResult.UriFlags;
                switch (uriFlags)
                {
                case UriFlags.Sharepoint:
                case UriFlags.Unc:
                    goto IL_645;

                case UriFlags.Sharepoint | UriFlags.Unc:
                case UriFlags.DocumentLibrary:
                    break;

                case UriFlags.SharepointDocumentLibrary:
                    documentLibrary = SharepointDocumentLibrary.Read(sharepointSession, classifyResult.ObjectId);
                    goto IL_645;

                case UriFlags.UncDocumentLibrary:
                    documentLibrary = UncDocumentLibrary.Read(uncSession, classifyResult.ObjectId);
                    goto IL_645;

                default:
                    switch (uriFlags)
                    {
                    case UriFlags.SharepointDocument:
                        documentLibraryItem = SharepointDocument.Read(sharepointSession, classifyResult.ObjectId);
                        goto IL_645;

                    case UriFlags.UncDocument:
                        documentLibraryItem = UncDocument.Read(uncSession, classifyResult.ObjectId);
                        goto IL_645;

                    default:
                        switch (uriFlags)
                        {
                        case UriFlags.SharepointFolder:
                            documentLibraryFolder = SharepointDocumentLibraryFolder.Read(sharepointSession, classifyResult.ObjectId);
                            goto IL_645;

                        case UriFlags.UncFolder:
                            documentLibraryFolder = UncDocumentLibraryFolder.Read(uncSession, classifyResult.ObjectId);
                            goto IL_645;
                        }
                        break;
                    }
                    break;
                }
                AirSyncDiagnostics.TraceDebug <string, UriFlags>(ExTraceGlobals.RequestsTracer, this, "The Uri {0} of type {1} is not supported for Search", this.linkId, classifyResult.UriFlags);
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "BadLinkInDocSearch3");
                throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, false);
IL_645:
                if (documentLibrary != null)
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Calling GetView() for document library...");
                    this.tableView = documentLibrary.GetView(null, DocumentLibrarySearchProvider.sortBy, DocumentLibraryQueryOptions.FoldersAndFiles, DocumentLibrarySearchProvider.documentLibraryProps);
                    this.rootProps = documentLibrary.GetProperties(DocumentLibrarySearchProvider.documentLibraryProps);
                }
                else if (documentLibraryFolder != null)
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Calling GetView() for document folder...");
                    this.tableView = documentLibraryFolder.GetView(null, DocumentLibrarySearchProvider.sortBy, DocumentLibraryQueryOptions.FoldersAndFiles, DocumentLibrarySearchProvider.documentLibraryProps);
                    this.rootProps = documentLibraryFolder.GetProperties(DocumentLibrarySearchProvider.documentLibraryProps);
                }
                else if (documentLibraryItem != null)
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Getting properties for the document item...");
                    this.rootProps = documentLibraryItem.GetProperties(DocumentLibrarySearchProvider.documentLibraryProps);
                }
                else if (sharepointSession != null)
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Calling GetView() on Sharepoint session...");
                    this.tableView    = sharepointSession.GetView(ListBaseType.DocumentLibrary, DocumentLibrarySearchProvider.documentLibraryProps);
                    this.rootProps    = new object[DocumentLibrarySearchProvider.airSyncProps.GetLength(0)];
                    this.rootProps[0] = sharepointSession.Uri;
                    this.rootProps[1] = sharepointSession.DisplayName;
                    this.rootProps[2] = true;
                }
                else
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Calling GetView() on UNC session...");
                    this.tableView    = uncSession.GetView(null, null, DocumentLibrarySearchProvider.documentLibraryProps);
                    this.rootProps    = new object[DocumentLibrarySearchProvider.airSyncProps.GetLength(0)];
                    this.rootProps[0] = uncSession.Uri;
                    this.rootProps[1] = uncSession.Title;
                    this.rootProps[2] = true;
                }
            }
            catch (UnknownErrorException innerException2)
            {
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "BadLinkInDocSearch4");
                throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, innerException2, false);
            }
            catch (AccessDeniedException innerException3)
            {
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "AccessDeniedInDocSearch2");
                throw new AirSyncPermanentException(StatusCode.Sync_ServerError, innerException3, false);
            }
            catch (ConnectionException innerException4)
            {
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ConnFailedInDocSearch");
                throw new AirSyncPermanentException(StatusCode.Sync_Conflict, innerException4, false);
            }
            catch (ObjectNotFoundException innerException5)
            {
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NotFoundInDocSearch");
                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, innerException5, false);
            }
            catch (DocumentLibraryException innerException6)
            {
                this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "FailureInDocSearch");
                throw new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, innerException6, false);
            }
            finally
            {
                if (authenticationContext != null)
                {
                    authenticationContext.Dispose();
                    authenticationContext = null;
                }
            }
        }
 /// <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>
 private IResultError CloseFile(IDocumentLibrary documentLibrary, IFilePath filePath) =>
 _applicationConverting.CloseDocument(documentLibrary, filePath.FilePathServer).
 Void(_ => _messagingService.ShowMessage($"Конвертация файла {filePath.FileNameClient} завершена")).
 Void(_ => _loggerService.LogByObject(LoggerLevel.Info, LoggerAction.Operation, ReflectionInfo.GetMethodBase(this), filePath.FileNameServer));
示例#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();
 public IResultValue <IFileDataSourceServer> CreateExportFile(IDocumentLibrary documentLibrary, IFilePath filePath,
                                                              StampDocumentType stampDocumentType) =>
 ExecuteAndHandleError(() => documentLibrary.Export(filePath.FilePathServer, stampDocumentType),
                       errorMessage: new ErrorCommon(ErrorConvertingType.ExportError, $"Ошибка экспорта файла {filePath.FileNameClient}")).
 ResultValueOk(fileExportPath => new FileDataSourceServer(filePath.FilePathServer, filePath.FilePathClient, ConvertingModeType.Export));
示例#15
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();
示例#16
0
 /// <summary>
 /// Получить путь к сохраненному файлу для обработки
 /// </summary>
 private static IResultCollection <IFileDataSourceServer> GetSavedFileDataSource(IDocumentLibrary documentLibrary, IFilePath filePath) =>
 new FileDataSourceServer(documentLibrary.FullName,
                          filePath.ChangeExtensions(FilePathOperations.ExtensionWithoutPointFromPath(documentLibrary.FullName)).
                          FilePathClient,
                          ConvertingModeType.Main).
 Map(fileDataSource => new ResultValue <IFileDataSourceServer>(fileDataSource).ToResultCollection());
示例#17
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());
示例#18
0
 private IResultError PrintCommand(IDocumentLibrary documentLibrary, IStamp stamp, string filePath,
                                   ConvertingModeType convertingModeType, ColorPrintType colorPrintType,
                                   string prefixSearchPaperSize) =>
 PrintCommandFunc(documentLibrary, stamp, colorPrintType, prefixSearchPaperSize).
 Map(printCommand => convertingModeType switch
 public IResultError CloseDocument(IDocumentLibrary documentLibrary, string filePath) =>
 ExecuteAndHandleError(documentLibrary.Close,
                       catchMethod: documentLibrary.CloseApplication,
                       errorMessage: new ErrorCommon(ErrorConvertingType.FileNotSaved, $"Ошибка закрытия файла {filePath}")).
 ToResult();
示例#20
0
        /// <summary>
        /// Transforms <see cref="DocumentSelectionData" /> from a <see cref="PluginConfigurationData" /> object into a
        /// corresponding <see cref="DocumentCollection" /> using data from the specified <see cref="IDocumentLibrary" />.
        /// </summary>
        /// <param name="configurationData">The <see cref="PluginConfigurationData" />.</param>
        /// <param name="documentLibrary">The <see cref="IDocumentLibrary" />.</param>
        /// <returns>An <see cref="DocumentCollection" /> object.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="configurationData" /> is null.
        /// <para>or</para>
        /// <paramref name="documentLibrary" /> is null.
        /// </exception>
        public static DocumentCollection GetExecutionDocuments(PluginConfigurationData configurationData, IDocumentLibrary documentLibrary)
        {
            if (configurationData == null)
            {
                throw new ArgumentNullException(nameof(configurationData));
            }

            if (documentLibrary == null)
            {
                throw new ArgumentNullException(nameof(documentLibrary));
            }

            DocumentSelectionData documentSelectionData = configurationData.Documents ?? new DocumentSelectionData();
            DocumentCollection    documents             = null;

            switch (documentSelectionData.SelectionMode)
            {
            case DocumentSelectionMode.SpecificDocuments:
                var selected = documentLibrary.GetDocuments().Where(n => documentSelectionData.SelectedDocuments.Contains(n.DocumentId));
                documents = new DocumentCollection(selected.ToList());
                break;

            case DocumentSelectionMode.DocumentSet:
                var documentSet = documentLibrary.GetDocumentSets().First(n => n.Name == documentSelectionData.DocumentSetName);
                documents = documentSet.Documents;
                break;

            case DocumentSelectionMode.DocumentQuery:
                documents = documentLibrary.GetDocuments(documentSelectionData.DocumentQuery);
                break;
            }

            return(documents);
        }