1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using Cksoft.Data;
- using Cksoft.Data.Repository;
- using Cksoft.Unity;
- using Cksoft.Unity.Log4NetConfig;
- using DllEapEntity;
- using DllEapEntity.OFILM;
- using Microsoft.Extensions.Configuration;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DllEapCommon.Notice
- {
- public class ServiceErrorNoticeHelper
- {
- public static void Notice(string content, ref string errorinfo)
- {
- var builder = new ConfigurationBuilder().AddJsonFile("appsettings.json");
- var configuration = builder.Build();
- var lanxinConfig = configuration.GetSection("LanXinConfig").Get<LanxinConfig>();
- if (lanxinConfig == null)
- {
- errorinfo = "配置文件中LanXin节点未找到或配置不正确";
- return;
- }
- var requestData = new LanxinRequestDto
- {
- Appid = lanxinConfig.Appid,
- Secret = lanxinConfig.Secret,
- Tousers = lanxinConfig.Tousers,
- Content = content
- };
- var json = JsonConvert.SerializeObject(requestData);
- var res = HttpRequestHelper<OfilmLanxinReponseDto>.Post(lanxinConfig.Url, json, ref errorinfo, "application/json");
- if (res == null || res.Code != 1)
- {
- errorinfo = $"推送机台[{content}]BI信息失败:{res.Message ?? "请求蓝信接口异常"}";
- }
- }
- /// <summary>
- /// WebApi接口调用失败预警
- /// </summary>
- /// <param name="content"></param>
- /// <param name="errorinfo"></param>
- public static void NoticeApiError(string content, ref string errorinfo)
- {
- var builder = new ConfigurationBuilder().AddJsonFile("appsettings.json");
- var configuration = builder.Build();
- var lanxinConfig = configuration.GetSection("LanXinConfig").Get<LanxinConfig>();
- if (lanxinConfig == null)
- {
- errorinfo = "配置文件中LanXin节点未找到或配置不正确";
- return;
- }
- var requestData = new LanxinRequestDto
- {
- Appid = lanxinConfig.Appid,
- Secret = lanxinConfig.Secret,
- Tousers = lanxinConfig.Tousers,
- Content = content
- };
- var json = JsonConvert.SerializeObject(requestData);
- var res = HttpRequestHelper<OfilmLanxinReponseDto>.Post(lanxinConfig.Url, json, ref errorinfo, "application/json");
- if (res == null || res.Code != 1)
- {
- errorinfo = $"推送提醒失败:{res.Message ?? "请求蓝信接口异常"}";
- LogHelper<ServiceErrorNoticeHelper>.LogError(errorinfo,
- "接口调用", string.Empty);
- }
- }
- }
- }
|