コード例 #1
0
ファイル: Role.cs プロジェクト: zszqwe/anycmd
 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;
 }
コード例 #2
0
ファイル: RoleUpdatedEvent.cs プロジェクト: zszqwe/anycmd
 public RoleUpdatedEvent(IAcSession acSession, RoleBase source, IRoleUpdateIo output)
     : base(acSession, source)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     this.Output = output;
 }
コード例 #3
0
ファイル: Role.cs プロジェクト: mingkongbin/anycmd
 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;
 }
コード例 #4
0
 public RoleUpdatedEvent(IAcSession acSession, RoleBase source, IRoleUpdateIo output)
     : base(acSession, source)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     this.Output = output;
 }
コード例 #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));
                }
            }
コード例 #6
0
ファイル: RoleUpdatedEvent.cs プロジェクト: zszqwe/anycmd
 internal RoleUpdatedEvent(IAcSession acSession, RoleBase source, IRoleUpdateIo input, bool isPrivate)
     : this(acSession, source, input)
 {
     this.IsPrivate = isPrivate;
 }
コード例 #7
0
 internal RoleUpdatedEvent(IAcSession acSession, RoleBase source, IRoleUpdateIo input, bool isPrivate)
     : this(acSession, source, input)
 {
     this.IsPrivate = isPrivate;
 }