示例#1
0
 public static DsdSet Create(IDsdSetCreateIo input)
 {
     Debug.Assert(input.Id != null, "input.Id != null");
     return(new DsdSet(input.Id.Value)
     {
         Description = input.Description,
         IsEnabled = input.IsEnabled,
         Name = input.Name,
         DsdCard = input.DsdCard
     });
 }
示例#2
0
 public static DsdSet Create(IDsdSetCreateIo input)
 {
     Debug.Assert(input.Id != null, "input.Id != null");
     return new DsdSet
     {
         Id = input.Id.Value,
         Description = input.Description,
         IsEnabled = input.IsEnabled,
         Name = input.Name,
         DsdCard = input.DsdCard
     };
 }
示例#3
0
            private void Handle(IAcSession acSession, IDsdSetCreateIo input, bool isCommand)
            {
                var acDomain         = _set._acDomain;
                var dsdSetDic        = _set._dsdSetDic;
                var dsdSetRepository = acDomain.RetrieveRequiredService <IRepository <DsdSet> >();

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

                var entity = DsdSet.Create(input);

                lock (Locker)
                {
                    DsdSetState dsdSet;
                    if (acDomain.DsdSetSet.TryGetDsdSet(entity.Id, out dsdSet))
                    {
                        throw new AnycmdException("意外的重复标识");
                    }
                    if (!dsdSetDic.ContainsKey(entity.Id))
                    {
                        dsdSetDic.Add(entity.Id, DsdSetState.Create(entity));
                    }
                    if (isCommand)
                    {
                        try
                        {
                            dsdSetRepository.Add(entity);
                            dsdSetRepository.Context.Commit();
                        }
                        catch
                        {
                            if (dsdSetDic.ContainsKey(entity.Id))
                            {
                                dsdSetDic.Remove(entity.Id);
                            }
                            dsdSetRepository.Context.Rollback();
                            throw;
                        }
                    }
                }
                if (isCommand)
                {
                    acDomain.MessageDispatcher.DispatchMessage(new DsdSetAddedEvent(acSession, entity, input, isPrivate: true));
                }
            }
 public void CreateDsdSet(IAcSession subject, IDsdSetCreateIo input)
 {
     _acDomain.Handle(new AddDsdSetCommand(subject, input));
 }
示例#5
0
 public void CreateDsdSet(IAcSession subject, IDsdSetCreateIo input)
 {
     _acDomain.Handle(new AddDsdSetCommand(subject, input));
 }