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(); 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.Post(lanxinConfig.Url, json, ref errorinfo, "application/json"); if (res == null || res.Code != 1) { errorinfo = $"推送机台[{content}]BI信息失败:{res.Message ?? "请求蓝信接口异常"}"; } } /// /// WebApi接口调用失败预警 /// /// /// 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(); 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.Post(lanxinConfig.Url, json, ref errorinfo, "application/json"); if (res == null || res.Code != 1) { errorinfo = $"推送提醒失败:{res.Message ?? "请求蓝信接口异常"}"; LogHelper.LogError(errorinfo, "接口调用", string.Empty); } } } }