예제 #1
0
        /// <summary>
        /// Sets the content stream of the given Document instance ID
        /// </summary>
        /// <param name="blob">Information about the given blob</param>
        /// <returns>the newly created Blob instance</returns>
        public BlobResponse SetBlobStream(BlobMessage blob)
        {
            using (Logging.Facade.DebugTraceMethodCall("SetBlobStream"))
            {
                if (blob == null)
                    throw new ArgumentNullException("blob");
                try
                {
                    DebugLogIdentity();
                    if (Logging.Facade.IsDebugEnabled)
                    {
                        long length = -1;
                        try { length = blob.Stream.Length; }
                        catch (NotSupportedException)
                        {
                            // ignore missing support for accessing the stream's length
                            length = -2;
                        }
                        catch (Exception ex)
                        {
                            Logging.Facade.Debug(string.Format("SetBlobStream failed to access {0}.Length", blob.Stream.GetType()), ex);
                            length = -3;
                        }

                        Logging.Facade.DebugFormat("SetBlobStream started with BlobMessage ( FileName='{0}', MimeType='{1}', Stream='{2}' of length={3} )",
                            blob.FileName,
                            blob.MimeType,
                            blob.Stream.GetType().FullName,
                            length);
                    }

                    using (IZetboxContext ctx = _ctxFactory())
                    {
                        var result = _sohFactory
                            .GetServerDocumentHandler()
                            .SetBlobStream(blob.Version, ctx, blob.Stream, blob.FileName, blob.MimeType);

                        if (Logging.Facade.IsDebugEnabled)
                        {
                            using (var stream = result.GetStream())
                                Logging.Facade.DebugFormat("SetBlobStream created Blob with ID=#{0}, length={1}.", result.ID, stream.Length);
                        }
                        return new BlobResponse()
                        {
                            ID = result.ID,
                            BlobInstance = SendObjects(new IDataObject[] { result }, true)
                        };
                    }
                }
                catch (Exception ex)
                {
                    Helper.ThrowFaultException(ex);
                    // Never called, Handle errors throws an Exception
                    return null;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Sets the content stream of the given Document instance ID
        /// </summary>
        /// <param name="blob">Information about the given blob</param>
        /// <returns>the newly created Blob instance</returns>
        public BlobResponse SetBlobStream(BlobMessage blob)
        {
            using (Logging.Facade.DebugTraceMethodCall("SetBlobStream"))
            {
                if (blob == null)
                    throw new ArgumentNullException("blob");
                try
                {
                    DebugLogIdentity();

                    using (IZetboxContext ctx = _ctxFactory())
                    {
                        var result = _sohFactory
                            .GetServerDocumentHandler()
                            .SetBlobStream(blob.Version, ctx, blob.Stream, blob.FileName, blob.MimeType);
                        BlobResponse resp = new BlobResponse();
                        resp.ID = result.ID;
                        resp.BlobInstance = SendObjects(new IDataObject[] { result }, true);
                        return resp;
                    }
                }
                catch (Exception ex)
                {
                    Helper.ThrowFaultException(ex);
                    // Never called, Handle errors throws an Exception
                    return null;
                }
            }
        }