|
|
|
using Autofac;
|
|
|
|
using Entity.Attr;
|
|
|
|
using Entity.Constant;
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
using HybirdFrameworkCore.Autofac;
|
|
|
|
using log4net;
|
|
|
|
using Service.Station;
|
|
|
|
|
|
|
|
namespace Service.Execute.Api;
|
|
|
|
|
|
|
|
public class SoundApi
|
|
|
|
{
|
|
|
|
private static readonly string BASE_URL = "http://localhost:5038";
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger("SoundApi");
|
|
|
|
|
|
|
|
static SysRunningFaultService sysRunningFaultService = AppInfo.Container.Resolve<SysRunningFaultService>();
|
|
|
|
|
|
|
|
private static readonly HttpClient _httpClient = new HttpClient()
|
|
|
|
{
|
|
|
|
Timeout = TimeSpan.FromSeconds(5)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
public static void PlayOneSound(int soundNo)
|
|
|
|
{
|
|
|
|
SaveSysRunningFault(soundNo);
|
|
|
|
string url = BASE_URL + "/Api/PlayOneSound?soundcode=" + soundNo;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
_httpClient.GetStringAsync(url);
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
Log.Error($" SoundApi PlayOneSound e = {e}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void SaveSysRunningFault(int soundNo)
|
|
|
|
{
|
|
|
|
if (Enum.TryParse<InfoEnum.SwapInfo>(soundNo.ToString(), out InfoEnum.SwapInfo enumMember))
|
|
|
|
{
|
|
|
|
string soundContent= InfoExtend.GetSound(enumMember);
|
|
|
|
if (InfoExtend.GetSound(enumMember).Contains("失败")||InfoExtend.GetLed(enumMember).Contains("失败"))
|
|
|
|
{
|
|
|
|
sysRunningFaultService.InsertAsync(new SysRunningFault()
|
|
|
|
{
|
|
|
|
FaultDescribe=soundContent,
|
|
|
|
FalustHappenTime=DateTime.Now,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|