Ejemplo n.º 1
0
        public ErrCode Register(RegisterRequestDto dto, out string retMsg)
        {
            retMsg = "";
            try
            {
                int brandId;
                if (!_tokenBrandLogic.MatchBrandId(dto.Brand, out brandId))
                {
                    return(ErrCode.DataIsnotExist);
                }
                int systemType = brandId == APPLE_BRAND_ID ? 0 : 1;
                //获取通过RToken获取注册列表
                var tokenBrandList = _pushTokenBrandService.GetTokenBrandListByTokenAsync(dto.Token).Result;
                var tokenBrands    = tokenBrandList.Where(e => e.SystemType == systemType).OrderByDescending(e => e.UpdateAt).ToList();
                var tokenBrand     = tokenBrands.SingleOrDefault(e => e.AppId == dto.AppId && e.BrandId == brandId && e.DeviceId == dto.DeviceId);

                if (tokenBrands.Count() >= 3)
                {
                    for (int i = 2; i < tokenBrands.Count(); i++)
                    {
                        int deleteRow = _pushTokenBrandService.DeleteTokenBrandByIdAsync(tokenBrands[i].Id).Result;
                    }
                }

                //检查AppId是否存在
                if (!_tokenBrandLogic.CheckAppId(dto.AppId.Value, out retMsg))
                {
                    return(ErrCode.AppNotExist);
                }

                //清除设备之前注册的用户信息,避免设备收到别的用户的消息。
                _pushTokenBrandService.TryClearDeviceOldUserAsync(dto.DeviceId, dto.Token).Wait();

                RegisterRequestDomainModel model = _mapper.Map <RegisterRequestDomainModel>(dto);
                model.SystemType = systemType;
                model.BrandId    = brandId;
                var ret = _pushTokenBrandService.InsertTokenBrandAsync(model).Result;
                if (ret > 0)
                {
                    return(ErrCode.Sucess);
                }
                return(ErrCode.Failure);
            }
            catch (Exception ex)
            {
                retMsg = ex.Message;
                return(ErrCode.Failure);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 检查RZToken是否注册
        /// </summary>
        /// <param name="RZToken"></param>
        /// <returns></returns>
        public List <TokenBrandDto> GetRzTokenBrandListByRZToken(string RzToken)
        {
            var list = CourseCacheListLogic <string, TokenBrandDto> .Get(string.Format("RzTokenBrandList_RZToken_{0}", RzToken), () => {
                var model = _pushTokenBrandService.GetTokenBrandListByTokenAsync(RzToken).Result;
                return(_mapper.Map <List <TokenBrandDto> >(model));
            });

            return(list);
        }