diff --git a/CRSim.Core/Services/NetworkService.cs b/CRSim.Core/Services/NetworkService.cs index 99632fb..727caca 100644 --- a/CRSim.Core/Services/NetworkService.cs +++ b/CRSim.Core/Services/NetworkService.cs @@ -84,7 +84,7 @@ namespace CRSim.Core.Services string tel = ""; foreach (string station in stations) { - if (station == "';") continue; + if (station.StartsWith("';")) continue; if (station.Split("|")[1] == name) { tel = station.Split("|")[2]; diff --git a/CRSim/ViewModels/Pages/DataManagement/StationManagementPageViewModel.cs b/CRSim/ViewModels/Pages/DataManagement/StationManagementPageViewModel.cs index 7541b10..272cdfc 100644 --- a/CRSim/ViewModels/Pages/DataManagement/StationManagementPageViewModel.cs +++ b/CRSim/ViewModels/Pages/DataManagement/StationManagementPageViewModel.cs @@ -538,17 +538,24 @@ public partial class StationManagementPageViewModel : ObservableObject [RelayCommand] public async Task ImportFromInternet() { - if (!CheckCanImport()) return; - var stops = await _networkService.GetTrainNumbersAsync(SelectedStation.Name); - if (stops.Count != 0) + try { - TrainStops.Clear(); - foreach (TrainStop t in stops) + if (!CheckCanImport()) return; + var stops = await _networkService.GetTrainNumbersAsync(SelectedStation.Name); + if (stops.Count != 0) { - TrainStops.Add(RandomTrainStopProperties(t)); + TrainStops.Clear(); + foreach (TrainStop t in stops) + { + TrainStops.Add(RandomTrainStopProperties(t)); + } + } + else + { + throw new Exception(); } } - else + catch { _dialogService.ShowMessage("获取失败", "服务器繁忙或车站不存在。"); }