| | |
| | | public void ShowPage (Timer timerTemp, List<Timer> listTimer, bool isEdit = false) |
| | | { |
| | | UserMiddle.SettingPageView.ScrollEnabled = false; |
| | | timerTemp.RegionID = UserConfig.Instance.CurrentRegion.RegionID; |
| | | timerTemp.RegionID = UserConfig.Instance.CurrentRegion.Id; |
| | | #region topview |
| | | var topView = new RowLayout () { |
| | | Y = Application.GetRealHeight (36), |
| | |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (timerTemp); |
| | | ResponsePack revertObj = null; |
| | | if (isEdit) { |
| | | revertObj = MainPage.RequestHttps ("EditTimer", requestJson); |
| | | revertObj = MainPage.RequestHttps (API.EditTimer, requestJson, true); |
| | | } else { |
| | | revertObj = MainPage.RequestHttps ("AddTimer", requestJson); |
| | | revertObj = MainPage.RequestHttps (API.AddTimer, requestJson, true); |
| | | } |
| | | |
| | | Application.RunOnMainThread (() => { |
| | | if (revertObj == null) { |
| | | new Alert ("", "Unable to save data, please check the network.", "Close").Show (); |
| | | } else if (revertObj.StateCode == "SUCCESS") { |
| | | } else if (revertObj.StateCode.ToUpper() == "SUCCESS") { |
| | | this.RemoveFromParent (); |
| | | action (timerTemp); |
| | | } else { |
| | | ShowErrorInfo (revertObj.StateCode); |
| | | } |
| | | }); |
| | | } catch (Exception ex) { |
| | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | //(1)Success 则调用此接口成功 |
| | | //(2)NoRecord 住宅未绑定网关! |
| | | //(3)NoExist 住宅不存在! |
| | | //(4)Exist 生成的Guid已存在! |
| | | /// </summary> |
| | | void ShowErrorInfo (string stateCodeStr) |
| | | { |
| | | string mes = ""; |
| | | if (stateCodeStr == "NoRecord") { |
| | | // 住宅未绑定网关! |
| | | mes = ErrorCode.HomeNoRecord; |
| | | } else if (stateCodeStr == "NoExist") { |
| | | //住宅不存在! |
| | | mes = ErrorCode.HomeNoExist; |
| | | } else if (stateCodeStr == "Exist") { |
| | | //生成的Guid已存在! |
| | | mes = ErrorCode.GuidExist; |
| | | } else if (stateCodeStr == ErrorCode.NetworkError) { |
| | | mes = ErrorCode.NetworkError; |
| | | } else { |
| | | mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr; |
| | | |
| | | } |
| | | if (!string.IsNullOrEmpty (mes)) { |
| | | //Application.RunOnMainThread (() => { |
| | | new Alert ("", mes, Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | //}); |
| | | } |
| | | |
| | | } |
| | | |
| | | private static void InitDeviceListView (List<Common> roomDeviceList, List<DeviceInfo> timerControlDeviceList, FrameLayout devicesListView) |
| | | { |
| | | devicesListView.RemoveAll (); |