From e87985ec1dcb69beedaf9f95e8e7aba14b7c08d6 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期三, 09 十二月 2020 18:50:14 +0800
Subject: [PATCH] 2020-12-09 1.信息中心,增加下划线和点击Alter提醒详情。

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs |  254 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 245 insertions(+), 9 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs
index e48fd03..ea91731 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs
@@ -1,6 +1,9 @@
 锘縰sing System;
 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
@@ -14,25 +17,73 @@
         /// </summary>
         public static void MainShow()
         {
-
             automationPage.RemoveAll();
-            VerticalScrolViewLayout vv = new VerticalScrolViewLayout();
+            VerticalRefreshLayout vv = new VerticalRefreshLayout();
+            vv.Height = Application.GetRealHeight(667 - 64 - 49);//妯℃嫙楂樺害
             automationPage.AddChidren(vv);
-
-            for (int i = 0; i < 2; i++)
+            vv.BeginHeaderRefreshingAction += () =>
             {
-                Logic.LogicList.Add(new Logic { name = "123456" });
-            }
-
+                //娓呴櫎涔嬪墠鑷姩鍖栧垪琛�;
+                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];
                 ///涓婁笅闂撮殧12鍍忕礌
                 vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12) });
                 LogicView.SingleLogicView logicView = new LogicView.SingleLogicView();
                 vv.AddChidren(logicView.FLayoutView());
-                logicView.btnLogicName.Text = i.ToString();
-                logicView.btnWeekText.Text = "姣忓ぉ";
+                logicView.btnLogicName.Text = currLogic.name;
+                logicView.btnWeekText.Text = GetWeekText(currLogic);
+                logicView.btnclick.MouseUpEventHandler += (sen, e) =>
+                {
+                    Logic.currlogic = currLogic;
+                    var addLogic = new AddLogic();
+                    MainPage.BasePageView.AddChidren(addLogic);
+                    addLogic.Show();
+                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                };
+                logicView.btnSwitchIcon.MouseUpEventHandler += (sender1, e1) =>
+                {
+                    logicView.btnSwitchIcon.IsSelected = !logicView.btnSwitchIcon.IsSelected;
+                    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;
+                }
+                else
+                {
+                    logicView.btnSwitchIcon.IsSelected = false;
+                }
             }
 
             if (Logic.LogicList.Count == 0)
@@ -69,5 +120,190 @@
             addLogic.Show();
             MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
         }
+        /// <summary>
+        ///杩斿洖寰幆鎻忚堪鏂囨湰
+        /// </summary>
+        /// <param name="logic"></param>
+        public static string GetWeekText(Logic logic)
+        {
+
+            string weekName = "";
+            /// (鎵ц涓�娆�:once锛屾瘡澶�:day锛屾瘡鏈�:mon锛屾槦鏈�:week锛屾棩鏈熸:date_to_date)
+            switch (logic.cycle.type)
+            {
+                case "once":
+                    {
+                        weekName = Language.StringByID(StringId.performA);
+                    }
+                    break;
+                case "day":
+                    {
+                        weekName = Language.StringByID(StringId.days);
+                    }
+                    break;
+                case "week":
+                    {
+
+                        weekName = GetWeekString(logic.cycle.value);
+
+                    }
+                    break;
+                case "mon":
+                    {
+                        weekName = GetMonString(logic.cycle.value);
+                    }
+                    break;
+            }
+            return weekName;
+        }
+        /// <summary>
+        /// 鑾峰彇鏄熸湡鐨勫瓧绗︿覆
+        /// </summary>
+        /// <param name="weekList"></param>
+        /// <returns></returns>
+        public static string GetWeekString(List<string> weekList)
+        {
+            string weekTextName = "";
+
+            if (weekList.Contains("0"))
+            {
+                weekTextName += Language.StringByID(StringId.monday) + ",";
+            }
+            if (weekList.Contains("1"))
+            {
+                weekTextName += Language.StringByID(StringId.tuesday) + ",";
+            }
+            if (weekList.Contains("2"))
+            {
+                weekTextName += Language.StringByID(StringId.wednesday) + ",";
+            }
+            if (weekList.Contains("3"))
+            {
+                weekTextName += Language.StringByID(StringId.thursday) + ",";
+            }
+            if (weekList.Contains("4"))
+            {
+                weekTextName += Language.StringByID(StringId.friday) + ",";
+            }
+            if (weekList.Contains("5"))
+            {
+                weekTextName += Language.StringByID(StringId.saturday) + ",";
+            }
+            if (weekList.Contains("6"))
+            {
+                weekTextName += Language.StringByID(StringId.sunday) + ",";
+            }
+            if (weekTextName == "")
+            {
+                return "";
+            }
+            return weekTextName.TrimEnd(',');
+        }
+        /// <summary>
+        /// 鑾峰彇姣忔湀鐨勫瓧绗︿覆
+        /// </summary>
+        /// <param name="monList"></param>
+        /// <returns></returns>
+        public static string GetMonString(List<string> monList)
+        {
+            string monTextName = Language.StringByID(StringId.monthly);
+
+            for (int i = 1; i < 32; i++)
+            {
+                if (monList.Contains(i.ToString()))
+                {
+                    monTextName += i.ToString() + ",";
+                }
+            }
+            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&& idStr.Data.ToString()!="")
+            {
+                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 && logicStr.Data.ToString() != "")
+            {
+                //鑾峰彇閫昏緫璇︾粏杩斿洖鏄竴涓暟缁�(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