예제 #1
0
        /// <summary>
        /// 批量发送给推送平台,在返回结果中也只有批量返回的唯一标识
        /// 批量成功或批量失败
        /// </summary>
        /// <param name="senderRet"></param>
        /// <param name="processList"></param>
        /// <param name="requestTime"></param>
        public void SendMsgListBatchToDB(SenderRet senderRet, List <SendProcessDto> processList, int requestTime)
        {
            //不管发送成功或失败,入历史表
            List <ProcessHistoryDto> processHistoryDtoList = _mapper.Map <List <ProcessHistoryDto> >(processList);
            DateTime sendTime = DateTimeHelper.GetNow();

            processHistoryDtoList.ForEach(e =>
            {
                if (senderRet.IsSuccess)
                {
                    e.SendStatus = (int)SendStatusEnum.Success;
                    e.ReturnSign = senderRet.Sign;
                }
                else
                {
                    e.SendStatus = (int)SendStatusEnum.Failure;
                    e.ErrorType  = (int)ErrorTypeEnum.PushPlatform;
                    e.Remark     = senderRet.Code;
                }
                e.SendTime    = sendTime;
                e.RequestTime = requestTime;
            });
            List <AddProcessHistoryDomainModel> modelList = _mapper.Map <List <AddProcessHistoryDomainModel> >(processHistoryDtoList);
            int rows = _pushProcessHistoryService.InsertProcessHistoryListAsync(modelList).Result;

            if (!senderRet.IsSuccess)
            {
                //发送失败的逻辑
                //sendTime 其实没有什么用,以备以后扩展;
                //以前的策略DateTime.Now.AddSeconds((sendProcessDto.EndTime - DateTime.Now).TotalSeconds / 2);只适用于单条
                //回写字段
                int writeBackRows = _pushSendProcessService.WriteBackProcessByIdsAsync(processList.Select(t => t.Id).ToList(), sendTime).Result;
                return;
            }
            //发送成功才会删除待发送列表
            List <long> ids = processList.Select(t => t.Id).ToList();

            rows = _pushSendProcessService.DeleteProcessByIdsAsync(ids).Result;
        }
예제 #2
0
 /// <summary>
 /// 批处理,超时推送
 /// </summary>
 /// <param name="processList"></param>
 public  bool Handle(List<SendProcessDto> processList, out string retMsg)
 {
     retMsg = "";
     List<ProcessHistoryDto> processHistoryDtoList = _mapper.Map<List<ProcessHistoryDto>>(processList);
     processHistoryDtoList.ForEach(e =>
     {
         e.SendStatus = (int)SendStatusEnum.Failure;
         e.ErrorType = (int)ErrorTypeEnum.TimeOut;
     });
     List<AddProcessHistoryDomainModel> modelList = _mapper.Map<List<AddProcessHistoryDomainModel>>(processHistoryDtoList);
     _pushProcessHistoryService.InsertProcessHistoryListAsync(modelList);
     List<long> ids = processList.Select(t => t.Id).ToList();
     int rows = _pushSendProcessService.DeleteProcessByIdsAsync(ids).Result;
     return true;
 }