public CurrentGasPricesViewModelDT() { FuelType = FuelTypeEnum.Diesel; LocationName = "Leoben"; QueryResult = new GasQueryResult(); QueryResult.GasStationResults.Add(new GasStationResult() { Name = "Fantasy Brand Gas Station", Price = 1.28, City = "Leoben", PostalCode = "8700", Street = "Some street 21" }); }
public async Task <bool> AddResultAsync(GasQueryResult result) { try { var existingErgebnisse = await LoadResultsAsync(); existingErgebnisse.Add(result); bool saveOk = await SaveResultsAsync(existingErgebnisse); return(saveOk); } catch (Exception) { return(false); } }
private void SetQueryResultToGeocodeResult(GasQueryResult currentQueryResult) { if (currentQueryResult != null) { var result = new GasQueryResult(currentQueryResult); if (_geocodeResult != null) { result.GeocodeLatitude = _geocodeResult.Latitude; result.GeocodeLongitude = _geocodeResult.Longitude; result.Name = _geocodeResult.Name; } QueryResult = result; return; } QueryResult = currentQueryResult; }
public async Task NotifyGasQueryResultChanged(GasQueryResult currentResult) { string tileId = currentResult.UniqueId; bool isCurrentlyPinned = SecondaryTile.Exists(tileId); if (isCurrentlyPinned) { string details = String.Format("{0} ({1})", currentResult.Name, currentResult.LastUpdatedFormatted); // http://msdn.microsoft.com/en-us/library/windows/apps/hh761491.aspx var wideTile = TileContentFactory.CreateTileWideText09(); wideTile.TextHeading.Text = currentResult.PriceAtCheapestGasStation.ToString(); wideTile.TextBodyWrap.Text = details; var squareTile = TileContentFactory.CreateTileSquareText02(); squareTile.TextHeading.Text = currentResult.PriceAtCheapestGasStation.ToString(); squareTile.TextBodyWrap.Text = details; wideTile.SquareContent = squareTile; TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId) .Update(wideTile.CreateNotification()); } }
public async Task <GasQueryRefreshResult> RefreshAsync() { bool bExceptionInExecution = false; try { // Show activitiy var badgeContent = new BadgeGlyphNotificationContent(GlyphValue.Activity); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification()); // TODO: Work with roaming parameters as well as local results var existingResults = await LoadResultsAsync(); var taskList = new List <Task <GasQueryDownloadResult> >(); foreach (GasQueryResult current in existingResults) { var copyForClosure = current; var task = new Task <GasQueryDownloadResult>(() => CreateGasPriceInfoProxy().DownloadAsync(copyForClosure).Result); taskList.Add(task); task.Start(); } await Task.WhenAll(taskList); List <GasQueryResult> returnedResults = new List <GasQueryResult>(); var notify = CreateResultChangedNotification(); foreach (var current in taskList) { var downloadResult = current.Result; GasQueryResult currentResult = downloadResult.Result; if (downloadResult.Succeeded) { returnedResults.Add(currentResult); await notify.NotifyGasQueryResultChanged(currentResult); } else { // Keep the old information around instead var oldToReuse = existingResults.Single(r => r.UniqueId == currentResult.UniqueId); returnedResults.Add(oldToReuse); } } bool saveOk = await SaveResultsAsync(returnedResults); return(new GasQueryRefreshResult() { Succeeded = true, Results = returnedResults }); } catch (Exception) { bExceptionInExecution = false; } finally { BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear(); } return(new GasQueryRefreshResult() { Succeeded = false, Results = null }); }
public void SetViewModelToResult(GasQueryResult item) { QueryResult = item; SendUpdateMapNotification(); }
public SampleDataSource() { var se = new GasQueryResult() { UniqueId = "S1-Leoben-TestData", FuelType = FuelTypeEnum.Diesel, Longitude1 = 15.051175814518464, Latitude1 = 47.36476416660497, Longitude2 = 15.13108418548611, Latitude2 = 47.38801327070198, GeocodeLongitude = 15.093971, GeocodeLatitude = 47.3827604, Name = "Leoben / Steiermark", LastUpdated = default(DateTime) }; se.GasStationResults.Add(new GasStationResult() { Name = "Beispieldaten: Markentankstelle", PostalCode = "8700", Price = 0.0f }); SuchErgebnisse.Add(se); se = new GasQueryResult() { UniqueId = "S2-Leoben-TestData", FuelType = FuelTypeEnum.Super, Longitude1 = 15.051175814518464, Latitude1 = 47.36476416660497, Longitude2 = 15.13108418548611, Latitude2 = 47.38801327070198, GeocodeLongitude = 15.093971, GeocodeLatitude = 47.3827604, Name = "Leoben / Steiermark", LastUpdated = default(DateTime) }; se.GasStationResults.Add(new GasStationResult() { Name = "Beispieldaten: Freie Tankstelle", PostalCode = "8700", Price = 0.0f }); SuchErgebnisse.Add(se); _geocodeResults.Add(new GeocodeResult() { Name = "Leoben / Austria", Latitude = 47.3827604, Longitude = 15.093971 }); // Fuel Actions _fuelTypeActions.Add(new FuelTypeAction() { FuelType = FuelTypeEnum.Diesel }); _fuelTypeActions.Add(new FuelTypeAction() { FuelType = FuelTypeEnum.Super }); // Main Page Actions _mainpageActions = MainPageAction.GenerateMainPageActions(); }