Пример #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)
        {

            try
            {
                teachDsq = (DataServiceQuery<COURSE_AVAIL>)(from course in ctx.COURSE_AVAIL
                                                            where course.TEACHER_NAME == Constants.User.NAME
                                                            select course);

                TaskFactory<IEnumerable<COURSE_AVAIL>> tf = new TaskFactory<IEnumerable<COURSE_AVAIL>>();


                IEnumerable<COURSE_AVAIL> attends = await tf.FromAsync(ctx.BeginExecute<COURSE_AVAIL>(
                    new Uri("/GetAllCoursesAttendedByCustomer?customer_id=" + Constants.User.ID, UriKind.Relative), null, null),
                    iar => ctx.EndExecute<COURSE_AVAIL>(iar));
                IEnumerable<COURSE_AVAIL> teaches = await tf.FromAsync(teachDsq.BeginExecute(null, null), iar => teachDsq.EndExecute(iar));


                courseData = new StoreData();
                foreach (var c in attends)
                {
                    Course tmpCourse = Constants.CourseAvail2Course(c);
                    tmpCourse.IsBuy = true;
                    tmpCourse.IsTeach = false;
                    courseData.AddCourse(tmpCourse);
                }
                foreach (var c in teaches)
                {
                    Course tmpCourse = Constants.CourseAvail2Course(c);
                    tmpCourse.IsTeach = true;
                    tmpCourse.IsBuy = false;
                    courseData.AddCourse(tmpCourse);
                }

                dataCategory = courseData.GetGroupsByAttendingOrTeaching();
                cvs1.Source = dataCategory;
                UserProfileBt.DataContext = Constants.User;

            }
            catch
            {
                ShowMessageDialog("on navi to");
            }
            
        }
Пример #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
        private async void OnSearchResultComplete(IAsyncResult result)
        {
            storeSearchResult = new StoreData();
            try
            {
                IEnumerable<COURSE_AVAIL> courses = courseDsq.EndExecute(result);

                foreach (var c in courses)
                {
                    storeSearchResult.AddCourse(Constants.CourseAvail2Course(c));
                }
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        searchResults = storeSearchResult.GetSearchResultGroup(searchString);
                        cvs1.Source = searchResults;
                        loadingProgressRing.IsActive = false;
                    });
            }
            catch
            {
                ShowMessageDialog();
            }
        }
Пример #5
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.
            }
        }
Пример #6
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.
            }
        }
Пример #7
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)
        {
            SetAllTextBlock();
            allCourses = new List<Course>();
            loadingProgressRing.IsActive = true;

            var borders = from b in topograph.Children.OfType<Border>()
                          select b;

            List<string> courseNameList = new List<string>();
            List<CloudEDU.Common.Constants.CourseAvaiStates> courseStatesList = new List<Constants.CourseAvaiStates>();
            foreach (Border border in borders)
            {
                TextBlock textBlock = border.Child as TextBlock;
                string courseShowName = textBlock.Text.Replace("\n", " ");
                courseNameList.Add(textBlock.Text);
                courseStatesList.Add(Constants.DepCourse.GetCourseLearnedState(courseShowName));
            }
            SetAllCoursesStates(courseNameList, courseStatesList);


            SetCourseState("Compute\nArchitecture", Constants.CourseAvaiStates.NotLearnedDisable);

            try
            {
                teachDsq = (DataServiceQuery<COURSE_AVAIL>)(from course in ctx.COURSE_AVAIL
                                                            where course.TEACHER_NAME == Constants.User.NAME
                                                            select course);

                TaskFactory<IEnumerable<COURSE_AVAIL>> tf = new TaskFactory<IEnumerable<COURSE_AVAIL>>();

                IEnumerable<COURSE_AVAIL> attends = await tf.FromAsync(ctx.BeginExecute<COURSE_AVAIL>(
                    new Uri("/GetAllCoursesAttendedByCustomer?customer_id=" + Constants.User.ID, UriKind.Relative), null, null),
                    iar => ctx.EndExecute<COURSE_AVAIL>(iar));
                IEnumerable<COURSE_AVAIL> teaches = await tf.FromAsync(teachDsq.BeginExecute(null, null), iar => teachDsq.EndExecute(iar));

                DataServiceQuery<COURSE_AVAIL> allCoursesDsq = (DataServiceQuery<COURSE_AVAIL>)(from c in ctx.COURSE_AVAIL
                                                                                                select c);
                IEnumerable<COURSE_AVAIL> allCoursesEnum = await tf.FromAsync(allCoursesDsq.BeginExecute(null, null), iar => allCoursesDsq.EndExecute(iar));
                foreach (var c in allCoursesEnum)
                {
                    Course tmpCourse = Constants.CourseAvail2Course(c);
                    allCourses.Add(tmpCourse);
                }

                courseData = new StoreData();
                foreach (var c in attends)
                {
                    Course tmpCourse = Constants.CourseAvail2Course(c);
                    tmpCourse.IsBuy = true;
                    tmpCourse.IsTeach = false;
                    courseData.AddCourse(tmpCourse);
                }
                foreach (var c in teaches)
                {
                    Course tmpCourse = Constants.CourseAvail2Course(c);
                    tmpCourse.IsTeach = true;
                    tmpCourse.IsBuy = false;
                    courseData.AddCourse(tmpCourse);
                }

                dataCategory = courseData.GetGroupsByAttendingOrTeaching();
                cvs1.Source = dataCategory;
                UserProfileBt.DataContext = Constants.User;

            }
            catch
            {
                ShowMessageDialog("on navi to");
            }

            loadingProgressRing.IsActive = false;
        }
Пример #8
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)
        {
            SetAllTextBlock();
            allCourses = new List <Course>();
            loadingProgressRing.IsActive = true;

            var borders = from b in topograph.Children.OfType <Border>()
                          select b;

            List <string> courseNameList = new List <string>();
            List <CloudEDU.Common.Constants.CourseAvaiStates> courseStatesList = new List <Constants.CourseAvaiStates>();

            foreach (Border border in borders)
            {
                TextBlock textBlock      = border.Child as TextBlock;
                string    courseShowName = textBlock.Text.Replace("\n", " ");
                courseNameList.Add(textBlock.Text);
                courseStatesList.Add(Constants.DepCourse.GetCourseLearnedState(courseShowName));
            }
            SetAllCoursesStates(courseNameList, courseStatesList);


            SetCourseState("Compute\nArchitecture", Constants.CourseAvaiStates.NotLearnedDisable);

            try
            {
                teachDsq = (DataServiceQuery <COURSE_AVAIL>)(from course in ctx.COURSE_AVAIL
                                                             where course.TEACHER_NAME == Constants.User.NAME
                                                             select course);

                TaskFactory <IEnumerable <COURSE_AVAIL> > tf = new TaskFactory <IEnumerable <COURSE_AVAIL> >();

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

                IEnumerable <COURSE_AVAIL> teaches = await tf.FromAsync(teachDsq.BeginExecute(null, null), iar => teachDsq.EndExecute(iar));

                DataServiceQuery <COURSE_AVAIL> allCoursesDsq = (DataServiceQuery <COURSE_AVAIL>)(from c in ctx.COURSE_AVAIL
                                                                                                  select c);
                IEnumerable <COURSE_AVAIL> allCoursesEnum = await tf.FromAsync(allCoursesDsq.BeginExecute(null, null), iar => allCoursesDsq.EndExecute(iar));

                foreach (var c in allCoursesEnum)
                {
                    Course tmpCourse = Constants.CourseAvail2Course(c);
                    allCourses.Add(tmpCourse);
                }

                courseData = new StoreData();
                foreach (var c in attends)
                {
                    Course tmpCourse = Constants.CourseAvail2Course(c);
                    tmpCourse.IsBuy   = true;
                    tmpCourse.IsTeach = false;
                    courseData.AddCourse(tmpCourse);
                }
                foreach (var c in teaches)
                {
                    Course tmpCourse = Constants.CourseAvail2Course(c);
                    tmpCourse.IsTeach = true;
                    tmpCourse.IsBuy   = false;
                    courseData.AddCourse(tmpCourse);
                }

                dataCategory = courseData.GetGroupsByAttendingOrTeaching();
                cvs1.Source  = dataCategory;
                UserProfileBt.DataContext = Constants.User;
            }
            catch
            {
                ShowMessageDialog("on navi to");
            }

            loadingProgressRing.IsActive = false;
        }