public AppSystemUpdatedEvent(IAcSession acSession, AppSystemBase source, IAppSystemUpdateIo input) : base(acSession, source) { if (input == null) { throw new ArgumentNullException("input"); } this.Input = input; }
public void Update(IAppSystemUpdateIo input) { this.Code = input.Code; this.Description = input.Description; this.Icon = input.Icon; this.ImageUrl = input.ImageUrl; this.IsEnabled = input.IsEnabled; this.Name = input.Name; this.PrincipalId = input.PrincipalId; this.SortCode = input.SortCode; this.SsoAuthAddress = input.SsoAuthAddress; }
private void Handle(IAcSession acSession, IAppSystemUpdateIo input, bool isCommand) { var acDomain = _set._acDomain; var repository = acDomain.RetrieveRequiredService <IRepository <AppSystem> >(); if (string.IsNullOrEmpty(input.Code)) { throw new ValidationException("编码不能为空"); } AppSystemState bkState; if (!acDomain.AppSystemSet.TryGetAppSystem(input.Id, out bkState)) { throw new NotExistException("意外的应用系统标识" + input.Id); } AppSystem entity; var stateChanged = false; lock (MessageLocker) { AppSystemState oldState; if (!acDomain.AppSystemSet.TryGetAppSystem(input.Id, out oldState)) { throw new NotExistException("意外的应用系统标识" + input.Id); } AppSystemState outAppSystem; if (acDomain.AppSystemSet.TryGetAppSystem(input.Code, out outAppSystem) && outAppSystem.Id != input.Id) { throw new ValidationException("重复的应用系统编码" + input.Code); } entity = repository.GetByKey(input.Id); if (entity == null) { throw new NotExistException(); } entity.Update(input); var newState = AppSystemState.Create(acDomain, entity); stateChanged = newState != bkState; if (stateChanged) { Update(newState); } if (isCommand) { try { repository.Update(entity); repository.Context.Commit(); } catch { if (stateChanged) { Update(bkState); } repository.Context.Rollback(); throw; } } } if (isCommand && stateChanged) { acDomain.MessageDispatcher.DispatchMessage(new AppSystemUpdatedEvent(acSession, entity, input, isPrivate: true)); } }
internal AppSystemUpdatedEvent(IAcSession acSession, AppSystemBase source, IAppSystemUpdateIo input, bool isPrivate) : this(acSession, source, input) { this.IsPrivate = isPrivate; }