private async void ExecutePullToRefreshCommand() { this.DataGridSF_Scheduling.IsBusy = true; await Task.Delay(new TimeSpan(0, 0, 2)); DataGridSF_Scheduling.Refresh(); this.DataGridSF_Scheduling.IsBusy = false; }
//private async void PullToRefresh_Refreshing(object sender, EventArgs args) //{ // GlobalVar.urutanPhotoScheduling = 0; // if (string.IsNullOrEmpty(Combobox_Division.Text) || txtDate.Text.ToUpper().Contains("DATE")) // { // //sfPullToRefresh.IsRefreshing = false; // return; // } // else // { // if (AppSettings.IsMqttConnected) // { // string pubmsg = null; // pubmsg = string.Format("{0},{1},{2}", Combobox_Division.Text,txtDate.Text, GlobalVar.PlantID); // _application.mqttHelper.PublishMQTT(pubmsg, "GETSCHEDULING_" + GlobalVar.MacAddress); // _application.mqttHelper.SubscribeMQTT("SEND_SCHEDULING_" + GlobalVar.MacAddress); // _application.mqttHelper.SubscribeMQTT("IMAGE_SCHEDULING_" + GlobalVar.MacAddress); // //sfPullToRefresh.IsRefreshing = true; // await Task.Delay(2000); // } // } //} //private void PullToRefresh_Pulling(object sender, PullingEventArgs args) //{ // args.Cancel = false; // var progress = args.Progress; //} protected override void OnAppearing() { base.OnAppearing(); MessagingCenter.Send(this, "OnlyLandscape"); if (AppSettings.IsMqttConnected) { _application.mqttHelper.PublishMQTT(GlobalVar.MacAddress, "SEND_MAC_ADDRESS_YSL_SCHEDULE"); _application.mqttHelper.SubscribeMQTT("SEND_SCHEDULING_1" + GlobalVar.MacAddress); } else { DisplayAlert("Error", "MQTT Not Connected Please Restart Application", "OK"); } MessagingCenter.Subscribe <MqttHelper, string>(this, MessagingCenterKeys.Scheduling, (sender, args) => { GlobalVar._listScheduling = new List <Scheduling>(); if (args != null) { Device.BeginInvokeOnMainThread(async() => { if (!receiveData) { receiveData = true; if (args == "EMPTY") { //sfPullToRefresh.IsRefreshing = false; await DisplayAlert("Information", "Data Empty or Not Valid", "OK"); viewModel.schedulings = new List <Scheduling>(); DataGridSF_Scheduling.ItemsSource = viewModel.schedulings; DataGridSF_Scheduling.Refresh(); } else { DataBefore = new List <string>(); //string[] strsplit = args.Split(','); string[] strarray = { "@#$@" }; string[] strsplit = args.Split(strarray, StringSplitOptions.None); //int TTLqty = 0; int i = 0; Scheduling scheduling = new Scheduling(); foreach (string newstr in strsplit) { if (i == 0) { scheduling = new Scheduling(); scheduling.NPK = newstr; i++; } else if (i == 1) { scheduling.Nama = newstr; i++; } else if (i == 2) { scheduling.Masuk = newstr; i++; } else if (i == 3) { scheduling.Pulang = newstr; i++; } else if (i == 4) { scheduling.MasukAktual = newstr; i++; } else if (i == 5) { scheduling.PulangAktual = newstr; i++; } else if (i == 6) { DataBefore.Add(string.Format("{0},{1}", scheduling.NPK, newstr)); scheduling.JumlahLembur = newstr; i++; } else if (i == 7) { scheduling.JumlahLemburAktual = newstr; i++; } else if (i == 8) { scheduling.Keterangan = newstr; //GlobalVar._listScheduling.Add(scheduling); i++; } else if (i == 9) { scheduling.ApproveBy = newstr; GlobalVar._listScheduling.Add(scheduling); i = 0; } } viewModel.schedulings = GlobalVar._listScheduling; DataGridSF_Scheduling.ItemsSource = viewModel.schedulings; //sfPullToRefresh.IsRefreshing = false; DataGridSF_Scheduling.Refresh(); } } }); } }); MessagingCenter.Subscribe <MqttHelper, string>(this, MessagingCenterKeys.ResponseSave, (sender, args) => { if (args != null) { Device.BeginInvokeOnMainThread(async() => { receiveData = true; if (args == "EMPTY") { //sfPullToRefresh.IsRefreshing = false; await DisplayAlert("Information", "Data Empty or Not Valid", "OK"); } else { await DisplayAlert("Information", "Data has been Saved", "OK"); } GetDataEmployee(); }); } receiveData = false; }); }