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