Пример #1
0
            private void Handle(IAcSession acSession, ISsdSetCreateIo input, bool isCommand)
            {
                var acDomain         = _set._acDomain;
                var ssdSetDic        = _set._ssdSetDic;
                var ssdSetRepository = acDomain.RetrieveRequiredService <IRepository <SsdSet, Guid> >();

                if (!input.Id.HasValue)
                {
                    throw new ValidationException("标识是必须的");
                }
                if (acDomain.SsdSetSet.Any(a => a.Id == input.Id.Value))
                {
                    throw new GeneralException("重复的SsdSet标识" + input.Id);
                }
                if (acDomain.SsdSetSet.Any(a => a.Name.Equals(input.Name, StringComparison.OrdinalIgnoreCase)))
                {
                    throw new ValidationException("重复的静态责任分离角色集名称");
                }

                var entity = SsdSet.Create(input);

                lock (Locker)
                {
                    SsdSetState ssdSet;
                    if (acDomain.SsdSetSet.TryGetSsdSet(entity.Id, out ssdSet))
                    {
                        throw new GeneralException("意外的重复标识");
                    }
                    if (!ssdSetDic.ContainsKey(entity.Id))
                    {
                        ssdSetDic.Add(entity.Id, SsdSetState.Create(entity));
                    }
                    if (isCommand)
                    {
                        try
                        {
                            ssdSetRepository.Add(entity);
                            ssdSetRepository.Context.Commit();
                        }
                        catch
                        {
                            if (ssdSetDic.ContainsKey(entity.Id))
                            {
                                ssdSetDic.Remove(entity.Id);
                            }
                            ssdSetRepository.Context.Rollback();
                            throw;
                        }
                    }
                }
                if (isCommand)
                {
                    acDomain.MessageDispatcher.DispatchMessage(new SsdSetAddedEvent(acSession, entity, input, isPrivate: true));
                }
            }
Пример #2
0
 public static SsdSet Create(ISsdSetCreateIo input)
 {
     Debug.Assert(input.Id != null, "input.Id != null");
     return(new SsdSet(input.Id.Value)
     {
         Description = input.Description,
         IsEnabled = input.IsEnabled,
         Name = input.Name,
         SsdCard = input.SsdCard
     });
 }
Пример #3
0
 public static SsdSet Create(ISsdSetCreateIo input)
 {
     Debug.Assert(input.Id != null, "input.Id != null");
     return new SsdSet
     {
         Id = input.Id.Value,
         Description = input.Description,
         IsEnabled = input.IsEnabled,
         Name = input.Name,
         SsdCard = input.SsdCard
     };
 }
Пример #4
0
 public void CreateSsdSet(IAcSession subject, ISsdSetCreateIo input)
 {
     _acDomain.Handle(new AddSsdSetCommand(subject, input));
 }
Пример #5
0
 public void CreateSsdSet(IAcSession subject, ISsdSetCreateIo input)
 {
     _acDomain.Handle(new AddSsdSetCommand(subject, input));
 }