protected override void OnVehicleSelected() { AttentionItems.Clear(); AllItems.Clear(); var svc = Infrastructure.Container.GetInstance <IVtsWebService>(); try { List <VehicleEventViewModel> vms = svc.GetVehicleEvents(SelectedVehicle.Vin). Select(VehicleEventAssembler.FromDtoToDomainObject). Select(v => new VehicleEventViewModel(v, SelectedVehicle.Model)). ToList(); foreach (VehicleEventViewModel viewModel in vms.OrderByDescending(v => v.Date)) { AllItems.Add(viewModel); if (RequiresAttention(viewModel, vms)) { AttentionItems.Add(viewModel); } } } catch (Exception e) { ErrorWindow w = new ErrorWindow(e, "Cannot get vehicle events"); w.ShowDialog(); Log.Error(e, "Cannot get vehicle events"); } finally { StopWaiting(); } }
public void UpdateMyWeatherPage() { AttentionItems.Clear(); Dictionary <String, List <RichListItem> > allForecast = AppService.Instance.mAreaWeatherList; List <String> listAttentionArea = AppService.Instance.GetLocalAttentionAreaList(); if (allForecast == null || allForecast.Count <= 0) { if (LoadDataError != null) { LoadDataError(); } } else { foreach (String area in listAttentionArea) { if (allForecast.ContainsKey(area)) { // 找得到這個地區 List <RichListItem> items = allForecast[area]; TIMEBLOCK timeBlock = 0; if (items.Count > 0) { timeBlock = UtilityHelper.NowTargetTimeBlock(items); } if (items.Count > (int)timeBlock) { AreaWeatherListItem areaItem = new AreaWeatherListItem(); areaItem.Title = items[(int)timeBlock].Title; areaItem.Description = items[(int)timeBlock].Description; areaItem.Area = items[(int)timeBlock].Area; areaItem.Temperature = String.Format("{0}{1}", items[(int)timeBlock].Temperature, Constants.SUFFIX_TEMPERATURE); areaItem.ChanceOfRain = String.Format("{0}{1}{2}", Constants.PREFIX_CHANCE_OF_RAIN, items[(int)timeBlock].ChanceOfRain, Constants.SUFFIX_CHANCE_OF_RAIN); areaItem.StartTime = items[(int)timeBlock].StartTime; areaItem.EndTime = items[(int)timeBlock].EndTime; areaItem.ItemType = WeatherItemType.WI_TYPE_USE_APPSERVICE_DATA; areaItem.ItemTemplate = WeatherItemTemplate.WI_TEMPLATE_ATTENTION; // 這裡白寫了…因為這個 Template 只用一次 areaItem.SubItemTemplate = WeatherItemTemplate.WI_TEMPLATE_AREA; // 若點下項目,下一層要要用 AreaItem 來秀 String strWeatherImage = UtilityHelper.GetImageByWeatherDescription(areaItem.Description, areaItem.Title); areaItem.Icon = strWeatherImage; AttentionItems.Add(areaItem); } } } } NotifyPropertyChanged("MyWeatherItems"); }