void Handle_ItemAppearing(object sender, Xamarin.Forms.ItemVisibilityEventArgs e) { AlertAndAlarmt item = e.Item as AlertAndAlarmt; if (item == dataList[dataList.Count - 1] && haveMole == true && item != null) { pageIndex += 1; BackgroundWorker wrk = new BackgroundWorker(); wrk.DoWork += (a, ee) => { haveAlertOrAlarm(); }; wrk.RunWorkerAsync(); } }
public AlarmInfoPage(AlertAndAlarmt alarm, string businessName) { InitializeComponent(); NavigationPage.SetBackButtonTitle(this, ""); _alarm = alarm; this.Title = "预警记录"; businessNameLab.Text = businessName; BackgroundWorker wrk = new BackgroundWorker(); wrk.DoWork += (sender, e) => { makeData(); }; wrk.RunWorkerCompleted += (sender, e) => { this.BindingContext = list; _alarmInfo = list; flowName.Text = _alarmInfo.flowName + " " + _alarmInfo.equipmentName + " " + _alarmInfo.operName; }; wrk.RunWorkerAsync(); }
void haveAlertOrAlarm() { try { DateTime sd = startDatePicker.Date + startTime; DateTime ed = endDatePicker.Date + endTime; string url = App.BaseURL + "AppAlarm/GetAllAlarm?id=" + _businessId + "&startTime=" + sd.ToString("yyyy-MM-dd HH:mm") + "&endTime=" + ed.ToString("yyyy-MM-dd HH:mm") + "&pageIndex=" + pageIndex + "&pageSize=20" + "&flag=" + _flag; Console.WriteLine("请求接口:" + url); string result = EasyWebRequest.sendGetHttpWebRequest(url); Console.WriteLine("请求结果:" + result); resutlDic resultList = JsonConvert.DeserializeObject <resutlDic>(result); if (pageIndex == 0) { dataList.Clear(); } for (int i = 0; i < resultList.Items.Count; i++) { AlertAndAlarmt item = resultList.Items[i]; dataList.Add(item); } if (resultList.Totals <= dataList.Count) { haveMole = false; } else { haveMole = true; } } catch (Exception ex) { DisplayAlert("Alert", ex.Message, "OK"); } }