From ef52fd6fd07508883dce4eb002acda59f0169e59 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期四, 23 四月 2026 10:19:33 +0800
Subject: [PATCH] 优化;

---
 SimpleUtil/HMI.Simple.Util/AlarmUtil.cs |   42 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/SimpleUtil/HMI.Simple.Util/AlarmUtil.cs b/SimpleUtil/HMI.Simple.Util/AlarmUtil.cs
index 1a752ee..c6bcb1b 100644
--- a/SimpleUtil/HMI.Simple.Util/AlarmUtil.cs
+++ b/SimpleUtil/HMI.Simple.Util/AlarmUtil.cs
@@ -4,14 +4,19 @@
 {
     public class AlarmUtil
     {
-        public static bool CreateAlarm(string alarmContent, out string msg)
+        private static string ConcatAlarm(string source, string content)
+        {
+            return $"{source},{content}";
+        }
+
+        public static bool CreateAlarm(string source, string content, out string msg)
         {
             msg = string.Empty;
             try
             {
                 using (var helper = new MSMQHelper("HMI_Alarm"))
                 {
-                    helper.Send("Alarm", alarmContent);
+                    helper.Send("Alarm", ConcatAlarm(source, content));
                     return true;
                 }
             }
@@ -21,5 +26,38 @@
                 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, out string msg)
+        {
+            msg = string.Empty;
+            try
+            {
+                using (var helper = new MSMQHelper("HMI_Alarm"))
+                {
+                    foreach (string content in contents)
+                    {
+                        helper.Send("Alarm", ConcatAlarm(source, content));
+                    }
+                    return true;
+                }
+            }
+            catch (Exception ex)
+            {
+                msg = ex.Message;
+                return false;
+            }
+        }
+
+        public static bool CreateAlarm(string content, out string msg)
+        {
+            return CreateAlarm("PC", content, out msg);
+        }
     }
 }

--
Gitblit v1.9.1