示例#1
0
 public AppSystemAddedEvent(IAcSession acSession, AppSystemBase source, IAppSystemCreateIo input)
     : base(acSession, source)
 {
     if (input == null)
     {
         throw new ArgumentNullException("input");
     }
     this.Input = input;
 }
示例#2
0
 public AppSystemAddedEvent(IAcSession acSession, AppSystemBase source, IAppSystemCreateIo input)
     : base(acSession, source)
 {
     if (input == null)
     {
         throw new ArgumentNullException("input");
     }
     this.Input = input;
 }
示例#3
0
 public static AppSystem Create(IAppSystemCreateIo input)
 {
     Debug.Assert(input.Id != null, "input.Id != null");
     return(new AppSystem(input.Id.Value)
     {
         Code = input.Code,
         Name = input.Name,
         Description = input.Description,
         Icon = input.Icon,
         PrincipalId = input.PrincipalId,
         SsoAuthAddress = input.SsoAuthAddress,
         IsEnabled = input.IsEnabled,
         SortCode = input.SortCode,
         ImageUrl = input.ImageUrl
     });
 }
示例#4
0
 public static AppSystem Create(IAppSystemCreateIo input)
 {
     Debug.Assert(input.Id != null, "input.Id != null");
     return new AppSystem
     {
         Code = input.Code,
         Id = input.Id.Value,
         Name = input.Name,
         Description = input.Description,
         Icon = input.Icon,
         PrincipalId = input.PrincipalId,
         SsoAuthAddress = input.SsoAuthAddress,
         IsEnabled = input.IsEnabled,
         SortCode = input.SortCode,
         ImageUrl = input.ImageUrl
     };
 }
示例#5
0
            private void Handle(IAcSession acSession, IAppSystemCreateIo input, bool isCommand)
            {
                var dicByCode  = _set._dicByCode;
                var dicById    = _set._dicById;
                var acDomain   = _set._acDomain;
                var repository = acDomain.RetrieveRequiredService <IRepository <AppSystem> >();

                if (string.IsNullOrEmpty(input.Code))
                {
                    throw new ValidationException("编码不能为空");
                }
                if (!input.Id.HasValue)
                {
                    throw new AnycmdException("标识是必须的");
                }
                AppSystem entity;

                lock (MessageLocker)
                {
                    if (acDomain.AppSystemSet.ContainsAppSystem(input.Id.Value))
                    {
                        throw new AnycmdException("给定标识的记录已经存在" + input.Id);
                    }
                    if (acDomain.AppSystemSet.ContainsAppSystem(input.Code))
                    {
                        throw new ValidationException("重复的应用系统编码" + input.Code);
                    }
                    AccountState principal;
                    // TODO:考虑将AppSystem.PrincipalId重命名为AppSystem.DevPrincipalId,从而与业务负责人分开。
                    if (!acDomain.SysUserSet.TryGetDevAccount(input.PrincipalId, out principal))
                    {
                        throw new ValidationException("意外的应用系统负责人,业务系统负责人必须是开发人员");
                    }

                    entity = AppSystem.Create(input);

                    var state = AppSystemState.Create(acDomain, entity);
                    if (!dicByCode.ContainsKey(state.Code))
                    {
                        dicByCode.Add(state.Code, state);
                    }
                    if (!dicById.ContainsKey(state.Id))
                    {
                        dicById.Add(state.Id, state);
                    }
                    // 如果是命令则持久化
                    if (isCommand)
                    {
                        try
                        {
                            repository.Add(entity);
                            repository.Context.Commit();
                        }
                        catch
                        {
                            if (dicByCode.ContainsKey(entity.Code))
                            {
                                dicByCode.Remove(entity.Code);
                            }
                            if (dicById.ContainsKey(entity.Id))
                            {
                                dicById.Remove(entity.Id);
                            }
                            repository.Context.Rollback();
                            throw;
                        }
                    }
                }
                // 如果是命令则分发事件
                if (isCommand)
                {
                    acDomain.MessageDispatcher.DispatchMessage(new AppSystemAddedEvent(acSession, entity, input, isPrivate: true));
                }
            }
示例#6
0
 internal AppSystemAddedEvent(IAcSession acSession, AppSystemBase source, IAppSystemCreateIo input, bool isPrivate)
     : this(acSession, source, input)
 {
     this.IsPrivate = isPrivate;
 }
示例#7
0
 internal AppSystemAddedEvent(IAcSession acSession, AppSystemBase source, IAppSystemCreateIo input, bool isPrivate)
     : this(acSession, source, input)
 {
     this.IsPrivate = isPrivate;
 }