private void UpdateAll()
 {
     ElectricityService.ElectricityServiceClient esc = new ElectricityService.ElectricityServiceClient();
     try
     {
         foreach (StationUI stationui in StationUIList)
         {
             List <ElectricityService.RuntimeStationData> DataList = esc.UpdateRuntimeStationData(stationui.RuntimeID, stationui.ID).ToList();
             if (DataList.Count == 0)
             {
                 return;
             }
             ElectricityService.RuntimeStationData LastRecord = null;
             foreach (ElectricityService.RuntimeStationData record in DataList)
             {
                 if (record.Time > DateTime.Now)
                 {
                     break;
                 }
                 if (ListViewStationList.SelectedItem == stationui)
                 {
                     TemplateWebBrowserChart.JavaScript("AddData", "runtime", record.Time.ToString("yyyy-MM-dd HH:mm:ss"), record.ActivePower);
                 }
                 LastRecord = record;
             }
             if (LastRecord != null)
             {
                 stationui.Active    = LastRecord.ActivePower;
                 stationui.Reactive  = LastRecord.ReactivePower;
                 stationui.RuntimeID = LastRecord.ID;
                 this.Dispatcher.Invoke(new Action(() => { WriteLine("[BGW_UpdateRuntime]数据已更新:{0}", stationui.ID); }));
             }
         }
         ListViewStationList.UpdateLayout();
         esc.Close();
     }
     catch (TimeoutException)
     {
         MessageBox.Show("服务器请求超时");
         esc.Abort();
     }
 }
 private void FetchAll()
 {
     ElectricityService.ElectricityServiceClient esc = new ElectricityService.ElectricityServiceClient();
     try
     {
         foreach (StationUI stationui in StationUIList)
         {
             List <ElectricityService.RuntimeStationData> DataList = esc.SelectRuntimeStationData(stationui.ID, DateTime.Today).ToList();
             if (DataList.Count == 0)
             {
                 return;
             }
             ElectricityService.RuntimeStationData LastRecord = null;
             foreach (ElectricityService.RuntimeStationData record in DataList)
             {
                 if (record.Time > DateTime.Now)
                 {
                     break;
                 }
                 LastRecord = record;
             }
             if (LastRecord != null)
             {
                 stationui.Active    = LastRecord.ActivePower;
                 stationui.Reactive  = LastRecord.ReactivePower;
                 stationui.RuntimeID = LastRecord.ID;
             }
         }
         ListViewStationList.UpdateLayout();
         DrawStations();
         esc.Close();
     }
     catch (TimeoutException)
     {
         MessageBox.Show("服务器请求超时");
         esc.Abort();
     }
 }