/// <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) { //TODO: Add code to perform your task in background if (task is PeriodicTask) { //ToastMessage = ""; } try { student = StudentData.LoadMyData("Student"); currentPeriod = student.Programs[0].Periods[0]; if (student != null && currentPeriod != null && student.ID != null && student.Password != null) { ObisisMobileServiceClient client = new ObisisMobileServiceClient(); client.GetCurrentPeriodAsync(currentPeriod, student.ID, student.Password); client.GetCurrentPeriodCompleted += client_GetCurrentPeriodCompleted; } else { NotifyComplete(); } } catch (Exception) { NotifyComplete(); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { PageCanvas = new SwipeMenu(this, PageCanvas, LayoutRoot, MoveAnimation, LeftMenu); Container.Height = App.Current.RootVisual.RenderSize.Height; if (Database.Student == null) { MessageBox.Show("Giriş yapmanız gerekiyor.."); NavigationService.Navigate(new Uri("/LoginPage.xaml", UriKind.Relative)); } else { code = NavigationContext.QueryString.ContainsKey("Code") ? Convert.ToInt32(NavigationContext.QueryString["Code"]) : 0; yearCode = NavigationContext.QueryString.ContainsKey("YearCode") ? Convert.ToInt32(NavigationContext.QueryString["YearCode"]) : 0; Period currentPeriod = Database.Student.Programs[0].Periods.First(); if ((code == 0 && yearCode == 0) || (code == currentPeriod.Code && yearCode == currentPeriod.YearCode)) { code = currentPeriod.Code; yearCode = currentPeriod.YearCode; Container.DataContext = currentPeriod; if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType != Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None) { try { ProgressIndicator indicator = new ProgressIndicator(); indicator.IsIndeterminate = true; indicator.IsVisible = true; indicator.Text = "Dersler güncelleniyor.."; ObisisMobileServiceClient client = new ObisisMobileServiceClient(); client.GetCurrentPeriodAsync(currentPeriod, Database.Student.ID, Database.Student.Password); client.GetCurrentPeriodCompleted += client_GetCurrentPeriodCompleted; SystemTray.SetProgressIndicator(this, indicator); } catch (Exception) { if (SystemTray.ProgressIndicator != null) { SystemTray.ProgressIndicator.IsVisible = false; } } } } else { Container.DataContext = Database.Student.Programs[0].Periods.SingleOrDefault(x => x.Code == code && x.YearCode == yearCode); } Lessons.SelectedItem = null; } base.OnNavigatedTo(e); }