示例#1
0
        public static async Task test()
        {
            Console.WriteLine("Start");

            var context     = new WienerLinienContext("O56IE8eH7Kf5R5aQ");
            var allStations = await Stations.GetAllStationsAsync();

            //initialize the RealtimeData object using the created context
            var rtd = new RealtimeData(context);

            var listRbls = new List <int>();

            foreach (var v in allStations)
            {
                if (v.Name.Equals("Pilgramgasse"))
                {
                    foreach (var v2 in v.Platforms)
                    {
                        if (v2.Name.Equals("12A"))
                        {
                            listRbls.Add(v2.RblNumber);
                        }
                    }
                    break;
                }
            }

            //Create a Parameters object to include the Rbls  and get Realtime Data for them
            var parameters = new Parameters.MonitorParameters()
            {
                Rbls = listRbls
            };

            //Get the monitor informatino asynchronous, and save them as MonitorData class
            var monitorInfo = await rtd.GetMonitorDataAsync(parameters);

            foreach (var v in monitorInfo.Data.Monitors)
            {
                foreach (var v2 in v.Lines)
                {
                    Console.WriteLine();
                    Console.WriteLine(v2.Name);
                    foreach (var v3 in v2.Departures.Departure)
                    {
                        Console.WriteLine(v3.DepartureTime.Countdown);
                    }
                    Console.WriteLine();
                }
            }

            //Get the planned arrival time for the first line and the next vehicle arriving (index at Departure)
            //var plannedTime = monitorInfo.Data.Monitors[0].Lines[0].Departures.Departure[0].DepartureTime.TimePlanned;


            Console.WriteLine("Finished");
            Console.ReadKey();
        }
        public static async Task <List <string> > GetStaionNames(string type)
        {
            stations = await Stations.GetAllStationsAsync();

            var mot            = MeansOfTransportWrapper.GetMeansOfTransportFromString(type);
            var listOfStations = (from v in stations
                                  from p in v.Platforms
                                  where p.MeansOfTransport == mot
                                  select v.Name).Distinct().ToList();

            return(listOfStations);
        }
示例#3
0
        public async Task GetStations()
        {
            var stations = await Stations.GetAllStationsAsync();

            foreach (var item in stations)
            {
                foreach (var item1 in item.Platforms)
                {
                    Console.WriteLine(item1.MeansOfTransport + " " + item1.Name);
                }
            }
            Assert.IsNotNull(stations);
        }
示例#4
0
        public static async Task <List <string> > GetStaionNames(MeansOfTransport type)
        {
            if (stations == null)
            {
                stations = await Stations.GetAllStationsAsync();
            }
            var mot            = type;
            var listOfStations = (from v in stations
                                  from p in v.Platforms
                                  where p.MeansOfTransport == type
                                  select v.Name).Distinct().ToList();

            return(listOfStations);
        }
        public static async Task <List <string> > GetLinesFromStation(string station, string type)
        {
            if (stations == null)
            {
                stations = await Stations.GetAllStationsAsync();
            }
            var lines = (from v in stations
                         where v.Name == station
                         from p in v.Platforms
                         where p.MeansOfTransport == MeansOfTransport.Bus
                         group p by p.Name
                         into linesList
                         select linesList.Key).ToList();

            return(lines);
        }
示例#6
0
        public async Task GetMonitorData()
        {
            var wlc      = new WienerLinienContext("VgIHscNiquj8LYbV");
            var stations = await Stations.GetAllStationsAsync();

            var firstFive = stations.Take(4);
            var rtd       = new RealtimeData.RealtimeData(wlc);
            var listRbls  = firstFive.Select(item => item.Platforms[0].RblNumber).ToList();
            var mp        = new Parameters.MonitorParameters {
                Rbls = listRbls
            };
            var data = await rtd.GetMonitorDataAsync(mp);

            var a = data.Data.Monitors[0].Lines[0].Departures.Departure[0].DepartureTime.TimePlanned;

            Assert.IsFalse(data.Data.IsNull());
        }
        public static async Task <Dictionary <string, string> > GetDirections(string station, string line)
        {
            if (stations == null)
            {
                stations = await Stations.GetAllStationsAsync();
            }
            Console.WriteLine("Station=" + station + "&line=" + line + "&type=");
            var directions = (from v in stations
                              where v.Name == station
                              from p in v.Platforms
                              where p.Name == line
                              select p.RblNumber.ToString()).ToList();

            var rbls = directions.Select(int.Parse).ToList();

            var rtd = new RealtimeData.RealtimeData(Context);

            var parameters = new Parameters.MonitorParameters()
            {
                Rbls = rbls
            };
            var monitorInfo = await rtd.GetMonitorDataAsync(parameters);

            Data = monitorInfo;
            var strings = new  Dictionary <string, string>();
            var b       =
                monitorInfo.Data.Monitors.Where(i => i.Lines[0].Direction == "R" && i.Lines[0].Name == line).ToList();

            if (b.Count > 0)
            {
                strings.Add("R", ReplaceString(b.Select(i => i.Lines[0].Towards)
                                               .ToList()
                                               .First() + " "));
            }
            var c =
                monitorInfo.Data.Monitors.Where(i => i.Lines[0].Direction == "H" && i.Lines[0].Name == line).ToList();

            if (c.Count > 0)
            {
                strings.Add("H", ReplaceString(c.Select(i => i.Lines[0].Towards)
                                               .ToList()
                                               .First() + " "));
            }
            return(strings);
        }
示例#8
0
        public static async Task test()
        {
            Console.WriteLine("Start");

            var context     = new WienerLinienContext("O56IE8eH7Kf5R5aQ");
            var allStations = await Stations.GetAllStationsAsync();

            //initialize the RealtimeData object using the created context
            var rtd = new RealtimeData(context);

            var listRbls = new List <int>();

            Console.WriteLine("Please enter the desired station (e.g. Pilgramgasse):");
            var station = Console.ReadLine();

            Console.WriteLine();

            // the desired station
            var SelectedStation = allStations.Find(x => station != null && x.Name.Contains(station));

            var listLines = new List <Station.Platform>();

            // gets every line once
            for (int i = 0; i < SelectedStation.Platforms.Count; i++)
            {
                if (i % 2 == 0)
                {
                    listLines.Add(SelectedStation.Platforms.ElementAt(i));
                }
            }

            // lists all possible lines
            listLines.ForEach(x => Console.WriteLine("- " + x.Name));

            Console.WriteLine("\nPlease enter the desired plattform (e.g. 14A):");
            var plattform = Console.ReadLine();;

            var StationLines = SelectedStation.Platforms.FindAll(x => x.Name.Equals(plattform));

            foreach (var x in StationLines)
            {
                listRbls.Add(x.RblNumber);
            }

            //Create a Parameters object to include the Rbls  and get Realtime Data for them
            var parameters = new Parameters.MonitorParameters()
            {
                Rbls = listRbls
            };

            //Get the monitor informatino asynchronous, and save them as MonitorData class
            var monitorInfo = await rtd.GetMonitorDataAsync(parameters);

            foreach (var m in monitorInfo.Data.Monitors)
            {
                foreach (var lineIterate in m.Lines)
                {
                    if (lineIterate.Name.Equals(plattform))
                    {
                        Console.WriteLine();
                        Console.WriteLine(lineIterate.Name + " " + lineIterate.Towards);
                        lineIterate.Departures.Departure.ForEach(x => Console.WriteLine(" " + x.DepartureTime.TimePlanned.Normalize().Substring(11, 5)));
                    }
                }
            }



            //Get the planned arrival time for the first line and the next vehicle arriving (index at Departure)
            //var plannedTime = monitorInfo.Data.Monitors[0].Lines[0].Departures.Departure[0].DepartureTime.TimePlanned;


            Console.WriteLine("Finished");
            Console.ReadKey();
        }