Example #1
0
 public GroupUpdatedEvent(IAcSession acSession, GroupBase source, IGroupUpdateIo output)
     : base(acSession, source)
 {
     if (output == null)
     {
         throw new System.ArgumentNullException("output");
     }
     this.Output = output;
 }
Example #2
0
 public void Update(IGroupUpdateIo input)
 {
     this.CategoryCode = input.CategoryCode;
     this.Description = input.Description;
     this.IsEnabled = input.IsEnabled;
     this.Name = input.Name;
     this.ShortName = input.ShortName;
     this.SortCode = input.SortCode;
 }
Example #3
0
 public void Update(IGroupUpdateIo input)
 {
     this.CategoryCode = input.CategoryCode;
     this.Description  = input.Description;
     this.IsEnabled    = input.IsEnabled;
     this.Name         = input.Name;
     this.ShortName    = input.ShortName;
     this.SortCode     = input.SortCode;
 }
Example #4
0
 public GroupUpdatedEvent(IAcSession acSession, GroupBase source, IGroupUpdateIo output)
     : base(acSession, source)
 {
     if (output == null)
     {
         throw new System.ArgumentNullException("output");
     }
     this.Output = output;
 }
Example #5
0
 internal GroupUpdatedEvent(IAcSession acSession, GroupBase source, IGroupUpdateIo input, bool isPrivate)
     : this(acSession, source, input)
 {
     this.IsPrivate = isPrivate;
 }
Example #6
0
            private void Handle(IAcSession acSession, IGroupUpdateIo input, bool isCommand)
            {
                var        acDomain        = _set._acDomain;
                var        groupRepository = acDomain.RetrieveRequiredService <IRepository <Group, Guid> >();
                GroupState bkState;

                if (!acDomain.GroupSet.TryGetGroup(input.Id, out bkState))
                {
                    throw new NotExistException();
                }
                Group entity;
                var   stateChanged = false;

                lock (Locker)
                {
                    GroupState oldState;
                    if (!acDomain.GroupSet.TryGetGroup(input.Id, out oldState))
                    {
                        throw new NotExistException();
                    }
                    if (acDomain.GroupSet.Any(a => a.Name.Equals(input.Name, StringComparison.OrdinalIgnoreCase) && a.Id != input.Id))
                    {
                        throw new ValidationException("重复的工作组名");
                    }
                    entity = groupRepository.GetByKey(input.Id);
                    if (entity == null)
                    {
                        throw new NotExistException();
                    }

                    entity.Update(input);

                    var newState = GroupState.Create(entity);
                    stateChanged = newState != bkState;
                    if (stateChanged)
                    {
                        Update(newState);
                    }
                    if (isCommand)
                    {
                        try
                        {
                            groupRepository.Update(entity);
                            groupRepository.Context.Commit();
                        }
                        catch
                        {
                            if (stateChanged)
                            {
                                Update(bkState);
                            }
                            groupRepository.Context.Rollback();
                            throw;
                        }
                    }
                }
                if (isCommand && stateChanged)
                {
                    acDomain.MessageDispatcher.DispatchMessage(new GroupUpdatedEvent(acSession, entity, input, isPrivate: true));
                }
            }
Example #7
0
 internal GroupUpdatedEvent(IAcSession acSession, GroupBase source, IGroupUpdateIo input, bool isPrivate)
     : this(acSession, source, input)
 {
     this.IsPrivate = isPrivate;
 }