public UiViewButtonUpdatedEvent(IAcSession acSession, UiViewButtonBase source, IUiViewButtonUpdateIo input) : base(acSession, source) { if (input == null) { throw new System.ArgumentNullException("input"); } this.Input = input; }
public void Update(IUiViewButtonUpdateIo input) { this.IsEnabled = input.IsEnabled; this.FunctionId = input.FunctionId; }
private void Handle(IAcSession acSession, IUiViewButtonUpdateIo input, bool isCommand) { var acDomain = _set._acDomain; var viewButtonRepository = acDomain.RetrieveRequiredService <IRepository <UiViewButton> >(); var bkState = acDomain.UiViewSet.GetUiViewButtons().FirstOrDefault(a => a.Id == input.Id); if (bkState == null) { throw new NotExistException(); } if (input.FunctionId.HasValue) { FunctionState function; if (!acDomain.FunctionSet.TryGetFunction(input.FunctionId.Value, out function)) { throw new ValidationException("非法的托管功能标识" + input.FunctionId); } } UiViewButton entity; var stateChanged = false; lock (Locker) { if (acDomain.UiViewSet.GetUiViewButtons().All(a => a.Id != input.Id)) { throw new NotExistException(); } entity = viewButtonRepository.GetByKey(input.Id); if (entity == null) { throw new NotExistException(); } entity.Update(input); var newState = UiViewButtonState.Create(acDomain, entity); stateChanged = newState != bkState; if (stateChanged) { Update(newState); } if (isCommand) { try { viewButtonRepository.Update(entity); viewButtonRepository.Context.Commit(); } catch { if (stateChanged) { Update(bkState); } viewButtonRepository.Context.Rollback(); throw; } } } if (isCommand && stateChanged) { acDomain.MessageDispatcher.DispatchMessage(new UiViewButtonUpdatedEvent(acSession, entity, input, isPrivate: true)); } }
internal UiViewButtonUpdatedEvent(IAcSession acSession, UiViewButtonBase source, IUiViewButtonUpdateIo input, bool isPrivate) : this(acSession, source, input) { this.IsPrivate = isPrivate; }