From 6ba43603ccd8868a4ee73e9b978b7cb20a5b2c52 Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期五, 04 十二月 2020 14:24:53 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/WJC' --- HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 118 insertions(+), 2 deletions(-) diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs index ecfd441..2025a0a 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,9 +18,23 @@ 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 = Logic.LogicList.Count-1; i >= 0; i--)闄嶅簭鎺掑垪 for (int i = 0; i < Logic.LogicList.Count; i++) { var currLogic = Logic.LogicList[i]; @@ -42,12 +58,24 @@ if (logicView.btnSwitchIcon.IsSelected) { logicView.btnSwitchIcon.IsSelected = true; + currLogic.enable = "true"; + + } else { logicView.btnSwitchIcon.IsSelected = false; + currLogic.enable = "false"; } + Send.switchLogic(currLogic); + }; + //if (i==0)闄嶅簭鎺掑垪 + 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 +217,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; } } -- Gitblit v1.8.0