From e08a444a9d7acea0cf39f50d22d29179f6a59292 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 01 十二月 2020 09:37:11 +0800
Subject: [PATCH] 2020-12-1

---
 HDL_ON/DAL/Mqtt/MqttInfoConfig.cs |   78 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/HDL_ON/DAL/Mqtt/MqttInfoConfig.cs b/HDL_ON/DAL/Mqtt/MqttInfoConfig.cs
new file mode 100644
index 0000000..c83e9f5
--- /dev/null
+++ b/HDL_ON/DAL/Mqtt/MqttInfoConfig.cs
@@ -0,0 +1,78 @@
+锘縰sing System;
+using System.Text;
+using HDL_ON.DAL.Server;
+
+namespace HDL_ON.DAL.Mqtt
+{
+    [System.Serializable]
+    public class MqttInfoConfig
+    {
+        public static readonly string ConfigFile = "MqttInfoConfig";
+
+        /// <summary>
+        /// 鎺ュ彛绫荤殑杩斿洖淇℃伅
+        /// </summary>
+        static MqttInfoConfig m_Current = null;
+        /// <summary>
+        /// 鎺ュ彛绫荤殑杩斿洖淇℃伅
+        /// </summary>
+        public static MqttInfoConfig Current
+        {
+            get
+            {
+                if (m_Current == null)
+                {
+                    try
+                    {
+                        var MqttInfoConfigBytes = FileUtils.ReadFile(ConfigFile);
+                        var MqttInfoConfigString = Encoding.UTF8.GetString(MqttInfoConfigBytes);
+                        MqttInfoConfig temp = null;
+                        if (MqttInfoConfigString != null)
+                        {
+                            temp = Newtonsoft.Json.JsonConvert.DeserializeObject<MqttInfoConfig>(MqttInfoConfigString);
+                        }
+                        if (temp == null)
+                        {
+                            m_Current = new MqttInfoConfig { };
+                        }
+                        else
+                        {
+                            m_Current = temp;
+                        }
+                    }
+                    catch
+                    {
+                        m_Current = new MqttInfoConfig { };
+                    }
+                }
+                return m_Current;
+            }
+        }
+
+        public HomeGatewayInfo HomeGatewayInfo = null;
+
+        public MqttInfo mMqttInfo = null;
+
+        /// <summary>
+        /// 鏄惁鑾峰彇MQTT鍙傛暟鎴愬姛
+        /// </summary>
+        public bool IfGetMqttInfoSuccess = false;
+
+
+        byte[] GetMqttInfoConfigBytes()
+        {
+            return Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
+        }
+
+        public void Refresh()
+        {
+            m_Current = null;
+            Save();
+        }
+
+        public void Save()
+        {
+            FileUtils.WriteFileByBytes(ConfigFile, GetMqttInfoConfigBytes());
+        }
+    }
+}
\ No newline at end of file

--
Gitblit v1.8.0