public ReadMessageResponse ReadMessage(ReadMessageRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            var      response   = new ReadMessageResponse();
            IBxAgent agentModel = GetAgentModelFactory(request.Agent);

            //参数校验
            if (!agentModel.AgentCanUse())
            {
                response.ErrCode = -10001;
                response.ErrMsg  = "参数校验错误,请检查您的校验码";
                return(response);
            }
            if (!AppValidateReqest(pairs, request.SecCode))
            {
                response.ErrCode = -10001;
                response.ErrMsg  = "参数校验错误,请检查您的校验码";
                return(response);
            }

            int result = 0;

            switch (request.MsgType)
            {
            case 1:
            {        //修改bx_notice_xb表
                bx_notice_xb bxNoticeXb = _noticexbRepository.Find(request.MsgId);
                if (bxNoticeXb != null)
                {
                    bxNoticeXb.stauts = 1;
                    result            = _noticexbRepository.Update(bxNoticeXb);
                }
            }
            break;

            case 2:
            {        //修改bx_consumer_review表
                bx_consumer_review bxConsumerReview = _consumerReviewRepository.Find(request.MsgId);
                if (bxConsumerReview != null)
                {
                    bxConsumerReview.read_status = 1;
                    result = _consumerReviewRepository.UpdateDetail(bxConsumerReview);
                }
            }
            break;

            default:
            {        //修改bx_message表
                bx_message bxMessage = _messageRepository.Find(request.MsgId);
                if (bxMessage != null)
                {
                    bxMessage.Msg_Status  = 1;
                    bxMessage.Update_Time = DateTime.Now;
                    result = _messageRepository.Update(bxMessage);
                }
            }
            break;
            }
            if (result > 0)
            {
                response.Status = HttpStatusCode.OK;
            }
            return(response);
        }
示例#2
0
        /// <summary>
        /// 旧的推送到期通知方法,因为不涉及数据存库,暂不使用
        /// </summary>
        /// <param name="licenseNo">车牌</param>
        /// <param name="businessExpireDate">上一年商业险到期时间</param>
        /// <param name="forceExpireDate">交强险到期</param>
        /// <param name="nextBusinessStartDate">商业险开始日期</param>
        /// <param name="nextForceExpireDate">交强险开始日期</param>
        /// <param name="source">投保公司</param>
        /// <param name="agentId">代理人id</param>
        /// <param name="buid"></param>
        /// <param name="isRead"></param>
        /// isRead 是否已读判断,即:第一次续保保存到库里之后,不做提醒则置为已读,其他情况为 未读状态
        /// <returns></returns>
        public long AddNoticexbOld(string licenseNo, string businessExpireDate, string forceExpireDate, string nextBusinessStartDate, string nextForceExpireDate, int source, int agentId, long buid, int isRead = 0)
        {
            //取库里的bx_notice_xb对象
            bx_notice_xb bxNoticeXb = _noticexbRepository.FindByBuid(buid);
            //保险到期天数3:30天,2:60天,1:90天
            int daysType = 0;
            //交强险剩余天数
            int forceDays = 0;

            //不符合90内插入条件的不执行插入
            if (!IsInTime(0, businessExpireDate, forceExpireDate, out forceDays))
            {
                return(0);
            }
            //符合90内插入条件的执行插入
            if (forceDays >= 0 && forceDays < 30)
            {
                daysType = 3;
            }
            else if (forceDays >= 30 && forceDays < 60)
            {
                daysType = 2;
            }
            else if (forceDays >= 60 && forceDays < 90)
            {
                daysType = 1;
            }

            var model = new bx_notice_xb
            {
                license_no  = licenseNo,
                create_time = DateTime.Now,
                stauts      = isRead
            };

            if (!string.IsNullOrWhiteSpace(businessExpireDate))
            {
                model.Last_biz_end_date = DateTime.Parse(businessExpireDate);
            }
            if (!string.IsNullOrWhiteSpace(forceExpireDate))
            {
                model.last_force_end_date = DateTime.Parse(forceExpireDate);
            }
            if (!string.IsNullOrWhiteSpace(nextBusinessStartDate))
            {
                model.next_biz_start_date = DateTime.Parse(nextBusinessStartDate);
            }
            if (!string.IsNullOrWhiteSpace(nextForceExpireDate))
            {
                model.next_force_start_date = DateTime.Parse(nextForceExpireDate);
            }
            model.source   = source;
            model.b_uid    = buid;
            model.days     = daysType;
            model.agent_id = agentId;
            model.day_num  = forceDays;

            long nxId = 0;

            if (bxNoticeXb != null)
            {
                nxId     = bxNoticeXb.id;
                model.id = bxNoticeXb.id;
                _noticexbRepository.Update(model);
            }
            else
            {
                nxId = _noticexbRepository.Add(model);
            }
            //推送消息
            model.id = nxId;
            using (var client = new HttpClient())
            {
                var datas    = CommonHelper.ReverseEachProperties(model);
                var postData = new FormUrlEncodedContent(datas);
                //请求串
                var clientResult =
                    client.PostAsync(string.Format("{0}/api/Message/SendXbMessage", _messageCenterHost), postData);
                _logAppInfo.Info(string.Format("消息发送SendToMessageCenter请求串: url:{0}/api/Message/SendXbMessage ; data:{1}", _messageCenterHost, model.ToJson()));
                //请求返回值
                var responseContent = clientResult.Result.Content;
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/json"));
                _logAppInfo.Info(string.Format("消息发送SendToMessageCenter返回值:{0}", responseContent.ReadAsStringAsync().Result));
            }
            return(nxId);
        }