public InfoDicItemUpdatedEvent(IAcSession acSession, InfoDicItemBase source, IInfoDicItemUpdateIo output)
     : base(acSession, source)
 {
     if (output == null)
     {
         throw new System.ArgumentNullException("output");
     }
     this.Output = output;
 }
Example #2
0
 public InfoDicItemUpdatedEvent(IAcSession acSession, InfoDicItemBase source, IInfoDicItemUpdateIo output)
     : base(acSession, source)
 {
     if (output == null)
     {
         throw new System.ArgumentNullException("output");
     }
     this.Output = output;
 }
Example #3
0
 public void Update(IInfoDicItemUpdateIo input)
 {
     this.Code = input.Code;
     this.Description = input.Description;
     this.InfoDicId = input.InfoDicId;
     this.IsEnabled = input.IsEnabled;
     this.Level = input.Level;
     this.Name = input.Name;
     this.SortCode = input.SortCode;
 }
Example #4
0

        
 internal InfoDicItemUpdatedEvent(IAcSession acSession, InfoDicItemBase source, IInfoDicItemUpdateIo input, bool isPrivate)
     : this(acSession, source, input)
 {
     this.IsPrivate = isPrivate;
 }
Example #6
0
 internal InfoDicItemUpdatedEvent(IAcSession acSession, InfoDicItemBase source, IInfoDicItemUpdateIo input, bool isPrivate)
     : this(acSession, source, input)
 {
     this.IsPrivate = isPrivate;
 }
Example #7
0
            private void Handle(IAcSession acSession, IInfoDicItemUpdateIo input, bool isCommand)
            {
                var acDomain = _set._acDomain;
                var infoDicItemRepository = acDomain.RetrieveRequiredService <IRepository <InfoDicItem, Guid> >();

                if (string.IsNullOrEmpty(input.Code))
                {
                    throw new ValidationException("编码不能为空");
                }
                InfoDicState infoDic;

                if (!acDomain.NodeHost.InfoDics.TryGetInfoDic(input.InfoDicId, out infoDic))
                {
                    throw new ValidationException("意外的信息字典项字典标识");
                }
                InfoDicItemState infoDicItem;

                if (!acDomain.NodeHost.InfoDics.TryGetInfoDicItem(input.Id, out infoDicItem))
                {
                    throw new NotExistException();
                }
                if (acDomain.NodeHost.InfoDics.TryGetInfoDicItem(infoDic, input.Code, out infoDicItem) && infoDicItem.Id != input.Id)
                {
                    throw new ValidationException("重复的编码");
                }
                var entity = infoDicItemRepository.GetByKey(input.Id);

                if (entity == null)
                {
                    throw new NotExistException();
                }
                var bkState = InfoDicItemState.Create(entity);

                entity.Update(input);

                var  newState     = InfoDicItemState.Create(entity);
                bool stateChanged = newState != bkState;

                lock (Locker)
                {
                    if (stateChanged)
                    {
                        Update(newState);
                    }
                    if (isCommand)
                    {
                        try
                        {
                            infoDicItemRepository.Update(entity);
                            infoDicItemRepository.Context.Commit();
                        }
                        catch
                        {
                            if (stateChanged)
                            {
                                Update(bkState);
                            }
                            infoDicItemRepository.Context.Rollback();
                            throw;
                        }
                    }
                }
                if (isCommand && stateChanged)
                {
                    acDomain.MessageDispatcher.DispatchMessage(new InfoDicItemUpdatedEvent(acSession, entity, input, isPrivate: true));
                }
            }
Example #8
0
 public static void UpdateInfoDicItem(this IAcDomain acDomain, IAcSession acSession, IInfoDicItemUpdateIo input)
 {
     acDomain.Handle(new UpdateInfoDicItemCommand(acSession, input));
 }
 public static void UpdateInfoDicItem(this IAcDomain acDomain, IAcSession acSession, IInfoDicItemUpdateIo input)
 {
     acDomain.Handle(new UpdateInfoDicItemCommand(acSession, input));
 }