Ejemplo n.º 1
0
        private static void OnNewConverterCreatedCallback(IComWorker <IOleConverter> converterProcess, object requestParameters)
        {
            IOleConverter worker = converterProcess.Worker;
            uint          num    = 0U;
            string        conversionsDirectory = OleConverter.GetConversionsDirectory(true);

            if (conversionsDirectory == null)
            {
                StorageGlobals.ContextTraceError(ExTraceGlobals.CcOleTracer, "OleConverter::OnNewConverterCreatedCallback: conversions directory full or inaccessible.");
                throw new OleConversionFailedException(ServerStrings.OleConversionFailed);
            }
            int num2;

            worker.ConfigureConverter(out num2, 4194304U, 262144U, conversionsDirectory, out num);
            if (num2 != 0)
            {
                StorageGlobals.ContextTraceError(ExTraceGlobals.CcOleTracer, "OleConverter::OnNewConverterCreatedCallback: failed to configure converter.");
                throw new OleConversionFailedException(ServerStrings.OleConversionFailed, new COMException("HRESULT =", num2));
            }
            if (num != (uint)converterProcess.ProcessId)
            {
                StorageGlobals.ContextTraceError(ExTraceGlobals.CcOleTracer, "OleConverter::OnNewConverterCreatedCallback: process id mismatch.");
                throw new OleConversionFailedException(ServerStrings.OleConversionInitError(Process.GetCurrentProcess().ProcessName, converterProcess.ProcessId, (int)num));
            }
        }
Ejemplo n.º 2
0
        private static bool OnExecuteRequestCallback(IComWorker <IOleConverter> converterProcess, object requestParameters)
        {
            OleConverter.ConversionRequestParameters conversionRequestParameters = (OleConverter.ConversionRequestParameters)requestParameters;
            object responseData = null;
            int    num;

            converterProcess.Worker.OleConvertToBmp(out num, conversionRequestParameters.RequestData, out responseData);
            if (num != 0)
            {
                throw new OleConversionFailedException(ServerStrings.OleConversionFailed, new COMException("HRESULT =", num));
            }
            conversionRequestParameters.ResponseData = responseData;
            return(true);
        }
        // Token: 0x06001CB9 RID: 7353 RVA: 0x000A52D8 File Offset: 0x000A34D8
        private void OnCreateWorkerDelegate(IComWorker <ITranscoder> worker, object requestParameters)
        {
            ITranscoder worker2 = worker.Worker;

            if (worker2 == null)
            {
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_TranscodingWorkerInitializationFailed, string.Empty, new object[]
                {
                    string.Empty
                });
                throw new TranscodingFatalFaultException("TranscodingTaskManager failed to get ITranscoder interface", null, this);
            }
            TranscodingInitOption initOption = default(TranscodingInitOption);

            initOption.MaxOutputSize         = this.maxOutputSize;
            initOption.RowNumberPerExcelPage = this.rowNumberInExcel;
            initOption.HtmlOutputFormat      = this.htmlFormat;
            initOption.IsImageMode           = this.isImageMode;
            TranscodeErrorCode transcodeErrorCode = TranscodeErrorCode.Succeeded;

            try
            {
                transcodeErrorCode = worker2.Initialize(initOption);
            }
            catch (NullReferenceException innerException)
            {
                throw new TranscodingFatalFaultException("Worker has been terminated by some reason", innerException, this);
            }
            catch (COMException ex)
            {
                ExTraceGlobals.TranscodingTracer.TraceDebug((long)this.GetHashCode(), "Work object initialize failed!");
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_TranscodingWorkerInitializationFailed, string.Empty, new object[]
                {
                    ex.Message
                });
                throw new TranscodingFatalFaultException("TranscodingTaskManager call ITranscoder.Initialize() failed!", ex, this);
            }
            if (transcodeErrorCode != TranscodeErrorCode.Succeeded)
            {
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_TranscodingWorkerInitializationFailed, string.Empty, new object[]
                {
                    string.Empty
                });
                throw new TranscodingFatalFaultException(string.Format("Initializalize Transcoding service failed with error code : {0}.", transcodeErrorCode), null, this);
            }
        }
Ejemplo n.º 4
0
 private static void OnConverterDestroyedCallback(IComWorker <IOleConverter> converterProcess, object requestParameters, bool isForcedTermination)
 {
 }
        // Token: 0x06001CBA RID: 7354 RVA: 0x000A541C File Offset: 0x000A361C
        private bool OnExecuteRequestDelegate(IComWorker <ITranscoder> worker, object requestParameters)
        {
            TranscodingParameters transcodingParameters = (TranscodingParameters)requestParameters;
            ITranscoder           transcoder            = null;

            try
            {
                transcoder = worker.Worker;
            }
            catch (ObjectDisposedException innerException)
            {
                throw new TranscodingFatalFaultException("Worker object has been disposed", innerException);
            }
            this.UpdatePerformanceCounterAfterLeftQueue(transcodingParameters);
            this.UpdatePerformanceCounterBeforeConversion(transcodingParameters);
            int totalPageNumber = 0;
            int num             = 0;
            TranscodeErrorCode?transcodeErrorCode = null;
            string             text  = null;
            string             text2 = null;
            bool result;

            try
            {
                try
                {
                    ExTraceGlobals.TranscodingTracer.TraceDebug <string>((long)this.GetHashCode(), "Start to cache input document {0}", transcodingParameters.DocumentId);
                    this.cache.CacheInputDocument(transcodingParameters.SessionId, transcodingParameters.DocumentId, transcodingParameters.SourceStream, out text, out text2);
                    using (FileStream fileStream = File.Open(text, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        transcodingParameters.SourceDocSize = (int)fileStream.Length;
                    }
                    ExTraceGlobals.TranscodingTracer.TraceDebug <string>((long)this.GetHashCode(), "Start to transcode {0}", transcodingParameters.DocumentId);
                    transcodeErrorCode = new TranscodeErrorCode?(transcoder.Convert(text, text2, transcodingParameters.SourceDocType, transcodingParameters.CurrentPageNumber, out totalPageNumber, out num));
                    ExTraceGlobals.TranscodingTracer.TraceDebug <string, TranscodeErrorCode?>((long)this.GetHashCode(), "Document {0} transcoding finished with return code {1}", transcodingParameters.DocumentId, transcodeErrorCode);
                    transcodingParameters.TotalPageNumber = totalPageNumber;
                }
                finally
                {
                    this.UpdatePerformanceCounterAfterConversion(transcodingParameters);
                    transcodingParameters.ErrorCode = transcodeErrorCode;
                    if (transcodeErrorCode == TranscodeErrorCode.Succeeded)
                    {
                        OwaSingleCounters.TotalConvertingResponseRate.IncrementBy((long)(num / 1024));
                    }
                    string rewrittenHtmlFileName = null;
                    if (!string.IsNullOrEmpty(text2))
                    {
                        this.cache.NotifyTranscodingFinish(transcodingParameters.SessionId, transcodingParameters.DocumentId, Path.GetFileName(text2), out rewrittenHtmlFileName, transcodeErrorCode == TranscodeErrorCode.Succeeded);
                        transcodingParameters.RewrittenHtmlFileName = rewrittenHtmlFileName;
                    }
                }
                if (transcodeErrorCode == TranscodeErrorCode.Succeeded || transcodeErrorCode == TranscodeErrorCode.WrongFileTypeError || transcodeErrorCode == TranscodeErrorCode.InvalidPageNumberError)
                {
                    result = true;
                }
                else
                {
                    this.blockList.AddNew(transcodingParameters.DocumentId);
                    result = false;
                }
            }
            catch (IOException ex)
            {
                ExTraceGlobals.TranscodingTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Document {0} can not be transcoded because of an IO error. Exception message: {1}", transcodingParameters.DocumentId, ex.Message);
                throw new TranscodingUnconvertibleFileException(string.Format("Document {0} can not be transcoded because of an IO error.", transcodingParameters.DocumentId), ex, this);
            }
            return(result);
        }