From 1c4904d77f484c075080942d87785481b52b6fb2 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期一, 28 十月 2019 14:58:46 +0800
Subject: [PATCH] Revert "Merge branch 'dev-tzy' into DEV_GXC"

---
 ZigbeeApp/Shared/Phone/Device/Logic/Send.cs |  309 ++++-----------------------------------------------
 1 files changed, 25 insertions(+), 284 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs b/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs
index a4e865e..3cb527e 100755
--- a/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs
@@ -3,18 +3,16 @@
 using Newtonsoft.Json.Linq;
 using ZigBee.Device;
 using ZigBee.Common;
-using Shared.Common;
 
 namespace Shared.Phone.Device.Logic
 {
     public class Send
     {
-
         /// <summary>
         /// 鑾峰彇LogicId鐨勬柟娉�
         /// </summary>
         /// <returns>The logic identifier.</returns>
-        public static async System.Threading.Tasks.Task<List<int>> GetLogicId(int LogicType)
+        public static async System.Threading.Tasks.Task<List<int>> GetLogicId()
         {
             return await System.Threading.Tasks.Task.Run(async () =>
             {
@@ -53,8 +51,6 @@
                 mainGateWay.GwResDataAction += action;
 
                 var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 2004 } };
-                var jObjectdata1 = new JObject { { "LogicType", LogicType } };
-                jObject.Add("Data", jObjectdata1);
                 mainGateWay?.Send("Logic/GetLogicList", jObject.ToString());
                 //await System.Threading.Tasks.Task.Run(async () =>
                 //{
@@ -76,7 +72,7 @@
         /// 鑾峰彇Logic鐨勬柟娉�
         /// </summary>
         /// <returns>The logic identifier.</returns>
-        public static async System.Threading.Tasks.Task<Common.Logic> GetLogic(int LogicId,int LogicType)
+        public static async System.Threading.Tasks.Task<Common.Logic> GetLogic(int LogicId)
         {
             return await System.Threading.Tasks.Task.Run(async () =>
             {
@@ -101,9 +97,8 @@
                         logic.LogicName = Logicifon["LogicName"]?.ToString();
 
                         logic.Relationship = int.Parse(Logicifon["Relationship"]?.ToString());
-                        logic.TimeAttribute = Newtonsoft.Json.JsonConvert.DeserializeObject<TimeAttributeObj>(Logicifon["TimeAttribute"].ToString());
+                        logic.TimeAttribute = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.TimeAttributeObj>(Logicifon["TimeAttribute"].ToString());
                         logic.Conditions = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(Logicifon["Conditions"].ToString());
-                        logic.Accounts = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(Logicifon["Accounts"].ToString());
                         var listactions = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(Logicifon["Actions"].ToString());
                         if (listactions != null)
                         {
@@ -138,7 +133,7 @@
 
                         }
 
-                    }
+                    };
                 };
                 var mainGateWay = ZbGateway.MainGateWay;
                 if (mainGateWay == null)
@@ -151,8 +146,7 @@
                 {
                     var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 2002 } };
                     var data = new JObject {
-                        { "LogicId",LogicId},
-                        { "LogicType",LogicType}
+                        { "LogicId",LogicId}
                         };
                     jObject.Add("Data", data);
                     ZbGateway.MainGateWay?.Send("Logic/GetLogicInfo", jObject.ToString());
@@ -257,6 +251,10 @@
 
                 try
                 {
+                    //var bytes = new byte[64];
+                    //var LogicNameBytes = System.Text.Encoding.UTF8.GetBytes(logic.LogicName);
+                    //Array.Copy(LogicNameBytes, 0, bytes, 0, 64 < LogicNameBytes.Length ? 64 : LogicNameBytes.Length);
+                    //logic.LogicName = System.Text.Encoding.UTF8.GetString(bytes);
 
                     var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 2000 } };
                     var selectMonthList = new JArray { };
@@ -312,13 +310,8 @@
                                     ["AttriButeId"] = int.Parse(dictionary["AttriButeId"]),
                                     ["AttriButeData1"] = int.Parse(dictionary["AttriButeData1"]),
                                     ["AttriButeData2"] = int.Parse(dictionary["AttriButeData2"]),
-                                    ["Range"] = int.Parse(dictionary["Range"])
+                                    ["Range"] = int.Parse(dictionary["Range"]),
                                 };
-                                if (dictionary.ContainsKey("IgnoreTime"))
-                                {
-                                    dInfo.Add("IgnoreTime", int.Parse(dictionary["IgnoreTime"]));
-                                }
-
                                 conditions.Add(dInfo);
                                 break;
                             case 2:
@@ -441,51 +434,16 @@
                                 };
                                 actions.Add(cdInfo);
                                 break;
-                            case 7:
-                                var timeInfo = new JObject
-                                {
-                                    ["LinkType"] = int.Parse(dictionary["LinkType"].ToString()),
-                                    ["DelayTime"] = int.Parse(dictionary["DelayTime"].ToString()),
-                                };
-                                actions.Add(timeInfo);
-                                break;
                         }
-                    }
-                    var accounts = new JArray();
-                    foreach (var dictionary in logic.Accounts) {
-                        var Type = int.Parse(dictionary["Type"]);
-                        switch (Type)
-                        {
-                            case 1: {
-                                    ///
-                                } break;
-                            case 7:
-                                {
-                                    var location = new JObject
-                                    {
-                                        ["Type"] = int.Parse(dictionary["Type"]),
-                                        ["Account"] = dictionary["Account"],
-                                        ["Longitude"] = int.Parse(dictionary["Longitude"]),
-                                        ["Latitude"] = int.Parse(dictionary["Latitude"]),
-                                        ["Radius"] = int.Parse(dictionary["Radius"]),
-
-                                    };
-                                    accounts.Add(location);
-                                }
-                                break;
-                        }
-
                     }
                     var data = new JObject{
                         { "LogicId",logic.LogicId},
                         { "IsEnable", logic.IsEnable} ,
                         { "LogicName", logic.LogicName},
                         { "Relationship",logic.Relationship} ,
-                        { "LogicCustomPushText",logic.LogicCustomPushText} ,
                         { "TimeAttribute", timeAttribute} ,
                         { "Conditions", conditions },
                         { "Actions", actions },
-                        { "Accounts", accounts },
                     };
                     jObject.Add("Data", data);
                     ZbGateway.MainGateWay?.Send("Logic/AddLogic", jObject.ToString());
@@ -545,9 +503,8 @@
                 jObject.Add("Data", date);
                 date.Add("LogicId", logic.LogicId);
                 date.Add("IsEnable", logic.IsEnable);
-                date.Add("LogicName", logic.LogicName);
-                date.Add("Relationship", logic.Relationship);
-                date.Add("LogicCustomPushText", logic.LogicCustomPushText);
+                //date.Add("LogicName", logic.LogicName);
+                //date.Add("Relationship", logic.Relationship);
                 mainGateWay?.Send("Logic/ReviseAttribute", jObject.ToString());
                 //await System.Threading.Tasks.Task.Run(async () =>
                 //{
@@ -569,13 +526,13 @@
         /// 鑾峰彇Logic鍒楄〃鐨勬柟娉�
         /// </summary>
         /// <returns>The logic identifier.</returns>
-        public static async System.Threading.Tasks.Task<List<Common.Logic>> ReadList(int sum,int LogicType)
+        public static async System.Threading.Tasks.Task<List<Common.Logic>> ReadList(int sum)
         {
             return await System.Threading.Tasks.Task.Run(async () =>
             {
 
                 var listLogic = new List<Common.Logic>();
-               // bool @bool = false;
+                bool @bool = false;
                 Action<string, string> action = (topic, data) =>
                 {
                     var gatewayID = topic.Split('/')[0];
@@ -593,7 +550,6 @@
                         logic.LogicId = int.Parse(Logicifon["LogicId"].ToString());
                         logic.IsEnable = int.Parse(Logicifon["IsEnable"].ToString());
                         logic.LogicName = Logicifon["LogicName"].ToString();
-                        logic.LogicType = int.Parse(Logicifon["LogicType"].ToString());
                         logic.Relationship = int.Parse(Logicifon["Relationship"].ToString());
                         logic.TimeAttribute = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.TimeAttributeObj>(Logicifon["TimeAttribute"].ToString());
                         logic.Conditions = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(Logicifon["Conditions"].ToString());
@@ -643,10 +599,10 @@
                         }
 
                     }
-                    //if (topic == $"{gatewayID}/Logic/AllLogicNum_Respon")
-                    //{
-                    //    @bool = true;
-                    //}
+                    if (topic == $"{gatewayID}/Logic/AllLogicNum_Respon")
+                    {
+                        @bool = true;
+                    }
                 };
                 var mainGateWay = ZbGateway.MainGateWay;
                 if (mainGateWay == null)
@@ -658,8 +614,6 @@
                 try
                 {
                     var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 2015 } };
-                    var jObjectdata = new JObject { { "LogicType", LogicType } };
-                    jObject.Add("Data", jObjectdata);
                     ZbGateway.MainGateWay?.Send("Logic/GetAllLogicListInfo", jObject.ToString());
                 }
                 catch { }
@@ -667,241 +621,28 @@
                 while ((DateTime.Now - dateTime).TotalMilliseconds < 8 * 1000)
                 {
                     await System.Threading.Tasks.Task.Delay(100);
-                    if (sum == listLogic.Count)
-                    {
-                        break;
-                    }
-                    //if (@bool)
+                    //if (sum == listLogic.Count)
                     //{
                     //    break;
                     //}
+                    if (@bool)
+                    {
+                        break;
+                    }
                 }
                 ZbGateway.MainGateWay.GwResDataAction -= action;
                 return listLogic;
             });
         }
         // <summary>
-        /// 閫氳繃璁惧鎵惧埌鍖哄煙(鎴块棿)鍚嶇О
+        /// 閫氳繃璁惧鎵惧埌鍖哄煙(鎴块棿)鍚嶇О
         /// </summary>
         /// <param name="btnregionname">Btnregionname.</param>
         /// <param name="device">Device.</param>
         public static void RoomNmae(Button btnregionname, CommonDevice device)
         {
-            var room = new Common.Room();
+            var room = new Common.Room();
             btnregionname.Text = room.GetRoomNameByDevice(device);
         }
-
-        public static List<Common.Room> GetRoomList(string floorId)
-        {
-            return Common.Room.Lists.FindAll((obj) => obj.FloorId == floorId);
-
-        }
-
-        #region  ----鑾峰彇闂ㄩ攣
-        public static List<DoorLock> ReadDoorLockIfon(string doorlockMac)
-        {
-            List<DoorLock> list = new List<DoorLock>();
-            string url = "https://global.hdlcontrol.com/HangZhouHdlCloudApi/App/GetHomePager";//瀛愯处鍙峰拰涓昏处鍙峰彲鑳介摼鎺ヤ笉鍚�
-            System.Net.WebClient webClient = new System.Net.WebClient();
-            System.Collections.Specialized.NameValueCollection postValues = new System.Collections.Specialized.NameValueCollection();
-            postValues.Add("RequestVersion", CommonPage.RequestVersion);
-            postValues.Add("ReqDto.LoginAccessToken", Config.Instance.Token);
-            System.Threading.Tasks.Task.Run(() =>
-           {
-               try
-               {
-
-                   byte[] responseArray = webClient.UploadValues(url, postValues);
-                   var str = System.Text.Encoding.UTF8.GetString(responseArray);
-                   var jObject = JObject.Parse(str);
-                   if (jObject == null || jObject["StateCode"].ToString() != "Success")
-                   {
-                       return;
-                   }
-                   var pageData = jObject["ResponseData"]["PageData"].ToString();
-                   var datalist = JArray.Parse(pageData);
-                   for (int i = 0; i < datalist.Count; i++)
-                   {
-                       var data = JObject.Parse(datalist[i].ToString());
-                       if (Config.Instance.HomeId == data["Id"].ToString())
-                       {
-                           Residential residential = new Residential();
-
-                           if (Convert.ToBoolean(data["IsOthreShare"].ToString()))
-                           {
-                                //鍒嗕韩鑰匢D
-                                residential.Id = data["Id"].ToString();
-                                //鏄惁鏄垎浜处鍙穂true(鏄垎浜�);false;(涓嶆槸鍒嗕韩)];
-                                residential.IsOthreShare = Convert.ToBoolean(data["IsOthreShare"].ToString());
-                                //鍒嗕韩鑰呬綇瀹匢D
-                                residential.MainUserDistributedMark = data["MainUserDistributedMark"].ToString();
-                               residential.IsOtherAccountCtrl = true;
-                               residential.doorlockmac = doorlockMac;
-                               list = ReadToken(residential);
-                           }
-                           else
-                           {
-                               residential.Url = "https://global.hdlcontrol.com/HangZhouHdlCloudApi/DoorLock/GetDoorLockPager";
-                               residential.Token = Config.Instance.Token;
-                               residential.Id = Config.Instance.HomeId;
-                               residential.IsOtherAccountCtrl = false;
-                               residential.doorlockmac = doorlockMac;
-                               list = ReadDoorLock(residential);
-
-                           }
-                       }
-
-                   }
-               }
-               catch { }
-           });
-            var datetime = DateTime.Now;
-            while ((DateTime.Now - datetime).TotalMilliseconds < 3*1000)
-            {
-                if (list.Count != 0)
-                {
-                    break;
-                }
-            }
-            return list;
-
-        }
-
-        public static List<DoorLock> ReadToken(Residential residential)
-        {
-            List<DoorLock> list = new List<DoorLock>();
-            string url = "https://global.hdlcontrol.com/HangZhouHdlCloudApi/App/GetSharedHomeApiControl";
-            System.Net.WebClient webClient = new System.Net.WebClient();
-            System.Collections.Specialized.NameValueCollection postValues = new System.Collections.Specialized.NameValueCollection();
-            postValues.Add("RequestVersion", CommonPage.RequestVersion);
-            postValues.Add("LoginAccessToken", Config.Instance.Token);
-            postValues.Add("MainAccountId", residential.MainUserDistributedMark);
-            postValues.Add("SharedHid", residential.Id);
-            System.Threading.Tasks.Task.Run(() =>
-            {
-                try
-                {
-                    byte[] responseArray = webClient.UploadValues(url, postValues);
-                    var str = System.Text.Encoding.UTF8.GetString(responseArray);
-                    var jObject = JObject.Parse(str);
-                    if (jObject == null || jObject["StateCode"].ToString() != "Success")
-                    {
-                        return;
-                    }
-                    var RequestBaseUrl = jObject["ResponseData"]["RequestBaseUrl"].ToString();
-                    var RequestToken = jObject["ResponseData"]["RequestToken"].ToString();
-                    Residential lockifon = new Residential();
-                    lockifon.Url = RequestBaseUrl + "/App/GetDoorLockPager";
-                    lockifon.Token = RequestToken;
-                    lockifon.Id = Config.Instance.HomeId;
-                    lockifon.IsOtherAccountCtrl = true;
-                    lockifon.doorlockmac = residential.doorlockmac;
-                    list = ReadDoorLock(lockifon);
-
-                }
-                catch { }
-            });
-            var datetime = DateTime.Now;
-            while ((DateTime.Now - datetime).TotalMilliseconds < 3 * 1000)
-            {
-                if (list.Count != 0)
-                {
-                    break;
-                }
-            }
-            return list;
-        }
-
-        public static List<DoorLock> ReadDoorLock(Residential lockifon)
-        {
-            List<DoorLock> list = new List<DoorLock>();
-            System.Net.WebClient webClient = new System.Net.WebClient(); 
-            System.Collections.Specialized.NameValueCollection postValues = new System.Collections.Specialized.NameValueCollection();
-            postValues.Add("RequestVersion", CommonPage.RequestVersion);
-            postValues.Add("LoginAccessToken", lockifon.Token);
-            postValues.Add("HomeId", lockifon.Id);
-            postValues.Add("DoorLockId", lockifon.doorlockmac);//闂ㄩ攣Mac19091
-            postValues.Add("IsOtherAccountCtrl", lockifon.IsOtherAccountCtrl.ToString());
-            System.Threading.Tasks.Task.Run(() =>
-            {
-                try
-                {
-
-                    byte[] responseArray = webClient.UploadValues(lockifon.Url, postValues);
-                    var str = System.Text.Encoding.UTF8.GetString(responseArray);
-                    var jObject = JObject.Parse(str);
-                    if (jObject == null || jObject["StateCode"].ToString() != "Success")
-                    {
-                        return;
-                    }
-                    var pageData = jObject["ResponseData"]["PageData"].ToString();
-                    var datalist = JArray.Parse(pageData);
-                    for (int i = 0; i < datalist.Count; i++)
-                    {
-                        var data = JObject.Parse(datalist[i].ToString());
-                        DoorLock doorLock = new DoorLock();
-                        doorLock.DoorLockLocalUserId = data["DoorLockLocalUserId"].ToString();
-                        doorLock.OpenLockMode = int.Parse(data["OpenLockMode"].ToString());
-                        doorLock.CloudAccountId = data["CloudAccountId"].ToString();
-                        list.Add(doorLock);
-                    }
-
-                }
-                catch
-                {
-
-                }
-
-            });
-            var datetime = DateTime.Now;
-            while ((DateTime.Now - datetime).TotalMilliseconds < 3 * 1000)
-            {
-                if (list.Count != 0)
-                {
-                    break;
-                }
-            }
-            return list;
-        }
-
-        public class Residential
-        {
-            public string Id = string.Empty;
-            public bool IsOthreShare;
-            public string MainUserDistributedMark = string.Empty;
-            public string Url = string.Empty;
-            public string Token = string.Empty;
-            public bool IsOtherAccountCtrl;
-            public string doorlockmac;
-        }
-
-        public class DoorLock
-        {
-            public string DoorLockLocalUserId = string.Empty;
-            public int OpenLockMode;
-            public string CloudAccountId = string.Empty;
-            /// <summary>
-            /// 韬唤+瑙﹀彂婧�(0鎸夐敭/3鍗�/15鎸囩汗)
-            /// </summary>
-            public string UserIdMode
-            {
-                get
-                {
-                    return DoorLockLocalUserId + "_" + OpenLockMode.ToString();
-                }
-            }
-        }
-
-        public class MembershipIfon
-        {
-            public string MembershipId = string.Empty;
-            public List<string> UserIdMode=new List<string>();
-            public string MembershipName = string.Empty;
-        }
-
-        public static List<MembershipIfon> UserList = new List<MembershipIfon>();
-
-        
-        #endregion
     }
 }

--
Gitblit v1.8.0