예제 #1
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="childAgent">子集agent</param>
        /// <param name="agentId">顶级agent</param>
        /// <param name="buid"></param>
        /// <param name="isRead"></param>
        /// <returns>0未推送1已推送</returns>
        public long AddNoticexb(int cityCode, string licenseNo, string businessExpireDate, string forceExpireDate, string nextBusinessStartDate, string nextForceExpireDate, int source, int childAgent, int agentId, long buid, int isRead = 0)
        {
            //交强险剩余天数
            int forceDays = 0;
            //不符合90内插入条件的不执行插入
            bool isInTime = IsInTime(cityCode, businessExpireDate, forceExpireDate, out forceDays);

            if (!isInTime)
            {
                return(0);
            }
            var model = new CompositeBuIdLicenseNo
            {
                BuId      = buid,
                LicenseNo = licenseNo,
                Days      = forceDays
            };
            var list = new List <CompositeBuIdLicenseNo> {
                model
            };
            var sendModel = new DuoToNoticeViewModel
            {
                AgentId     = childAgent,
                Data        = list,
                BuidsString = buid.ToString()
            };
            var sendList = new List <DuoToNoticeViewModel> {
                sendModel
            };
            string url  = string.Format("{0}/api/Message/SendDuetToNotice", _messageCenterHost);
            var    data = sendList.ToJson();

            _logAppInfo.Info(string.Format("消息发送SendDuetToNotice请求串: url:{0}/api/Message/SendDuetToNotice ; data:{1}", _messageCenterHost, data));
            string resultMessage = HttpWebAsk.HttpClientPostAsync(data, url);

            _logAppInfo.Info(string.Format("消息发送SendDuetToNotice返回值:{0}", resultMessage));

            //using (var client = new HttpClient())
            //{
            //    var datas = CommonHelper.ReverseEachProperties(sendList);
            //    var postData = new FormUrlEncodedContent(datas);
            //    //请求串
            //    var clientResult =
            //        client.PostAsync(string.Format("{0}/api/Message/SendDuetToNotice", _messageCenterHost), postData);
            //    _logAppInfo.Info(string.Format("消息发送SendDuetToNotice请求串: url:{0}/api/Message/SendDuetToNotice ; data:{1}", _messageCenterHost, datas));
            //    //请求返回值
            //    var responseContent = clientResult.Result.Content;
            //    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/json"));
            //    _logAppInfo.Info(string.Format("消息发送SendDuetToNotice返回值:{0}", responseContent.ReadAsStringAsync().Result));
            //}
            return(1);
        }
예제 #2
0
        /// <summary>
        /// 获取待发送信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <string> MessageShorById(string userId)
        {
            string request = "{ 'UserId':" + userId + "}";
            string url     = $"{_urlModel.BihuApi}/api/Message/MessageExistById";
            string result  = await HttpWebAsk.HttpClientPostAsync(request, url);

            JObject resultResponse = JsonConvert.DeserializeObject(result) as JObject;

            if (resultResponse["Code"].ToString() != "1")
            {
                _logger.LogError("请求获取人员推送信息出错,用户id:" + userId + Environment.NewLine + result);
                return("");
            }
            string value = resultResponse["Data"]["Value"].ToString();

            if (value == "[]")
            {
                return("");
            }
            value = value.Replace("\r\n", "");
            return(value);
        }