From f7c931e07919d62eb7fb1d1e6f0daaa5929be422 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 04 十二月 2020 14:20:25 +0800
Subject: [PATCH] 2020-12-04-2
---
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