コード例 #1
0
ファイル: Login.xaml.cs プロジェクト: CloudEDU/CloudEDUClient
        /// <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");
            //}
        }
コード例 #2
0
ファイル: Comment.xaml.cs プロジェクト: CloudEDU/Courstore
        /// <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);
        }
コード例 #3
0
 public IQueryable<DataServicePackage> GetPackages()
 {
     if (_query == null) {
         _query = _context.CreateQuery<DataServicePackage>(Constants.PackageServiceEntitySetName);
     }
     return _query;
 }
コード例 #4
0
ファイル: Profile.xaml.cs プロジェクト: CloudEDU/Courstore
 /// <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);
 }
コード例 #5
0
        /// <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;
        }
        public ManagementCredential GetManagementCredential(DataServiceQuery<ManagementCredential> managementCredentials, long id)
        {
            Contract.Requires(null != managementCredentials);
            Contract.Requires(0 < id);
            Contract.Ensures(null != Contract.Result<ManagementCredential>());

            var result = managementCredentials
                .Where(e => e.Id == id)
                .FirstOrDefault();
            
            return result;
        }
        public ManagementUri GetManagementUri(DataServiceQuery<ManagementUri> managementUris, string name)
        {
            Contract.Requires(null != managementUris);
            Contract.Requires(!string.IsNullOrWhiteSpace(name));
            Contract.Ensures(null != Contract.Result<ManagementUri>());
            Contract.Ensures(Contract.Result<ManagementUri>().ManagementCredentialId.HasValue);

            var result = managementUris
                .Where(e => e.Name == name)
                .FirstOrDefault();
            
            return result;
        }
コード例 #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)
        {

            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");
            }
            
        }
コード例 #9
0
ファイル: Note.xaml.cs プロジェクト: CloudEDU/Courstore
        /// <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));
            }
        }
コード例 #10
0
ファイル: User.cs プロジェクト: CloudEDU/CloudEDUClient
 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 ");
     }
 }
コード例 #11
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 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;
        }
コード例 #12
0
 public void GetCourseByID(int id, onQueryComplete onComplete)
 {
     courseDsq = (DataServiceQuery<COURSE>)(ctx.COURSE.Where(r => r.ID == id));
     this.onUQC = onComplete;
     resourceDsq.BeginExecute(onResComplete, null);
 }
コード例 #13
0
 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);
 }
コード例 #14
0
 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);
 }
コード例 #15
0
 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);
 }
コード例 #16
0
 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);
 }
コード例 #17
0
 public void GetTypeByResourceID(int id, onQueryComplete onComplete)
 {
     resourceDsq = (DataServiceQuery<RESOURCE>)(ctx.RESOURCE.Where(r => r.ID == id));
     this.onUQC = onComplete;
     resourceDsq.BeginExecute(onResComplete, null);
 }
コード例 #18
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)
        {
            
            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;
        }
コード例 #19
0
 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);
 }
コード例 #20
0
 public void GetLessonByID(int id, onQueryComplete onComplete)
 {
     lessonDsq = (DataServiceQuery<LESSON>)(ctx.LESSON.Where(r => r.ID == id));
     this.onUQC = onComplete;
     resourceDsq.BeginExecute(onResComplete, null);
 }
コード例 #21
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 override void OnNavigatedTo(NavigationEventArgs e)
 {
     customerDsq = (DataServiceQuery<CUSTOMER>)(from user in ctx.CUSTOMER select user);
     customerDsq.BeginExecute(OnCustomerComplete, null);
 }
コード例 #22
0
ファイル: Courstore.xaml.cs プロジェクト: CloudEDU/Courstore
        /// <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;
        }
コード例 #23
0
ファイル: Courstore.xaml.cs プロジェクト: CloudEDU/Courstore
        /// <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();
        }
コード例 #24
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)
        {
            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";
            }
        }
コード例 #25
0
ファイル: Uploading.xaml.cs プロジェクト: CloudEDU/Courstore
        /// <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);
            }
        }
コード例 #26
0
ファイル: Note.xaml.cs プロジェクト: CloudEDU/Courstore
        /// <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!");
            }
        }
コード例 #27
0
        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!");
            }
            
        }
コード例 #28
0
 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);
 }
コード例 #29
0
 /// <summary>
 /// Load  next page of UserDevice objects from Context for the passed in query and
 /// adds this page to passed in lis.
 /// </summary>
 /// <param name="list">List results will be added to.</param>
 /// <param name="Query">DataServiceQuery object</param>
 /// <param name="nextRec"> NextRecordInfo object define begining of the page to load</param>
 /// <param name="PageSize">Size of the page.  If value is 0  or value greater than 1000 system will limit paze size to 1000 records  </param>
 /// <returns> NextRecordInfo object for the next page</returns>
 private NextRecordInfo GetNextPage(ref List<UserDevice> list, DataServiceQuery<UserDevices> Query, NextRecordInfo nextRec, int PageSize)
 {
     NextRecordInfo Result = new NextRecordInfo();
        QueryOperationResponse qor;
        if (!string.IsNullOrEmpty(nextRec.NextPartition))
        Query = Query.AddQueryOption("NextPartitionKey", nextRec.NextPartition).AddQueryOption("NextRowKey", nextRec.NextKey);
        if (PageSize > 0)
        qor = (QueryOperationResponse)((DataServiceQuery<UserDevices>)Query.Take(PageSize)).Execute();
        else
        qor = (QueryOperationResponse)(Query).Execute();
        string nextPartition = String.Empty;
        string nextRow = String.Empty;
        qor.Headers.TryGetValue("x-ms-continuation-NextPartitionKey", out nextPartition);
        qor.Headers.TryGetValue("x-ms-continuation-NextRowKey", out nextRow);
        IQueryable<UserDevices> qt = (IQueryable<UserDevices>)qor.AsQueryable();
        Result.NextKey = nextRow;
        Result.NextPartition = nextPartition;
        	   var enumer = qt.GetEnumerator();
        while (enumer.MoveNext())
     list.Add( new UserDevice(enumer.Current));
        return Result;
 }
コード例 #30
0
 public void GetNoteByID(int id, onQueryComplete onComplete)
 {
     noteDsq = (DataServiceQuery<NOTE>)(ctx.NOTE.Where(r => r.ID == id));
     this.onUQC = onComplete;
     resourceDsq.BeginExecute(onResComplete, null);
 }