/// <summary> /// Сохранить тело сообщения. /// </summary> /// <param name="body"></param> public virtual void SaveMessageBody(MessageBody body) { #region Validate parameters if (body == null) { throw new ArgumentNullException("body"); } #endregion MessageBodyInfo bodyInfo = body.BodyInfo(); ContentType contentType = bodyInfo.ContentType(); Encoding encoding = contentType.Encoding(); DAO.MessageBodyInfo dao = bodyInfo.ToDao(); using (UnitOfWork work = BeginWork()) { work.Update <DAO.MessageBodyInfo>(ref dao); using (MessageBodyStreamBase stream = ConstructMessageBodyStream(dao.MessageLINK, work, DataStreamMode.WRITE, encoding)) { stream.WriteTimeout = this.ExecuteTimeout; var buffer = new char[this.bufferSize]; int charsReaded; do { charsReaded = body.Value.Read(buffer, 0, buffer.Length); if (charsReaded > 0) { stream.Write(buffer, 0, charsReaded); } } while (charsReaded > 0); if (dao.Length == null) { dao.Length = (int)stream.Length; work.Update <DAO.MessageBodyInfo>(ref dao); } work.End(); } } bodyInfo = dao.ToObj(); body.ApplyInfo(bodyInfo); }