From 9c16d3614d9b88c637f967518a329f239fcd3aaf Mon Sep 17 00:00:00 2001
From: lss <316519258@qq.com>
Date: 星期五, 12 六月 2020 09:22:04 +0800
Subject: [PATCH] 2020.06.12

---
 ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundListForm.cs |  171 +++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 112 insertions(+), 59 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundListForm.cs b/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundListForm.cs
old mode 100755
new mode 100644
index 54f2151..65cff1b
--- a/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundListForm.cs
+++ b/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundListForm.cs
@@ -130,17 +130,11 @@
         /// <returns></returns>
         private async Task getData()
         {
-            //SmartSoundInfo.Auth auth = new SmartSoundInfo.Auth();
-            //auth.HomeID = Common.Config.Instance.Home.Id;
-            //auth.UserID = Common.Config.Instance.Guid;
-            //auth.Platform = "";
             string url = string.Format("https://developer.hdlcontrol.com/zigbeespeakerservice/Auth?Platform&PageSetting.PageSize=100&PageSetting.PageIndex=1&UserID={0}&HomeID={1}",
                 Common.Config.Instance.Guid,Common.Config.Instance.Home.Id);
             
-            dataString = await MyHttpWebResponse.GetWebRequest(url);
-            
-            smartSoundInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<SmartSoundInfo>(dataString);
-            
+            dataString = await MyHttpWebResponse.GetWebRequest(url);            
+            smartSoundInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<SmartSoundInfo>(dataString);            
         }
 
         /// <summary>
@@ -150,8 +144,7 @@
         /// <param name="new_remark"></param>
         /// <returns></returns>
         private async Task<string> setRemark(SmartSoundInfo.SoundInfo soundInfo, string new_remark)
-        {
-            
+        {            
             if (soundInfo == null)
                 return "";
 
@@ -162,7 +155,7 @@
                 "\"UserID\":" + "\"" + soundInfo.UserID + "\"" + "," +
                 "\"HomeID\":" + "\"" + soundInfo.HomeID + "\"" + "}";
 
-            string response_str = await MyHttpWebResponse.PutWebRequest(url, json, Encoding.UTF8);
+            string response_str = MyHttpWebResponse.PutWebRequest(url, json, Encoding.UTF8);
             JObject jObject = JObject.Parse(response_str);
             
             return jObject["StateCode"].ToString();
@@ -178,55 +171,66 @@
 
             for (int i = 0; i < smartSoundInfo.ResponseData.Data.Count; i++)
             {
-                //
-                var smartSound = smartSoundInfo.ResponseData.Data[i];
-                var row = new SoundRowLayout();
-                listView.AddChidren(row);
-
-                if (smartSound.Platform == "Baidu")
+                try
                 {
-                    row.Account = "灏忓害锛�" + smartSound.UserName;
-                    row.ImagePath = "SmartSound/Xiaodu.png";
-                    row.Remark = smartSound.Remark;
+                    //
+                    var smartSound = smartSoundInfo.ResponseData.Data[i];
+                    var row = new SoundRowLayout();
+                    listView.AddChidren(row);
+
+                    if (smartSound.Platform == "Baidu")
+                    {
+                        string remark = "灏忓害";
+                        if (smartSound.Remark != null && smartSound.Remark.Trim() != "")
+                            remark += "(" + smartSound.Remark + ")";
+
+                        row.ImagePath = "SmartSound/Xiaodu.png";
+                        row.Remark = remark;
+                    }
+
+                    row.InitControl();
+                    row.btnDelect.AddTag("index", i);
+                    row.btnRename.AddTag("index", i);
+                    row.frameTable.AddTag("index", i);
+
+                    //閲嶅懡鍚�
+                    row.btnRename.ButtonClickEvent += (sender, e) =>
+                    {
+                        int index = (int)((NormalViewControl)sender).GetTagByKey("index");
+                        var smartSound1 = smartSoundInfo.ResponseData.Data[index];
+                        ShowRenameDialog(row, smartSound1);
+                    };
+
+                    // 瑙i櫎缁戝畾
+                    row.btnDelect.ButtonClickEvent += (sender, e) =>
+                    {
+                        int index = (int)(((NormalViewControl)sender).GetTagByKey("index"));
+                        var smartSound1 = smartSoundInfo.ResponseData.Data[index];
+                        ShowDelectDialog(smartSound1);
+                    };
+
+                    //璺宠浆鍒版帶鍒跺唴瀹圭晫闈�  FrameRowControl
+                    row.frameTable.ButtonClickEvent += (sender, e) =>
+                    {
+                        int index = (int)row.frameTable.GetTagByKey("index");
+                        if (SmartSound.getInstantiate().LayerList != null)
+                            SmartSound.getInstantiate().LayerList.Clear();
+
+                        var smartSoundControlForm = new SmartSoundControlForm(smartSoundInfo.ResponseData.Data[index]);
+                        smartSoundControlForm.AddForm();
+                    };
                 }
-
-                row.InitControl();
-                row.btnDelect.AddTag("index", i);
-                row.btnRename.AddTag("index", i);
-                row.frameTable.AddTag("index", i);
-
-                //閲嶅懡鍚�
-                row.btnRename.ButtonClickEvent += (sender, e) =>
+                catch (Exception e)
                 {
-                    int index = (int)((NormalViewControl)sender).GetTagByKey("index");
-                    var smartSound1 = smartSoundInfo.ResponseData.Data[index];
-                    ShowRenameDialog(row, smartSound1);
-                };
-
-                // 瑙i櫎缁戝畾
-                row.btnDelect.ButtonClickEvent += (sender, e) =>
-                {
-                    int index = (int)(((NormalViewControl)sender).GetTagByKey("index"));
-                    ShowDelectDialog(index);
-                };
-
-                //璺宠浆鍒版帶鍒跺唴瀹圭晫闈�  FrameRowControl
-                row.frameTable.ButtonClickEvent += (sender, e) =>
-                {
-                    int index = (int)row.frameTable.GetTagByKey("index");
-                    if (SmartSound.getInstantiate().LayerList != null)
-                        SmartSound.getInstantiate().LayerList.Clear();
-
-                    var smartSoundControlForm = new SmartSoundControlForm(smartSoundInfo.ResponseData.Data[index]);
-                    smartSoundControlForm.AddForm();
-                };
+                    this.ShowMassage(ShowMsgType.Tip, e.Message);
+                }
             }
         }
 
         /// <summary>
         /// 瑙i櫎缁戝畾寮圭獥
         /// </summary>
-        private void ShowDelectDialog(int index)
+        private void ShowDelectDialog(SmartSoundInfo.SoundInfo smartSound)
         {
             //鐢熸垚涓�涓脊绐楃敾闈�
             var dialogForm = new TextDialog("瑙i櫎缁戝畾闇�瑕佸埌绗笁鏂� APP 杩涜鎿嶄綔", "璺宠浆鑷冲皬搴�");
@@ -235,8 +239,36 @@
             //鎸変笅纭鎸夐挳
             dialogForm.ComfirmClickEvent += () =>
             {
-                //鐢婚潰鍏抽棴
-                dialogForm.CloseDialog();
+                HdlThreadLogic.Current.RunThread(() =>
+                {
+                    this.ShowProgressBar("鍒犻櫎鏈嶅姟鍣ㄨ褰�...");
+
+                    DelectSmartSound(smartSound);
+
+                    HdlThreadLogic.Current.RunMainInThread(() =>
+                    {
+                        //鐢婚潰鍏抽棴
+                        dialogForm.CloseDialog();
+                        bool bol = false;
+                        try
+                        {
+#if Android
+                            bol = HDLUtils.OpenAppWithPackageName("com.baidu.duer.superapp");
+#else
+                            HDLUtils.OpenApp("xiaoduapp://");
+#endif
+                        }
+                        catch (Exception e)
+                        {
+                            string error = e.Message;
+                            bol = false;
+                        }
+                        if (!bol)
+                        {
+                            this.ShowMassage(ShowMsgType.Tip, "鎵撳紑APP澶辫触");
+                        }
+                    });
+                });
             };
         }
         /// <summary>
@@ -264,7 +296,7 @@
                 if (str == "SUCCESS")
                 {
                     smartSound.Remark = remark;
-                    soundRowLayout.btnRemark.Text = textValue;
+                    soundRowLayout.btnRemark.Text = "灏忓害" + "(" + textValue + ")";
                 }
                 else
                 {
@@ -276,8 +308,29 @@
 
         #endregion
 
+        /// <summary>
+        /// 鍒犻櫎鏁版嵁
+        /// </summary>
+        /// <param name="soundInfo"></param>
+        /// <returns></returns>
+        private string DelectSmartSound(SmartSoundInfo.SoundInfo soundInfo)
+        {
+            if (soundInfo == null)
+                return "";
 
-        #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________
+            string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/Auth";
+            string json = "{" +
+                "\"AuthID\":" + "\"" + soundInfo.Id + "\"" + "," +
+                "\"UserID\":" + "\"" + soundInfo.UserID + "\"" + "," +
+                "\"HomeID\":" + "\"" + soundInfo.HomeID + "\"" + "}";
+
+            string response_str = MyHttpWebResponse.DeleteWebRequest(url, json, Encoding.UTF8);
+            JObject jObject = JObject.Parse(response_str);
+
+            return jObject["StateCode"].ToString();
+        }
+
+#region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________
 
         /// <summary>
         /// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠�
@@ -287,9 +340,9 @@
             return 1;
         }
 
-        #endregion
+#endregion
 
-        #region 鈻� 鍏抽棴鐣岄潰___________________________
+#region 鈻� 鍏抽棴鐣岄潰___________________________
 
         /// <summary>
         /// 鐢婚潰鍏抽棴
@@ -299,7 +352,7 @@
             base.CloseFormBefore();
         }
 
-        #endregion
-
+#endregion
+                
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0