From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 17 十二月 2020 09:07:13 +0800
Subject: [PATCH] 新云端Ver1.3

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionAddTargetsForm.cs |  199 +++++++++++++++++++++++++------------------------
 1 files changed, 100 insertions(+), 99 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionAddTargetsForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionAddTargetsForm.cs
index 7b10608..95e534d 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionAddTargetsForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionAddTargetsForm.cs
@@ -14,17 +14,10 @@
         /// </summary>
         /// <param name="device"></param>
         /// <param name="deviceBindType">0:鍦烘櫙  1:寮�鍏�  2:鎻掑骇  3:鐏厜  4:閬槼 5:绌鸿皟 6:鏂伴</param>
-        public PanelSimpleMutilfunctionAddTargetsForm(string deviceMac, int deviceBindType)
+        public PanelSimpleMutilfunctionAddTargetsForm(Panel controlDev, int deviceBindType)
         {
-            curControlDev = new Panel();
-            var dev = Common.LocalDevice.Current.GetDevice(deviceMac, 62);//绠�绾﹂潰鏉块殢渚夸竴涓洖璺潵鑾峰彇璁惧
-            if (dev != null)
-            {
-                curControlDev.CurrentGateWayId = dev.CurrentGateWayId;
-            }
-            curControlDev.Type = DeviceType.OnOffSwitch;
-            curControlDev.DeviceAddr = deviceMac;
-            curBindType = deviceBindType;
+            this.curControlDev = controlDev;
+            this.curBindType = deviceBindType;
         }
         #endregion
 
@@ -146,6 +139,11 @@
             //棣栨鍒濆鍖栨暟鎹�
             CommonPage.Loading.Start("");
             InitData();
+
+            //澶囨敞寮圭獥鎻愮ず
+            string msg = Language.StringByID(R.MyInternationalizationString.BindRemarkTip1).Replace("{0}", "\r\n");
+            var alert = new Shared.Phone.ShowMsgControl(ShowMsgType.Confirm, msg, Language.StringByID(R.MyInternationalizationString.Iknown));
+            alert.Show();
         }
 
         /// <summary>
@@ -242,8 +240,8 @@
 
             btnFinifh = new Button()
             {
-                Width = Application.GetRealWidth(907),
-                Height = Application.GetRealHeight(127),
+                Width = Application.GetRealWidth(907),
+                Height = Application.GetRealHeight(127),
                 Y = Application.GetRealHeight(49 + 35),
                 Gravity = Gravity.CenterHorizontal,
                 Radius = (uint)Application.GetRealHeight(127) / 2,
@@ -512,7 +510,7 @@
                     X = devicePic.Right + Application.GetRealWidth(20),
                     TextAlignment = TextAlignment.CenterLeft,
                     TextSize = 15,
-                    Text = Common.LocalDevice.Current.GetDeviceEpointName(device),
+                    Text = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device),
                 };
                 rowLayout.AddChidren(btnBindName);
 
@@ -541,13 +539,13 @@
                 {
                     line2.Visible = false;
                 }
-                if (Common.LocalDevice.Current.CheckDeviceIsOnline(device) == true)
-                {
-                    btnBindName.TextColor = Shared.Common.ZigbeeColor.Current.TextBlack;
-                }
-                else
-                {
-                    btnBindName.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
+                if (HdlDeviceCommonLogic.Current.CheckDeviceIsOnline(device) == true)
+                {
+                    btnBindName.TextColor = Shared.Common.ZigbeeColor.Current.TextBlack;
+                }
+                else
+                {
+                    btnBindName.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
                 }
                 switch (curBindType)
                 {
@@ -607,6 +605,13 @@
 
                 EventHandler<MouseEventArgs> hander = (sender, e) =>
                 {
+                    //鐩爣澶囨敞澶勭悊
+                    var localName = System.Text.Encoding.UTF8.GetBytes(HdlDeviceCommonLogic.Current.GetDeviceEpointName(device));
+                    if (localName.Length > 20)
+                    {
+                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindRemarkTip2), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                        return;
+                    }
                     btnChoose.IsSelected = !btnChoose.IsSelected;
                     if (curBindType != 6)
                     {
@@ -838,6 +843,18 @@
 
                 EventHandler<MouseEventArgs> hander = (sender, e) =>
                 {
+
+                    //鐩爣澶囨敞澶勭悊
+                    if (!string.IsNullOrEmpty(scene.Name))
+                    {
+                        var localName = System.Text.Encoding.UTF8.GetBytes(scene.Name);
+                        if (localName.Length > 20)
+                        {
+                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindRemarkTip2), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                            return;
+                        }
+                    }
+
                     btnChoose.IsSelected = !btnChoose.IsSelected;
 
                     if (curSupportBindEpointList.Count == 0)
@@ -904,7 +921,7 @@
                     supportRoomList = BindInfo.GetSupportRoomList();
 
                     //鑾峰彇闈㈡澘宸茬粡缁戝畾鐨勫尮閰嶇被鍨嬬殑鍒楄〃
-                    curBindTypeList = MutilfunctionPanelMethod.GetMatchBindList(curBindType);
+                    curBindTypeList = MutilfunctionPanelMethod.GetMatchBindList(curControlDev, curBindType);
 
                     if (curBindType == 0)
                     {
@@ -920,7 +937,7 @@
                         undistributeDevList = MutilfunctionPanelMethod.GetUndistributeDeviceList(undistributeDevList, curBindTypeList, curBindType);
                     }
                     //鑾峰彇褰撳墠鏀寔鐨勭鐐圭粦瀹氳〃
-                    curSupportBindEpointList = MutilfunctionPanelMethod.GetMatchEpointList(curBindType);
+                    curSupportBindEpointList = MutilfunctionPanelMethod.GetMatchEpointList(curControlDev, curBindType);
                     if (curBindType == 3)
                     {
                         foreach (var ep in curSupportBindEpointList)
@@ -1026,22 +1043,20 @@
                         for (int i = 0; i < targetScList.Count; i++)
                         {
                             //缁戝畾鏂扮殑鏁版嵁
-                            var addBindeDev = new AddBindData();
-                            addBindeDev.DeviceAddr = curControlDev.DeviceAddr;
+                            var addSingleBindData = new AddSingleBindData();
+                            addSingleBindData.DeviceAddr = curControlDev.DeviceAddr;
                             for (int j = 0; j < curSupportBindEpointList.Count; j++)
                             {
                                 curSendEpointList.Add(curSupportBindEpointList[0]);
-                                addBindeDev.Epoint = curControlDev.DeviceEpoint = curSupportBindEpointList[0];
+                                addSingleBindData.Epoint = curControlDev.DeviceEpoint = curSupportBindEpointList[0];
                                 break;
                             }
                             var de = targetScList[i];
-                            var addBindInfo = new AddBindListObj();
-                            addBindInfo.BindType = 1;
-                            addBindInfo.BindCluster = 6;
-                            addBindInfo.BindScenesId = de.Id;
-                            addBindeDev.BindList.Add(addBindInfo);
+                            addSingleBindData.BindType = 1;
+                            addSingleBindData.BindClusterList.Add(6);
+                            addSingleBindData.BindScenesId = de.Id;
 
-                            var resT = AddDeviceBind(addBindeDev, targetSendCount, ref targetRecCount);
+                            var resT = AddDeviceBind(addSingleBindData, targetSendCount, ref targetRecCount);
                             if (!resT)
                             {
                                 break;
@@ -1070,8 +1085,8 @@
                         foreach (var de in targetList)
                         {
                             //缁戝畾鏂扮殑鏁版嵁
-                            var addBindeDev = new AddBindData();
-                            addBindeDev.DeviceAddr = curControlDev.DeviceAddr;
+                            var addSingleBindData = new AddSingleBindData();
+                            addSingleBindData.DeviceAddr = curControlDev.DeviceAddr;
 
                             if (curBindType == 3)
                             {
@@ -1080,7 +1095,7 @@
                                     for (int j = 0; j < curSupportDimmerEpointList.Count; j++)
                                     {
                                         curSendEpointList.Add(curSupportDimmerEpointList[0]);
-                                        addBindeDev.Epoint = curControlDev.DeviceEpoint = curSupportDimmerEpointList[0];
+                                        addSingleBindData.Epoint = curControlDev.DeviceEpoint = curSupportDimmerEpointList[0];
                                         break;
                                     }
                                 }
@@ -1090,7 +1105,7 @@
                                     for (int j = 0; j < curSupportLightEpointList.Count; j++)
                                     {
                                         curSendEpointList.Add(curSupportLightEpointList[0]);
-                                        addBindeDev.Epoint = curControlDev.DeviceEpoint = curSupportLightEpointList[0];
+                                        addSingleBindData.Epoint = curControlDev.DeviceEpoint = curSupportLightEpointList[0];
                                         break;
                                     }
                                 }
@@ -1100,68 +1115,48 @@
                                 for (int j = 0; j < curSupportBindEpointList.Count; j++)
                                 {
                                     curSendEpointList.Add(curSupportBindEpointList[0]);
-                                    addBindeDev.Epoint = curControlDev.DeviceEpoint = curSupportBindEpointList[0];
+                                    addSingleBindData.Epoint = curControlDev.DeviceEpoint = curSupportBindEpointList[0];
                                     break;
                                 }
                             }
 
-                            var addBindInfo = new AddBindListObj();
-                            addBindInfo.BindType = 0;
-                            addBindInfo.BindMacAddr = de.DeviceAddr;
-                            addBindInfo.BindEpoint = de.DeviceEpoint;
+                            addSingleBindData.BindType = 0;
+                            addSingleBindData.BindMacAddr = de.DeviceAddr;
+                            addSingleBindData.BindEpoint = de.DeviceEpoint;
                             switch (curBindType)
                             {
                                 case 0:
-                                    addBindInfo.BindCluster = 6;
-                                    break;
                                 case 1:
-                                    addBindInfo.BindCluster = 6;
-                                    break;
                                 case 2:
-                                    addBindInfo.BindCluster = 6;
+                                    addSingleBindData.BindClusterList.Add(6);
                                     break;
                                 case 3:
-                                    addBindInfo.BindCluster = 6;
-                                    break;
-                                case 4:
-                                    addBindInfo.BindCluster = 258;
-                                    break;
-                                case 5:
-                                    addBindInfo.BindCluster = 513;
-                                    break;
-                                case 6:
-                                    addBindInfo.BindCluster = 514;
-                                    break;
-                            }
-                            addBindeDev.BindList.Add(addBindInfo);
-
-                            //閮ㄥ垎鐩爣闇�瑕佷簩娆$粦瀹氱浜岀鍔熻兘
-                            var addBindInfo2 = new AddBindListObj();
-                            addBindInfo2.BindType = 0;
-                            addBindInfo2.BindMacAddr = de.DeviceAddr;
-                            addBindInfo2.BindEpoint = de.DeviceEpoint;
-                            switch (curBindType)
-                            {
-                                case 3:
-                                    var device = LocalDevice.Current.GetDevice(de.DeviceAddr, de.DeviceEpoint);
+                                    addSingleBindData.BindClusterList.Add(6);
+                                    var device = HdlDeviceCommonLogic.Current.GetDevice(de.DeviceAddr, de.DeviceEpoint);
                                     if (device != null)
                                     {
                                         if (device.Type == DeviceType.DimmableLight)
                                         {
                                             //鐏厜涓鸿皟鍏夋椂闇�瑕佺粦瀹�6锛�8
-                                            addBindInfo2.BindCluster = 8;
-                                            addBindeDev.BindList.Add(addBindInfo2);
+                                            addSingleBindData.BindClusterList.Add(8);
                                         }
                                     }
                                     break;
+                                case 4:
+                                    addSingleBindData.BindClusterList.Add(258);
+                                    break;
                                 case 5:
                                     //瑕佺粦瀹氱┖璋冿細闇�瑕佺粦瀹�513锛�514
-                                    addBindInfo2.BindCluster = 514;
-                                    addBindeDev.BindList.Add(addBindInfo2);
+                                    addSingleBindData.BindClusterList.Add(513);
+                                    addSingleBindData.BindClusterList.Add(514);
+                                    break;
+                                case 6:
+                                    addSingleBindData.BindClusterList.Add(514);
                                     break;
                             }
 
-                            var resT = AddDeviceBind(addBindeDev, targetSendCount, ref targetRecCount);
+
+                            var resT = AddDeviceBind(addSingleBindData, targetSendCount, ref targetRecCount);
                             if (!resT)
                             {
                                 break;
@@ -1185,53 +1180,53 @@
         /// <summary>
         /// AddDeviceBind
         /// </summary>
-        /// <param name="addBindeDev"></param>
+        /// <param name="addSingleBindData"></param>
         /// <param name="targetSendCount"></param>
         /// <param name="targetRecCount"></param>
         /// <returns></returns>
-        private bool AddDeviceBind(AddBindData addBindeDev, int targetSendCount, ref int targetRecCount)
+        private bool AddDeviceBind(AddSingleBindData addSingleBindData, int targetSendCount, ref int targetRecCount)
         {
             var addSuccess = false;
-            var dev = HdlDeviceBindLogic.Current.AddDeviceBindAsync(addBindeDev);
-            if (dev != null && dev.addedDeviceBindResponseData != null)
+            var dev = HdlDeviceBindLogic.Current.AddDeviceSingleBindAsync(addSingleBindData);
+            if (dev != null && dev.addedDeviceSingleBindResponseData != null)
             {
                 addSuccess = true;
                 targetRecCount++;
-                if (dev.addedDeviceBindResponseData.Result == 0)
+                if (dev.addedDeviceSingleBindResponseData.Result == 0)
                 {
                     var countTotal = targetRecCount;
-
                     var bList = new List<BindListAllInfo>();
-                    foreach (var devB in dev.addedDeviceBindResponseData.BindList)
+                    foreach (var cluster in dev.addedDeviceSingleBindResponseData.BindClusterList)
                     {
                         var curD = new BindListAllInfo();
                         curD.KeyMacAddr = curControlDev.DeviceAddr;
                         curD.KeyEpoint = curControlDev.DeviceEpoint;
-                        curD.BindCluster = devB.BindCluster;
-                        curD.BindScenesId = devB.BindScenesId;
-                        curD.BindMacAddr = devB.BindMacAddr;
-                        curD.BindEpoint = devB.BindEpoint;
-                        curD.ESName = devB.ESName;
-                        curD.BindType = devB.BindType;
+                        curD.BindCluster = cluster;
+                        curD.BindScenesId = dev.addedDeviceSingleBindResponseData.BindScenesId;
+                        curD.BindMacAddr = dev.addedDeviceSingleBindResponseData.BindMacAddr;
+                        curD.BindEpoint = dev.addedDeviceSingleBindResponseData.BindEpoint;
+                        curD.ESName = dev.addedDeviceSingleBindResponseData.ESName;
+                        curD.BindType = dev.addedDeviceSingleBindResponseData.BindType;
                         bList.Add(curD);
                     }
-                    if (MutilfunctionPanelMethod.bindTargetsFromMutilfunctionPanelList.ContainsKey(curControlDev.DeviceAddr + curControlDev.DeviceEpoint))
+
+                    if (curControlDev.bindTargetsFromMutilfunctionPanelList.ContainsKey(curControlDev.DeviceAddr + curControlDev.DeviceEpoint))
                     {
-                        MutilfunctionPanelMethod.bindTargetsFromMutilfunctionPanelList[curControlDev.DeviceAddr + curControlDev.DeviceEpoint] = bList;
+                        curControlDev.bindTargetsFromMutilfunctionPanelList[curControlDev.DeviceAddr + curControlDev.DeviceEpoint] = bList;
                     }
                     else
                     {
-                        MutilfunctionPanelMethod.bindTargetsFromMutilfunctionPanelList.Add(curControlDev.DeviceAddr + curControlDev.DeviceEpoint, bList);
+                        curControlDev.bindTargetsFromMutilfunctionPanelList.Add(curControlDev.DeviceAddr + curControlDev.DeviceEpoint, bList);
                     }
 
                     if (curBindType == 3)
                     {
-                        if (addBindeDev.Epoint >= 22 && addBindeDev.Epoint <= 28)
+                        if (addSingleBindData.Epoint >= 22 && addSingleBindData.Epoint <= 28)
                         {
                             curSupportDimmerEpointList.RemoveAt(0);
 
                         }
-                        if (addBindeDev.Epoint >= 52 && addBindeDev.Epoint <= 61)
+                        if (addSingleBindData.Epoint >= 52 && addSingleBindData.Epoint <= 61)
                         {
                             curSupportLightEpointList.RemoveAt(0);
                         }
@@ -1256,7 +1251,7 @@
                         }
                     });
                 }
-                else if (dev.addedDeviceBindResponseData.Result == 1)
+                else if (dev.addedDeviceSingleBindResponseData.Result == 1)
                 {
                     Application.RunOnMainThread(() =>
                     {
@@ -1267,7 +1262,7 @@
                         new Tip()
                         {
                             MaxWidth = 150,
-                            Text = Language.StringByID(R.MyInternationalizationString.BindFailed) + "(" + "5001_1" + ")",
+                            Text = Language.StringByID(R.MyInternationalizationString.BindFailed) + "(" + "5020_1" + ")",
                             Direction = AMPopTipDirection.Up,
                             CloseTime = 1
                         }.Show(btnFinifh);
@@ -1284,7 +1279,7 @@
                         new Tip()
                         {
                             MaxWidth = 150,
-                            Text = Language.StringByID(R.MyInternationalizationString.BindUnknownError) + "(" + "5001_2" + ")",
+                            Text = Language.StringByID(R.MyInternationalizationString.BindUnknownError) + "(" + "5020_2" + ")",
                             Direction = AMPopTipDirection.Up,
                             CloseTime = 1
                         }.Show(btnFinifh);
@@ -1298,6 +1293,13 @@
                     btnFinifh.Enable = true;
                     btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                     RefreshRoomList();
+                    new Tip()
+                    {
+                        MaxWidth = 150,
+                        Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "5020" + ")",
+                        Direction = AMPopTipDirection.Up,
+                        CloseTime = 1
+                    }.Show(btnFinifh);
                     CommonPage.Loading.Hide();
                     GetEpointData();
                 });
@@ -1337,7 +1339,6 @@
                                 curD.BindScenesId = dev.BindScenesId;
                                 curD.BindMacAddr = dev.BindMacAddr;
                                 curD.BindEpoint = dev.BindEpoint;
-                                curD.ESName = dev.ESName;
                                 curD.BindType = dev.BindType;
                                 bList.Add(curD);
 
@@ -1365,17 +1366,17 @@
                             }
 
                             //鏇存柊bindTargetsFromMutilfunctionPanelList
-                            if (MutilfunctionPanelMethod.bindTargetsFromMutilfunctionPanelList.ContainsKey(curControlDev.DeviceAddr + curControlDev.DeviceEpoint))
+                            if (curControlDev.bindTargetsFromMutilfunctionPanelList.ContainsKey(curControlDev.DeviceAddr + curControlDev.DeviceEpoint))
                             {
-                                MutilfunctionPanelMethod.bindTargetsFromMutilfunctionPanelList[curControlDev.DeviceAddr + curControlDev.DeviceEpoint] = bList;
+                                curControlDev.bindTargetsFromMutilfunctionPanelList[curControlDev.DeviceAddr + curControlDev.DeviceEpoint] = bList;
                             }
                             else
                             {
-                                MutilfunctionPanelMethod.bindTargetsFromMutilfunctionPanelList.Add(curControlDev.DeviceAddr + curControlDev.DeviceEpoint, bList);
+                                curControlDev.bindTargetsFromMutilfunctionPanelList.Add(curControlDev.DeviceAddr + curControlDev.DeviceEpoint, bList);
                             }
 
                             //鏇存柊褰撳墠鏀寔鐨勭鐐圭粦瀹氳〃
-                            curSupportBindEpointList = MutilfunctionPanelMethod.GetMatchEpointList(curBindType);
+                            curSupportBindEpointList = MutilfunctionPanelMethod.GetMatchEpointList(curControlDev, curBindType);
                             if (curBindType == 3)
                             {
                                 foreach (var ep in curSupportBindEpointList)

--
Gitblit v1.8.0