using System;
|
|
namespace HMI.Simple.Util
|
{
|
public class AlarmUtil
|
{
|
|
public static bool CreateAlarm(string source, string content, int level, out string msg)
|
{
|
msg = string.Empty;
|
try
|
{
|
using (var helper = new MSMQHelper("HMI_Alarm"))
|
{
|
helper.Send("Alarm", source, content, level);
|
return true;
|
}
|
}
|
catch (Exception ex)
|
{
|
msg = ex.Message;
|
return false;
|
}
|
}
|
|
/// <summary>
|
/// 创建报警
|
/// </summary>
|
/// <param name="source">报警来源</param>
|
/// <param name="contents">报警内容,同一来源的报警可以多条同时创建</param>
|
/// <param name="msg">创建失败时为异常信息</param>
|
/// <returns>创建失败时为异常信息</returns>
|
public static bool CreateAlarm(string source, string[] contents, int[] levels, out string msg)
|
{
|
msg = string.Empty;
|
try
|
{
|
using (var helper = new MSMQHelper("HMI_Alarm"))
|
{
|
for (int i = 0; i < contents.Length; i++)
|
{
|
helper.Send("Alarm", source, contents[i], levels[i]);
|
}
|
return true;
|
}
|
}
|
catch (Exception ex)
|
{
|
msg = ex.Message;
|
return false;
|
}
|
}
|
//private static string ConcatAlarm(string source, string content)
|
//{
|
// return $"{source},{content}";
|
//}
|
//public static bool CreateAlarm(string content, int level, out string msg)
|
//{
|
// return CreateAlarm("PC", content, level, out msg);
|
//}
|
}
|
}
|