internal void SeachStation(string p) { if (string.IsNullOrEmpty(p)) { StationList.Clear(); } else { p = p.ToLower(); var stations = StationNameService.GetStations().Where(x => x.Name.ToLower().StartsWith(p)).OrderBy(x => x.Sort).Take(7); if (stations.Count() < 7) { var extraStations = StationNameService.GetStations().Where(x => x.StartsWith(p)).OrderBy(x => x.Sort).Take(7 - stations.Count()); stations = stations.Union(extraStations); } StationList.Clear(); foreach (var s in stations) { StationList.Add(s); } } }
public void updateStations(string routeName)// { StationList.Clear(); Task.Run(async() => { string routeID = Database.routeID_NameMap.FirstOrDefault(x => x.Value == routeName).Key; SelectedRoute = routeID; ScheduleList = await DataQuery.getSchedule(routeID, RouteDirection.direction_id); if (Database.routeAbrevMap.ContainsKey(routeName)) { LineCode = Database.routeAbrevMap[routeName]; LineColor = Configs.lineColorMap[LineCode]; } else { LineCode = routeName; LineColor = "#AEA29F"; } List <Station> stationList = await DataQuery.getStations(routeID); Station start_st = stationList[0], final_st = stationList[stationList.Count - 1]; RouteDirection.start_station = start_st.attributes.name; RouteDirection.final_station = final_st.attributes.name; foreach (Station station in stationList) { StationList.Add(station.attributes.name); } }).Wait(); }
private async Task UpdateList(RecordChangedEventArgs <Station> e) { if (e.ChangeType == ChangeType.None) { return; } if (e.ChangeType == ChangeType.Delete) { var s = StationList.FirstOrDefault(c => c.Model.StationId == e.Entity.StationId); if (s == null) { return; } StationList.Remove(s); } else if (e.ChangeType == ChangeType.Insert) { StationList.Add(new StationModel(e.Entity, _repository)); } else if (e.ChangeType == ChangeType.Update) { var s = StationList.FirstOrDefault(c => c.Model.StationId == e.Entity.StationId); if (s == null) { return; } var i = StationList.IndexOf(s); StationList[i] = new StationModel(e.Entity, _repository); SelectedStation = StationList[i]; } }
private async Task LoadStationAsync() { //var s = await Task.Run(() => _repository.Stations.AddAsync(new Station //{ // Location = "a", // DisplayLocationArea = "b", // DisplayLocation = "c", // PhoneNumber = "1", // Imei = "2", // Keyword = "As" //})); var stations = await Task.Run(() => _repository.Stations.GetRangeAsync()); foreach (var item in stations) { StationList.Add(new StationModel(item, _repository)); //if (item.Name.Contains("y")) //{ // throw new InvalidOperationException("bawal naay y"); //} } //Stations = new AutoRefreshWrapper<Station>( // MyObjectContext.MyObjectSet, RefreshMode.StoreWins); }
public void Sorting() { StationList stationList = new StationList("s"); WeatherStation weatherStation1 = new WeatherStation("s1", new Location(50, 50, 100)); WeatherStation weatherStation2 = new WeatherStation("s1", new Location(50, 50, 70)); WeatherStation weatherStation3 = new WeatherStation("s1", new Location(25, 25, 70)); WeatherStation weatherStation4 = new WeatherStation("s1", new Location(25, 50, 70)); stationList.Add(weatherStation1); stationList.Add(weatherStation2); stationList.Add(weatherStation3); stationList.Add(weatherStation4); stationList.Sortuj(); List <WeatherStation> stationsAfterSorting = stationList.list; Console.WriteLine(stationsAfterSorting); CollectionAssert.AreEqual(new List <WeatherStation> { weatherStation3, weatherStation4, weatherStation2, weatherStation1 }, stationsAfterSorting); }
/// <summary> /// Show favorite stations /// </summary> private void ShowFavoriteStations() { //Show favoriete en gps stations var list = ViewModelLocator.MainStatic.StationList; if (list != null) { var stationCodes = list.Select(x => x.Code.ToLower()); var stations = StationNameService.GetStationsByCode(stationCodes).OrderBy(x => x.Name); foreach (var station in stations) { StationList.Add(station); } } }
/// <summary> /// Search a station /// </summary> /// <param name="p"></param> internal void SeachStation(string p) { if (string.IsNullOrEmpty(p)) { StationList.Clear(); ShowFavoriteStations(); } else { p = p.ToLower(); //Do a normal starts with var stations = StationNameService.GetStations().Where(x => x.Name.ToLower().StartsWith(p)).OrderBy(x => x.Sort).Take(8); if (stations.Count() < 8) { //Search extra names codes etc var extraStations = StationNameService.GetStations().Where(x => x.StartsWith(p)).OrderBy(x => x.Sort).Take(8 - stations.Count()); stations = stations.Union(extraStations); } //No results? Search international if (stations.Count() <= 2) { //Search extra names codes etc var extraStations = StationNameService.GetStations(true).Where(x => x.StartsWith(p)).OrderBy(x => x.Sort).Take(8); //Remove stations already found from extraStations var dubbel = extraStations.Where(x => stations.Select(s => s.Code).Contains(x.Code)).ToList(); extraStations = extraStations.Except(dubbel); stations = stations.Union(extraStations); } StationList.Clear(); foreach (var station in stations) { StationList.Add(station); } } }
private StationList getUniqueStations(ChannelList channels) { if (channels != null) { List<int> stIdList = new List<int>(); StationList stations = new StationList(); foreach (Channel ch in channels) { if (!(stIdList.Contains(ch.StationId))) { stations.Add(ch.Station); stIdList.Add(ch.StationId); } } return stations; } return null; }
protected override void InterpretRow(Dictionary <string, string> fields) { float price = float.Parse(fields["price"], System.Globalization.CultureInfo.InvariantCulture); int quantity = (int)float.Parse(fields["volRemaining"], System.Globalization.CultureInfo.InvariantCulture); int minQuantity = (int)float.Parse(fields["minVolume"], System.Globalization.CultureInfo.InvariantCulture); int typeId = int.Parse(fields["typeID"]); int range = int.Parse(fields["range"]); int regionId = int.Parse(fields["regionID"]); int stationId = int.Parse(fields["stationID"]); int systemId = int.Parse(fields["solarSystemID"]); string isWanted = fields["bid"]; SolarSystem s = map.GetSystem(systemId); Station station = map.GetStation(stationId); ItemType type = itemDatabase.GetItemType(typeId); if (s != null && type != null && station != null) { Trade trade = new Trade(type, price, quantity, minQuantity); if (isWanted == "True") { // Range is in station only if (range == -1) { station.AddItemWanted(trade); if (!stationsWithItemsWanted.Contains(station)) { stationsWithItemsWanted.Add(station); } } // Range it either system or greater else if ((range > -1) & (range < 32767)) { foreach (SolarSystem sAtRange in s.Region.Systems) { if (map.DistanceBetween(s, sAtRange, false) <= range) { sAtRange.AddItemWanted(trade); foreach (Station remoteStation in sAtRange.Stations) { if (!stationsWithItemsWanted.Contains(remoteStation)) { stationsWithItemsWanted.Add(remoteStation); } } } } } // Range is regional else if (range == 32767) { s.Region.AddItemWanted(trade); foreach (SolarSystem system in s.Region.Systems) { foreach (Station remoteStation in system.Stations) { if (!stationsWithItemsWanted.Contains(remoteStation)) { stationsWithItemsWanted.Add(remoteStation); } } } } } else { station.AddItemForSale(trade); if (!stationsWithItemsForSale.Contains(station)) { stationsWithItemsForSale.Add(station); } } } }
private static StationList TableToList(DataTable tbl) { StationList list = new StationList(); foreach (DataRow r in tbl.Rows) { Station st = DataRowToStation(r); AddStationLocation(st); list.Add(st); } return list; }