From f37f3a667bd81f78736e381717b82f632cb1fdeb Mon Sep 17 00:00:00 2001
From: lss <316519258@qq.com>
Date: 星期三, 10 六月 2020 15:52:57 +0800
Subject: [PATCH] test

---
 ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs |  126 +++++++++++++++++++++++------------------
 1 files changed, 70 insertions(+), 56 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs
index 19fbe70..c242403 100644
--- a/ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs
@@ -1,6 +1,9 @@
 锘縰sing System;
 using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
 using Shared.Common;
+using Shared.Phone.UserCenter.SmartSound.Util;
 using ZigBee.Device;
 
 namespace Shared.Phone.UserCenter.SmartSound.Forms
@@ -11,7 +14,8 @@
         /// 涓存椂鏁版嵁
         /// </summary>
         private List<SmartSound.Layer> TempDatas = new List<SmartSound.Layer>();
-        
+
+        private SmartSoundInfo.SoundInfo mSoundInfo;
         /// <summary>
         /// 鍒楄〃鎺т欢
         /// </summary>
@@ -21,9 +25,9 @@
         public int CurrentIndex = 0;
         private BottomClickButton bottomClickButton = null;
 
-        public SmartSoundControlContentForm()            
+        public SmartSoundControlContentForm(SmartSoundInfo.SoundInfo soundInfo)            
         {
-           //
+            this.mSoundInfo = soundInfo;
         }
 
         /// <summary>
@@ -41,15 +45,14 @@
             this.bodyFrameLayout.AddChidren(contentLayout);
             
             IniAllDataView();
-
         }
-        
+
         #region 鍔犺浇鏈湴鎵�鏈夋暟鎹紝鐢熸垚渚涚敤鎴烽�夋嫨鎴块棿鐨勭晫闈�
 
         private void IniAllDataView()
         {
             contentLayout.RemoveAll();
-            
+
             var pullLayout = new MyPullControl(this, SmartSound.LocaData);
             contentLayout.AddChidren(pullLayout);
             pullLayout.InitControl();
@@ -61,13 +64,27 @@
             bottomClickButton.Text = "纭";
             bottomClickButton.ButtonClickEvent += (sender, e) =>
             {
-                //淇濆瓨鏁版嵁
-                if (SmartSound.CurretnData == null)
-                    SmartSound.CurretnData = new List<SmartSound.Layer>();
+                HdlThreadLogic.Current.RunThread(async () =>
+                {
+                    this.ShowProgressBar();
+                    //淇濆瓨鏁版嵁
+                    if (SmartSound.getInstantiate().LayerList == null)
+                        SmartSound.getInstantiate().LayerList = new List<SmartSound.Layer>();
 
-                SmartSound.CurretnData.Clear();
-                SmartSound.CurretnData = CollateData();
-                this.CloseForm();
+                    SmartSound.getInstantiate().LayerList.Clear();
+                    SmartSound.getInstantiate().LayerList = CollateData();
+                    SmartSound.getInstantiate().TokenID = mSoundInfo.Id;
+                    SmartSound.getInstantiate().UserID = mSoundInfo.UserID;
+
+                    //涓婁紶鏁版嵁鍒版湇鍔″櫒
+                    string str = await postBatchEdit();
+                    CloseProgressBar();
+
+                    HdlThreadLogic.Current.RunMainInThread(() =>
+                    {
+                        CloseForm();
+                    });
+                });
             };
 
             bottomClickButton.Visible = false;
@@ -76,7 +93,7 @@
         private void LoadAllRoomListView()
         {
             try
-            {
+            {                
 
                 if (SmartSound.LocaData == null || SmartSound.LocaData.Count < 1)
                     return;
@@ -84,13 +101,11 @@
                 // 鍔犺浇褰撳墠妤煎眰鐨勬墍鏈夋埧闂� ListView
                 SmartSound.Layer layer = SmartSound.LocaData[CurrentIndex];
                 if (listView == null)
-                {
-                    
+                {                    
                     listView = new VerticalListControl();
                     contentLayout.AddChidren(listView);
                     listView.Y = Application.GetRealHeight(173);
-                    listView.Height = bodyFrameLayout.Height- Application.GetRealHeight(173);
-                    
+                    listView.Height = bodyFrameLayout.Height- Application.GetRealHeight(173);                    
                 }
 
                 listView.RemoveAll();
@@ -101,9 +116,25 @@
                     listView.AddChidren(roomRowLayout);
                     roomRowLayout.InitControl();
                 }
-                
+
+                //澶氫釜鐨勬椂鍊欙紝纭鎸夐挳浼氶伄鎸′竴閮ㄥ垎銆傝拷鍔犱笁涓┖鐨勮鐨勯珮搴︼紝鎶婂畠椤朵笂鏉�
+                if (listView.ChildrenCount > 5)
+                {
+                    TextView textView = new TextView();
+                    textView.Height = Application.GetRealHeight(127 * 3);
+                    listView.AddChidren(textView);
+                }
             }
             catch { }
+        }
+
+        private async Task<string> postBatchEdit()
+        {
+            // The remote server returned an error: (400) Bad Request.
+            string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/BatchEdit";
+            string json = Newtonsoft.Json.JsonConvert.SerializeObject(SmartSound.getInstantiate());
+            string response_str = await MyHttpWebResponse.PostWebRequest(url, json, Encoding.UTF8);
+            return response_str;
         }
 
         #endregion
@@ -113,36 +144,6 @@
         /// </summary>
         private void IniFloorData()
         {
-            #region//1.浠庢湇鍔″櫒鑾峰彇鐨勬暟鎹紝json鍙嶅簭鍒楀寲寰楁潵
-            //2.鐐瑰嚮"+"灏嗙綉鍏崇殑鏁版嵁杞崲涓� 鏅鸿兘闊崇浣跨敤鐨勬暟鎹�
-            /*{
-
-                Dictionary<string, string> ss = Config.Instance.Home.FloorDics;//妤煎眰鍒楄〃
-                string currentFloor = Config.Instance.Home.CurrentFloorId;//褰撳墠妤煎眰鐨勯敭
-
-                var listRoom = HdlRoomLogic.Current.GetFloorSortRoom("妤煎眰鐨勪富閿�");//鑾峰彇褰撳墠妤煎眰鐨勬墍鏈夋埧闂�
-                var room = listRoom[0];
-                for (int i=0;i<room.ListDevice.Count;i++)
-                {//璁惧鏁版嵁
-                    var device = LocalDevice.Current.GetDevice(room.ListDevice[i]);
-                    var myType = LocalDevice.Current.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice>() { device });                                      
-
-                    if (myType.BeloneType == DeviceBeloneType.A鐏厜)
-                    {
-                        //杩欓噷闈㈢殑灏辨槸鐏厜浜�
-                        var light = device;
-                        // light.DeviceAddr;  璁惧鐨勫湴鍧�
-                        // light.DeviceEpoint;//璁惧鐨勭鍙�
-                    }
-                }
-
-                for (int i = 0; i < room.ListSceneId.Count; i++)
-                {   //鍦烘櫙鏁版嵁
-                    var device = HdlSceneLogic.Current.GetSceneUIBySceneId(room.ListSceneId[i]);
-                    // device.Id;鍦烘櫙 id
-                }
-            }*/
-            #endregion
 
             if (SmartSound.LocaData == null)
                 SmartSound.LocaData = new List<SmartSound.Layer>();
@@ -156,7 +157,7 @@
             {
                 //娌℃湁妤煎眰,妯℃嫙涓�涓�
                 SmartSound.Layer layer = new SmartSound.Layer();
-                layer.LayerID = "0000";
+                layer.LayerID = DateTime.Now.ToString("yyyyMMddHHmmssms");
                 layer.LayerName = "涓�妤�";
                 layer.RoomList.Clear();
                 SmartSound.LocaData.Add(layer);
@@ -206,15 +207,17 @@
                                 continue;
 
                             SmartSound.Device smartDevice = new SmartSound.Device();
-                            smartDevice.Id = device.DeviceID.ToString();//璁惧 Id
+                            //smartDevice.Id = device.DeviceID.ToString();//璁惧 Id
                             smartDevice.DeviceAddress = device.DeviceAddr;//璁惧 MAC
                             smartDevice.Epoint = device.DeviceEpoint;//璁惧绔彛
-                            smartDevice.ClusterID = 0;
+                            //smartDevice.ClusterID = 0;
                             smartDevice.DeviceName = device.DeviceName;//璁惧鍚嶇О
                             smartDevice.NicksName = "";
                             smartDevice.DeviceType = GetDeviceType(device);//璁惧绫诲瀷
                             smartDevice.GatewayID = device.CurrentGateWayId;//缃戝叧 Id
-                            smartDevice.RoomID = room.Id;//鎴块棿 Id
+                            //smartDevice.RoomID = room.Id;//鎴块棿 Id
+                            if (smartDevice.DeviceName == "" || smartDevice.DeviceName == string.Empty)
+                                continue;
 
                             smartRoom.DeviceList.Add(smartDevice);
 
@@ -227,15 +230,20 @@
                         for (int k = 0; k < sceneList.Count; k++)
                         {
                             SceneUI scene = sceneList[k];
+                            
                             if (scene == null) continue;
                             SmartSound.Scene smartScene = new SmartSound.Scene();
-                            smartScene.Id = scene.DeviceID.ToString();
+                            //smartScene.Id = scene.DeviceID.ToString();
                             smartScene.SceneName = scene.Name;
                             smartScene.SceneID = scene.Id;
                             smartScene.DelayTime = scene.DelayTime;
-                            smartScene.ClusterID = 0;
+                            //smartScene.ClusterID = 0;
                             smartScene.NicksName = "";
-                            smartScene.RoomID = room.Id;
+                            //smartScene.RoomID = room.Id;
+                            smartScene.GatewayID = ZbGateway.MainGateWay.CurrentGateWayId;
+
+                            if (smartScene.SceneName == "" || smartScene.SceneName == string.Empty)
+                                continue;
 
                             smartRoom.SceneList.Add(smartScene);
                         }
@@ -513,7 +521,13 @@
                 layout.ButtonClickEvent += (sender, e) =>
                 {
                     ShowPullList();
-                };                              
+                };
+
+                if (Layers.Count == 1)
+                {
+                    right_icon.Visible = false;
+                    layout.Visible = false;
+                }
                 
             }
 

--
Gitblit v1.8.0