Exemplo n.º 1
0
 public ButtonUpdatedEvent(IAcSession acSession, ButtonBase source, IButtonUpdateIo input)
     : base(acSession, source)
 {
     if (input == null)
     {
         throw new System.ArgumentNullException("input");
     }
     this.Input = input;
 }
Exemplo n.º 2
0
 public ButtonUpdatedEvent(IAcSession acSession, ButtonBase source, IButtonUpdateIo input)
     : base(acSession, source)
 {
     if (input == null)
     {
         throw new System.ArgumentNullException("input");
     }
     this.Input = input;
 }
Exemplo n.º 3
0
 public void Update(IButtonUpdateIo input)
 {
     this.Code         = input.Code;
     this.CategoryCode = input.CategoryCode;
     this.Description  = input.Description;
     this.Icon         = input.Icon;
     this.IsEnabled    = input.IsEnabled;
     this.Name         = input.Name;
     this.SortCode     = input.SortCode;
 }
Exemplo n.º 4
0
 public void Update(IButtonUpdateIo input)
 {
     this.Code = input.Code;
     this.CategoryCode = input.CategoryCode;
     this.Description = input.Description;
     this.Icon = input.Icon;
     this.IsEnabled = input.IsEnabled;
     this.Name = input.Name;
     this.SortCode = input.SortCode;
 }
Exemplo n.º 5
0
            private void Handle(IAcSession acSession, IButtonUpdateIo input, bool isCommand)
            {
                var acDomain         = _set._acDomain;
                var buttonRepository = acDomain.RetrieveRequiredService <IRepository <Button> >();

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

                if (!acDomain.ButtonSet.TryGetButton(input.Id, out bkState))
                {
                    throw new NotExistException("意外的按钮标识" + input.Id);
                }
                Button entity;
                var    stateChanged = false;

                lock (MessageLocker)
                {
                    ButtonState oldState;
                    if (!acDomain.ButtonSet.TryGetButton(input.Id, out oldState))
                    {
                        throw new NotExistException("意外的按钮标识" + input.Id);
                    }
                    ButtonState button;
                    if (acDomain.ButtonSet.TryGetButton(input.Code, out button) && button.Id != input.Id)
                    {
                        throw new ValidationException("重复的按钮编码");
                    }
                    entity = buttonRepository.GetByKey(input.Id);
                    if (entity == null)
                    {
                        throw new NotExistException();
                    }

                    entity.Update(input);

                    var newState = ButtonState.Create(entity);
                    stateChanged = bkState != newState;
                    if (stateChanged)
                    {
                        Update(newState);
                    }
                    if (isCommand)
                    {
                        try
                        {
                            buttonRepository.Update(entity);
                            buttonRepository.Context.Commit();
                        }
                        catch
                        {
                            if (stateChanged)
                            {
                                Update(bkState);
                            }
                            buttonRepository.Context.Rollback();
                            throw;
                        }
                    }
                }
                if (isCommand && stateChanged)
                {
                    acDomain.MessageDispatcher.DispatchMessage(new ButtonUpdatedEvent(acSession, entity, input, isPrivate: true));
                }
            }
Exemplo n.º 6
0
 internal ButtonUpdatedEvent(IAcSession acSession, ButtonBase source, IButtonUpdateIo input, bool isPrivate)
     : this(acSession, source, input)
 {
     this.IsPrivate = isPrivate;
 }
Exemplo n.º 7
0
 internal ButtonUpdatedEvent(IAcSession acSession, ButtonBase source, IButtonUpdateIo input, bool isPrivate)
     : this(acSession, source, input)
 {
     this.IsPrivate = isPrivate;
 }