From 149adc620e7e120ee2adaa406a5302c9a0a2eff3 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 10 一月 2020 17:26:23 +0800
Subject: [PATCH] 2020-01-10 1.优化。

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

diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
index 9c092fc..3d2ffc6 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
@@ -431,11 +431,16 @@
                 timerTemp.RoomName = roomNameList [0];
             }
             btnRoomChoose.Text = timerTemp.RoomName;
-       
+
             #endregion
 
             #region Devices
-            timerControlDeviceList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<DeviceInfo>> (timerTemp.ControlDeviceData);//devicesControlDataList
+            try { 
+                timerControlDeviceList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<DeviceInfo>> (timerTemp.ControlDeviceData);//devicesControlDataList
+            } catch {
+                timerControlDeviceList = null;
+            }
+
             if (timerControlDeviceList == null)
                 timerControlDeviceList = new List<DeviceInfo> ();
 
@@ -572,7 +577,10 @@
                     //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 && !isEdit) {
+                } 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;
                 }
@@ -617,8 +625,8 @@
                     timerTemp.Periodicity = timerTemp.Periodicity.Remove (timerTemp.Periodicity.Length - 1, 1);
                 }
                 timerTemp.IsStart = true;
-                if (string.IsNullOrEmpty (timerTemp.Guid)) {
-                    timerTemp.Guid = Guid.NewGuid ().ToString ();
+                if (string.IsNullOrEmpty (timerTemp.Id)) {
+                    timerTemp.Id = Guid.NewGuid ().ToString ();
                 }
                 timerTemp.ControlDeviceData = Newtonsoft.Json.JsonConvert.SerializeObject (timerControlDeviceList);
                 MainPage.Loading.Start ("Saving...");
@@ -630,9 +638,9 @@
                         var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (timerTemp);
                         ResponsePack revertObj = null;
                         if (isEdit) {
-                            revertObj = MainPage.RequestHttps (API.EditTimer, requestJson, true);
+                            revertObj = MainPage.RequestHttps (API.EditTimer, requestJson);
                         } else {
-                            revertObj = MainPage.RequestHttps (API.AddTimer, requestJson, true);
+                            revertObj = MainPage.RequestHttps (API.AddTimer, requestJson);
                         }
 
                         Application.RunOnMainThread (() => {

--
Gitblit v1.8.0