From 5a5a2b696866f947b6025d26c3302e8ffef46435 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期一, 11 一月 2021 16:11:20 +0800
Subject: [PATCH] 2021-01-11 1.更新MQTT连接和本地搜索网关方法。2.子账号相关接口完善

---
 Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs |   79 ++++++++++++++++++++++++++++-----------
 1 files changed, 57 insertions(+), 22 deletions(-)

diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
index 44d93c1..a411967 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
@@ -125,7 +125,7 @@
                 X = btnTime.Right + Application.GetRealWidth (190),
                 Gravity = Gravity.CenterVertical,
                 Width = Application.GetRealWidth (75),
-                Height = Application.GetRealHeight (75),
+                Height = Application.GetRealWidth (75),
                 UnSelectedImagePath = "CrabtreeAdd/Timer.png",
             };
             timeView.AddChidren (btnTimeIcon);
@@ -570,13 +570,14 @@
 
                 if (btnMonday.IsSelected == false && btnFriday.IsSelected == false && btnThursday.IsSelected == false && btnSunday.IsSelected == false && btnTuesday.IsSelected == false && btnSaturday.IsSelected == false && btnWednesday.IsSelected == false) {
                     //new Alert ("", "璇烽�夋嫨鏃ユ湡!", "Close").Show ();
-                    new Alert ("", "Please setting date!", "Close").Show ();
+                    new Alert ("", "Please select the days.", "Close").Show ();
                     return;
                 }
-                timerTemp.TimerName = etName.Text.Trim ();
-                if (string.IsNullOrEmpty (timerTemp.TimerName)) {
+
+                string mTimerName = etName.Text.Trim ();
+                if (string.IsNullOrEmpty (mTimerName)) {
                     //new Alert ("", "璇峰~鍐欏畾鏃跺櫒鍚嶇О!", "Close").Show ();
-                    new Alert ("", "Please set name for the timer!", "Close").Show ();
+                    new Alert ("", "Please fill the tab Lable name.", "Close").Show ();
                     return;
                 }
                 //else if (listTimer.Find ((obj) => obj.TimerName == timerTemp.TimerName) != null && !isEdit) {//2020-01-09 缂栬緫鐨勬椂鍊欎篃鎻愮ず閲嶅鍚嶅瓧
@@ -592,7 +593,8 @@
                     return;
                 }
 
-                var mTimer = listTimer.Find ((obj) => obj.TimerName == timerTemp.TimerName);
+                //鍚嶅瓧閲嶅鍒ゆ柇闄愬埗
+                var mTimer = listTimer.Find ((obj) => obj.TimerName == mTimerName);
                 if (isEdit) {
                     if (mTimer != null && mTimer.Id != timerTemp.Id) {
                         new Alert ("", "The timer name already exists. Please change it before saving it.", "Close").Show ();
@@ -601,6 +603,22 @@
                 } else {
                     if (mTimer != null) {
                         new Alert ("", "The timer name already exists. Please change it before saving it.", "Close").Show ();
+                        return;
+                    }
+                }
+
+                //2020-02-10 鏃堕棿閲嶅鍒ゆ柇闄愬埗
+                string mExecutionTime = btnTimelbl.Text;
+                //timerTemp.ExecutionTime = btnTimelbl.Text;
+                var mTimerExecutionTime = listTimer.Find ((obj) => (obj.ExecutionTime == mExecutionTime));
+                if (isEdit) {
+                    if (mTimerExecutionTime != null && mTimerExecutionTime.Id != timerTemp.Id) {
+                        new Alert ("", "The timer time already exists. Please change it before saving it.", "Close").Show ();
+                        return;
+                    }
+                } else {
+                    if (mTimerExecutionTime != null) {
+                        new Alert ("", "The timer time already exists. Please change it before saving it.", "Close").Show ();
                         return;
                     }
                 }
@@ -641,6 +659,9 @@
                 if (timerTemp.Periodicity [timerTemp.Periodicity.Length - 1] == ',') {
                     timerTemp.Periodicity = timerTemp.Periodicity.Remove (timerTemp.Periodicity.Length - 1, 1);
                 }
+
+            
+
                 timerTemp.IsStart = true;
                 if (string.IsNullOrEmpty (timerTemp.Id)) {
                     timerTemp.Id = Guid.NewGuid ().ToString ();
@@ -663,7 +684,7 @@
                         Application.RunOnMainThread (() => {
                             if (revertObj == null) {
                                 new Alert ("", "Unable to save data, please check the network.", "Close").Show ();
-                            } else if (revertObj.StateCode.ToUpper() == "SUCCESS") {
+                            } else if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) {
                                 this.RemoveFromParent ();
                                 action (timerTemp);
                             } else {
@@ -671,7 +692,7 @@
                             }
                         });
                     } catch (Exception ex) {
-                        Console.WriteLine (ex.Message);
+                        Utlis.WriteLine (ex.Message);
                     } finally {
                         Application.RunOnMainThread (() => {
                             MainPage.Loading.Hide ();
@@ -802,7 +823,7 @@
                                         Tag = deviceCommon.CommonLoopID,
                                     };
                                     DeviceRowView.AddChidren (tempSwitch);
-                                  
+
 
                                     if (deviceCommon.Type == DeviceType.FanModule) {
                                         #region 椋庢墖
@@ -853,7 +874,7 @@
                                             ProgressColor = SkinStyle.Current.SelectedColor,
                                             ThumbRadius = Application.GetRealWidth (3),
                                             Max = 8,
-                                            Progress =2,// (int)(deviceCommon.SendBytes[1]),
+                                            Progress = 2,// (int)(deviceCommon.SendBytes[1]),
 
                                         };
                                         DeviceRowView.AddChidren (fanLevel);
@@ -874,7 +895,7 @@
                                                     btnFanLevel.Text = "S" + e.ToString ();
                                                 }
                                             } catch (Exception ex) {
-                                                Console.WriteLine ("ss1: " + ex.Message);
+                                                Utlis.WriteLine ("ss1: " + ex.Message);
                                             }
                                         };
 
@@ -1062,12 +1083,14 @@
                                         #endregion
                                     } else if (deviceCommon.Type == DeviceType.CurtainModel || deviceCommon.Type == DeviceType.CurtainTrietex || deviceCommon.Type == DeviceType.CurtainRoller) {
                                         #region 绐楀笜
+                                        //2020-07-09 鍒锋柊鎺у埗鎿嶄綔鐮�
+                                        deviceCommon.Command = (int)Command.UpdataCurtainModelStutas;
                                         tempSwitch.RemoveFromParent ();
-                                       var tempSwitch1 = new Button () {
-                                           Width = Application.GetMinRealAverage (90),
-                                           Height = Application.GetMinRealAverage (53),
-                                           X = Application.GetRealWidth (640 - 90 - 20),
-                                           Radius = 5,
+                                        var tempSwitch1 = new Button () {
+                                            Width = Application.GetMinRealAverage (90),
+                                            Height = Application.GetMinRealAverage (53),
+                                            X = Application.GetRealWidth (640 - 90 - 20),
+                                            Radius = 5,
                                             BorderColor = SkinStyle.Current.Transparent,
                                             BorderWidth = 1,
                                             Gravity = Gravity.CenterVertical,
@@ -1097,10 +1120,13 @@
                                                 btnChoose.IsSelected = true;
                                             }
                                             deviceCommon.SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
-                                            if (timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath) == null) {
+                                            //2020-07-09
+                                            DeviceInfo mDeviceInfo = timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath);
+                                            if (mDeviceInfo == null) {
                                                 timerControlDeviceList.Add (deviceCommon);
                                             } else {
-                                                timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath).SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
+                                                mDeviceInfo.Command = (int)Command.UpdataCurtainModelStutas;
+                                                mDeviceInfo.SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
                                             }
                                         };
 
@@ -1129,10 +1155,19 @@
                                                 }
                                                 deviceCommon.SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
 
-                                                if (timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath) == null) {
+                                                //if (timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath) == null) {
+                                                //    timerControlDeviceList.Add (deviceCommon);
+                                                //} else {
+                                                //    timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath).SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
+                                                //}
+
+                                                //2020-07-09
+                                                DeviceInfo mDeviceInfo = timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath);
+                                                if (mDeviceInfo == null) {
                                                     timerControlDeviceList.Add (deviceCommon);
                                                 } else {
-                                                    timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath).SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
+                                                    mDeviceInfo.Command = (int)Command.UpdataCurtainModelStutas;
+                                                    mDeviceInfo.SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
                                                 }
                                             } else {
                                                 timerControlDeviceList.Remove (timerControlDeviceList.Find ((obj) => obj.DeviceType == (int)deviceCommon.Type &&
@@ -1142,13 +1177,13 @@
                                         #endregion
                                     }
                                 }catch(Exception ex) {
-                                    Console.WriteLine ("AddSchedule error : "+ ex.Message);
+                                    Utlis.WriteLine ("AddSchedule error : "+ ex.Message);
                                 }
                             });
                         }
                     }
                 } catch (Exception ex) {
-                    Console.WriteLine (ex.Message);
+                    Utlis.WriteLine (ex.Message);
                 } finally {
                     Application.RunOnMainThread (() => {
                         MainPage.Loading.Hide ();

--
Gitblit v1.8.0