private void OnProcessCompleted(LocationsAllocateEventArgs args) { if (ProcessCompleted != null) { Application.Current.RootVisual.Dispatcher.BeginInvoke(ProcessCompleted, new object[] { this, args }); } }
private void request_Completed(object sender, RequestEventArgs e) { JsonObject jsonObject = (JsonObject)JsonObject.Parse(e.Result); LocationsAllocateResult result = LocationsAllocateResult.FromJson(jsonObject); LastResult = result; LocationsAllocateEventArgs args = new LocationsAllocateEventArgs(result, e.Result, e.UserState); OnProcessCompleted(args); }
private void service_ProcessCompleted(object sender, LocationsAllocateEventArgs e) { //对结果进行判断,增强程序健壮性 if (e.Result == null) { MessageBox.Show("查询无结果"); return; } if (e.Result.ResultCenterData == null) { MessageBox.Show("查询无结果"); return; } if (e.Result.ResultCenterData.RecordSet == null) { MessageBox.Show("查询无结果"); return; } //显示结果面板 DataStackPanel.Visibility = Visibility.Visible; List<ResultData> listResultData = new List<ResultData>(); FeatureCollection features = e.Result.ResultCenterData.RecordSet.ToFeatureSet(); int i = 0; //遍历结果,listResultData变量 foreach (Feature item in features) { Scroll.Visibility = Visibility.Visible; ResultGrid.Visibility = Visibility.Visible; listResultData.Add(new ResultData { SmID = item.Attributes["SmID"].ToString(), AltCost = item.Attributes["AltCost"].ToString(), AltDemand = item.Attributes["AltDemand"].ToString(), AltResource = item.Attributes["AltResource"].ToString(), AveCost = item.Attributes["AveCost"].ToString(), }); i++; } //给datagrid控件赋值。 ResultGrid.ItemsSource = listResultData; }