private object InternalExecute()
        {
            DEInstenceOperationContext context = new DEInstenceOperationContext(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);
        }
        private void PersistOperationLog(DEInstenceOperationContext context)
        {
            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                context.Logs.ForEach(log => DEOperationLogAdapter.Instance.Insert(log));

                scope.Complete();
            }
        }
Пример #3
0
        protected override void PrepareOperationLog(DEInstenceOperationContext context)
        {
            DEOperationLog log = DEOperationLog.CreateLogFromEnvironment();

            log.ResourceID    = this.Data.ID;
            log.SchemaType    = "DynamiceEntityInstence";
            log.OperationType = this.OperationType;
            log.Category      = this.Data.Name;
            log.Subject       = string.Format("{0}: {1}",
                                              EnumItemDescriptionAttribute.GetDescription(this.OperationType), this.Data.Name);

            log.SearchContent = this.Data.Name;
            context.Logs.Add(log);
        }
Пример #4
0
        /// <summary>
        /// 执行操作
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        protected override object DoOperation(DEInstenceOperationContext context)
        {
            object result = null;

            if (this.NeedValidation)
            {
                //验证数据
                this.Data.Validate();
                DEInstanceAdapter.Instance.Update(this.Data);
            }
            else
            {
                //不验证 直接入库
                DEInstanceAdapter.Instance.Update(this.Data);
            }

            if (this.NeedSnapshot && this.SnapshotAdapter != null)
            {
                this.SnapshotAdapter.Update(this.Data);
            }

            return(result);
        }
Пример #5
0
 protected override void PrepareData(DEInstenceOperationContext context)
 {
     this.Validate();
     base.PrepareData(context);
 }
 /// <summary>
 /// 准备操作日志
 /// </summary>
 /// <param name="context"></param>
 protected virtual void PrepareOperationLog(DEInstenceOperationContext context)
 {
 }
 /// <summary>
 /// 操作
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 protected abstract object DoOperation(DEInstenceOperationContext context);