Пример #1
0
        public Stream GetCollectionSnapshot(string collectionId, string id)
        {
            try
            {
                var format = GetRequestedFormat();

                if (format.Equals("nt"))
                {
                    var woc = WebOperationContext.Current;
                    woc.OutgoingResponse.ContentType = "text/plain";
                }
                else
                {
                    var woc = WebOperationContext.Current;
                    woc.OutgoingResponse.ContentType = "application/xml";
                    woc.OutgoingResponse.Format      = WebMessageFormat.Xml;
                }
                var snapshot = _serverCore.GetSnapshot(collectionId, id, format);
                if (snapshot == null)
                {
                    RaiseNotFound("No collection with id " + collectionId + " or snapshot " + id);
                }
                return(snapshot);
            }
            catch (Exception ex)
            {
                if (!(ex is WebFaultException <string>))
                {
                    RaiseServerException(ex,
                                         "Error processing GetCollectionSnapshot for " + collectionId + " " + id +
                                         " see server logs for details.");
                    return(null);
                }
                throw;
            }
        }