| | |
| | | UserMiddle.SettingPageView.PageIndex = 2; |
| | | }); |
| | | }catch(Exception ex){ |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | } |
| | | finally{ |
| | | Application.RunOnMainThread (() => { |
| | |
| | | try { |
| | | var requestObj = new Timer () { RegionID = UserConfig.Instance.CurrentRegion.Id }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps (API.GetTimerList, requestJson, true); |
| | | if (revertObj.StateCode.ToUpper() == "SUCCESS") { |
| | | var revertObj = MainPage.RequestHttps (API.GetTimerList, requestJson); |
| | | if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) { |
| | | timers = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Timer>> (revertObj.ResponseData.ToString ()); |
| | | foreach (var schedule in timers) { |
| | | initSchedule (schedule); |
| | |
| | | ShowGetTimerListErrorInfo (revertObj.StateCode); |
| | | } |
| | | } catch (Exception ex) { |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | } finally { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | |
| | | var view = bodyView.GetChildren (i); |
| | | if(view.GetType() == typeof(RowLayout)){ |
| | | var rowView = view as RowLayout; |
| | | if (rowView.GetTagByKey("guid").ToString () == schedule.Guid) { |
| | | if (rowView.GetTagByKey("guid").ToString () == schedule.Id) { |
| | | for (int j = 0; j < rowView.ChildrenCount; j++) { |
| | | var viewChilren = rowView.GetChildren (j); |
| | | if (viewChilren.GetType () == typeof (Button)) { |
| | |
| | | Height = Application.GetRealHeight (180), |
| | | }; |
| | | bodyView.AddChidren (rowView); |
| | | rowView.AddTag ("guid", schedule.Guid); |
| | | rowView.AddTag ("guid", schedule.Id); |
| | | |
| | | var btnScheduleName = new Button () { |
| | | X = Application.GetRealWidth (30), |
| | |
| | | Tag = "btnScheduleName", |
| | | }; |
| | | rowView.AddChidren (btnScheduleName); |
| | | btnScheduleName.AddTag ("guid", schedule.Guid); |
| | | btnScheduleName.AddTag ("guid", schedule.Id); |
| | | |
| | | var btnScheduleRoomName = new Button () { |
| | | X = btnScheduleName.Right, |
| | |
| | | Tag = "btnScheduleRoomName", |
| | | }; |
| | | rowView.AddChidren (btnScheduleRoomName); |
| | | btnScheduleRoomName.AddTag ("guid", schedule.Guid); |
| | | btnScheduleRoomName.AddTag ("guid", schedule.Id); |
| | | |
| | | var btnScheduleTime = new Button () { |
| | | X = Application.GetRealWidth (30), |
| | |
| | | Tag = "btnScheduleTime", |
| | | }; |
| | | rowView.AddChidren (btnScheduleTime); |
| | | btnScheduleTime.AddTag ("guid", schedule.Guid); |
| | | btnScheduleTime.AddTag ("guid", schedule.Id); |
| | | |
| | | var btnScheduleDay = new Button () { |
| | | X = Application.GetRealWidth (33), |
| | |
| | | Tag = "btnScheduleDay", |
| | | }; |
| | | rowView.AddChidren (btnScheduleDay); |
| | | btnScheduleDay.AddTag ("guid", schedule.Guid); |
| | | btnScheduleDay.AddTag ("guid", schedule.Id); |
| | | |
| | | if (schedule.Periodicity.Contains ("0")) { |
| | | btnScheduleDay.Text += "Sun "; |
| | |
| | | UnSelectedImagePath = "Item/SwitchClose.png", |
| | | SelectedImagePath = "Item/SwitchOpen.png", |
| | | IsSelected = schedule.IsStart, |
| | | Tag = schedule.Guid |
| | | Tag = schedule.Id |
| | | }; |
| | | rowView.AddChidren (tempSiwtch); |
| | | |
| | |
| | | MainPage.Loading.Start ("Loading"); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | try { |
| | | var switchObj = new Timer () { Guid = (sdd as Button).Tag.ToString () }; |
| | | var switchObj = new Timer () { Id = (sdd as Button).Tag.ToString () }; |
| | | var switchRequestJson = Newtonsoft.Json.JsonConvert.SerializeObject (switchObj); |
| | | var switchRevertObj = MainPage.RequestHttps (API.IsEnableTimer, switchRequestJson, true); |
| | | if (switchRevertObj.StateCode.ToUpper() != "SUCCESS") { |
| | | var switchRevertObj = MainPage.RequestHttps (API.IsEnableTimer, switchRequestJson); |
| | | if (switchRevertObj.StateCode.ToUpper() != StateCode.SUCCESS) { |
| | | Application.RunOnMainThread (() => { |
| | | tempSiwtch.IsSelected = !tempSiwtch.IsSelected; |
| | | }); |
| | | } |
| | | } catch (Exception ex) { |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | } finally { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | |
| | | Button btnDel = new Button () { |
| | | TextID = R.MyInternationalizationString.Del, |
| | | BackgroundColor = SkinStyle.Current.DelColor, |
| | | Tag = schedule.Guid |
| | | Tag = schedule.Id |
| | | }; |
| | | rowView.AddRightView (btnDel); |
| | | btnDel.MouseUpEventHandler += (sender, er) => { |
| | | if ((sender as Button).Tag == null) return; |
| | | //string uuid = (sender as Button).Tag.ToString (); |
| | | |
| | | DeleteTimerAction ((sender as Button).Tag.ToString (), rowView, true); |
| | | //var delObj = new Timer () { Guid = (sender as Button).Tag.ToString () }; |
| | | //var delRequestJson = Newtonsoft.Json.JsonConvert.SerializeObject (delObj); |
| | | //var delRevertObj = MainPage.RequestHttps ("DeleteTimer", delRequestJson); |
| | | //if (delRevertObj.StateCode.ToUpper() == "SUCCESS") { |
| | | //if (delRevertObj.StateCode.ToUpper() == StateCode.SUCCESS) { |
| | | // rowView.RemoveFromParent (); |
| | | // timers.Remove (timers.Find((obj) => obj.Guid == delObj.Guid)); |
| | | //} |
| | |
| | | alert.Show (); |
| | | alert.ResultEventHandler += (sender2, e2) => { |
| | | if (e2) { |
| | | if ((sender as Button).GetTagByKey ("guid") == null) return; |
| | | DeleteTimerAction ((sender as Button).GetTagByKey ("guid").ToString (), rowView); |
| | | } |
| | | }; |
| | |
| | | alert.Show (); |
| | | alert.ResultEventHandler += (sender2, e2) => { |
| | | if (e2) { |
| | | if ((sender as Button).GetTagByKey ("guid") == null) return; |
| | | DeleteTimerAction ((sender as Button).GetTagByKey ("guid").ToString (), rowView); |
| | | } |
| | | }; |
| | |
| | | alert.Show (); |
| | | alert.ResultEventHandler += (sender2, e2) => { |
| | | if (e2) { |
| | | if ((sender as Button).GetTagByKey ("guid") == null) return; |
| | | DeleteTimerAction ((sender as Button).GetTagByKey ("guid").ToString (), rowView); |
| | | } |
| | | }; |
| | |
| | | /// <param name="bTimersRemove"></param> |
| | | void DeleteTimerAction (string GUID, View rowView, bool bTimersRemove = false) |
| | | { |
| | | var delObj = new Timer () { Guid = GUID }; |
| | | //2020-01-11 |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Start ("Please wait..."); |
| | | }); |
| | | |
| | | var delObj = new Timer () { Id = GUID }; |
| | | var delRequestJson = Newtonsoft.Json.JsonConvert.SerializeObject (delObj); |
| | | var delRevertObj = MainPage.RequestHttps (API.DeleteTimer, delRequestJson, true); |
| | | if (delRevertObj.StateCode.ToUpper () == "SUCCESS") { |
| | | var delRevertObj = MainPage.RequestHttps (API.DeleteTimer, delRequestJson); |
| | | |
| | | |
| | | if (delRevertObj.StateCode.ToUpper () == StateCode.SUCCESS) { |
| | | rowView.RemoveFromParent (); |
| | | if (bTimersRemove) { |
| | | timers.Remove (timers.Find ((obj) => obj.Guid == delObj.Guid)); |
| | | timers.Remove (timers.Find ((obj) => obj.Id == delObj.Id)); |
| | | } |
| | | } else { |
| | | //删除失败 |
| | |
| | | new Alert ("", ErrorCode.FailedDelete, Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | } |
| | | |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | |
| | | |
| | | } |
| | | } |
| | | } |