From be95e839f40eb3ddf64706b60cba6dfcf4fad5e5 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 03 四月 2020 14:31:44 +0800
Subject: [PATCH] 2020-04-03 1.去掉登录前ping百度域名的网络监测。

---
 Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs |   75 ++++++++++++++++++++++++++++++++-----
 1 files changed, 64 insertions(+), 11 deletions(-)

diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
index e3c9da0..57d0c7f 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
@@ -7,6 +7,7 @@
     public class AddSchedule : FrameLayout
     {
         VerticalScrolViewLayout bodyView;
+        FrameLayout devicesListView;
         Action<Timer> action;
         List<Common> roomDeviceList = new List<Common>();
         List<string> roomNameList = new List<string> ();
@@ -459,7 +460,7 @@
             };
             devicesView.AddChidren (btnDeviceTitle);
 
-            var devicesListView = new FrameLayout () {
+           devicesListView = new FrameLayout () {
                 Height = Application.GetRealHeight (130 * roomDeviceList.Count),
             };
             bodyView.AddChidren (devicesListView);
@@ -572,19 +573,56 @@
                     new Alert ("", "Please setting date!", "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 ();
                     return;
-                } else if (listTimer.Find ((obj) => obj.TimerName == timerTemp.TimerName) != null) {//2020-01-09 缂栬緫鐨勬椂鍊欎篃鎻愮ず閲嶅鍚嶅瓧
-                    new Alert ("", "The timer name already exists. Please change it before saving it.", "Close").Show ();
-                    return;
                 }
+                //else if (listTimer.Find ((obj) => obj.TimerName == timerTemp.TimerName) != null && !isEdit) {//2020-01-09 缂栬緫鐨勬椂鍊欎篃鎻愮ず閲嶅鍚嶅瓧
+                //    //if (isEdit) {
+
+                //    //}
+                //    new Alert ("", "The timer name already exists. Please change it before saving it.", "Close").Show ();
+                //    return;
+                //}
+
                 if (timerControlDeviceList.Count == 0) {
                     new Alert ("", "Please choose at least one device!", "Close").Show ();
                     return;
                 }
+
+                //鍚嶅瓧閲嶅鍒ゆ柇闄愬埗
+                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 ();
+                        return;
+                    }
+                } 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;
+                    }
+                }
+
                 timerTemp.Periodicity = "";
                 if (btnMonday.IsSelected == true && btnFriday.IsSelected == true && btnThursday.IsSelected == true && btnSunday.IsSelected == true && btnTuesday.IsSelected == true && btnSaturday.IsSelected == true && btnWednesday.IsSelected == true) {
                     timerTemp.TimerType = TimerType.EveryDay;
@@ -621,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 ();
@@ -636,7 +677,7 @@
                         ResponsePack revertObj = null;
                         if (isEdit) {
                             revertObj = MainPage.RequestHttps (API.EditTimer, requestJson);
-                        } else {
+                        } else {   
                             revertObj = MainPage.RequestHttps (API.AddTimer, requestJson);
                         }
 
@@ -651,7 +692,7 @@
                             }
                         });
                     } catch (Exception ex) {
-                        Console.WriteLine (ex.Message);
+                        Utlis.WriteLine (ex.Message);
                     } finally {
                         Application.RunOnMainThread (() => {
                             MainPage.Loading.Hide ();
@@ -661,6 +702,8 @@
             };
 
         }
+
+        
 
         /// <summary>
         //(1)Success 鍒欒皟鐢ㄦ鎺ュ彛鎴愬姛
@@ -697,6 +740,7 @@
         private static void InitDeviceListView (List<Common> roomDeviceList, List<DeviceInfo> timerControlDeviceList, FrameLayout devicesListView)
         {
             devicesListView.RemoveAll ();
+            
             System.Threading.Tasks.Task.Run (() => {
                 try {
                     int iniIndex = 0;
@@ -707,6 +751,15 @@
                             i++;
                         }
                     }
+
+#if __IOS__
+
+
+#else
+                  //鍒锋柊devicesListView 楂樺害
+                    devicesListView.Height = Application.GetRealHeight (130 * roomDeviceList.Count);
+#endif
+
                     foreach (var deviceCommon2 in roomDeviceList) {
                         if (deviceCommon2 == null)
                             continue;
@@ -842,7 +895,7 @@
                                                     btnFanLevel.Text = "S" + e.ToString ();
                                                 }
                                             } catch (Exception ex) {
-                                                Console.WriteLine ("ss1: " + ex.Message);
+                                                Utlis.WriteLine ("ss1: " + ex.Message);
                                             }
                                         };
 
@@ -1110,13 +1163,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