Ejemplo n.º 1
0
        /// <summary>
        /// DataServiceQuery callback method to refresh the UI.
        /// </summary>
        /// <param name="result">Async operation result.</param>
        private async void OnCourseAvailComplete(IAsyncResult result)
        {
            coursesData = new StoreData();

            try
            {
                /************************ 搜索推荐课程 *********************/
                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));
                //DataServiceQuery<COURSE_AVAIL> recCourseDsq = (DataServiceQuery<COURSE_AVAIL>)(from rc in ctx.COURSE_AVAIL
                //                                                                               where rc.ID > 5
                //                                                                               select rc);
                //TaskFactory<IEnumerable<COURSE_AVAIL>> recTF = new TaskFactory<IEnumerable<COURSE_AVAIL>>();
                //IEnumerable<COURSE_AVAIL> recCourses = await recTF.FromAsync(recCourseDsq.BeginExecute(null, null), iar => recCourseDsq.EndExecute(iar));

                foreach (var c in recCourses)
                {
                    coursesData.AddCourse(Constants.CourseRec2Course(c));
                }
                /************************ 搜索推荐课程 *********************/
            }
            catch
            {
                coursesData = new StoreData();
            }


            try
            {
                DataServiceQuery<COURSE_RECO_AVAIL> craDsq = (DataServiceQuery<COURSE_RECO_AVAIL>)(from re in ctx.COURSE_RECO_AVAIL
                                                                                                   select re);
                TaskFactory<IEnumerable<COURSE_RECO_AVAIL>> tf = new TaskFactory<IEnumerable<COURSE_RECO_AVAIL>>();
                IEnumerable<COURSE_RECO_AVAIL> recommendation = await tf.FromAsync(craDsq.BeginExecute(null, null), iar => craDsq.EndExecute(iar));
                foreach (var re in recommendation)
                {
                    coursesData.AddCourse(Constants.CourseRecAvail2Course(re));
                }
                IEnumerable<COURSE_AVAIL> courses = courseDsq.EndExecute(result);
                foreach (var c in courses)
                {
                    coursesData.AddCourse(Constants.CourseAvail2Course(c));
                }

                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    dataCategory = coursesData.GetGroupsByCategory();
                    cvs1.Source = dataCategory;
                    (SemanticZoom.ZoomedOutView as ListViewBase).ItemsSource = cvs1.View.CollectionGroups;
                    loadingProgressRing.IsActive = false;
                });
            }
            catch
            {
                ShowMessageDialog("on course avail complete");
                // Network Connection error.
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// DataServiceQuery callback method to refresh the UI.
        /// </summary>
        /// <param name="result">Async operation result.</param>
        private async void OnCourseAvailComplete(IAsyncResult result)
        {
            coursesData = new StoreData();

            try
            {
                /************************ 搜索推荐课程 *********************/
                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));

                //DataServiceQuery<COURSE_AVAIL> recCourseDsq = (DataServiceQuery<COURSE_AVAIL>)(from rc in ctx.COURSE_AVAIL
                //                                                                               where rc.ID > 5
                //                                                                               select rc);
                //TaskFactory<IEnumerable<COURSE_AVAIL>> recTF = new TaskFactory<IEnumerable<COURSE_AVAIL>>();
                //IEnumerable<COURSE_AVAIL> recCourses = await recTF.FromAsync(recCourseDsq.BeginExecute(null, null), iar => recCourseDsq.EndExecute(iar));

                foreach (var c in recCourses)
                {
                    coursesData.AddCourse(Constants.CourseRec2Course(c));
                }
                /************************ 搜索推荐课程 *********************/
            }
            catch
            {
                coursesData = new StoreData();
            }


            try
            {
                DataServiceQuery <COURSE_RECO_AVAIL> craDsq = (DataServiceQuery <COURSE_RECO_AVAIL>)(from re in ctx.COURSE_RECO_AVAIL
                                                                                                     select re);
                TaskFactory <IEnumerable <COURSE_RECO_AVAIL> > tf = new TaskFactory <IEnumerable <COURSE_RECO_AVAIL> >();
                IEnumerable <COURSE_RECO_AVAIL> recommendation    = await tf.FromAsync(craDsq.BeginExecute(null, null), iar => craDsq.EndExecute(iar));

                foreach (var re in recommendation)
                {
                    coursesData.AddCourse(Constants.CourseRecAvail2Course(re));
                }
                IEnumerable <COURSE_AVAIL> courses = courseDsq.EndExecute(result);
                foreach (var c in courses)
                {
                    coursesData.AddCourse(Constants.CourseAvail2Course(c));
                }

                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    dataCategory = coursesData.GetGroupsByCategory();
                    cvs1.Source  = dataCategory;
                    (SemanticZoom.ZoomedOutView as ListViewBase).ItemsSource = cvs1.View.CollectionGroups;
                    loadingProgressRing.IsActive = false;
                });
            }
            catch
            {
                ShowMessageDialog("on course avail complete");
                // Network Connection error.
            }
        }