/// <summary>
        ///
        /// </summary>
        /// <param name="dbContext"></param>
        /// <param name="work"></param>
        /// <param name="mode"></param>
        /// <param name="msgLink"></param>
        /// <param name="encoding"></param>
        public MessageBodyStream(DbContext dbContext, UnitOfWork work, DataStreamMode mode, int msgLink, Encoding encoding)
            : base(dbContext, work, mode, msgLink, encoding)
        {
            switch (mode)
            {
            case DataStreamMode.READ:
            {
                string sql = String.Format("SELECT BODY_VALUE FROM {0} WHERE LINK={1}", this.tableName, this.MessageLINK);
                this.command = new SqlCommand(sql, (SqlConnection)work.Session.Connection);
                this.command.CommandTimeout = this.ReadTimeout;
            }
            break;

            case DataStreamMode.WRITE:
            {
                string sql = String.Format("UPDATE {0} SET BODY_VALUE = ISNULL(BODY_VALUE, '') WHERE LINK={1};", this.tableName, this.MessageLINK);
                sql           += String.Format("UPDATE {0} SET BODY_VALUE .WRITE(@data, null, null) WHERE LINK={1};", this.tableName, this.MessageLINK);
                this.command   = new SqlCommand(sql, (SqlConnection)work.Session.Connection);
                this.parameter = new SqlParameter("@data", SqlDbType.NVarChar);
                this.command.CommandTimeout = this.WriteTimeout;
                this.command.Parameters.Add(this.parameter);
            }
            break;
            }

            if (this.Work.Transaction != null)
            {
                this.Work.Transaction.Enlist(this.command);
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dbContext"></param>
        /// <param name="work"></param>
        /// <param name="mode"></param>
        /// <param name="encoding"></param>
        protected DataStreamBase(DbContext dbContext, UnitOfWork work, DataStreamMode mode, Encoding encoding)
        {
            #region Validate parameters
            if (dbContext == null)
            {
                throw new ArgumentNullException("dbContext");
            }

            if (work == null)
            {
                throw new ArgumentNullException("work");
            }

            if (encoding == null)
            {
                throw new ArgumentNullException("encoding");
            }
            #endregion

            this.DbContext = dbContext;
            this.Work      = work;
            this.Mode      = mode;
            this.Encoding  = encoding;

            this.ReadTimeout = this.WriteTimeout = 30;
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="dbContext"></param>
 /// <param name="work"></param>
 /// <param name="mode"></param>
 /// <param name="msgLink"></param>
 /// <param name="encoding"></param>
 protected MessageBodyStreamBase(DbContext dbContext, UnitOfWork work, DataStreamMode mode, int msgLink, Encoding encoding)
     : base(dbContext, work, mode, encoding)
 {
     this.MessageLINK = msgLink;
 }
示例#4
0
 protected override MessageContentStreamBase ConstructMessageContentStream(int contentLink, UnitOfWork work, DataStreamMode mode, Encoding encoding)
 {
     return(new MessageContentStream(this.DbContext, work, mode, contentLink, encoding));
 }
 protected abstract MessageContentStreamBase ConstructMessageContentStream(int contentLink, UnitOfWork work, DataStreamMode mode, Encoding encoding);
 protected abstract MessageBodyStreamBase ConstructMessageBodyStream(int msgLink, UnitOfWork work, DataStreamMode mode, Encoding encoding);