public MainPage()
		{
			InitializeComponent();

			// Repository für Laden/Sync erzeugen
			repository = new NewsRepository();

			// ProgressIndicator erzeugen und anzeigen
			indicator = new ProgressIndicator();
			indicator.Text = "Lade lokale Daten...";
			indicator.IsIndeterminate = true;
			indicator.IsVisible = true;
			SystemTray.SetProgressIndicator(this, indicator);

			// Asynchrone Laden der lokalen Daten starten
			loadDataTask = repository.LoadLocalDataAsync();
		}
		/// <summary>
		/// Agent that runs a scheduled task
		/// </summary>
		/// <param name="task">
		/// The invoked task
		/// </param>
		/// <remarks>
		/// This method is called when a periodic or resource intensive task is invoked
		/// </remarks>
		protected override void OnInvoke(ScheduledTask task)
		{
			OutputAvailableMemory("Start");
						
			try
			{
				DateTime newsDate = (DateTime)IsolatedStorageSettings.ApplicationSettings["NewsDate"];
				NewsRepository repository = new NewsRepository();

				OutputAvailableMemory("Repo erzeugt");

				repository.GetNewNewsCountAsync(newsDate).ContinueWith(t =>
				{
					if (t.Status == TaskStatus.RanToCompletion)
					{
						ShellTile appTile = ShellTile.ActiveTiles.First();
						appTile.Update(new StandardTileData() { Count = t.Result });
					}

					if (task is ResourceIntensiveTask)
					{
						// Bei einem RessourceIntensiveTask alte Nachrichten löschen
						DateTime timeLimit = DateTime.Now.AddMonths(-1);
						repository.DeleteNewsOlderThan(timeLimit);
					}

					OutputAvailableMemory("Ende");
					NotifyComplete();
				});			
			}
			catch (Exception ex)
			{
				// Nichts machen
				NotifyComplete();
			}			
		}
Exemple #3
0
		private void SaveNewestNewsDate()
		{
			var repository = new NewsRepository();
			DateTime newsDate = repository.GetNewestLocalNewsDate();
			IsolatedStorageSettings.ApplicationSettings["NewsDate"] = newsDate;
			IsolatedStorageSettings.ApplicationSettings.Save();
		}