Пример #1
0
        /// <summary>
        /// 单个新增推送消息
        /// </summary>
        /// <returns></returns>
        public async Task <int> InsertProcessAsync(PushSendProcessDomainModel domainModel)
        {
            if (domainModel == null)
            {
                return(0);
            }
            domainModel.Id = _idGenerator.GenerateId();
            PushSendProcess entity = _mapper.Map <PushSendProcess>(domainModel);

            entity.CreateAt = entity.UpdateAt = DateTimeHelper.GetNow();
            return(await _repository.InsertAsync(entity));
        }
Пример #2
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="domainModel"></param>
        /// <returns></returns>
        public async Task <int> InsertTokenBrandAsync(RegisterRequestDomainModel domainModel)
        {
            if (domainModel == null)
            {
                return(0);
            }
            var oldTokenBrand = await GetTokenBrandAsync(domainModel.Token, domainModel.AppId?.ToString() ?? "", domainModel.DeviceId);

            PushTokenBrand entity = null;

            if (oldTokenBrand == null)
            {
                entity          = _mapper.Map <RegisterRequestDomainModel, PushTokenBrand>(domainModel);
                entity.CreateAt = entity.UpdateAt = DateTimeHelper.GetNow();
                entity.Id       = _idGeneratorService.GenerateId();
                int row = await _repository.InsertAsync(entity);
            }
            else
            {
                entity = oldTokenBrand;
            }

            foreach (var detail in domainModel.DeviceTokens)
            {
                detail.TokenBrandId = entity.Id;
                detail.CreateAt     = detail.UpdateAt = DateTimeHelper.GetNow();
                await _pushTokenBrandDetailService.InsertAsync(detail);
            }
            return(domainModel.DeviceTokens.Count() + 1);
        }
        /// <summary>
        /// 插入明细
        /// </summary>
        /// <param name="domainModel"></param>
        /// <returns></returns>
        public async Task <int> InsertAsync(PushTokenBrandDetailDomainModel domainModel)
        {
            if (domainModel == null)
            {
                return(0);
            }
            //如果设备旧的通道不存在或者通道的deviceToken发生更改,进行插入或者更新操作。
            var oldDeviceChannel = await GetDeviceTokenAsync(domainModel.TokenBrandId, domainModel.ChannelId);

            if (oldDeviceChannel == null)
            {
                var entity = _mapper.Map <PushTokenBrandDetail>(domainModel);
                entity.Id = _idGenerationService.GenerateId();
                return(await _repository.InsertAsync(entity));
            }
            else
            {
                if (oldDeviceChannel.DeviceToken != domainModel.DeviceToken)
                {
                    oldDeviceChannel.DeviceToken = domainModel.DeviceToken;
                    return(await _repository.UpdateAsync(oldDeviceChannel));
                }
                else
                {
                    //成功执行一条记录
                    return(1);
                }
            }
        }
Пример #4
0
        public Task AddLoginAsync(TUser user, UserLoginInfo login, CancellationToken cancellationToken)
        {
            ThrowIfDisposed();
            Guard.ArgumentNotNull(user, nameof(user));
            Guard.ArgumentNotNull(login, nameof(login));

            UserLogin ul = new UserLogin
            {
                Id                  = _idGenerationService.GenerateId(),
                LoginProvider       = login.LoginProvider,
                ProviderDisplayName = login.ProviderDisplayName,
                ProviderKey         = login.ProviderKey,
                UserId              = user.Id
            };

            return(_userLoginRepository.InsertAsync(ul));
        }
Пример #5
0
        public async Task <int> InsertProcessHistoryAsync(AddProcessHistoryDomainModel dto)
        {
            if (dto == null)
            {
                return(0);
            }
            dto.Id = _idGenerator.GenerateId();
            PushProcessHistory entity = _mapper.Map <PushProcessHistory>(dto);

            entity.CreateAt = entity.UpdateAt = DateTimeHelper.GetNow();
            if (entity.DeviceToken.IsNullOrEmpty())
            {
                entity.DeviceToken = "";
            }
            int row = await _repository.InsertAsync(entity);

            return(row);
        }
Пример #6
0
 public async Task AddPushMessageAsync(object sender, object args)
 {
     using (var scope = SherlockEngine.Current.CreateScope())
     {
         PushMessageDomainModel pushMessageDomainModel = (PushMessageDomainModel)args;
         Guard.ArgumentNotNull(pushMessageDomainModel, nameof(pushMessageDomainModel));
         PushMessage entity = _mapper.Map <PushMessage>(pushMessageDomainModel);
         entity.Id       = _idGenerationService.GenerateId();
         entity.CreateAt = entity.UpdateAt = DateTimeHelper.GetNow();
         await _pushMessageRepository.InsertAsync(entity);
     }
 }
Пример #7
0
 protected virtual RoleClaim CreateRoleClaim(TRole role, Claim claim)
 {
     return(new RoleClaim {
         Id = _idGenerationService.GenerateId(), RoleId = role.Id, ClaimType = claim.Type, ClaimValue = claim.Value
     });
 }