Ejemplo n.º 1
0
 public FunctionUpdatedEvent(IAcSession acSession, FunctionBase source, IFunctionUpdateIo input)
     : base(acSession, source)
 {
     if (input == null)
     {
         throw new System.ArgumentNullException("input");
     }
     this.Input = input;
 }
Ejemplo n.º 2
0
 public void Update(IFunctionUpdateIo input)
 {
     this.Code = input.Code;
     this.IsManaged = input.IsManaged;
     this.IsEnabled = input.IsEnabled;
     this.Description = input.Description;
     this.DeveloperId = input.DeveloperId;
     this.SortCode = input.SortCode;
 }
Ejemplo n.º 3
0
 public void Update(IFunctionUpdateIo input)
 {
     this.Code        = input.Code;
     this.IsManaged   = input.IsManaged;
     this.IsEnabled   = input.IsEnabled;
     this.Description = input.Description;
     this.DeveloperId = input.DeveloperId;
     this.SortCode    = input.SortCode;
 }
Ejemplo n.º 4
0
 public FunctionUpdatedEvent(IAcSession acSession, FunctionBase source, IFunctionUpdateIo input)
     : base(acSession, source)
 {
     if (input == null)
     {
         throw new System.ArgumentNullException("input");
     }
     this.Input = input;
 }
Ejemplo n.º 5
0
            private void Handle(IAcSession acSession, IFunctionUpdateIo input, bool isCommand)
            {
                var acDomain           = _set._acDomain;
                var functionRepository = acDomain.RetrieveRequiredService <IRepository <Function> >();

                if (string.IsNullOrEmpty(input.Code))
                {
                    throw new ValidationException("编码不能为空");
                }
                FunctionState bkState;

                if (!acDomain.FunctionSet.TryGetFunction(input.Id, out bkState))
                {
                    throw new NotExistException();
                }
                CatalogState resource;

                if (!acDomain.CatalogSet.TryGetCatalog(bkState.ResourceTypeId, out resource))
                {
                    throw new ValidationException("意外的功能资源标识" + bkState.ResourceTypeId);
                }
                Function entity;
                bool     stateChanged = false;

                lock (Locker)
                {
                    FunctionState oldState;
                    if (!acDomain.FunctionSet.TryGetFunction(input.Id, out oldState))
                    {
                        throw new NotExistException();
                    }
                    FunctionState functionState;
                    if (acDomain.FunctionSet.TryGetFunction(resource, input.Code, out functionState) && functionState.Id != input.Id)
                    {
                        throw new ValidationException("重复的编码");
                    }
                    entity = functionRepository.GetByKey(input.Id);
                    if (entity == null)
                    {
                        throw new NotExistException("更新的实体不存在");
                    }

                    entity.Update(input);

                    var newState = FunctionState.Create(acDomain, entity);
                    stateChanged = newState != bkState;
                    if (stateChanged)
                    {
                        Update(newState);
                    }
                    if (isCommand)
                    {
                        try
                        {
                            functionRepository.Update(entity);
                            functionRepository.Context.Commit();
                        }
                        catch
                        {
                            if (stateChanged)
                            {
                                Update(bkState);
                            }
                            functionRepository.Context.Rollback();
                            throw;
                        }
                    }
                }
                if (isCommand && stateChanged)
                {
                    acDomain.MessageDispatcher.DispatchMessage(new FunctionUpdatedEvent(acSession, entity, input)
                    {
                        IsPriviate = true
                    });
                }
            }