public GroupUpdatedEvent(IAcSession acSession, GroupBase source, IGroupUpdateIo output) : base(acSession, source) { if (output == null) { throw new System.ArgumentNullException("output"); } this.Output = output; }
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; }
internal GroupUpdatedEvent(IAcSession acSession, GroupBase source, IGroupUpdateIo input, bool isPrivate) : this(acSession, source, input) { this.IsPrivate = isPrivate; }
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)); } }