Example #1
0
        private async void Refresh_Click(object sender, RoutedEventArgs e)
        {
            contentRing.IsActive = true;

            var htmlResources = await LNUWebProcess.GetLNUFromLeftRequest(MainPage.LoginClient, currentUri.ToString());

            await CacheHelpers.SaveSpecificCacheValue(MainPage.LoginCache.UserID, htmlResources);

            var nameList = DataProcess.FetchScheduleTableFromHtml(htmlResources);

            TableGrid.Children.Clear();
            // Show the schedule table
            InitTableView(nameList);

            var list = DataProcess.FetchScheduleListFromHtml(htmlResources);

            ScheduleQueue.Clear();
            ScheduleQueue.AddRange(list);
            nameList.ForEach(item => { // finish lecture message into ScheduleQueue items .
                ScheduleQueue.FindAll(i => i.Title == GetSingleTitle(item.WholeTitle)).ForEach(s => { if (s.Lecturer == null)
                                                                                                      {
                                                                                                          s.Lecturer = GetLecturerName(item.WholeTitle);
                                                                                                      }
                                                                                               });
            });

            CourseListView.ItemsSource = ScheduleQueue;

            contentRing.IsActive = false;
        }
Example #2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var args = e.Parameter as NavigateParameter;

            if (args == null || args.ToUri == null)   // make sure the navigation action is right.
            {
                ReportHelper.ReportAttention(GetUIString("WebViewLoadError"));
                return;
            }
            if (args.MessageBag as string != null)
            {
                navigateTitle = navigateTitlePath.Text = args.MessageBag as string;
            }
            contentRing.IsActive = true;
            currentUri           = args.ToUri;
            thisPageType         = args.ToFetchType;
            thisNaviType         = args.NaviType;

            var cache = await CacheHelpers.ReadSpecificCacheValue(MainPage.LoginCache.UserID);

            var htmlResources = cache ?? await LNUWebProcess.GetLNUFromLeftRequest(MainPage.LoginClient, args.ToUri.ToString());

            if (cache == null && htmlResources != null)
            {
                await CacheHelpers.SaveSpecificCacheValue(MainPage.LoginCache.UserID, htmlResources);
            }
            var nameList = DataProcess.FetchScheduleTableFromHtml(htmlResources);

            // Show the schedule table
            InitTableView(nameList);

            var list = DataProcess.FetchScheduleListFromHtml(htmlResources);

            ScheduleQueue.Clear();
            ScheduleQueue.AddRange(list);
            nameList.ForEach(item => { // finish lecture message into ScheduleQueue items .
                ScheduleQueue.FindAll(i => i.Title == GetSingleTitle(item.WholeTitle)).ForEach(s => { if (s.Lecturer == null)
                                                                                                      {
                                                                                                          s.Lecturer = GetLecturerName(item.WholeTitle);
                                                                                                      }
                                                                                               });
            });

            CourseListView.ItemsSource = ScheduleQueue;

            contentRing.IsActive = false;
        }