Esempio n. 1
0
 public void Update(IRoleUpdateIo input)
 {
     this.CategoryCode = input.CategoryCode;
     this.Description  = input.Description;
     this.Icon         = input.Icon;
     this.IsEnabled    = input.IsEnabled;
     this.Name         = input.Name;
     this.SortCode     = input.SortCode;
 }
Esempio n. 2
0
 public RoleUpdatedEvent(IAcSession acSession, RoleBase source, IRoleUpdateIo output)
     : base(acSession, source)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     this.Output = output;
 }
Esempio n. 3
0
 public void Update(IRoleUpdateIo input)
 {
     this.CategoryCode = input.CategoryCode;
     this.Description = input.Description;
     this.Icon = input.Icon;
     this.IsEnabled = input.IsEnabled;
     this.Name = input.Name;
     this.SortCode = input.SortCode;
 }
Esempio n. 4
0
 public RoleUpdatedEvent(IAcSession acSession, RoleBase source, IRoleUpdateIo output)
     : base(acSession, source)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     this.Output = output;
 }
Esempio n. 5
0
            private void Handle(IAcSession acSession, IRoleUpdateIo input, bool isCommand)
            {
                var       acDomain       = _set._acDomain;
                var       roleDic        = _set._roleDic;
                var       roleRepository = acDomain.RetrieveRequiredService <IRepository <Role> >();
                RoleState bkState;

                if (!acDomain.RoleSet.TryGetRole(input.Id, out bkState))
                {
                    throw new NotExistException();
                }
                Role entity;
                bool stateChanged = false;

                lock (Locker)
                {
                    RoleState oldState;
                    if (!acDomain.RoleSet.TryGetRole(input.Id, out oldState))
                    {
                        throw new NotExistException();
                    }
                    if (acDomain.RoleSet.Any(a => string.Equals(a.Name, input.Name, StringComparison.OrdinalIgnoreCase) && a.Id != input.Id))
                    {
                        throw new ValidationException("角色名称重复");
                    }
                    entity = roleRepository.GetByKey(input.Id);
                    if (entity == null)
                    {
                        throw new NotExistException();
                    }

                    entity.Update(input);

                    var newState = RoleState.Create(entity);
                    stateChanged = newState != bkState;
                    if (stateChanged)
                    {
                        Update(newState);
                    }
                    if (isCommand)
                    {
                        try
                        {
                            roleRepository.Update(entity);
                            roleRepository.Context.Commit();
                        }
                        catch
                        {
                            if (stateChanged)
                            {
                                Update(bkState);
                            }
                            roleRepository.Context.Rollback();
                            throw;
                        }
                    }
                }
                if (isCommand && stateChanged)
                {
                    acDomain.MessageDispatcher.DispatchMessage(new RoleUpdatedEvent(acSession, entity, input, isPrivate: true));
                }
            }
Esempio n. 6
0
 internal RoleUpdatedEvent(IAcSession acSession, RoleBase source, IRoleUpdateIo input, bool isPrivate)
     : this(acSession, source, input)
 {
     this.IsPrivate = isPrivate;
 }
Esempio n. 7
0
 internal RoleUpdatedEvent(IAcSession acSession, RoleBase source, IRoleUpdateIo input, bool isPrivate)
     : this(acSession, source, input)
 {
     this.IsPrivate = isPrivate;
 }