From 74b7633fc57593542157e9d82513b5cfc4d5d8c4 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期三, 02 十二月 2020 14:20:04 +0800 Subject: [PATCH] 2020-12-2-1 --- HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/SingleLogicView.cs | 2 HDL_ON/UI/UI2/3-Intelligence/Automation/Set.cs | 1 .vs/HDL_APP_Project/xs/sqlite3/storage.ide-shm | 0 HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs | 1 HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs | 9 + HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs | 136 +-------------------------- .vs/HDL_APP_Project/xs/sqlite3/storage.ide | 0 .vs/HDL_APP_Project/xs/UserPrefs.xml | 29 ++--- .vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal | 0 HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs | 119 +++++++++++++++++++++++ 10 files changed, 145 insertions(+), 152 deletions(-) diff --git a/.vs/HDL_APP_Project/xs/UserPrefs.xml b/.vs/HDL_APP_Project/xs/UserPrefs.xml index 67e0774..bcfa191 100644 --- a/.vs/HDL_APP_Project/xs/UserPrefs.xml +++ b/.vs/HDL_APP_Project/xs/UserPrefs.xml @@ -1,11 +1,17 @@ 锘�<Properties StartupConfiguration="{09712674-2A38-407B-B1E2-560B2C352F9A}|Default"> - <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs"> + <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs"> <Files> - <File FileName="HDL_ON/DAL/Server/HttpUtil.cs" Line="188" Column="1" /> - <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs" Line="176" Column="37" /> - <File FileName="HDL_ON/DAL/Server/NewAPI.cs" Line="419" Column="77" /> - <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs" Line="28" Column="64" /> - <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs" Line="21" Column="35" /> + <File FileName="HDL_ON/DAL/Server/HttpUtil.cs" Line="526" Column="18" /> + <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs" Line="40" Column="32" /> + <File FileName="HDL_ON/DAL/Server/NewAPI.cs" Line="1" Column="1" /> + <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs" Line="235" Column="33" /> + <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs" Line="10" Column="1" /> + <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/AddTarget.cs" /> + <File FileName="HDL_ON/DAL/Server/HttpServerRequest.cs" Line="1" Column="1" /> + <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs" Line="18" Column="36" /> + <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/Set.cs" Line="101" Column="30" /> + <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/SingleLogicView.cs" Line="13" Column="15" /> + <File FileName="HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs" Line="132" Column="13" /> </Files> <Pads> <Pad Id="ProjectPad"> @@ -15,24 +21,15 @@ <Node name="DAL" expanded="True"> <Node name="Server" expanded="True" /> </Node> - <Node name="Entity" expanded="True" /> <Node name="UI" expanded="True"> <Node name="UI2" expanded="True"> <Node name="3-Intelligence" expanded="True"> <Node name="Automation" expanded="True"> <Node name="LogicView" expanded="True" /> - <Node name="AddLogic.cs" selected="True" /> </Node> + <Node name="IntelligencePage.cs" selected="True" /> </Node> </Node> - </Node> - </Node> - <Node name="HDL-ON_Android" expanded="True"> - <Node name="Assets" expanded="True" /> - </Node> - <Node name="HDL-ON_iOS" expanded="True"> - <Node name="Resources" expanded="True"> - <Node name="Phone" expanded="True" /> </Node> </Node> </Node> diff --git a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide index c1fd0f9..31b5f00 100644 --- a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide +++ b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide Binary files differ diff --git a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-shm b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-shm index be55d48..9506845 100644 --- a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-shm +++ b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-shm Binary files differ diff --git a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal index 47e661d..12baa64 100644 --- a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal +++ b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal Binary files differ diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs index 39434f2..70cfa25 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs @@ -188,8 +188,13 @@ } else { - LogicMethod.RemoveAllView(); - MainView.MainShow(); + + var responsePackNew = Send.updateLogic(Logic.currlogic); + if (responsePackNew.Code == "0") + { + LogicMethod.RemoveAllView(); + MainView.MainShow(); + } //鍙戦�佹柊鍔犱慨鏀归�昏緫鍛戒护锛� } diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs index af6daaf..a388ffb 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs @@ -7,6 +7,7 @@ /// </summary> public class Logic { + /// <summary> /// 閫昏緫鍒楄〃 /// </summary> diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/SingleLogicView.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/SingleLogicView.cs index 32f8898..1356c70 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/SingleLogicView.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/SingleLogicView.cs @@ -10,7 +10,7 @@ public FrameLayout frameLayout = new FrameLayout { X = Application.GetRealWidth(16), - Y = Application.GetRealHeight(12), + //Y = Application.GetRealHeight(12), Width = Application.GetRealWidth(343), Height = Application.GetRealHeight(102), BackgroundColor = CSS.CSS_Color.view, diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs index ecfd441..35d231b 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs @@ -2,6 +2,8 @@ using HDL_ON.UI.UI2.Intelligence.Automation.LogicView; using Shared; using System.Collections.Generic; +using Newtonsoft.Json.Linq; + namespace HDL_ON.UI.UI2.Intelligence.Automation { public class MainView @@ -16,14 +18,27 @@ public static void MainShow() { automationPage.RemoveAll(); - VerticalScrolViewLayout vv = new VerticalScrolViewLayout(); + VerticalRefreshLayout vv = new VerticalRefreshLayout(); + vv.Height = Application.GetRealHeight(667 - 64 - 49);//妯℃嫙楂樺害 automationPage.AddChidren(vv); - + vv.BeginHeaderRefreshingAction += () => + { + //娓呴櫎涔嬪墠鑷姩鍖栧垪琛�; + Logic.LogicList.Clear(); + //鑾峰彇鑷姩鍒楄〃 + GetLogicList(); + //鍒锋柊鑷姩鍖栫晫闈� + MainShow(); + //鍏抽棴鍒锋柊View锛� + vv.EndHeaderRefreshing(); + }; + //鑾峰彇鑷姩鍖栧垪琛� + GetLogicList(); for (int i = 0; i < Logic.LogicList.Count; i++) { var currLogic = Logic.LogicList[i]; ///涓婁笅闂撮殧12鍍忕礌 - vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12) }); + vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12)}); LogicView.SingleLogicView logicView = new LogicView.SingleLogicView(); vv.AddChidren(logicView.FLayoutView()); logicView.btnLogicName.Text = currLogic.name; @@ -42,12 +57,22 @@ if (logicView.btnSwitchIcon.IsSelected) { logicView.btnSwitchIcon.IsSelected = true; + currLogic.enable = "true"; + + } else { logicView.btnSwitchIcon.IsSelected = false; + currLogic.enable = "false"; } + Send.switchLogic(currLogic); + }; + if (Logic.LogicList.Count-1==i) { + ///鏈�鍚庝竴涓窛绂绘渶搴曢儴12,鐣岄潰鏄剧ず鏁堟灉浣滅敤; + vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12) }); + } if (currLogic.enable == "true") { logicView.btnSwitchIcon.IsSelected = true; @@ -189,5 +214,93 @@ } return monTextName.TrimEnd(','); } + /// <summary> + /// 鑾峰彇閫昏緫鍒楄〃 + /// </summary> + private static void GetLogicList() + { + + if (Logic.LogicList.Count != 0) + { + //鑷姩鍖栧垪琛ㄤ负0鎵嶅幓鑾峰彇鑷姩鍖栧垪琛紱 + return; + } + List<string> logicIdList = new List<string>(); + //鑾峰彇閫昏緫ID鍒楄〃 + var idStr = Send.getLogicIdList(); + if (idStr.Code == "0" && idStr.Data != null) + { + var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data); + var dateList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Date>>(date); + for (int i = 0; i < dateList.Count; i++) + { + //娣诲姞閫昏緫ID + logicIdList.Add(dateList[i].userLogicId); + } + } + //鑾峰彇鑷姩鍖栧垪琛� + var logicStr = Send.getLogic(logicIdList); + if (logicStr.Code == "0" && logicStr.Data != null) + { + //鑾峰彇閫昏緫璇︾粏杩斿洖鏄竴涓暟缁�(object绫诲瀷杞崲涓烘暟缁�); + var jArray = JArray.Parse(logicStr.Data.ToString()); + for (int a = 0; a < jArray.Count; a++) + { + var jay = jArray[a]; + //鏁版嵁杩斿簭鍒楀寲涓篖ogic瀵硅薄 + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay); + var logic = Newtonsoft.Json.JsonConvert.DeserializeObject<Logic>(str); + if (logic != null) + { + //鏌ユ壘鏄惁宸茬粡瀛樺湪璇ラ�昏緫 + var if_logic = Logic.LogicList.Find((c) => c.userLogicId == logic.userLogicId); + if (if_logic == null) + { + //娣诲姞閫昏緫 + Logic.LogicList.Add(logic); + } + } + + } + } + + } + /// <summary> + /// 鍒ゆ柇JObject瀵硅薄鏄瓨鍦ㄥ仴鍊� + /// </summary> + /// <param name="jObject"></param> + /// <param name="key"></param> + /// <returns></returns> + private bool Exist(JObject jObject, string key) + { + + if (jObject.Property(key) != null) + { + return true; + } + return false; + } + } + class Date + { + /// <summary> + /// 浜戠鍞竴id + /// </summary> + public string userLogicId = ""; + public string gatewayId = ""; + /// <summary> + /// 閫昏緫鍞竴鏍囪瘑 + /// </summary> + public string sid = ""; + public string name = ""; + public string enable = ""; + //public CycleA cycle; + //public string modifyTime = ""; + } + + class CycleA + { + public string type = ""; + public string[] value; } } diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs index 4412688..278c08d 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs @@ -26,134 +26,6 @@ /// 缃戝叧ID /// </summary> public static string gatewayId = "1333723647223775233"; - ///// <summary> - ///// 鑾峰彇閫昏緫ID鍒楄〃 - ///// </summary> - ///// <returns></returns> - //public const string getLogicId = "鑾峰彇閫昏緫ID"; - ///// <summary> - ///// 鑾峰彇閫昏緫 - ///// </summary> - ///// <returns></returns> - //public const string getLogic= "鑾峰彇閫昏緫璇︾粏"; - ///// <summary> - ///// 娣诲姞鑷姩鍖栧懡浠� - ///// </summary> - ///// <returns></returns> - //public const string addLogic= "娣诲姞鏂伴�昏緫"; - ///// <summary> - ///// 缂栬緫鏇存柊閫昏緫 - ///// </summary> - ///// <returns></returns> - //public const string updateLogic = "缂栬緫閫昏緫"; - ///// <summary> - ///// 鍒犻櫎閫昏緫 - ///// </summary> - ///// <returns></returns> - //public const string delLogic = "鍒犻櫎閫昏緫"; - ///// <summary> - ///// 閫昏緫寮�鍏� - ///// </summary> - ///// <returns></returns> - //public const string switchLogic = "閫昏緫寮�鍏�"; - //public static ResponsePackNew Logic(string type,Logic logic) { - // string url = ""; - // var jObject = new JObject { }; - // switch (type) { - // case getLogicId: { - // jObject.Add("homeId",homeId); - // url = NewAPI.API_POST_Logic_List; - // } - // break; - // case getLogic: { - // var jArray = new JArray { }; - // jArray.Add(logic.userLogicId); - // jObject.Add("userLogicIds", jArray); - // url = NewAPI.API_POST_Logic_Info; - // } break; - // case addLogic: { - // try - // { - // var cycleJObject = new JObject { }; - // var cyclevaluejArray = new JArray { }; - // cycleJObject.Add("type", logic.cycle.type); - // foreach (var dictionary in logic.cycle.value) - // { - // cyclevaluejArray.Add(dictionary); - // } - // cycleJObject.Add("value", cyclevaluejArray); - - // var inputArray = new JArray { }; - // foreach (var dictionary in logic.input) - // { - // var inputTypeJOb = new JObject { }; - // inputTypeJOb.Add("sid", dictionary.sid); - // inputTypeJOb.Add("condition_type", dictionary.condition_type); - - // var conditionArray = new JArray { }; - // foreach (var dic in dictionary.condition) - // { - // var conditionJOb = new JObject { }; - // conditionJOb.Add("key", dic["key"]); - // conditionJOb.Add("comparator", dic["comparator"]); - // conditionJOb.Add("data_type", dic["data_type"]); - // conditionJOb.Add("value", dic["value"]); - // conditionArray.Add(conditionJOb); - // } - // inputTypeJOb.Add("condition", conditionArray); - // inputArray.Add(inputTypeJOb); - // } - - // var outputArray = new JArray { }; - // foreach (var dictionary in logic.output) - // { - // var outputTypeJOb = new JObject { }; - // outputTypeJOb.Add("sid", dictionary.sid); - // outputTypeJOb.Add("target_type", dictionary.target_type); - // var statusArray = new JArray { }; - // foreach (var dic in dictionary.status) - // { - // var statusJOb = new JObject { }; - // statusJOb.Add("key", dic["key"]); - // statusJOb.Add("value", dic["value"]); - // statusArray.Add(statusJOb); - // } - // outputTypeJOb.Add("status", statusArray); - // outputArray.Add(outputTypeJOb); - // } - - // var logicjArray = new JArray { }; - // var logicIfon = new JObject { }; - // logicIfon.Add("sid", logic.sid); - // logicIfon.Add("gatewayId", gatewayId); - // logicIfon.Add("name", logic.name); - // logicIfon.Add("relation", logic.relation); - // logicIfon.Add("enable", logic.enable); - // logicIfon.Add("cycle", cycleJObject); - // logicIfon.Add("input", inputArray); - // logicIfon.Add("output", outputArray); - // logicjArray.Add(logicIfon); - // var jObject = new JObject { { "homeId", homeId }, { "logics", logicjArray } }; - // responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Add); - - // } - // catch (Exception e) - // { - // var dd = e.Message; - // } - // } break; - // case updateLogic: { - // } break; - // case delLogic: { } break; - // case switchLogic: { } break; - - - // } - - // return RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Add); - //} - - /// <summary> /// 鑾峰彇閫昏緫ID鍒楄〃 @@ -168,11 +40,15 @@ /// <summary> /// 鑾峰彇閫昏緫 /// </summary> + /// <param name="userLogicId">閫昏緫ID</param> /// <returns></returns> - public static ResponsePackNew getLogic(Logic logic) + public static ResponsePackNew getLogic(List<string> listIdList) { var jArray = new JArray { }; - jArray.Add(logic.userLogicId); + for (int i = 0; i < listIdList.Count; i++) + { + jArray.Add(listIdList[i]); + } var jObject = new JObject { { "userLogicIds", jArray } }; var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Info); return responsePackNew; diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/Set.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/Set.cs index 94c4318..acd9170 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/Set.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/Set.cs @@ -98,6 +98,7 @@ new LogicView.TipPopView().TipBox(StringId.tip, StringId.delAutomation, () => { + Send.delLogic(Logic.currlogic); LogicMethod.RemoveAllView(); Logic.LogicList.Remove(Logic.currlogic); MainView.MainShow(); -- Gitblit v1.8.0