public void InvokeTaskManager()
        {
            if (!AppSettings.GetConfiguredValue <bool>("TranscodingServiceEnabled", false))
            {
                this.HandleFault(LocalizedStrings.GetNonEncoded(500694802));
                return;
            }
            AttachmentPolicy attachmentPolicy = this.owaContext.UserContext.AttachmentPolicy;

            using (Stream stream = this.LoadDocument(true, out this.decryptionStatus))
            {
                if (this.decryptionStatus.Failed)
                {
                    SanitizedHtmlString irmErrorDetails = WebReadyViewUtilities.GetIrmErrorDetails(this.owaContext.UserContext, this.decryptionStatus);
                    this.HandleFault(irmErrorDetails.ToString());
                }
                else if (!attachmentPolicy.WebReadyDocumentViewingEnable)
                {
                    this.HandleFault(LocalizedStrings.GetNonEncoded(500694802));
                }
                else if (!AttachmentUtility.IsWebReadyDocument(this.fileExtension, this.mimeType))
                {
                    this.HandleFault(LocalizedStrings.GetNonEncoded(-1584334964));
                }
                else
                {
                    try
                    {
                        byte[] bytes = Encoding.Default.GetBytes(this.documentIdStringBuilder.ToString());
                        byte[] value = null;
                        using (MessageDigestForNonCryptographicPurposes messageDigestForNonCryptographicPurposes = new MessageDigestForNonCryptographicPurposes())
                        {
                            value = messageDigestForNonCryptographicPurposes.ComputeHash(bytes);
                        }
                        WebReadyViewUtilities.InitializeTranscodingService();
                        Utilities.MakePageNoCacheNoStore(this.owaContext.HttpContext.Response);
                        string sourceDocType = string.IsNullOrEmpty(this.fileExtension) ? this.mimeType : this.fileExtension.TrimStart(new char[]
                        {
                            '.'
                        });
                        try
                        {
                            TranscodingTaskManager.Transcode(BitConverter.ToString(value), this.owaContext.UserContext.Key.UserContextId, stream, sourceDocType, this.currentPageNumber, out this.totalPageNumber, this.owaContext.HttpContext.Response);
                        }
                        catch (TranscodingCrashException innerException)
                        {
                            OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_TranscodingWorkerProcessFails, string.Empty, new object[]
                            {
                                this.owaContext.LogonIdentity.GetLogonName(),
                                this.owaContext.LogonIdentity.UserSid.Value,
                                this.messageFrom,
                                this.messageSubject,
                                this.messageId,
                                this.documentPath,
                                this.documentIdStringBuilder.ToString()
                            });
                            throw new TranscodingUnconvertibleFileException("Transcoding service crash when converting the document.", innerException, this);
                        }
                        if (this.currentPageNumber == 0)
                        {
                            this.currentPageNumber = this.totalPageNumber;
                        }
                    }
                    catch (TranscodingException ex)
                    {
                        ExTraceGlobals.TranscodingTracer.TraceDebug <Type, string>(0L, "Exception: Type: {0} Error: {1}.", ex.GetType(), ex.Message);
                        ErrorInformation exceptionHandlingInformation = Utilities.GetExceptionHandlingInformation(ex, this.owaContext.MailboxIdentity);
                        this.HandleFault(exceptionHandlingInformation.Message);
                    }
                }
            }
        }