public void Update(IInfoDicUpdateIo input) { this.Code = input.Code; this.Description = input.Description; this.IsEnabled = input.IsEnabled; this.Name = input.Name; this.SortCode = input.SortCode; }
public InfoDicUpdatedEvent(IAcSession acSession, InfoDicBase source, IInfoDicUpdateIo output) : base(acSession, source) { if (output == null) { throw new System.ArgumentNullException("output"); } this.Output = output; }
internal InfoDicUpdatedEvent(IAcSession acSession, InfoDicBase source, IInfoDicUpdateIo input, bool isPrivate) : this(acSession, source, input) { this.IsPrivate = isPrivate; }
private void Handle(IAcSession acSession, IInfoDicUpdateIo input, bool isCommand) { var acDomain = _set._acDomain; var infoDicRepository = acDomain.RetrieveRequiredService <IRepository <InfoDic, Guid> >(); if (string.IsNullOrEmpty(input.Code)) { throw new ValidationException("编码不能为空"); } InfoDicState infoDic; if (!acDomain.NodeHost.InfoDics.TryGetInfoDic(input.Id, out infoDic)) { throw new NotExistException(); } if (acDomain.NodeHost.InfoDics.TryGetInfoDic(input.Code, out infoDic) && infoDic.Id != input.Id) { throw new ValidationException("重复的编码"); } var entity = infoDicRepository.GetByKey(input.Id); if (entity == null) { throw new NotExistException(); } var bkState = InfoDicState.Create(acDomain, entity); entity.Update(input); var newState = InfoDicState.Create(acDomain, entity); bool stateChanged = newState != bkState; lock (Locker) { if (stateChanged) { Update(newState); } if (isCommand) { try { infoDicRepository.Update(entity); infoDicRepository.Context.Commit(); } catch { if (stateChanged) { Update(bkState); } infoDicRepository.Context.Rollback(); throw; } } } if (isCommand && stateChanged) { acDomain.MessageDispatcher.DispatchMessage(new InfoDicUpdatedEvent(acSession, entity, input, isPrivate: true)); } }
public static void UpdateInfoDic(this IAcDomain acDomain, IAcSession acSession, IInfoDicUpdateIo input) { acDomain.Handle(new UpdateInfoDicCommand(acSession, input)); }