Esempio n. 1
0
        internal void InitValues(string from, string to, string via, bool keepValues, DateTime?dateTime)
        {
            Settings = SettingService.GetSettings();

            if (!keepValues && !string.IsNullOrEmpty(from))
            {
                VanStation = StationNameService.GetStationByName(from);
                if (VanStation == null)
                {
                    VanStation = StationNameService.GetStationByCode(from);
                }
            }
            else if (!keepValues)
            {
                VanStation = null;
                GetGpsStation();
            }

            if (!keepValues && !string.IsNullOrEmpty(to))
            {
                NaarStation = StationNameService.GetStationByName(to);
            }
            else if (!keepValues)
            {
                NaarStation = null;
            }

            if (!keepValues && !string.IsNullOrEmpty(via))
            {
                ViaStation = StationNameService.GetStationByName(via);
            }
            else if (!keepValues)
            {
                ViaStation = null;
            }

            if (!keepValues)
            {
                if (dateTime.HasValue)
                {
                    Date = dateTime.Value.Date;
                    Time = dateTime.Value;
                }
                else
                {
                    Date = DateTime.Now;
                    Time = DateTime.Now;
                }

                IsYearCard     = Settings.HasYearCard;
                IsHogesnelheid = Settings.UseHsl;
                IsViaVisible   = false;
            }

            StationList.Clear();
        }
        public async void Initialize(string ritId, string company, string trein, string richting, string stationCode)
        {
            PageName = trein;
            Richting = _resourceLoader.GetString("RitInfoViewModelRichting") + " " + richting;
            RitStops = new List <RitInfoStop>();

            RitStops = await DataLoader.LoadAsync(async() =>
            {
                var serviceInfo = await RitnummerService.GetRit(ritId, company, DateTime.Now);

                List <RitInfoStop> stops = null;

                if (serviceInfo.FirstOrDefault() != null)
                {
                    stops = serviceInfo.First().Stops;

                    //Fill station name for each stop
                    foreach (var stop in stops)
                    {
                        var station = StationNameService.GetStationByCode(stop.Code);
                        if (station != null)
                        {
                            stop.Station = station.Name;
                        }

                        if (stop.Code.ToLower() == stationCode.ToLower())
                        {
                            stop.IsCurrent = true;
                        }
                    }
                }

                return(stops);
            });

            if (RitStops == null || !RitStops.Any())
            {
                RitStops = null;
                DataLoader.LoadingState = LoadingState.Error;
            }

            if (RitStops != null && RitInfoAvailable != null)
            {
                RitInfoAvailable(null, null);
            }
        }
Esempio n. 3
0
        public async void Initialize(string ritId, string company, string trein, string richting, string stationCode)
        {
            PageName = trein;

            if (!string.IsNullOrEmpty(richting))
            {
                Richting = AppResources.RitInfoViewModelRichting + " " + richting;
            }

            RitStops     = new List <RitInfoStop>();
            TreinInfo    = null;
            _stationCode = stationCode;

            var ritStopsLoader = DataLoader.LoadAsync(async() =>
            {
                var serviceInfo = await RitnummerService.GetRit(ritId, company, DateTime.Now);

                List <RitInfoStop> stops = null;

                if (serviceInfo.FirstOrDefault() != null)
                {
                    stops = serviceInfo.First().Stops;

                    //Fill station name for each stop
                    foreach (var stop in stops)
                    {
                        var station = StationNameService.GetStationByCode(stop.Code);
                        if (station != null)
                        {
                            stop.Station = station.Name;
                        }

                        if (stop.Code.ToLower() == stationCode.ToLower())
                        {
                            stop.IsCurrent = true;
                            _vertrekTijd   = stop.Departure;
                        }
                    }
                }

                return(stops);
            });

            //Start loading treinfo (but dont await yet)
            var treinInfoLoader = RitnummerService.GetTreinInfo(ritId);

            RitStops = await ritStopsLoader;

            if (RitStops == null || !RitStops.Any())
            {
                RitStops = null;
                DataLoader.LoadingState = LoadingState.Error;
            }

            if (RitStops != null && RitInfoAvailable != null)
            {
                RitInfoAvailable(null, null);
            }

            try
            {
                //Optional Treinfo
                TreinInfo = await treinInfoLoader;
            }
            catch { }
        }