public async Task UpdateParkingLotListAsync(MetaDataCityRow city, City data) { if (_phrases == null) { _phrases = await _loadPhrasesTask; } if (data?.Lots != null) { try { var commandSet = GetCurrentCommandSet(); if (commandSet != null) { _phrases.UpdateParkingLots(city, data.Lots); await commandSet.SetPhraseListAsync("parking_lot", _phrases.GetParkingLotPhraseList()); _storage.SaveVoiceCommandPhrases(_phrases); } } catch (Exception e) { _tracking.TrackException(e, new Dictionary <string, string> { { "type", "update_parkinglot_list" }, { "handled", "true" } }); } } }
public void TrackReloadCityEvent(MetaDataCityRow city) { var properties = new Dictionary <string, string> { { "city", city.Id }, }; _client.TrackEvent("Reload city", properties); _tracker.SendEvent("ui_action", "reload_city", city.Id, 0); }
public void TrackSelectCityEvent(MetaDataCityRow city) { var properties = new Dictionary <string, string> { { "city", city?.Id }, }; _client.TrackEvent("Select city", properties); _tracker.SendEvent("ui_action", "select_city", city?.Id, 0); }
public void TrackSelectParkingLotEvent(MetaDataCityRow city, ParkingLot parkingLot) { var properties = new Dictionary <string, string> { { "city", city?.Id }, { "parkingLot", parkingLot?.Id } }; _client.TrackEvent("Select parking lot", properties); _tracker.SendEvent("ui_action", "select_parking_lot", city?.Id + " > " + parkingLot?.Id, 0); }
public void TrackNavigateToParkingLotEvent(MetaDataCityRow city, ParkingLot parkingLot) { var properties = new Dictionary <string, string> { { "city", city.Id }, { "parkingLot", parkingLot.Id } }; _client.TrackEvent("Navigate to parking lot", properties); _tracker.SendEvent("ui_action", "navigate_to_parking_lot", city.Id + " > " + parkingLot.Id, 0); }
public static void UpdateParkingLots(this VoiceCommandPhrases phrase, MetaDataCityRow city, IEnumerable <ParkingLot> lots) { var item = phrase.Cities.FirstOrDefault(x => x.Id == city.Id); if (item != null) { item.ParkingLots = lots.Select(x => new VoiceCommandCityPhrase { Id = x.Id, Name = x.Name }).ToList(); } }
public static void UpdateCity(this VoiceCommandPhrases phrase, MetaDataCityRow city) { var item = phrase.Cities.FirstOrDefault(x => x.Id == city.Id); if (item == null) { item = new VoiceCommandMetaDataPhrase { Id = city.Id }; phrase.Cities.Add(item); } item.Name = city.Name; }
public MainViewModel(IParkenDdClient client, VoiceCommandService voiceCommandService, JumpListService jumpList, ParkingLotListFilterService filterService, SettingsService settings, StorageService storage, GeolocationService geo, TrackingService tracking, ExceptionService exceptionService) { _client = client; _voiceCommands = voiceCommandService; _jumpList = jumpList; _filterService = filterService; _settings = settings; _storage = storage; _geo = geo; _tracking = tracking; _exceptionService = exceptionService; Messenger.Default.Register(this, (SettingChangedMessage msg) => { if (msg.IsSetting(nameof(_settings.ShowExperimentalCities))) { var temp = SelectedCity; _selectedCity = null; RaisePropertyChanged(() => SelectedCity); RaisePropertyChanged(() => MetaDataCities); _selectedCity = temp; RaisePropertyChanged(() => SelectedCity); } }); PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(MetaDataCities)) { UpdateServiceData(); } }; NetworkInformation.NetworkStatusChanged += sender => { UpdateInternetAvailability(); }; UpdateInternetAvailability(); }
public void HandleApiExceptionForForecastData(ApiException e, MetaDataCityRow city, ParkingLot lot) { _tracking.TrackException(e, new Dictionary <string, string>() { { "handled", "true" }, { "type", "forecast" }, { "city", city?.Id }, { "lot", lot?.Id } }); var mailStr = string.Format(EmailFormat, ContactEmail, Uri.EscapeDataString(string.Format(_res.ExceptionMailForecastSubject, lot?.Name, city?.Name)), Uri.EscapeDataString(string.Format(_res.ExceptionMailForecastBody, lot?.Name, city?.Name, e.Message)) ); var content = new ToastContent { Launch = "handledForecastApiException", Visual = new ToastVisual { TitleText = new ToastText { Text = _res.ExceptionToastTitle }, BodyTextLine1 = new ToastText { Text = string.Format(_res.ExceptionToastForecastContent, lot?.Name, city?.Name) } }, Actions = new ToastActionsCustom { Buttons = { new ToastButton(_res.ExceptionToastShowInBrowserButton, city?.Url.ToString()) { ActivationType = ToastActivationType.Protocol, }, new ToastButton(_res.ExceptionToastContactDevButton, mailStr) { ActivationType = ToastActivationType.Protocol, } } } }; ShowToast(content); }
private async Task <City> GetCity(string cityId, bool forceServerRefresh = false, MetaDataCityRow cityMetaData = null) { if (_cityLoading.ContainsKey(cityId) && _cityLoading[cityId] != null && !_cityLoading[cityId].IsFaulted && !_cityLoading[cityId].IsCompleted && !_cityLoading[cityId].IsCanceled) { if (!forceServerRefresh || _initialized) { return(await _cityLoading[cityId]); } } _cityLoading[cityId] = Task.Run(async() => { Debug.WriteLine("[MainVm] GetCity for {0} (forcerefresh={1})", cityId, forceServerRefresh); if (!forceServerRefresh) { var offlineCity = await GetOfflineCityData(cityId); if (offlineCity != null) { Debug.WriteLine("[MainVm] GetCity for {0} (forcerefresh={1}): found offline data", cityId, forceServerRefresh); return(offlineCity); } } if (!InternetAvailable) { Debug.WriteLine( "[MainVm] GetCity for {0} (forcerefresh={1}): internet not available, returning null", cityId, forceServerRefresh); return(null); } Debug.WriteLine("[MainVm] GetCity for {0} (forcerefresh={1}): perform request", cityId, forceServerRefresh); City city; try { city = await _client.GetCityAsync(cityId); } catch (ApiException e) { _exceptionService.HandleApiExceptionForCityData(e, MetaData.Cities.Get(cityId)); return(null); } Debug.WriteLine("[MainVm] GetCity for {0} (forcerefresh={1}): got response", cityId, forceServerRefresh); _cityHasOnlineData[cityId] = true; await Task.Run(() => { Task.Factory.StartNew(async() => { await Task.Delay(4000); _storage.SaveCityData(cityId, city); }); Task.Factory.StartNew(async() => { await Task.Delay(2000); _voiceCommands.UpdateParkingLotList(cityMetaData ?? SelectedCity, city); }); }); return(city); }); return(await _cityLoading[cityId]); }
private void CityChosen(MetaDataCityRow city) { SelectedCity = city; }
public async void UpdateParkingLotList(MetaDataCityRow city, City data) { await UpdateParkingLotListAsync(city, data); }