/// <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) { course = e.Parameter as Course; globalRate = 0; attendDsq = (DataServiceQuery<ATTEND>)(from attend in ctx.ATTEND where attend.COURSE_ID == course.ID && attend.CUSTOMER_ID == Constants.User.ID select attend); try { TaskFactory<IEnumerable<ATTEND>> tf = new TaskFactory<IEnumerable<ATTEND>>(); IEnumerable<ATTEND> attends = await tf.FromAsync(attendDsq.BeginExecute(null, null), iar => attendDsq.EndExecute(iar)); if (attends.Count() != 0) { enterCommentStackPanel.Visibility = Visibility.Visible; } } catch { ShowMessageDialog(); } commentDsq = (DataServiceQuery<COMMENT_DET>)(from comment in ctx.COMMENT_DET where comment.COURSE_ID == course.ID orderby comment.TIME ascending select comment); commentDsq.BeginExecute(OnCommentComplete, null); }
/// <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 override void OnNavigatedTo(NavigationEventArgs e) { customerDsq = (DataServiceQuery<CUSTOMER>)(from user in ctx.CUSTOMER select user); customerDsq.BeginExecute(OnCustomerComplete, null); // auto log //if (Constants.Read<bool>("AutoLog") == true) //{ // Constants.User = User.SelectLastUser(); // // navigate // Frame.Navigate(typeof(CourseStore.Courstore)); //} //// last user //if (Constants.Read<string>("LastUser") == default(string)) //{ //} //else //{ // System.Diagnostics.Debug.WriteLine(Constants.Read<string>("LastUser")); // if (Frame.Navigate(typeof(SignUp))) // System.Diagnostics.Debug.WriteLine("suc navigate"); // else // System.Diagnostics.Debug.WriteLine("fail navigate"); //} }
/// <summary>Loads the collection asynchronously from a DataServiceQuery instance.</summary> /// <param name="query">A query of type DataServiceQuery.</param> /// <remarks>This method uses the event-based async pattern. /// The method returns immediately without waiting for the query to complete. Then it calls the handler of the /// <see cref="LoadCompleted"/> event exactly once on the UI thread. The event will be raised regradless /// if the query succeeded or not. /// This class only support one asynchronous operation in flight.</remarks> public void LoadAsync(IQueryable <T> query) { Util.CheckArgumentNull(query, "query"); DataServiceQuery <T> dsq = query as DataServiceQuery <T>; if (dsq == null) { throw new ArgumentException(Strings.DataServiceCollection_LoadAsyncRequiresDataServiceQuery, "query"); } if (this.asyncOperationInProgress) { throw new InvalidOperationException(Strings.DataServiceCollection_MultipleLoadAsyncOperationsAtTheSameTime); } if (this.trackingOnLoad) { this.StartTracking(((DataServiceQueryProvider)dsq.Provider).Context, null, this.entitySetName, this.entityChangedCallback, this.collectionChangedCallback); this.trackingOnLoad = false; } BeginLoadAsyncOperation( asyncCallback => dsq.BeginExecute(asyncCallback, null), asyncResult => { QueryOperationResponse <T> response = (QueryOperationResponse <T>)dsq.EndExecute(asyncResult); this.Load(response); return(response); }); }
/// <summary> /// 在此页将要在 Frame 中显示时进行调用。 /// </summary> /// <param name="e">描述如何访问此页的事件数据。Parameter /// 属性通常用于配置页。</param> protected override void OnNavigatedTo(NavigationEventArgs e) { //!!!!!!!!!! Constants.User.SetAttendTeachNumber(); image.DataContext = Constants.User; biggestGrid.DataContext = Constants.User; customerDsq = (DataServiceQuery<CUSTOMER>)(from user in ctx.CUSTOMER select user); customerDsq.BeginExecute(OnCustomerComplete, null); }
/// <summary> /// 在此页将要在 Frame 中显示时进行调用。 /// </summary> /// <param name="e">描述如何访问此页的事件数据。Parameter /// 属性通常用于配置页。</param> protected override void OnNavigatedTo(NavigationEventArgs e) { searchString = e.Parameter as string; loadingProgressRing.IsActive = true; courseDsq = (DataServiceQuery<COURSE_AVAIL>)(from course_avail in ctx.COURSE_AVAIL where course_avail.TITLE.Contains(searchString) select course_avail); courseDsq.BeginExecute(OnSearchResultComplete, null); UserProfileBt.DataContext = Constants.User; }
/// <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"); } }
/// <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) { course = e.Parameter as Course; sharedNoteDsq = (DataServiceQuery<NOTE_AVAIL>)(from selectNote in ctx.NOTE_AVAIL where selectNote.COURSE_ID == course.ID.Value && selectNote.SHARE == true orderby selectNote.DATE descending select selectNote); switchButton.Content = "Mine"; TaskFactory<IEnumerable<NOTE_AVAIL>> tf = new TaskFactory<IEnumerable<NOTE_AVAIL>>(); IEnumerable<NOTE_AVAIL> nas = await tf.FromAsync(sharedNoteDsq.BeginExecute(null, null), iar => sharedNoteDsq.EndExecute(iar)); sharedNotesList = nas.ToList(); foreach (var n in sharedNotesList) { allSharedNotesStackPanel.Children.Add(GenerateSharedNoteItem(n.ID, n.TITLE, n.CONTENT, n.CUSTOMER_NAME, n.DATE, n.LESSON_NUMBER, n.CUSTOMER_ID.Value)); } }
public async void SetAttendTeachNumber() { try { ctx = new CloudEDUEntities(new Uri(Constants.DataServiceURI)); teachDsq = (DataServiceQuery<COURSE_AVAIL>)(from course in ctx.COURSE_AVAIL where course.TEACHER_NAME == this.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=" + this.ID, UriKind.Relative), null, null), iar => ctx.EndExecute<COURSE_AVAIL>(iar)); ATTEND_COUNT = attends.Count(); IEnumerable<COURSE_AVAIL> teaches = await tf.FromAsync(teachDsq.BeginExecute(null, null), iar => teachDsq.EndExecute(iar)); TEACH_COUNT = teaches.Count(); } catch { ShowMessageDialog("Set Attend Teach Number "); } }
/// <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 override void OnNavigatedTo(NavigationEventArgs e) { categoryName = e.Parameter as string; Title.Text = Constants.UpperInitialChar(categoryName); loadingProgressRing.IsActive = true; 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; }
public void GetTypeByResourceID(int id, onQueryComplete onComplete) { resourceDsq = (DataServiceQuery<RESOURCE>)(ctx.RESOURCE.Where(r => r.ID == id)); this.onUQC = onComplete; resourceDsq.BeginExecute(onResComplete, null); }
public void GetResourcesByLessonId(int id, onQueryComplete onComplete) { resourceDsq = (DataServiceQuery<RESOURCE>)(ctx.RESOURCE.Where(r => r.LESSON_ID == id)); this.onUQC = onComplete; resourceDsq.BeginExecute(onQueryComplete2, null); }
public void GetNoteByLessonId(int id, onQueryComplete onComplete) { noteDsq = (DataServiceQuery<NOTE>)(from note in ctx.NOTE where note.LESSON_ID == id select note); this.onUQC = onComplete; noteDsq.BeginExecute(onQueryComplete2, null); }
public void GetNoteByCustomerID(int id, onQueryComplete onComplete) { noteDsq = (DataServiceQuery<NOTE>)(ctx.NOTE.Where(n => n.CUSTOMER_ID == id)); this.onUQC = onComplete; noteDsq.BeginExecute(onQueryComplete2, null); }
/// <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; }
/// <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 override void OnNavigatedTo(NavigationEventArgs e) { customerDsq = (DataServiceQuery<CUSTOMER>)(from user in ctx.CUSTOMER select user); customerDsq.BeginExecute(OnCustomerComplete, null); }
public void GetLessonById(int id, onQueryComplete onComplete) { lessonDsq = (DataServiceQuery<LESSON>)(from les in ctx.LESSON where les.ID == id select les); this.onUQC = onComplete; lessonDsq.BeginExecute(onQueryComplete2, null); }
/// <summary> /// Handles the Click event of the SwitchButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private async void SwitchButton_Click(object sender, RoutedEventArgs e) { Button bt = sender as Button; sharedNoteDsq = (DataServiceQuery<NOTE_AVAIL>)(from selectNote in ctx.NOTE_AVAIL where selectNote.COURSE_ID == course.ID.Value && selectNote.SHARE == true orderby selectNote.DATE descending select selectNote); myNoteDsq = (DataServiceQuery<NOTE_AVAIL>)(from myNote in ctx.NOTE_AVAIL where myNote.COURSE_ID == course.ID.Value && myNote.CUSTOMER_ID == Constants.User.ID orderby myNote.DATE descending select myNote); try { if (bt.Content.ToString() == "Mine") { bt.Content = "Shared"; myNotesStackPanel.Visibility = Visibility.Visible; allSharedNotesStackPanel.Visibility = Visibility.Collapsed; myNotesStackPanel.Children.Clear(); TaskFactory<IEnumerable<NOTE_AVAIL>> tf = new TaskFactory<IEnumerable<NOTE_AVAIL>>(); IEnumerable<NOTE_AVAIL> nas = await tf.FromAsync(myNoteDsq.BeginExecute(null, null), iar => myNoteDsq.EndExecute(iar)); mySharedNotesList = nas.ToList(); foreach (var n in mySharedNotesList) { myNotesStackPanel.Children.Add(GenerateMySharedNoteItem(n.ID, n.TITLE, n.CONTENT, n.CUSTOMER_NAME, n.DATE, n.LESSON_NUMBER)); } } else if (bt.Content.ToString() == "Shared") { bt.Content = "Mine"; myNotesStackPanel.Visibility = Visibility.Collapsed; allSharedNotesStackPanel.Visibility = Visibility.Visible; allSharedNotesStackPanel.Children.Clear(); TaskFactory<IEnumerable<NOTE_AVAIL>> tf = new TaskFactory<IEnumerable<NOTE_AVAIL>>(); IEnumerable<NOTE_AVAIL> nas = await tf.FromAsync(sharedNoteDsq.BeginExecute(null, null), iar => sharedNoteDsq.EndExecute(iar)); sharedNotesList = nas.ToList(); foreach (var n in sharedNotesList) { allSharedNotesStackPanel.Children.Add(GenerateSharedNoteItem(n.ID, n.TITLE, n.CONTENT, n.CUSTOMER_NAME, n.DATE, n.LESSON_NUMBER, n.CUSTOMER_ID.Value)); } } } catch { ShowMessageDialog("Network connection error38!"); } }
/// <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) { InitializePopupStyle(); //Constants.DepCourse.GetAllLearned(); //await Task.Delay(TimeSpan.FromSeconds(10)); //if (!Constants.DepCourse.IfLearned("Organic Chemistry")) //{ // System.Diagnostics.Debug.WriteLine("NONONONONONO"); //} //else //{ // System.Diagnostics.Debug.WriteLine("YESYESYES"); //} loadingProgressRing.IsActive = true; try { if (Constants.RecUriDic.Count == 0 && Constants.CategoryNameList.Count == 0) { try { DataServiceQuery<CATEGORY> cateDsq = (DataServiceQuery<CATEGORY>)(from cate in ctx.CATEGORY select cate); TaskFactory<IEnumerable<CATEGORY>> tfc = new TaskFactory<IEnumerable<CATEGORY>>(); IEnumerable<CATEGORY> categories = await tfc.FromAsync(cateDsq.BeginExecute(null, null), iar => cateDsq.EndExecute(iar)); foreach (var c in categories) { Constants.CategoryNameList.Add(c.CATE_NAME); } } catch { ShowMessageDialog("categories!"); } try { DataServiceQuery<RECOMMENDATION> craDsq = (DataServiceQuery<RECOMMENDATION>)(from re in ctx.RECOMMENDATION select re); TaskFactory<IEnumerable<RECOMMENDATION>> tf = new TaskFactory<IEnumerable<RECOMMENDATION>>(); IEnumerable<RECOMMENDATION> recommendation = await tf.FromAsync(craDsq.BeginExecute(null, null), iar => craDsq.EndExecute(iar)); foreach (var r in recommendation) { Constants.RecUriDic.Add(r.TITLE, r.ICON_URL); } Constants.RecUriDic.Add("Recommendation", "ms-appx:///Images/Category/Recommendation.jpg"); } catch { ShowMessageDialog("recommedations!"); } } } catch { ShowMessageDialog("On nav to"); } courseDsq = (DataServiceQuery<COURSE_AVAIL>)(from course_avail in ctx.COURSE_AVAIL select course_avail); courseDsq.BeginExecute(OnCourseAvailComplete, null); UserProfileBt.DataContext = Constants.User; //UserProfileBt.IsEnabled = false; Constants.DepCourse.GetAllLearned(); }
/// <summary> /// Initializes the popup style. /// </summary> private void InitializePopupStyle() { // 样式设置 var grids = from g in AdvanceSearchStackPanel.Children.OfType<Grid>() where !g.Name.Equals(searchButtonsGrid.Name) select g; foreach (var grid in grids) { grid.Margin = new Thickness(10); grid.Height = 70; var filterTitles = from c in grid.Children.OfType<TextBlock>() select c; filterTitles.FirstOrDefault().FontSize = 50; var filterContent = from c in grid.Children.OfType<TextBox>() select c; if (filterContent != null && filterContent.Count() != 0) { filterContent.FirstOrDefault().FontSize = 40; filterContent.FirstOrDefault().Text = ""; } } // Category内容设置 categoryDsq = (DataServiceQuery<CATEGORY>)(from category in ctx.CATEGORY select category); categoryDsq.BeginExecute(OnCategoryComplete, null); SearchPopTitleText.KeyDown += AdvanceSearch_KeyDown; SearchPopAuthorText.KeyDown += AdvanceSearch_KeyDown; SearchPopDescriptionText.KeyDown += AdvanceSearch_KeyDown; }
/// <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) { loadingProgressRing.IsActive = true; try { if (Constants.RecUriDic.Count == 0 && Constants.CategoryNameList.Count == 0) { try { DataServiceQuery<CATEGORY> cateDsq = (DataServiceQuery<CATEGORY>)(from cate in ctx.CATEGORY select cate); TaskFactory<IEnumerable<CATEGORY>> tfc = new TaskFactory<IEnumerable<CATEGORY>>(); IEnumerable<CATEGORY> categories = await tfc.FromAsync(cateDsq.BeginExecute(null, null), iar => cateDsq.EndExecute(iar)); foreach (var c in categories) { Constants.CategoryNameList.Add(c.CATE_NAME); } } catch { ShowMessageDialog("categories!"); } try { DataServiceQuery<RECOMMENDATION> craDsq = (DataServiceQuery<RECOMMENDATION>)(from re in ctx.RECOMMENDATION select re); TaskFactory<IEnumerable<RECOMMENDATION>> tf = new TaskFactory<IEnumerable<RECOMMENDATION>>(); IEnumerable<RECOMMENDATION> recommendation = await tf.FromAsync(craDsq.BeginExecute(null, null), iar => craDsq.EndExecute(iar)); foreach (var r in recommendation) { Constants.RecUriDic.Add(r.TITLE, r.ICON_URL); } } catch { ShowMessageDialog("recommedations!"); } } } catch { ShowMessageDialog("On nav to"); } courseDsq = (DataServiceQuery<COURSE_AVAIL>)(from course_avail in ctx.COURSE_AVAIL select course_avail); courseDsq.BeginExecute(OnCourseAvailComplete, null); UserProfileBt.DataContext = Constants.User; //UserProfileBt.IsEnabled = false; }
public DataViewModelBase(DataServiceQuery query) { this.IsLoading = true; query.BeginExecute(OnAsyncExecutionComplete, new AsyncOperation() { Query = query, ViewModel = this }); }
public void getUserById(int id, onQueryComplete onComplete) { customerDsq = (DataServiceQuery<CUSTOMER>)(from cus in ctx.CUSTOMER where cus.ID == Constants.User.ID select cus); this.onUQC = onComplete; customerDsq.BeginExecute(onQueryComplete2, null); }
private void onResComplete(IAsyncResult res) { IEnumerable<RESOURCE> resources = resourceDsq.EndExecute(res); RESOURCE resource = resources.FirstOrDefault(); resTypeDsq = (DataServiceQuery<RES_TYPE>)(ctx.RES_TYPE.Where(r => r.ID == resource.TYPE)); resTypeDsq.BeginExecute(onQueryComplete2, null); }
/// <summary> /// Reset the page. /// </summary> private void ResetPage() { bool inFlag = false; hasImage = false; categoryDsq = (DataServiceQuery<CATEGORY>)(from category in ctx.CATEGORY select category); categoryDsq.BeginExecute(OnCategoryComplete, null); pgDsq = (DataServiceQuery<PARENT_GUIDE>)(from pg in ctx.PARENT_GUIDE select pg); pgDsq.BeginExecute(OnPGComplete, null); lessonCount = 0; cts = new CancellationTokenSource(); courseNameTextBox.Text = ""; priceTextBox.Text = ""; CourseDescriptionTextBox.Text = ""; lessonInfo.Children.Clear(); lessonRes.Children.Clear(); images = null; docs = null; audios = null; videos = null; allLessons = new List<Lesson>(); toBeUploadCourse = new Course(); imagePanel.Children.Clear(); foreach (var c in totalImagePanel.Children) { if (c == addImageButton) { inFlag = true; } } if (!inFlag) { totalImagePanel.Children.Add(addImageButton); } }
private async void LoginButton_Click(object sende, RoutedEventArgs e) { bool isLogined = false; if (InputPassword.Password.Equals(string.Empty)) { var messageDialog = new MessageDialog("Please Check your input!"); await messageDialog.ShowAsync(); return; } try { TaskFactory<IEnumerable<CUSTOMER>> tf = new TaskFactory<IEnumerable<CUSTOMER>>(); customerDsq = (DataServiceQuery<CUSTOMER>)(from user in ctx.CUSTOMER where user.NAME.Equals(Constants.User.NAME) select user); IEnumerable<CUSTOMER> cs = await tf.FromAsync(customerDsq.BeginExecute(null, null), iar => customerDsq.EndExecute(iar)); csl = new List<CUSTOMER>(cs); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); ShowMessageDialog("customerdsq error!"); } foreach (CUSTOMER c in csl) { if (c.NAME.Equals(Constants.User.NAME)) { if (c.PASSWORD == Constants.ComputeMD5(InputPassword.Password)) { if (!c.ALLOW) { ShowMessageDialog("The User is forbidden"); } Constants.User = new User(c); isLogined = true; Frame.Navigate(typeof(CourseStore.Courstore)); } } } /* bool isLogined = false; try { foreach (CUSTOMER c in csl) { if (c.NAME.Equals(Constants.User.NAME)) { if (c.PASSWORD == Constants.ComputeMD5(InputPassword.Password)) { if (!c.ALLOW) { var notAllowed = new MessageDialog("The User is forbidden!"); await notAllowed.ShowAsync(); return; } Constants.User = new User(c); //login success Constants.Save<bool>("AutoLog", (bool)CheckAutoLogin.IsChecked); System.Diagnostics.Debug.WriteLine("login success"); string courseUplaodUri = "/AddDBLog?opr='Login'&msg='" + Constants.User.NAME + "'"; try { TaskFactory<IEnumerable<bool>> tf = new TaskFactory<IEnumerable<bool>>(); IEnumerable<bool> result = await tf.FromAsync(ctx.BeginExecute<bool>(new Uri(courseUplaodUri, UriKind.Relative), null, null), iar => ctx.EndExecute<bool>(iar)); } catch { } isLogined = true; Frame.Navigate(typeof(CourseStore.Courstore)); // navigate } } } } catch (Exception exp) { System.Diagnostics.Debug.WriteLine("Msg: {0}\nInnerExp:{1}\nStackTrace: {2} ", exp.Message, exp.InnerException, exp.StackTrace); ShowMessageDialog(); } */ if (!isLogined) { ShowMessageDialog("Username or password is wrong!"); } }
/// <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) { course = e.Parameter as Course; try { DataServiceQuery<COURSE_AVAIL> cDsq = (DataServiceQuery<COURSE_AVAIL>)(from kc in ctx.COURSE_AVAIL where course.ID == kc.ID select kc); TaskFactory<IEnumerable<COURSE_AVAIL>> tf = new TaskFactory<IEnumerable<COURSE_AVAIL>>(); COURSE_AVAIL tmpCourse = (await tf.FromAsync(cDsq.BeginExecute(null, null), iar => cDsq.EndExecute(iar))).FirstOrDefault(); course = Constants.CourseAvail2Course(tmpCourse); } catch { ShowMessageDialog("Network connection error2!"); Frame.GoBack(); } UserProfileBt.DataContext = Constants.User; DataContext = course; introGrid.DataContext = course; frame.Navigate(typeof(CourseDetail.Overview), course); isTeach = false; isBuy = false; try { teachCourses = (DataServiceQuery<COURSE_AVAIL>)(from teachC in ctx.COURSE_AVAIL where teachC.TEACHER_NAME == Constants.User.NAME select teachC); TaskFactory<IEnumerable<COURSE_AVAIL>> teachTF = new TaskFactory<IEnumerable<COURSE_AVAIL>>(); IEnumerable<COURSE_AVAIL> tcs = await teachTF.FromAsync(teachCourses.BeginExecute(null, null), iar => teachCourses.EndExecute(iar)); buyCourses = (DataServiceQuery<ATTEND>)(from buyC in ctx.ATTEND where buyC.CUSTOMER_ID == Constants.User.ID select buyC); TaskFactory<IEnumerable<ATTEND>> buyCF = new TaskFactory<IEnumerable<ATTEND>>(); IEnumerable<ATTEND> bcs = await buyCF.FromAsync(buyCourses.BeginExecute(null, null), iar => buyCourses.EndExecute(iar)); foreach (var t in tcs) { if (t.ID == course.ID) { isTeach = true; break; } } foreach (var b in bcs) { if (b.COURSE_ID == course.ID) { isBuy = true; break; } } } catch { ShowMessageDialog("Network connection error3!"); Frame.GoBack(); } if (course.Price == null || course.Price.Value == 0) { PriceTextBlock.Text = "Free"; } else { PriceTextBlock.Text = "$ " + Math.Round(course.Price.Value, 2); } System.Diagnostics.Debug.WriteLine(course.Rate); SetStarsStackPanel(course.Rate ?? 0); if (isTeach) { courseButton.Content = "Teach"; } else if (isBuy) { courseButton.Content = "Attend"; } else { courseButton.Content = "Buy"; } }
/// <summary> /// 在此页将要在 Frame 中显示时进行调用。 /// </summary> /// <param name="e">描述如何访问此页的事件数据。Parameter /// 属性通常用于配置页。</param> protected override void OnNavigatedTo(NavigationEventArgs e) { course = e.Parameter as Course; List<object> courseInfo = e.Parameter as List<object>; course = courseInfo[0] as Course; DataContext = course; if ((courseInfo[1] as string) == "attending") { beginButton.Content = "Start Learning!"; getLearnedPercentage(); } else if ((courseInfo[1] as string) == "teaching") { beginButton.Content = "Edit Course"; } SetStarsStackPanel(course.Rate ?? 0); categoryDsq = (DataServiceQuery<CATEGORY>)(from category in ctx.CATEGORY select category); categoryDsq.BeginExecute(OnCategoryComplete, null); pgDsq = (DataServiceQuery<PARENT_GUIDE>)(from pg in ctx.PARENT_GUIDE select pg); pgDsq.BeginExecute(OnPGComplete, null); // getLearnedPercentage(); }
/// <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; }