public void GetFile()
        {
            string text  = (string)base.GetParameter("d");
            string text2 = (string)base.GetParameter("fileName");

            if (text == null || text2 == null)
            {
                throw new OwaInvalidRequestException("DocumentId or fileName does not exist");
            }
            base.DontWriteHeaders = true;
            Utilities.MakePageNoCacheNoStore(this.HttpContext.Response);
            if (text2.EndsWith(".css", StringComparison.OrdinalIgnoreCase))
            {
                this.HttpContext.Response.ContentType = Utilities.GetContentTypeString(OwaEventContentType.Css);
            }
            else
            {
                if (!text2.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase))
                {
                    throw new OwaInvalidRequestException("Unsupported file type");
                }
                this.HttpContext.Response.ContentType = Utilities.GetContentTypeString(OwaEventContentType.Jpeg);
            }
            try
            {
                TranscodingTaskManager.TransmitFile(base.UserContext.Key.UserContextId, text, text2, this.HttpContext.Response);
            }
            catch (TranscodingFatalFaultException innerException)
            {
                throw new OwaInvalidRequestException("The TransmitFile function fails", innerException);
            }
        }
예제 #2
0
 internal void ExecuteApplicationEnd(object sender, EventArgs e)
 {
     Tokenizer.ReleaseWordBreakers();
     InstantMessageOCSProvider.DisposeEndpointManager();
     if (TranscodingTaskManager.IsInitialized)
     {
         TranscodingTaskManager.StopTranscoding();
     }
     OwaConfigurationManager.ShutDownConfigurationManager();
     PerformanceCounterManager.ArePerfCountersEnabled = false;
     Globals.UnloadOwaSettings();
 }
        private static void InitializeTranscodingService()
        {
            if (!TranscodingTaskManager.IsInitialized)
            {
                int    num  = OwaRegistryKeys.WebReadyDocumentViewingConversionTimeout;
                int    num2 = OwaRegistryKeys.WebReadyDocumentViewingRecycleByConversions;
                string text = OwaRegistryKeys.WebReadyDocumentViewingTempFolderLocation;
                int    num3 = OwaRegistryKeys.WebReadyDocumentViewingCacheDiskQuota;
                int    num4 = OwaRegistryKeys.WebReadyDocumentViewingExcelRowsPerPage;
                int    num5 = OwaRegistryKeys.WebReadyDocumentViewingMaxDocumentInputSize;
                int    num6 = OwaRegistryKeys.WebReadyDocumentViewingMaxDocumentOutputSize;
                bool   webReadyDocumentViewingWithInlineImage = OwaRegistryKeys.WebReadyDocumentViewingWithInlineImage;
                int    num7 = OwaRegistryKeys.WebReadyDocumentViewingMemoryLimitInMB;
                if (num <= 0)
                {
                    num = 20;
                }
                if (num2 <= 0)
                {
                    num2 = 150;
                }
                if (!text.EndsWith("\\"))
                {
                    text += "\\";
                }
                if (Path.IsPathRooted(text) && text.Length <= TranscodingTaskManager.XCRootPathMaxLength)
                {
                    if (Directory.Exists(text))
                    {
                        goto IL_ED;
                    }
                    try
                    {
                        Directory.CreateDirectory(text);
                        goto IL_ED;
                    }
                    catch (IOException ex)
                    {
                        ExTraceGlobals.TranscodingTracer.TraceDebug <Type, string>(0L, "Fail to create the XC temp folder. Exception: Type: {0} Error: {1}.", ex.GetType(), ex.Message);
                        text = OwaRegistryKeys.DefaultTempFolderLocation;
                        goto IL_ED;
                    }
                    catch (UnauthorizedAccessException ex2)
                    {
                        ExTraceGlobals.TranscodingTracer.TraceDebug <Type, string>(0L, "Fail to create the XC temp folder. Exception: Type: {0} Error: {1}.", ex2.GetType(), ex2.Message);
                        text = OwaRegistryKeys.DefaultTempFolderLocation;
                        goto IL_ED;
                    }
                }
                text = OwaRegistryKeys.DefaultTempFolderLocation;
IL_ED:
                if (num3 <= 0)
                {
                    num3 = 1000;
                }
                if (num4 <= 0)
                {
                    num4 = 200;
                }
                if (num5 <= 0)
                {
                    num5 = 5000;
                }
                if (num6 <= 0)
                {
                    num6 = 5000;
                }
                if (num7 <= 0)
                {
                    num7 = 200;
                }
                TranscodingTaskManager.Initialize(num, num2, text, num3, num4, num5, num6, webReadyDocumentViewingWithInlineImage, HtmlFormat.Version40, num7);
            }
        }
        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);
                    }
                }
            }
        }