From f441a3c49f8b5cedee3e4def6fbb448ef40eb9cb Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期三, 10 六月 2020 14:46:58 +0800 Subject: [PATCH] Crabtree-ON 2020-06-10 基于最新HDL ON 优化问题,Crabtree-ONAPP部分功能同步修改优化调整 1. 增加大图片大文件上传处理. 2.远程连接交互提示,由原来的Loading修改成顶部Tip提示。 3.灯光全开、全关和场景控制多线程发送,和HDLON同样加锁处理。 4.Android ,判断移动网络失败,网络监测修复方法修改,后台前台切换优化。 --- Crabtree/SmartHome/UI/SimpleControl/CommonPage.cs | 87 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 84 insertions(+), 3 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/CommonPage.cs b/Crabtree/SmartHome/UI/SimpleControl/CommonPage.cs index 3d6bd2c..a220793 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/CommonPage.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/CommonPage.cs @@ -2112,6 +2112,85 @@ return s;// } + //static void httpListener_EventHandler (System.Collections.Specialized.NameValueCollection nameValueCollection, System.IO.Stream outputStream, System.IO.Stream inputStream) + //{ + // //if (!isHttpListenerStart) { + // // return; + // //} + // try { + // //System.Net.WebClient webClient = new System.Net.WebClient (); + // //byte []bytes= webClient.DownloadData("http://ip:6001/GetAllFiles"); + // // System.Text.Encoding.UTF8.GetString (bytes); + // //List<string> list = new List<string> (); + // //foreach(string s in list) { + // // byte [] bytes = webClient.DownloadData ("http://ip:6001/Get"+s); + // // FileUtils.WriteFileByBytes (s, bytes); + // //} + + // if (nameValueCollection ["Command"] != null && nameValueCollection ["Command"].StartsWith ("Get")) { + // string tempFileName = nameValueCollection ["Command"].Replace ("Get", ""); + // if ("AllFiles" == tempFileName) { + // byte [] bytes = System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (IO.FileUtils.ReadFiles ())); + // outputStream.Write (bytes, 0, bytes.Length); + // outputStream.Flush (); + // } else { + // byte [] bytes; + // if (!IO.FileUtils.Exists (tempFileName)) { + // bytes = System.Text.Encoding.UTF8.GetBytes ("鏂囦欢鍚嶄笉瀛樺湪锛�"); + // outputStream.Write (bytes, 0, bytes.Length); + // outputStream.Flush (); + // return; + // } + // System.IO.FileStream fs = new System.IO.FileStream (Application.RootPath + tempFileName, System.IO.FileMode.Open); + // bytes = new byte [fs.Length]; + // fs.Read (bytes, 0, bytes.Length); + // fs.Close (); + // outputStream.Write (bytes, 0, bytes.Length); + // outputStream.Flush (); + // } + // } else if (nameValueCollection ["Command"].StartsWith ("Upload")) { + // string path = Application.RootPath + nameValueCollection ["Command"].Replace ("Upload", ""); + // string dePath = nameValueCollection ["Command"].Replace ("Upload", ""); + // if (dePath.StartsWith ("Room_")) { + // new Room ().Add (dePath); + // } + // if (dePath.Split ('_').Length == 5) { + // if (dePath.Split ('_') [1] == (typeof (OnePortBus).Name) || dePath.Split ('_') [1] == (typeof (OnePortWirelessFR).Name)) { + // UserConfig.Instance.RemoteModeFile = dePath; + // UserConfig.Instance.SaveUserConfig (); + // } + // if (dePath.Split ('_') [1] == (typeof (SecurityModul).Name)) { + // if (UserConfig.Instance.HideDeviceTypes.Contains ((R.MyInternationalizationString.Security))) { + // UserConfig.Instance.HideDeviceTypes.Remove (R.MyInternationalizationString.Security); + // UserConfig.Instance.SaveUserConfig (); + // } + // } + // } + + // if (dePath.Split ('_').Length == 2 && dePath.StartsWith ("GlobalScene")) { + // var sceneFileList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (Scene.GlobalSceneFilePath))); + // if (!sceneFileList.Contains (dePath)) { + // sceneFileList.Add (dePath); + // IO.FileUtils.WriteFileByBytes (Scene.GlobalSceneFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (sceneFileList))); + // } + // } + // //Utlis.WriteLine ("鎺ユ敹"+path); + // FileUtils.WriteFileByInputStream (path, inputStream); + // Common common = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (path))); + // if (common.DeviceTextID == R.MyInternationalizationString.ElectricalControl) { + // UserConfig.Instance.SocketList.Add (common.CommonLoopID); + // } + // } else { + // byte [] bytes = System.Text.Encoding.UTF8.GetBytes ("璇锋眰鍛戒护鏃犳晥锛�"); + // outputStream.Write (bytes, 0, bytes.Length); + // outputStream.Flush (); + // } + // } catch (Exception ex) { + // Utlis.WriteLine ("httpListener_EventHandler" + ex.ToString ()); + // } + //} + + static void httpListener_EventHandler (System.Collections.Specialized.NameValueCollection nameValueCollection, System.IO.Stream outputStream, System.IO.Stream inputStream) { //if (!isHttpListenerStart) { @@ -2151,9 +2230,11 @@ } else if (nameValueCollection ["Command"].StartsWith ("Upload")) { string path = Application.RootPath + nameValueCollection ["Command"].Replace ("Upload", ""); string dePath = nameValueCollection ["Command"].Replace ("Upload", ""); - if (dePath.StartsWith ("Room_")) { + if (dePath.Contains ("Room_")) { new Room ().Add (dePath); } + + if (dePath.Split ('_').Length == 5) { if (dePath.Split ('_') [1] == (typeof (OnePortBus).Name) || dePath.Split ('_') [1] == (typeof (OnePortWirelessFR).Name)) { UserConfig.Instance.RemoteModeFile = dePath; @@ -2165,6 +2246,7 @@ UserConfig.Instance.SaveUserConfig (); } } + } if (dePath.Split ('_').Length == 2 && dePath.StartsWith ("GlobalScene")) { @@ -2174,7 +2256,6 @@ IO.FileUtils.WriteFileByBytes (Scene.GlobalSceneFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (sceneFileList))); } } - //Utlis.WriteLine ("鎺ユ敹"+path); FileUtils.WriteFileByInputStream (path, inputStream); Common common = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (path))); if (common.DeviceTextID == R.MyInternationalizationString.ElectricalControl) { @@ -2187,7 +2268,7 @@ } } catch (Exception ex) { Utlis.WriteLine ("httpListener_EventHandler" + ex.ToString ()); - } + } } /// <summary> -- Gitblit v1.8.0