Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        internal Stream ConvertToBitmap(Stream oleDataStream)
        {
            object obj = null;
            int    num = Interlocked.Increment(ref this.nQueueSize);
            Stream result;

            try
            {
                try
                {
                    bool canCacheInMemory = num <= 30;
                    obj = OleConverter.CreateOleObjectData(oleDataStream, canCacheInMemory);
                    OleConverter.ConversionRequestParameters conversionRequestParameters = new OleConverter.ConversionRequestParameters(obj, null);
                    base.ExecuteRequest(conversionRequestParameters);
                    result = OleConverter.CreateResultStream(conversionRequestParameters.ResponseData);
                }
                catch (ComInterfaceInitializeException ex)
                {
                    StorageGlobals.ContextTraceError <ComInterfaceInitializeException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex);
                    throw new OleConversionServerBusyException(ServerStrings.OleConversionFailed, ex);
                }
                catch (ComProcessBusyException ex2)
                {
                    StorageGlobals.ContextTraceError <ComProcessBusyException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex2);
                    throw new OleConversionServerBusyException(ServerStrings.OleConversionFailed, ex2);
                }
                catch (ComProcessTimeoutException ex3)
                {
                    StorageGlobals.ContextTraceError <ComProcessTimeoutException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex3);
                    throw new OleConversionFailedException(ServerStrings.OleConversionFailed, ex3);
                }
                catch (ComProcessBeyondMemoryLimitException ex4)
                {
                    StorageGlobals.ContextTraceError <ComProcessBeyondMemoryLimitException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex4);
                    throw new OleConversionFailedException(ServerStrings.OleConversionFailed, ex4);
                }
                catch (COMException ex5)
                {
                    StorageGlobals.ContextTraceError <COMException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex5);
                    throw new OleConversionFailedException(ServerStrings.OleConversionFailed, ex5);
                }
                catch (InvalidComObjectException ex6)
                {
                    StorageGlobals.ContextTraceError <InvalidComObjectException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex6);
                    throw new OleConversionFailedException(ServerStrings.OleConversionFailed, ex6);
                }
                catch (InvalidCastException ex7)
                {
                    StorageGlobals.ContextTraceError <InvalidCastException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex7);
                    throw new OleConversionFailedException(ServerStrings.OleConversionFailed, ex7);
                }
                catch (NoSupportException ex8)
                {
                    StorageGlobals.ContextTraceError <NoSupportException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex8);
                    throw new OleConversionFailedException(ServerStrings.OleConversionFailed, ex8);
                }
            }
            catch (StoragePermanentException exc)
            {
                OleConverter.SaveFailedConversionData(obj, exc, null);
                throw;
            }
            catch (StorageTransientException exc2)
            {
                OleConverter.SaveFailedConversionData(obj, exc2, null);
                throw;
            }
            finally
            {
                Interlocked.Decrement(ref this.nQueueSize);
                if (obj != null)
                {
                    OleConverter.DestroyOleObjectData(obj);
                }
            }
            return(result);
        }