From 6fa9d69da922c8049f5acfcbb9ce9fd26811024c Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期四, 16 四月 2020 17:10:57 +0800
Subject: [PATCH] 请合并代码

---
 ZigbeeApp/Shared/Phone/Device/Logic/LogicIfon.cs |  252 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 252 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/LogicIfon.cs b/ZigbeeApp/Shared/Phone/Device/Logic/LogicIfon.cs
new file mode 100755
index 0000000..af09f9e
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/LogicIfon.cs
@@ -0,0 +1,252 @@
+锘縰sing System;
+using System.Collections.Generic;
+using Shared;
+using ZigBee.Device;
+
+namespace Shared.Phone.Device.Logic
+{
+    public class LogicIfon
+    {
+        #region ----閫昏緫鏉′欢杈撳叆----
+        /// <summary>
+        /// 娣诲姞璁惧鏉′欢鐨勬柟娉�
+        /// </summary>
+        /// <param name="common">Common.</param>
+        /// <param name="objecttype">Objecttype.</param>
+        public static void AddDeviceconditions(CommonDevice common, Dictionary<string, string> objecttype) 
+        {
+            for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++)
+            {
+                if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == "1")
+                {
+                    if ((Common.Logic.CurrentLogic.Conditions[i]["MacAddr"] == common.DeviceAddr) && (Common.Logic.CurrentLogic.Conditions[i]["Epoint"] == common.DeviceEpoint.ToString()))
+                    {
+                        if (common.Type == DeviceType.TemperatureSensor)//璁惧娓╁害浼犳劅鍣ㄦ湁鐐圭壒鍒�
+                        {
+                            var dev = common as TemperatureSensor;
+                            string str = "";
+                            if (dev.SensorDiv == 1)
+                            {
+                                str = "1026";
+                            }
+                            else
+                            {
+                                str = "1029";
+                            }
+                            if (Common.Logic.CurrentLogic.Conditions[i]["Cluster_ID"] == str)
+                            {
+                                Common.Logic.CurrentLogic.Conditions.RemoveAt(i);
+                                Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype);
+                                return;
+                            }
+
+                        }
+                        else
+                        {
+                            Common.Logic.CurrentLogic.Conditions.RemoveAt(i);
+                            Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype);
+                            return;
+                        }
+                    }
+
+                }
+            }
+            Common.Logic.CurrentLogic.Conditions.Add(objecttype);
+        }
+        /// <summary>
+        /// 娣诲姞Logic鏉′欢鐨勬柟娉�
+        /// </summary>
+        /// <param name="common">Common.</param>
+        /// <param name="objecttype">Objecttype.</param>
+        public static void AddLogicconditions(Common.Logic logic, Dictionary<string, string> objecttype)
+        {
+            for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++)
+            {
+                if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == "2")
+                {
+
+                    if (Common.Logic.CurrentLogic.Conditions[i]["Condition_LogicId"] == logic.LogicId.ToString())
+                    {
+                        Common.Logic.CurrentLogic.Conditions.RemoveAt(i);
+                        Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype);
+                        return;
+                    }
+
+                }
+
+            }
+            Common.Logic.CurrentLogic.Conditions.Add(objecttype);
+        }
+        /// <summary>
+        /// 娣诲姞瀹夐槻鏉′欢鐨勬柟娉�
+        /// </summary>
+        /// <param name="objecttype">Objecttype.</param>
+        public static void AddSecurityconditions(Dictionary<string, string> objecttype)
+        {
+            for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++)
+            {
+                if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == "6")
+                {
+
+                    Common.Logic.CurrentLogic.Conditions.RemoveAt(i);
+                    Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype);
+                    return;
+
+                }
+
+            }
+            Common.Logic.CurrentLogic.Conditions.Add(objecttype);
+        }
+
+        /// <summary>
+        /// 娣诲姞鍦扮悊浣嶇疆鏉′欢鐨勬柟娉�
+        /// </summary>
+        /// <param name="objecttype">Objecttype.</param>
+        public static void AddLocationconditions(Dictionary<string, string> objecttype)
+        {
+            for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++)
+            {
+                if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == objecttype["Type"])
+                {
+
+                    Common.Logic.CurrentLogic.Conditions.RemoveAt(i);
+                    Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype);
+                    return;
+
+                }
+
+            }
+            Common.Logic.CurrentLogic.Conditions.Add(objecttype);
+        }
+        #endregion
+        #region ----閫昏緫杈撳嚭鐩爣----
+
+        /// <summary>
+        /// 娣诲姞璁惧杈撳嚭鐨勬柟娉�
+        /// </summary>
+        /// <param name="common">Common.</param>
+        /// <param name="actionsInfo">Objecttype.</param>
+        public static void AddDeviceActions(ZigBee.Device.CommonDevice common, Dictionary<string, object> actionsInfo)
+        {
+            for (int i = 0; i < Common.Logic.CurrentLogic.Actions.Count; i++)
+            {
+                if (Common.Logic.CurrentLogic.Actions[i]["LinkType"].ToString() == "0")
+                {
+                    if (Common.Logic.CurrentLogic.Actions[i]["DeviceAddr"].ToString() == common.DeviceAddr && Common.Logic.CurrentLogic.Actions[i]["Epoint"].ToString() == common.DeviceEpoint.ToString())
+                    {
+                        Common.Logic.CurrentLogic.Actions.RemoveAt(i);
+                        Common.Logic.CurrentLogic.Actions.Insert(i, actionsInfo);
+                        return;
+                    }
+                }
+            }
+            Common.Logic.CurrentLogic.Actions.Add(actionsInfo);
+        }
+        /// <summary>
+        /// 娣诲姞闂ㄩ攣璁惧杈撳嚭鐨勬柟娉�
+        /// </summary>
+        /// <param name="common">Common.</param>
+        /// <param name="actionsInfo">Objecttype.</param>
+        public static void AddDoorLockActions(ZigBee.Device.CommonDevice common, Dictionary<string, object> actionsInfo)
+        {
+            for (int i = 0; i < Common.Logic.CurrentLogic.Actions.Count; i++)
+            {
+                if (Common.Logic.CurrentLogic.Actions[i]["LinkType"].ToString() == "8")
+                {
+                    if (Common.Logic.CurrentLogic.Actions[i]["DeviceAddr"].ToString() == common.DeviceAddr && Common.Logic.CurrentLogic.Actions[i]["Epoint"].ToString() == common.DeviceEpoint.ToString())
+                    {
+                        Common.Logic.CurrentLogic.Actions.RemoveAt(i);
+                        Common.Logic.CurrentLogic.Actions.Insert(i, actionsInfo);
+                        return;
+                    }
+                }
+            }
+            Common.Logic.CurrentLogic.Actions.Add(actionsInfo);
+        }
+        /// <summary>
+        /// 娣诲姞Scene杈撳嚭鐨勬柟娉�
+        /// </summary>
+        /// <param name="Scene">Common.</param>
+        /// <param name="actionsInfo">Objecttype.</param>
+        public static void AddSceneactions(Shared.Common.SceneUI Scene, Dictionary<string, object> actionsInfo)
+        {
+            for (int i = 0; i < Common.Logic.CurrentLogic.Actions.Count; i++)
+            {
+                if (Common.Logic.CurrentLogic.Actions[i]["LinkType"].ToString() == "2")
+                {
+                    if (Common.Logic.CurrentLogic.Actions[i]["DeviceAddr"].ToString() == Scene.Id.ToString())
+                    {
+                        Common.Logic.CurrentLogic.Actions.RemoveAt(i);
+                        Common.Logic.CurrentLogic.Actions.Insert(i, actionsInfo);
+                        return;
+                    }
+                }
+            }
+            Common.Logic.CurrentLogic.Actions.Add(actionsInfo);
+        }
+        /// <summary>
+        /// 娣诲姞瀹夐槻杈撳嚭鐨勬柟娉�
+        /// </summary>
+        /// <param name="objecttype">Objecttype.</param>
+        /// <param name="o">O.</param>
+        public static void AddSecurityactions(Dictionary<string, object> actionsInfo)
+        {
+            for (int i = 0; i < Common.Logic.CurrentLogic.Actions.Count; i++)
+            {
+                if (Common.Logic.CurrentLogic.Actions[i]["LinkType"].ToString() == "6")
+                {
+                    Common.Logic.CurrentLogic.Actions.RemoveAt(i);
+                    Common.Logic.CurrentLogic.Actions.Insert(i, actionsInfo);
+                    return;
+                }
+            }
+            Common.Logic.CurrentLogic.Actions.Add(actionsInfo);
+        }
+
+        /// <summary>
+        /// 娣诲姞鑷姩鍖栬緭鍑虹殑鏂规硶
+        /// </summary>
+        /// <param name="objecttype">Objecttype.</param>
+        /// <param name="o">O.</param>
+        public static void AddLogicactions(Common.Logic logic, Dictionary<string, object> actionsInfo)
+        {
+
+            for (int i = 0; i < Common.Logic.CurrentLogic.Actions.Count; i++)
+            {
+                if (Common.Logic.CurrentLogic.Actions[i]["LinkType"].ToString() == "4")
+                {
+                    if (Common.Logic.CurrentLogic.Actions[i]["DeviceAddr"].ToString() == logic.LogicId.ToString())
+                    {
+                        Common.Logic.CurrentLogic.Actions.RemoveAt(i);
+                        Common.Logic.CurrentLogic.Actions.Insert(i, actionsInfo);
+                        return;
+                    }
+                }
+            }
+            Common.Logic.CurrentLogic.Actions.Add(actionsInfo);
+
+        }
+        #endregion
+        #region ----鍏宠仈app璐﹀彿----
+        /// <summary>
+        /// 鍏宠仈app璐﹀彿
+        /// </summary>
+        /// <param name="accountsInfo"></param>
+        public static void Addaccounts(Dictionary<string, string> accountsInfo)
+        {
+            for (int i = 0; i < Common.Logic.CurrentLogic.Accounts.Count; i++)
+            {
+                if (Common.Logic.CurrentLogic.Accounts[i]["Type"] == accountsInfo["Type"])
+                {
+                    Common.Logic.CurrentLogic.Accounts.RemoveAt(i);
+                    Common.Logic.CurrentLogic.Accounts.Insert(i, accountsInfo);
+                    return;
+                }
+            }
+            Common.Logic.CurrentLogic.Accounts.Add(accountsInfo);
+        }
+        #endregion
+    }
+
+
+}

--
Gitblit v1.8.0