コード例 #1
0
        public async Task CreateKeyAsync(DataKey dataKey)
        {
            Application application = await _applicationCommandRepository.GetSingleAsync(a => a.SystemName == _appSettings.SystemName);

            if (application == null)
            {
                application = await _createApplicationCommand.ExecuteAsync(new CreateApplicationCommandDdto
                {
                    SystemName = _appSettings.SystemName
                });

                await _addApplicationDataKeyCommand.ExecuteAsync(application, new AddApplicationDataKeyCommandDdto
                {
                    Type  = dataKey.Name,
                    Value = dataKey.Value
                });

                await _applicationCommandRepository.AddAsync(application);
            }
            else
            {
                await _addApplicationDataKeyCommand.ExecuteAsync(application, new AddApplicationDataKeyCommandDdto
                {
                    Type  = dataKey.Name,
                    Value = dataKey.Value
                });

                await _applicationCommandRepository.UpdateAsync(application);
            }
        }
コード例 #2
0
        public async Task RegisterAsync(RegisterApplicationAdto registerApplicationAdto)
        {
            using (ITransaction transaction = _transactionManager.Create())
            {
                try
                {
                    Domain.Applications.Application application = await _commandRepository.GetSingleAsync(a => a.SystemName == registerApplicationAdto.SystemName);

                    if (application == null)
                    {
                        application = await _createApplicationCommand.ExecuteAsync(new CreateApplicationDdto
                        {
                            Name       = registerApplicationAdto.Name,
                            SystemName = registerApplicationAdto.SystemName,
                            HostUri    = registerApplicationAdto.HostUri
                        });

                        await _commandRepository.AddAsync(application);
                    }
                    else
                    {
                        await _changeApplicationCommand.ExecuteAsync(application, new ChangeApplicationDdto
                        {
                            Name    = registerApplicationAdto.Name,
                            HostUri = registerApplicationAdto.HostUri
                        });
                    }

                    transaction.Commit();
                }
                catch (CreateDomainException e)
                {
                    throw new BusinessApplicationException(ExceptionType.Unknown, e);
                }
                catch (ConcurrencyDomainException e)
                {
                    throw new BusinessApplicationException(ExceptionType.Unknown, e);
                }
            }
        }