From 2562ee38c58a113113a2943ae057c1937ae533cb Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期四, 02 七月 2020 13:49:20 +0800 Subject: [PATCH] 2020-07-01 1.去掉读电能操作,去掉kwh状态显示。 2.当前是分享住宅,不允许删除备份。 3.进入搜索网关页面,切换到本地模式。 4.Alexa页面 增加添加设备失败提示。 5.子账号页面,底部增加文字提示。6.Android 默认隐藏底部虚拟按键。 --- Crabtree/SmartHome/IO/FileUtils.cs | 34 +++++++++++++++++++++++----------- 1 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Crabtree/SmartHome/IO/FileUtils.cs b/Crabtree/SmartHome/IO/FileUtils.cs index 559f8b7..ffc8686 100644 --- a/Crabtree/SmartHome/IO/FileUtils.cs +++ b/Crabtree/SmartHome/IO/FileUtils.cs @@ -1,6 +1,7 @@ 锘縰sing System; using System.IO; using System.Collections.Generic; +using System.Threading; namespace Shared.IO { @@ -242,13 +243,19 @@ WriteFileByBytes (fileName, SimpleControl.CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (common))); } - /// <summary> - /// Writes the file by bytes. - /// </summary> - /// <returns><c>true</c>, if file by bytes was writed, <c>false</c> otherwise.</returns> - /// <param name="fileName">File name.</param> - /// <param name="bytes">Bytes.</param> - public static bool WriteFileByBytes (string fileName, byte [] bytes) + /// <summary> + /// 澧炲姞 璇诲啓閿侊紝褰撹祫婧愬浜庡啓鍏ユā寮忔椂锛屽叾浠栫嚎绋嬪啓鍏ラ渶瑕佺瓑寰呮湰娆″啓鍏ョ粨鏉熶箣鍚庢墠鑳界户缁啓鍏� + /// 鐢ㄤ簬瑙e喅澶氱嚎绋嬬幆澧冨啓鍏ユ枃浠堕棶棰� + /// </summary> + static ReaderWriterLockSlim LogWriteLock = new ReaderWriterLockSlim (); + + /// <summary> + /// Writes the file by bytes. + /// </summary> + /// <returns><c>true</c>, if file by bytes was writed, <c>false</c> otherwise.</returns> + /// <param name="fileName">File name.</param> + /// <param name="bytes">Bytes.</param> + public static bool WriteFileByBytes (string fileName, byte [] bytes) { if (fileName == null || (fileName = fileName.Trim ()) == ("")) { return false; @@ -257,10 +264,13 @@ System.IO.FileStream fs = null; try { - fs = new FileStream (System.IO.Path.Combine (RootPath, fileName), FileMode.Create, FileAccess.Write); + //璁剧疆璇诲啓閿佷负鍐欏叆妯″紡鐙崰璧勬簮锛屽叾浠栧啓鍏ヨ姹傞渶瑕佺瓑寰呮湰娆″啓鍏ョ粨鏉熶箣鍚庢墠鑳界户缁啓鍏� + LogWriteLock.EnterWriteLock (); + + fs = new FileStream (System.IO.Path.Combine (RootPath, fileName), FileMode.Create, FileAccess.Write); fs.Write (bytes, 0, bytes.Length); fs.Flush (); - Utlis.WriteLine ("SaveFile:" + fileName); + //Utlis.WriteLine ("SaveFile:" + fileName + " : " + bytes.Length.ToString()); //if (!UserConfig.Instance.LocalFiles.Contains (fileName)) { // UserConfig.Instance.LocalFiles.Add (fileName); //} @@ -269,8 +279,10 @@ Utlis.WriteLine ("FileUtiles Code 113:" + ex.ToString ()); return false; } finally { - try { - if (fs != null) { + try { + //閫�鍑哄啓鍏ユā寮忥紝閲婃斁璧勬簮鍗犵敤 + LogWriteLock.ExitWriteLock (); + if (fs != null) { fs.Close (); } } catch (Exception ex) { -- Gitblit v1.8.0