From f71e74b5f0d2716fbf05da016cdaa18d64e09f80 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期四, 31 十二月 2020 17:01:18 +0800
Subject: [PATCH] 又换完成最新门锁。空气质量传感器完成数据和基本配置功能。开发图表和自动化的同事可下载此代码

---
 ZigbeeApp/Shared/Phone/ZigBee/Common/Global.cs |  101 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 101 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Common/Global.cs b/ZigbeeApp/Shared/Phone/ZigBee/Common/Global.cs
new file mode 100755
index 0000000..4a7371a
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Common/Global.cs
@@ -0,0 +1,101 @@
+锘縰sing System;
+using System.Collections.Generic;
+
+namespace Shared.Common
+{
+    public class Global
+    {
+        /// <summary>
+        /// 鑾峰彇浣忓畢鏂囦欢澶逛笅闈㈢殑鏂囦欢
+        /// </summary>
+        /// <param name="fileName">File name.</param>
+        public static byte[] ReadFileByHomeId(string fileName)
+        {
+
+            var path = System.IO.Path.Combine(Config.Instance.FullPath, fileName);
+            return Shared.IO.FileUtils.ReadFile(path);
+        }
+
+        public static List<string> FileListByHomeId()
+        {
+            var list = new List<string> { };
+            var path = Config.Instance.FullPath;
+            if (!System.IO.Directory.Exists(path)) {
+                return new List<string> { };
+            }
+            var files = System.IO.Directory.GetFiles(path);
+            foreach (var file in files)
+            {
+                var f = file.Substring(path.Length + 1);
+                System.Console.WriteLine(f);
+                list.Add(f);
+            }
+            return list;
+        }
+
+        /// <summary>
+        /// 鍐欐枃浠跺埌浣忓畢鏂囦欢澶圭洰褰�
+        /// </summary>
+        /// <param name="fileName">File name.</param>
+        /// <param name="bytes">Bytes.</param>
+        public static void WriteFileByBytesByHomeId(string fileName, byte[] bytes)
+        {
+            //濡傛灉娌℃湁瀛樺湪浣忓畢鐩綍锛屽厛鍒涘缓
+            if (!System.IO.Directory.Exists(Config.Instance.FullPath))
+            {
+                System.IO.Directory.CreateDirectory(Config.Instance.FullPath);
+            }
+            var path = System.IO.Path.Combine(Config.Instance.FullPath, fileName);
+            Shared.IO.FileUtils.WriteFileByBytes(path, bytes);
+        }
+        /// <summary>
+        /// 鍒犻櫎浣忓畢涓嬮潰鐨勬枃浠�
+        /// </summary>
+        /// <param name="fileName">File name.</param>
+        public static void DeleteFilebyHomeId(string fileName)
+        {
+            var path = System.IO.Path.Combine(Config.Instance.FullPath, fileName);
+            System.IO.File.Delete(path);
+        }
+
+        /// <summary>
+        /// 鏄惁瀛樺湪褰撳墠鏂囦欢
+        /// </summary>
+        /// <param name="fileName">File name.</param>
+        public static bool IsExistsByHomeId(string fileName)
+        {
+            var path = System.IO.Path.Combine(Config.Instance.FullPath, fileName);
+            return System.IO.File.Exists(path);
+        }
+
+        /// <summary>
+        /// 鏇存柊鏂囦欢鍚嶇О
+        /// </summary>
+        /// <param name="oldFilePath">Old file path.</param>
+        /// <param name="newFilePath">New file path.</param>
+        public static void ReNameFileByHomeId(string oldFilePath, string newFilePath)
+        {
+            if (oldFilePath == newFilePath)
+            {
+                return;
+            }
+
+            var fileInfo = new System.IO.FileInfo(Config.Instance.FullPath + oldFilePath);
+            if (fileInfo.Exists)
+            {
+                DeleteFilebyHomeId(newFilePath);
+                fileInfo.MoveTo(Config.Instance.FullPath + newFilePath);
+            }
+        }
+
+        public static void CreateHomeDirectory(string homeId)
+        {
+            var path= System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, homeId);
+            if (!System.IO.Directory.Exists(path))
+            {
+                System.IO.Directory.CreateDirectory(path);
+            }
+        }
+    }
+}
+

--
Gitblit v1.8.0