public UiViewUpdatedEvent(IAcSession acSession, UiViewBase source, IUiViewUpdateIo input) : base(acSession, source) { if (input == null) { throw new System.ArgumentNullException("input"); } this.Input = input; }
private void Handle(IAcSession acSession, IUiViewUpdateIo input, bool isCommand) { var acDomain = _set._acDomain; var viewRepository = acDomain.RetrieveRequiredService <IRepository <UiView> >(); UiViewState bkState; if (!acDomain.UiViewSet.TryGetUiView(input.Id, out bkState)) { throw new NotExistException(); } UiView entity; var stateChanged = false; lock (Locker) { UiViewState state; if (!acDomain.UiViewSet.TryGetUiView(input.Id, out state)) { throw new NotExistException(); } entity = viewRepository.GetByKey(input.Id); if (entity == null) { throw new NotExistException(); } entity.Update(input); var newState = UiViewState.Create(acDomain, entity); stateChanged = newState != bkState; if (stateChanged) { Update(newState); } if (isCommand) { try { viewRepository.Update(entity); viewRepository.Context.Commit(); } catch { if (stateChanged) { Update(bkState); } viewRepository.Context.Rollback(); throw; } } } if (isCommand && stateChanged) { acDomain.MessageDispatcher.DispatchMessage(new UiViewUpdatedEvent(acSession, entity, input, isPrivate: true)); } }
internal UiViewUpdatedEvent(IAcSession acSession, UiViewBase source, IUiViewUpdateIo input, bool isPrivate) : this(acSession, source, input) { this.IsPrivate = isPrivate; }
public void Update(IUiViewUpdateIo input) { this.Tooltip = input.Tooltip; this.Icon = input.Icon; }