Пример #1
0
        public System.IO.Stream ExportHistory(string SenderID)
        {
            StringBuilder result = new StringBuilder();

            try
            {
                IChatMessageRepository repo = new ChatMessageRepository();
                var messages = repo.GetConversationHistory(SPContext.Current.Web.CurrentUser.ID, Int32.Parse(SenderID));
                result.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
                result.Append("<ChatMessages>");
                foreach (ChatMessage msg in messages)
                {
                    result.Append(msg.GetXml());
                }
                result.Append("</ChatMessages>");
            }
            catch (Exception ex)
            {
                Config.WriteException(ex);
                WebOperationContext.Current.OutgoingResponse.StatusCode        = System.Net.HttpStatusCode.InternalServerError;
                WebOperationContext.Current.OutgoingResponse.StatusDescription = Language.CreateChatMessageError;
            }
            WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
            return(new MemoryStream(Encoding.UTF8.GetBytes(result.ToString())));;
        }