示例#1
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            categoryName = e.Parameter as string;
            Title.Text = Constants.UpperInitialChar(categoryName);
            loadingProgressRing.IsActive = true;

            /****** 这里是所有推荐课程的搜索 ***/
            if (categoryName.Equals("Recommendation"))
            {
                TaskFactory<IEnumerable<COURSE_AVAIL>> tfRec = new TaskFactory<IEnumerable<COURSE_AVAIL>>();

                IEnumerable<COURSE_AVAIL> recCourses = await tfRec.FromAsync(ctx.BeginExecute<COURSE_AVAIL>(
                    new Uri("/GetRecommendedCourses?customer_id=" + Constants.User.ID, UriKind.Relative), null, null),
                    iar => ctx.EndExecute<COURSE_AVAIL>(iar));


                categoryCourses = new StoreData();
                foreach (var c in recCourses)
                {
                    categoryCourses.AddCourse(Constants.CourseRec2Course(c));
                }
                dataCategory = categoryCourses.GetSingleGroupByCategoryTitle(categoryName);
                cvs1.Source = dataCategory;
                loadingProgressRing.IsActive = false;


                //courseDsq = (DataServiceQuery<COURSE_AVAIL>)(from course in ctx.COURSE_AVAIL
                //                                             where course.ID > 5
                //                                             select course);
                //courseDsq.BeginExecute(OnRecommendationMannualCoursesComplete, null);
            }
            else
            {

                if (Constants.CategoryNameList.Contains(categoryName))
                {
                    courseDsq = (DataServiceQuery<COURSE_AVAIL>)(from course_avail in ctx.COURSE_AVAIL
                                                                 where course_avail.CATE_NAME == categoryName
                                                                 select course_avail);
                    courseDsq.BeginExecute(OnCategoryCoursesComplete, null);
                }
                else
                {
                    recDsq = (DataServiceQuery<COURSE_RECO_AVAIL>)(from re in ctx.COURSE_RECO_AVAIL
                                                                   where re.RECO_TITLE == categoryName
                                                                   select re);
                    recDsq.BeginExecute(OnRecommendationCoursesComplete, null);
                }
            }
            UserProfileBt.DataContext = Constants.User;
        }
示例#2
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            categoryName = e.Parameter as string;
            Title.Text   = Constants.UpperInitialChar(categoryName);
            loadingProgressRing.IsActive = true;

            /****** 这里是所有推荐课程的搜索 ***/
            if (categoryName.Equals("Recommendation"))
            {
                TaskFactory <IEnumerable <COURSE_AVAIL> > tfRec = new TaskFactory <IEnumerable <COURSE_AVAIL> >();

                IEnumerable <COURSE_AVAIL> recCourses = await tfRec.FromAsync(ctx.BeginExecute <COURSE_AVAIL>(
                                                                                  new Uri("/GetRecommendedCourses?customer_id=" + Constants.User.ID, UriKind.Relative), null, null),
                                                                              iar => ctx.EndExecute <COURSE_AVAIL>(iar));


                categoryCourses = new StoreData();
                foreach (var c in recCourses)
                {
                    categoryCourses.AddCourse(Constants.CourseRec2Course(c));
                }
                dataCategory = categoryCourses.GetSingleGroupByCategoryTitle(categoryName);
                cvs1.Source  = dataCategory;
                loadingProgressRing.IsActive = false;


                //courseDsq = (DataServiceQuery<COURSE_AVAIL>)(from course in ctx.COURSE_AVAIL
                //                                             where course.ID > 5
                //                                             select course);
                //courseDsq.BeginExecute(OnRecommendationMannualCoursesComplete, null);
            }
            else
            {
                if (Constants.CategoryNameList.Contains(categoryName))
                {
                    courseDsq = (DataServiceQuery <COURSE_AVAIL>)(from course_avail in ctx.COURSE_AVAIL
                                                                  where course_avail.CATE_NAME == categoryName
                                                                  select course_avail);
                    courseDsq.BeginExecute(OnCategoryCoursesComplete, null);
                }
                else
                {
                    recDsq = (DataServiceQuery <COURSE_RECO_AVAIL>)(from re in ctx.COURSE_RECO_AVAIL
                                                                    where re.RECO_TITLE == categoryName
                                                                    select re);
                    recDsq.BeginExecute(OnRecommendationCoursesComplete, null);
                }
            }
            UserProfileBt.DataContext = Constants.User;
        }
示例#3
0
 private async void OnRecommendationCoursesComplete(IAsyncResult result)
 {
     categoryCourses = new StoreData();
     try
     {
         IEnumerable<COURSE_RECO_AVAIL> courses = recDsq.EndExecute(result);
         foreach (var c in courses)
         {
             categoryCourses.AddCourse(Constants.CourseRecAvail2Course(c));
         }
         await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             dataCategory = categoryCourses.GetSingleGroupByCategoryTitle(categoryName);
             cvs1.Source = dataCategory;
             loadingProgressRing.IsActive = false;
         });
     }
     catch
     {
         ShowMessageDialog();
     }
 }
示例#4
0
 /// <summary>
 /// DataServiceQuery callback method to refresh the UI.
 /// </summary>
 /// <param name="result">Async operation result.</param>
 private async void OnCategoryCoursesComplete(IAsyncResult result)
 {
     categoryCourses = new StoreData();
     try
     {
         IEnumerable <COURSE_AVAIL> courses = courseDsq.EndExecute(result);
         foreach (var c in courses)
         {
             categoryCourses.AddCourse(Constants.CourseAvail2Course(c));
         }
         await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             dataCategory = categoryCourses.GetSingleGroupByCategoryTitle(categoryName);
             cvs1.Source  = dataCategory;
             loadingProgressRing.IsActive = false;
         });
     }
     catch
     {
         ShowMessageDialog();
     }
 }