Esempio n. 1
0
        private object InternalExecute()
        {
            AMSOperationContext context = new AMSOperationContext(this.OperationType, this);

            ExecutionWrapper("PrepareData", () => PrepareData(context));
            ExecutionWrapper("PrepareOperationLog", () => PrepareOperationLog(context));

            object result = null;

            if (this.AutoStartTransaction)
            {
                using (TransactionScope scope = TransactionScopeFactory.Create())
                {
                    ExecutionWrapper("DoOperation", () => result = DoOperation(context));
                    ExecutionWrapper("PersistOperationLog", () => PersistOperationLog(context));

                    scope.Complete();
                }
            }
            else
            {
                ExecutionWrapper("DoOperation", () => result = DoOperation(context));
                ExecutionWrapper("PersistOperationLog", () => PersistOperationLog(context));
            }

            return(result);
        }
        protected override object DoOperation(AMSOperationContext context)
        {
            if (this._DataAction != null)
            {
                this._DataAction(this._Key);
            }

            return(this._Key);
        }
Esempio n. 3
0
        private void PersistOperationLog(AMSOperationContext context)
        {
            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                context.Logs.ForEach(log => UserOperationLogSqlAdapter.Instance.Add(log));

                scope.Complete();
            }
        }
        protected override void PrepareOperationLog(AMSOperationContext context)
        {
            UserOperationLog log = new UserOperationLog();

            log.Subject    = this.GetOperationDescription();
            log.ResourceID = this._Key.ToString();

            log.FillHttpContext();

            context.Logs.Add(log);
        }
Esempio n. 5
0
 protected override object DoOperation(AMSOperationContext context)
 {
     try
     {
         return(AMSEventSqlAdapter.Instance.AddChannel(this.EventID, this.ChannelIDs));
     }
     catch (System.Data.SqlClient.SqlException ex)
     {
         if (ex.Number == 2627)
         {
             throw new SystemSupportException(string.Format("在事件{0}中不能增加重复的频道", this.EventID));
         }
         else
         {
             throw;
         }
     }
 }
 protected override object DoOperation(AMSOperationContext context)
 {
     return(AMSEventSqlAdapter.Instance.DeleteChannels(this.EventID, this.ChannelIDs));
 }
        /// <summary>
        /// 重载了准备数据,进行校验
        /// </summary>
        /// <param name="context"></param>
        protected override void PrepareData(AMSOperationContext context)
        {
            base.PrepareData(context);

            this.Validate();
        }
Esempio n. 8
0
 /// <summary>
 /// 准备操作日志
 /// </summary>
 /// <param name="context"></param>
 protected virtual void PrepareOperationLog(AMSOperationContext context)
 {
 }
Esempio n. 9
0
 /// <summary>
 /// 准备数据,包括校验数据。这个操作在事务之外
 /// </summary>
 /// <param name="context"></param>
 protected virtual void PrepareData(AMSOperationContext context)
 {
 }
Esempio n. 10
0
 /// <summary>
 /// 执行在事务内具体的数据操作,需要重载
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 protected abstract object DoOperation(AMSOperationContext context);