// // Uaktualnia kafelek na ekranie startowym // private void TileAdministrator(MediboxDataContext dc) { /* * CEL: * Uaktualnia kafelek na ekranie startowy * * PARAMETRU: * dc:MediboxDataContext - dataContext */ // Zwróć liczbę zadań w bazie int allTasksCount = (from at in dc.MediTasksTable select at).Count(); // Koniec dnia DateTime endDay = DateTime.Today.AddHours(24); // Liczba zadań do końca dnia int currentTasksCount = (from ct in dc.MediTasksTable where (ct.StartDate > DateTime.Now) && (ct.StartDate < endDay) select ct).Count(); // Domyślny kafelek na ekranie start ShellTile currentTile = ShellTile.ActiveTiles.First(); // Nowy kafelek Iconic IconicTileData newTile = new IconicTileData(); // Ustaw kafelek newTile.Title = "Medibox"; newTile.Count = currentTasksCount; newTile.BackgroundColor = System.Windows.Media.Colors.Red; //newTile.IconImage = new Uri("/Assets/Tiles/IconicTileMediumLarge.png", UriKind.Relative); //newTile.SmallIconImage = new Uri("/Assets/Tiles/IconicTileSmall.png", UriKind.Relative); // Jeśli allTasksCount > 0 to dodaj informacje // Jeśli allTasksCount == 0 to nie dodawaj informacji if (allTasksCount > 0) { // Następne zadanie MediTask nextTask = (from ct in dc.MediTasksTable where ct.StartDate > DateTime.Now orderby ct.StartDate ascending select ct).First(); // Dodaj informacje na kafelku newTile.WideContent1 = nextTask.MedicineName; newTile.WideContent2 = nextTask.ReminderContent; newTile.WideContent3 = string.Format("{0:ddd, dd MMM yyyy, HH:mm}", nextTask.StartDate); } else { // Nie dodawaj informacji na kafelku newTile.WideContent1 = ""; newTile.WideContent2 = ""; newTile.WideContent3 = ""; } // Uaktualnij kafelek currentTile.Update(newTile); }
/// <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) { // Koniec dnia DateTime endDay = DateTime.Today.AddHours(24); using (MediboxDataContext dc = new MediboxDataContext(DATA_BASE_FILE)) { // Odśwież kafelek TileAdministrator(dc); } //TODO: Tylko do testów //ShellToast Toast = new ShellToast(); //Toast.Title = "Medibox"; //Toast.Content = "Test agenta"; //Toast.Show(); NotifyComplete(); //TODO: Usunąć //ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60)); }