From 6d73bf6e816570291865674bef8bce8972e4de3f Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期三, 01 十二月 2021 16:32:57 +0800
Subject: [PATCH] 2021-12-01-01
---
HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs | 1022 ++++++++++++++++++++++++++++++++------------------------
1 files changed, 579 insertions(+), 443 deletions(-)
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs
index 101d71f..67752df 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs
@@ -6,462 +6,598 @@
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
- public class MainView
+ public class MainView
+ {
+ /// <summary>
+ /// VerticalRefreshLayout鐖舵帶浠�
+ /// </summary>
+ public static FrameLayout automationPage;
+ /// <summary>
+ /// 鍔犺浇閫昏緫鍒楄〃鏄剧ず鐣岄潰
+ /// </summary>
+ public static void MainShow()
{
- /// <summary>
- /// 璁板綍閫昏緫鑷姩鍖栫埗鎺т欢
- /// </summary>
- public static FrameLayout automationPage;
- /// <summary>
- /// 鍔犺浇閫昏緫鍒楄〃鏄剧ず鐣岄潰
- /// </summary>
- public static void MainShow()
+ automationPage.RemoveAll();
+ 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];
+ ///涓婁笅闂撮殧12鍍忕礌
+ vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12) });
+ LogicView.SingleLogicView logicView = new LogicView.SingleLogicView();
+ vv.AddChidren(logicView.FLayoutView());
+ logicView.btnLogicName.Text = currLogic.name;
+ logicView.btnWeekText.Text = GetCyclicText(currLogic);
+ logicView.btnclick.MouseUpEventHandler += (sen, e) =>
{
- automationPage.RemoveAll();
- 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];
- ///涓婁笅闂撮殧12鍍忕礌
- vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12) });
- LogicView.SingleLogicView logicView = new LogicView.SingleLogicView();
- vv.AddChidren(logicView.FLayoutView());
- 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);
- new System.Threading.Thread(() =>
- {
- try
- {
- //閫昏緫浣胯兘鐨勫懡浠�
- Send.switchLogic(currLogic);
-
- }
- catch { }
-
- })
- { IsBackground = true }.Start();
- };
- GetSelectIcon(logicView.frameLayout, 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)
- {
- Button btnTipNot = new Button()
- {
- Gravity = Gravity.CenterHorizontal,
- Y = Application.GetRealHeight(120),
- Width = Application.GetRealWidth(180),
- Height = Application.GetRealWidth(180),
- UnSelectedImagePath = "TipNot.png",
- };
- automationPage.AddChidren(btnTipNot);
- Button btnTipNotText = new Button()
- {
- Y = btnTipNot.Bottom,
- Height = Application.GetRealWidth(100),
- TextID = StringId.ContentIsEmpty,
- TextAlignment = TextAlignment.Center,
- TextColor = CSS.CSS_Color.TextualColor,
- TextSize = CSS.CSS_FontSize.PromptFontSize_FirstLevel,
- };
- automationPage.AddChidren(btnTipNotText);
- }
- }
- /// <summary>
- /// 鎸�+璺宠浆鍒伴�昏緫鐣岄潰鐨勬柟娉�
- /// </summary>
- public static void SkipAddLogicPage()
+ //Logic.currlogic = currLogic;
+ //var addLogic = new AddLogic();
+ //MainPage.BasePageView.AddChidren(addLogic);
+ //addLogic.Show();
+ //MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+ new MainView { }.SkipAddLogicPage(currLogic);
+ };
+ //寮�鍏冲浘鏍囩殑鐐瑰嚮浜嬩欢
+ logicView.btnSwitchIcon.MouseUpEventHandler += (sender1, e1) =>
{
- Logic.currlogic = new Logic();
- var addLogic = new AddLogic();
- MainPage.BasePageView.AddChidren(addLogic);
- addLogic.Show();
- MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
- }
- /// <summary>
- ///杩斿洖寰幆鎻忚堪鏂囨湰
- /// </summary>
- /// <param name="logic"></param>
- public static string GetWeekText(Logic logic)
+ 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);
+ new System.Threading.Thread(() =>
+ {
+ try
+ {
+ //閫昏緫浣胯兘鐨勫懡浠�
+ Send.SwitchLogic(currLogic);
+
+ }
+ catch { }
+
+ })
+ { IsBackground = true }.Start();
+ };
+ GetSelectIcon(logicView.frameLayout, currLogic);
+ if (i == 0)//闄嶅簭鎺掑垪
+ //if (Logic.LogicList.Count - 1 == i)
{
-
- 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;
+ ///鏈�鍚庝竴涓窛绂绘渶搴曢儴12,鐣岄潰鏄剧ず鏁堟灉浣滅敤;
+ vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12) });
}
- /// <summary>
- /// 鑾峰彇鏄熸湡鐨勫瓧绗︿覆
- /// </summary>
- /// <param name="weekList"></param>
- /// <returns></returns>
- public static string GetWeekString(List<string> weekList)
+ if (currLogic.enable == "true")
{
- string weekTextName = "";
- if (weekList.Contains("1"))
- {
- weekTextName += Language.StringByID(StringId.monday) + ",";
- }
- if (weekList.Contains("2"))
- {
- weekTextName += Language.StringByID(StringId.tuesday) + ",";
- }
- if (weekList.Contains("3"))
- {
- weekTextName += Language.StringByID(StringId.wednesday) + ",";
- }
- if (weekList.Contains("4"))
- {
- weekTextName += Language.StringByID(StringId.thursday) + ",";
- }
- if (weekList.Contains("5"))
- {
- weekTextName += Language.StringByID(StringId.friday) + ",";
- }
- if (weekList.Contains("6"))
- {
- weekTextName += Language.StringByID(StringId.saturday) + ",";
- }
- if (weekList.Contains("0"))
- {
- weekTextName += Language.StringByID(StringId.sunday) + ",";
- }
- if (weekTextName == "")
- {
- return "";
- }
- return weekTextName.TrimEnd(',');
+ logicView.btnSwitchIcon.IsSelected = true;
}
-
- /// <summary>
- /// 鑾峰彇姣忔湀鐨勫瓧绗︿覆
- /// </summary>
- /// <param name="monList"></param>
- /// <returns></returns>
- public static string GetMonString(List<string> monList)
+ else
{
- string monTextName = Language.StringByID(StringId.monthly);
-
- for (int i = 1; i < 32; i++)
- {
- if (monList.Contains(i.ToString()))
- {
- monTextName += i.ToString() + ",";
- }
- }
- return monTextName.TrimEnd(',');
+ logicView.btnSwitchIcon.IsSelected = false;
}
- /// <summary>
- /// 鑾峰彇閫昏緫鍒楄〃
- /// </summary>
- private static void GetLogicList()
+ }
+
+ if (Logic.LogicList.Count == 0)
+ {
+ Button btnTipNot = new Button()
{
-
- 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)
+ Gravity = Gravity.CenterHorizontal,
+ Y = Application.GetRealHeight(120),
+ Width = Application.GetRealWidth(180),
+ Height = Application.GetRealWidth(180),
+ UnSelectedImagePath = "TipNot.png",
+ };
+ automationPage.AddChidren(btnTipNot);
+ Button btnTipNotText = new Button()
{
-
- if (jObject.Property(key) != null)
- {
- return true;
- }
- return false;
- }
-
- /// <summary>
- /// 鏄剧ず鏉′欢鎴栬�呯洰鏍囩被鍨嬪浘鏍�
- /// </summary>
- /// <param name="layouFrame">鐖舵帶浠�</param>
- /// <param name="logic">褰撳墠閫昏緫</param>
- private static void GetSelectIcon(FrameLayout layouFrame, Logic logic)
- {
-
- //閲嶆柊鎺掑垪鍥炬爣搴忓彿
- List<int> iconIntValue = new List<int>();
- iconIntValue.Clear();
-
- //1-10(琛ㄧず鏉′欢鍥炬爣)鑷繁灞�閮ㄥ畾涔変负浜嗘樉绀洪�変腑鏉′欢绫诲瀷鍥炬爣
- //1-鏃堕棿鍥炬爣
- //2-鍔熻兘鍥炬爣
- for (int i = 0; i < logic.input.Count; i++)
- {
-
- var int1 = int.Parse(logic.input[i].condition_type);
- int iconInt = 0;
- switch (int1)
- {
- case 1:
- case 2:
- {
- iconInt = 1;
-
- }
- break;
- case 3:
- {
- iconInt = 2;
-
- }
- break;
- }
-
- if (!iconIntValue.Contains(iconInt))
- {
- iconIntValue.Add(iconInt);
- }
-
- }
-
- //鍒嗗壊鏉′欢鍜岀洰鏍囩殑鍥炬爣
- iconIntValue.Add(11);
-
- //12-20(琛ㄧず鐩爣鍥炬爣)鑷繁灞�閮ㄥ畾涔変负浜嗘樉绀洪�変腑鐩爣绫诲瀷鍥炬爣
- //12-鍔熻兘鍥炬爣
- //13-鍦烘櫙鍥炬爣
- //14-寤舵椂鍥炬爣
- for (int i = 0; i < logic.output.Count; i++)
- {
- var int1 = int.Parse(logic.output[i].target_type);
- int iconInt = 0;
- switch (int1)
- {
- case 1:
- {
- iconInt = 12;
-
- }
- break;
- case 2:
- {
- iconInt = 13;
-
- }
- break;
- case 3:
- {
- iconInt = 14;
-
- }
- break;
- }
-
- if (!iconIntValue.Contains(iconInt))
- {
- iconIntValue.Add(iconInt);
- }
- }
- //鍥炬爣鎺т欢鐨勭埗鎺т欢
- FrameLayout frame = new FrameLayout {
- Height=Application.GetRealHeight(40),
- Width=Application.GetRealWidth(275),
- Y= Application.GetRealHeight(56),
- };
- layouFrame.AddChidren(frame);
-
-
- for (int i = 0; i < iconIntValue.Count; i++)
- {
- //鍥炬爣鎺т欢
- Button btnIcon = new Button
- {
- Width = Application.GetRealWidth(28),
- Height = Application.GetRealWidth(28),
- Gravity=Gravity.CenterVertical,
- };
- frame.AddChidren(btnIcon);
-
- if (i == 0)
- {
- btnIcon.X = Application.GetRealWidth(12);
- }
- else
- {
- btnIcon.X = Application.GetRealWidth(12+(28+4)*i);
- }
- string strIcon = "";
- switch (iconIntValue[i]) {
-
- case 1: {
- strIcon = "LogicIcon/selectTheTime.png";
- }
- break;
- case 2:
- {
-
- strIcon = "LogicIcon/selectTheFun.png";
- }
- break;
- case 11:
- {
- //鍒嗗壊鏉′欢鍜岀洰鏍囩殑鍥炬爣
- strIcon = "LogicIcon/link.png";
- } break;
- case 12:
- {
-
- strIcon = "LogicIcon/selectTheFun.png";
- }
- break;
- case 13: {
- strIcon = "LogicIcon/selectTheScene.png";
- } break;
- case 14: {
- //strIcon = "LogicIcon/timeicon.png";
- }
- break;
-
- }
- btnIcon.UnSelectedImagePath = strIcon;
- }
- }
+ Y = btnTipNot.Bottom + Application.GetRealHeight(16),
+ Height = Application.GetRealHeight(20),
+ TextID = StringId.logicnull,
+ TextAlignment = TextAlignment.Center,
+ TextSize = LogicView.TextSize.text14,
+ TextColor = CSS.CSS_Color.textConfirmColor,
+ };
+ automationPage.AddChidren(btnTipNotText);
+ }
}
- class Date
+ /// <summary>
+ /// 鎸�+璺宠浆鍒伴�昏緫鐣岄潰鐨勬柟娉�
+ /// </summary>
+ public void SkipAddLogicPage(Logic logic = null)
{
- /// <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 = "";
- }
+ if (logic == null)
+ {
+ Logic.currlogic = new Logic();
+ }
+ else
+ {
+ Logic.currlogic = logic;
+ }
+ if (IsGatewayType)
+ {
+ var addLogic = new AddLogic();
+ MainPage.BasePageView.AddChidren(addLogic);
+ addLogic.Show();
+ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+ }
+ else
+ {
- class CycleA
- {
- public string type = "";
- public string[] value;
+ var onePortAutomation = new OnePortAutomation();
+ MainPage.BasePageView.AddChidren(onePortAutomation);
+ onePortAutomation.Show();
+ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+ }
}
+ /// <summary>
+ ///杩斿洖寰幆鎻忚堪鏂囨湰
+ /// </summary>
+ /// <param name="logic"></param>
+ public static string GetCyclicText(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("1"))
+ {
+ weekTextName += Language.StringByID(StringId.monday) + ",";
+ }
+ if (weekList.Contains("2"))
+ {
+ weekTextName += Language.StringByID(StringId.tuesday) + ",";
+ }
+ if (weekList.Contains("3"))
+ {
+ weekTextName += Language.StringByID(StringId.wednesday) + ",";
+ }
+ if (weekList.Contains("4"))
+ {
+ weekTextName += Language.StringByID(StringId.thursday) + ",";
+ }
+ if (weekList.Contains("5"))
+ {
+ weekTextName += Language.StringByID(StringId.friday) + ",";
+ }
+ if (weekList.Contains("6"))
+ {
+ weekTextName += Language.StringByID(StringId.saturday) + ",";
+ }
+ if (weekList.Contains("0"))
+ {
+ 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>
+ public 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<LogicData>>(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 newlogic = new Logic();
+ newlogic.name = logic.name;
+ newlogic.userLogicId = logic.userLogicId;
+ newlogic.sid = logic.sid;
+ newlogic.relation = logic.relation;
+ newlogic.enable = logic.enable;
+ newlogic.cycle = logic.cycle;
+ for (int i = 0; i < logic.input.Count; i++)
+ {
+ if (logic.input[i] == null || string.IsNullOrEmpty(logic.input[i].condition_type))
+ {
+ //闃叉璋冭瘯杞欢涔变紶涓滆タ涓婃潵;
+ //闃叉鏈夌┖瀵硅薄锛�
+ //姝e父鎯呭喌涓嬩笉浼氬嚭鐜扮殑鐜拌薄锛�
+ continue;
+ }
+ newlogic.input.Add(logic.input[i]);
+ }
+ for (int i = 0; i < logic.output.Count; i++)
+ {
+ if (logic.output[i] == null || string.IsNullOrEmpty(logic.output[i].target_type))
+ {
+ //闃叉璋冭瘯杞欢涔变紶涓滆タ涓婃潵;
+ //闃叉鏈夌┖瀵硅薄锛�
+ //姝e父鎯呭喌涓嬩笉浼氳鐜拌薄锛�
+ continue;
+ }
+ newlogic.output.Add(logic.output[i]);
+ }
+ newlogic.noticeConfig = logic.noticeConfig;
+ newlogic.pushConfigs = logic.pushConfigs;
+ //娣诲姞閫昏緫
+ Logic.LogicList.Add(newlogic);
+ }
+ }
+
+ }
+ }
+
+ }
+ /// <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;
+ }
+ /// <summary>
+ /// 鏄剧ず鏉′欢鎴栬�呯洰鏍囩被鍨嬪浘鏍�
+ /// </summary>
+ /// <param name="layouFrame">鐖舵帶浠�</param>
+ /// <param name="logic">褰撳墠鑷姩鍖�</param>
+ private static void GetSelectIcon(FrameLayout layouFrame, Logic logic)
+ {
+
+ //閲嶆柊鎺掑垪鍥炬爣搴忓彿
+ List<int> iconIntValue = new List<int>();
+ iconIntValue.Clear();
+
+ //1-10(琛ㄧず鏉′欢鍥炬爣)鑷繁灞�閮ㄥ畾涔変负浜嗘樉绀洪�変腑鏉′欢绫诲瀷鍥炬爣
+ //1-鏃堕棿鍥炬爣
+ //2-鍔熻兘鍥炬爣
+ //3-浜戠鍥炬爣
+ //4-鍦烘櫙鍥炬爣
+ for (int i = 0; i < logic.input.Count; i++)
+ {
+ if (logic.input[i] == null)
+ continue;
+ var int1 = int.Parse(logic.input[i].condition_type);
+ int iconInt = 0;
+ switch (int1)
+ {
+ case 1:
+ case 2:
+ {
+ iconInt = 1;
+
+ }
+ break;
+ case 3:
+ {
+ iconInt = 2;
+
+ }
+ break;
+ case 4:
+ case 6:
+ case 9:
+ {
+ iconInt = 3;
+
+ }
+ break;
+ case 10:
+ {
+ iconInt = 4;
+
+ }
+ break;
+ case 8:
+ {
+ iconInt = 5;
+
+ }
+ break;
+ }
+
+ if (!iconIntValue.Contains(iconInt))
+ {
+ iconIntValue.Add(iconInt);
+ }
+
+ }
+
+ //鍒嗗壊鏉′欢鍜岀洰鏍囩殑鍥炬爣
+ iconIntValue.Add(11);
+
+ //12-20(琛ㄧず鐩爣鍥炬爣)鑷繁灞�閮ㄥ畾涔変负浜嗘樉绀洪�変腑鐩爣绫诲瀷鍥炬爣
+ //12-鍔熻兘鍥炬爣
+ //13-鍦烘櫙鍥炬爣
+ //14-瀹夐槻鍥炬爣
+ //14-寤舵椂鍥炬爣
+ for (int i = 0; i < logic.output.Count; i++)
+ {
+ var int1 = int.Parse(logic.output[i].target_type);
+ int iconInt = 0;
+ switch (int1)
+ {
+ case 1:
+ {
+ iconInt = 12;
+
+ }
+ break;
+ case 2:
+ {
+ iconInt = 13;
+
+ }
+ break;
+ case 3:
+ {
+ iconInt = 14;
+
+ }
+ break;
+ case 4:
+ {
+ iconInt = 15;
+
+ }
+ break;
+ }
+
+ if (!iconIntValue.Contains(iconInt))
+ {
+ iconIntValue.Add(iconInt);
+ }
+ }
+ //鍥炬爣鎺т欢鐨勭埗鎺т欢
+ FrameLayout frame = new FrameLayout
+ {
+ Height = Application.GetRealHeight(40),
+ Width = Application.GetRealWidth(275),
+ Y = Application.GetRealHeight(56),
+ };
+ layouFrame.AddChidren(frame);
+
+
+ for (int i = 0; i < iconIntValue.Count; i++)
+ {
+ //鍥炬爣鎺т欢
+ Button btnIcon = new Button
+ {
+ Width = Application.GetRealWidth(28),
+ Height = Application.GetRealWidth(28),
+ Gravity = Gravity.CenterVertical,
+ };
+ frame.AddChidren(btnIcon);
+
+ if (i == 0)
+ {
+ btnIcon.X = Application.GetRealWidth(12);
+ }
+ else
+ {
+ btnIcon.X = Application.GetRealWidth(12 + (28 + 4) * i);
+ }
+ string strIcon = "";
+ switch (iconIntValue[i])
+ {
+
+ case 1:
+ {
+ strIcon = "LogicIcon/selectTheTime.png";
+ }
+ break;
+ case 2:
+ {
+
+ strIcon = "LogicIcon/selectTheFun.png";
+ }
+ break;
+ case 3:
+ {
+
+ strIcon = "LogicIcon/shiwaitianqi.png";
+ }
+ break;
+ case 4:
+ {
+
+ strIcon = "LogicIcon/selectTheScene.png";
+ }
+ break;
+ case 5:
+ {
+
+ strIcon = "LogicIcon/selectTheautomLocation.png";
+ }
+ break;
+ case 11:
+ {
+ //鍒嗗壊鏉′欢鍜岀洰鏍囩殑鍥炬爣
+ strIcon = "LogicIcon/link.png";
+ }
+ break;
+ case 12:
+ {
+
+ strIcon = "LogicIcon/selectTheFun.png";
+ }
+ break;
+ case 13:
+ {
+ strIcon = "LogicIcon/selectTheScene.png";
+ }
+ break;
+ case 14:
+ {
+
+ strIcon = "LogicIcon/selectTheautomSecurity.png";
+ }
+ break;
+ case 15:
+ {
+ //strIcon = "LogicIcon/timeicon.png";
+
+ }
+ break;
+
+ }
+ btnIcon.UnSelectedImagePath = strIcon;
+ }
+ }
+ /// <summary>
+ /// 鍒ゆ柇缃戝叧绫诲瀷(0:bus缃戝叧锛�1:A鍗忚缃戝叧)
+ /// </summary>
+ /// <returns>true=A鍗忚缃戝叧;false=bus缃戝叧</returns>
+ public static bool IsGatewayType
+ {
+ get
+ {
+ if (Entity.DB_ResidenceData.Instance.GatewayType == 1)
+ {
+ return true;
+ }
+ return false;
+ }
+ }
+ }
+ class LogicData
+ {
+ /// <summary>
+ /// 浜戠鍞竴id
+ /// </summary>
+ public string userLogicId = "";
+ /// <summary>
+ /// 缃戝叧id
+ /// </summary>
+ public string gatewayId = "";
+ /// <summary>
+ /// 閫昏緫鍞竴鏍囪瘑
+ /// </summary>
+ public string sid = "";
+ /// <summary>
+ /// 閫昏緫鍚嶇О
+ /// </summary>
+ public string name = "";
+ /// <summary>
+ /// 閫昏緫浣胯兘锛堝紑锛屽叧锛�
+ /// </summary>
+ public string enable = "";
+ /// <summary>
+ /// 鍦扮悊鍥存爮閰嶇疆
+ /// </summary>
+ public Fence geo_fence = new Fence();
+ }
+
+ class CycleA
+ {
+ public string type = "";
+ public string[] value;
+ }
}
--
Gitblit v1.8.0