Beispiel #1
0
        private async void FromOfflineShareCode_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new InputDialog()
            {
                Title       = "请输入离线分享码",
                Placeholder = "离线分享码"
            };

            if ((await dialog.ShowAsyncQueue()) == ContentDialogResult.Primary)
            {
                try
                {
                    var tableCourses = JsonConvert.DeserializeObject <TableCourses>(dialog.Result);
                    Models.Add(await TimeTableHelper.GenerateTimeTableModel(tableCourses));

                    app.TimeTables.Add(tableCourses);
                    SaveTimeTables();
                }
                catch (Exception err)
                {
                    var msgDialog = new CommonDialog("分享码格式错误:\n" + err.Message)
                    {
                        Title = "错误",
                    };
                    await msgDialog.ShowAsyncQueue();
                }
            }
        }
        private async void SemesterComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (SemesterComboBox.SelectedItem != null)
            {
                currentRound = ((ExamRound)SemesterComboBox.SelectedItem).Name;

                LoadingProgressBar.Visibility = Visibility.Visible;

                try
                {
                    Arrangement = await app.Assist.GetExamArrangement((ExamRound)SemesterComboBox.SelectedItem);

                    ExamArrangementListView.ItemsSource = Arrangement;
                }
                catch (Exception err)
                {
                    var msgDialog = new CommonDialog(err.Message)
                    {
                        Title = "错误",
                    };

                    await msgDialog.ShowAsyncQueue();
                }
                finally
                {
                    LoadingProgressBar.Visibility = Visibility.Collapsed;
                }
            }
        }
        private async void SemesterComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (SemesterComboBox.SelectedItem != null)
            {
                LoadingProgressBar.Visibility = Visibility.Visible;

                try
                {
                    currentRound = (ExamRound)SemesterComboBox.SelectedItem;

                    Scores = await app.Assist.GetExamScores(
                        Convert.ToInt32(currentRound.Year),
                        Convert.ToInt32(currentRound.Semester),
                        showMajor
                        );

                    ExamScoreListView.ItemsSource = Scores;
                }
                catch (Exception err)
                {
                    var msgDialog = new CommonDialog(err.Message)
                    {
                        Title = "错误",
                    };

                    await msgDialog.ShowAsyncQueue();
                }
                finally
                {
                    LoadingProgressBar.Visibility = Visibility.Collapsed;
                }

                SaveScores();
            }
        }
        private async void Refresh()
        {
            if (LoadingProgressBar != null && currentRound != null && app.Assist != null && ExamScoreListView != null)
            {
                LoadingProgressBar.Visibility = Visibility.Visible;

                try
                {
                    Scores = await app.Assist.GetExamScores(
                        Convert.ToInt32(currentRound.Year),
                        Convert.ToInt32(currentRound.Semester),
                        showMajor
                        );

                    ExamScoreListView.ItemsSource = Scores;
                }
                catch (Exception err)
                {
                    var msgDialog = new CommonDialog(err.Message)
                    {
                        Title = "错误",
                    };

                    await msgDialog.ShowAsyncQueue();
                }
                finally
                {
                    LoadingProgressBar.Visibility = Visibility.Collapsed;
                }
            }
        }
Beispiel #5
0
        private async void DefaultTile_Clicked(object sender, RoutedEventArgs e)
        {
            if (app.TimeTables.Count == 0)
            {
                var dialog = new CommonDialog("请先导入课程表")
                {
                    Title = "提示",
                };

                await dialog.ShowAsyncQueue();

                return;
            }
            var tableCourses = app.TimeTables[TablePivot.SelectedIndex];

            localSettings.Values[AppConstants.TILE_TIMETABLE] = JsonConvert.SerializeObject(tableCourses);
            TileHelper.UpdateTile(await TileHelper.GetDefaultTileTimeTable());

            var msgDialog = new CommonDialog("设置成功!")
            {
                Title = "提示",
            };

            await msgDialog.ShowAsyncQueue();
        }
Beispiel #6
0
        private async void ImportItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var item         = (MenuFlyoutItem)e.OriginalSource;
                var semester     = Semesters.Find(o => o.Name == item.Text);
                var tableCourses = await app.Assist.GetTableCourses(semester);

                Models.Add(await TimeTableHelper.GenerateTimeTableModel(tableCourses));

                app.TimeTablePage_Models = Models.ToList();
                app.TimeTables.Add(tableCourses);
                app.HomePage_Models = null;
                SaveTimeTables();
            }
            catch (Exception err)
            {
                var msgDialog = new CommonDialog(err.Message)
                {
                    Title = "错误",
                };

                await msgDialog.ShowAsyncQueue();
            }
        }
        private async void Order_Clicked(object sender, RoutedEventArgs e)
        {
            var button = (Button)e.OriginalSource;

            if (button == null)
            {
                return;
            }

            var seat = (SeatLayoutItem)button.DataContext;

            if (seat == null)
            {
                return;
            }

            var msgDialog = new CommonDialog("状态:" + seat.ShowStatus +
                                             "\n电源:" + (seat.Power.GetValueOrDefault(false) ? "有" : "无"))
            {
                Title             = "预约:" + seat.Name,
                PrimaryButtonText = "预约",
            };

            if (await msgDialog.ShowAsyncQueue() == ContentDialogResult.Primary)
            {
                // Order
                var chooseTimeDialog = new ChooseSeatTimeDialog(seat.Id.GetValueOrDefault(0));
                if (await chooseTimeDialog.ShowAsyncQueue() == ContentDialogResult.Primary)
                {
                    var res = await app.SeatClient.OrderSeat(seat.Id.GetValueOrDefault(0),
                                                             DateTime.Now.ToString("yyyy-MM-dd"),
                                                             chooseTimeDialog.StartTime.Id,
                                                             chooseTimeDialog.EndTime.Id
                                                             );

                    if (res.Status == "success" && res.Data != null)
                    {
                        var dialog = new CommonDialog(res.Data.Location + "\n" +
                                                      "凭证号:" + res.Data.Receipt + "\n")
                        {
                            Title = "预约成功",
                        };
                        await dialog.ShowAsyncQueue();
                        await LoadReservations();
                        await LoadSeat();
                    }
                    else
                    {
                        var dialog = new CommonDialog(res.Message)
                        {
                            Title = "错误",
                        };
                        await dialog.ShowAsyncQueue();
                    }
                }
            }
        }
        private async void Stop_Clicked(object sender, RoutedEventArgs e)
        {
            LoadingProgressBar2.Visibility = Visibility.Visible;
            var res = await app.SeatClient.Stop();

            var dialog = new CommonDialog(res.Message)
            {
                Title = "提示",
            };
            await dialog.ShowAsyncQueue();

            LoadingProgressBar2.Visibility = Visibility.Collapsed;
        }
Beispiel #9
0
        private async void ClassroomPage_Loaded(object sender, RoutedEventArgs e)
        {
            double?diagonal = DisplayInformation.GetForCurrentView().DiagonalSizeInInches;

            //move commandbar to page bottom on small screens
            if (diagonal < 7)
            {
                topbar.Visibility             = Visibility.Collapsed;
                pageTitleContainer.Visibility = Visibility.Visible;
                bottombar.Visibility          = Visibility.Visible;
            }
            else
            {
                topbar.Visibility             = Visibility.Visible;
                pageTitleContainer.Visibility = Visibility.Collapsed;
                bottombar.Visibility          = Visibility.Collapsed;
            }

            LoadingProgressBar.Visibility = Visibility.Visible;

            try
            {
                var buildings = await ClassroomClient.GetBuildings();

                BuildingModels.Clear();
                foreach (var item in buildings)
                {
                    BuildingModels.Add(item);
                }
                BuildingComboBox.ItemsSource = BuildingModels;
                RoomListView.ItemsSource     = RoomModels;

                LoadingProgressBar.Visibility = Visibility.Collapsed;

                BuildingComboBox.SelectedIndex = 0;
            }
            catch (Exception err)
            {
                LoadingProgressBar.Visibility = Visibility.Collapsed;
                var msgDialog = new CommonDialog(err.Message)
                {
                    Title = "错误",
                };
                await msgDialog.ShowAsyncQueue();
            }

            // Prepare for Sharing
            DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();

            dataTransferManager.DataRequested += DataTransferManager_DataRequested;
        }
        private async void PreviewAppBarButton_Clicked(object sender, RoutedEventArgs e)
        {
            var dialog = new PreviewExamArragementDialog();

            if (await dialog.ShowAsyncQueue() == ContentDialogResult.Primary)
            {
                SemesterComboBox.SelectedItem = null;

                var year  = DateTime.Now.Year;
                var month = DateTime.Now.Month;
                var term  = 0; // 秋季学期

                if (month < 9)
                {
                    // 春季学期
                    term = 1;
                    year--;
                }

                currentRound = year + "-" + (year + 1) + "学年" +
                               (term == 0 ? "秋季学期" : "春季学期") +
                               "考试" + dialog.n;

                var round = new ExamRound("", year + "," + term + "," + dialog.n);

                LoadingProgressBar.Visibility = Visibility.Visible;

                try
                {
                    Arrangement = await app.Assist.GetExamArrangement(round);

                    ExamArrangementListView.ItemsSource = Arrangement;
                }
                catch (Exception err)
                {
                    var msgDialog = new CommonDialog(err.Message)
                    {
                        Title = "错误",
                    };

                    await msgDialog.ShowAsyncQueue();
                }
                finally
                {
                    LoadingProgressBar.Visibility = Visibility.Collapsed;
                }

                LoadingProgressBar.Visibility = Visibility.Collapsed;
            }
        }
        private async void BorrowedBookListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var item      = (BorrowedBook)e.ClickedItem;
            var msgDialog = new CommonDialog("应还日期:\t" + item.ReturnDate +
                                             "\n作者:\t\t" + item.Author +
                                             "\n位置:\t\t" + item.Building +
                                             "\n索书号:\t" + item.Position +
                                             "\n罚款:\t\t" + item.Fine)
            {
                Title = item.Title + " " + item.Description,
            };

            await msgDialog.ShowAsyncQueue();
        }
        private async void ExamArrangementListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var item      = (ExamArrangement)e.ClickedItem;
            var msgDialog = new CommonDialog("学分:" + item.Credit +
                                             "\n考核方式:" + item.ExamType +
                                             "\n课程类别:" + item.Classification +
                                             "\n\n倒计时:" + item.RemainingDays + "天" +
                                             "\n时间:" + item.Time +
                                             "\n地点:" + item.Location +
                                             "\n座号:" + item.Seat)
            {
                Title = item.CourseName,
            };

            await msgDialog.ShowAsyncQueue();
        }
Beispiel #13
0
        private async void Share_Clicked(object sender, RoutedEventArgs e)
        {
            try
            {
                TimeTableProgressBar.Visibility = Visibility.Visible;

                var shareCode  = JsonConvert.SerializeObject(app.TimeTables[TablePivot.SelectedIndex]);
                var onlineCode = "";

                var dialog = new ShareCodeDialog()
                {
                    OfflineShareCode = shareCode
                };
                var query = new AVQuery <AVObject>("TimeTable").WhereEqualTo("Content", shareCode);
                var objs  = await query.FindAsync();

                if (objs.Count() > 0)
                {
                    onlineCode = Convert.ToString(objs.First().ObjectId);
                }
                else
                {
                    var code = new AVObject("TimeTable")
                    {
                        ["Content"] = shareCode
                    };
                    await code.SaveAsync();

                    onlineCode = code.ObjectId;
                }
                dialog.OnlineShareCode = "欢迎使用北师小鸦,课程表分享码:" + onlineCode;

                TimeTableProgressBar.Visibility = Visibility.Collapsed;

                await dialog.ShowAsyncQueue();
            }
            catch (Exception err)
            {
                TimeTableProgressBar.Visibility = Visibility.Collapsed;
                var msgDialog = new CommonDialog(err.Message)
                {
                    Title = "错误",
                };

                await msgDialog.ShowAsyncQueue();
            }
        }
        private async void ReservationListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var item = (ReservationHistory)e.ClickedItem;

            if (item.State == "RESERVE")
            {
                var dialog = new CommonDialog("是否取消预约:" + item.Date + item.Location)
                {
                    Title             = "取消预约",
                    PrimaryButtonText = "取消预约",
                };
                if (await dialog.ShowAsyncQueue() == ContentDialogResult.Primary)
                {
                    await app.SeatClient.CancelReservation(Convert.ToInt32(item.Id));
                }
            }
        }
        private async void Add_Clicked(object sender, RoutedEventArgs e)
        {
            var dialog = new GatewayInputDialog();

            if (await dialog.ShowAsyncQueue() == ContentDialogResult.Primary)
            {
                if (!GatewayClient.SaveUser(dialog.Username, dialog.Password))
                {
                    var msgDialog = new CommonDialog("用户已存在")
                    {
                        Title = "提示",
                    };
                    await msgDialog.ShowAsyncQueue();
                }
            }
            LoadUsers();
        }
        private async void ExamScoreListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var item      = (ExamScore)e.ClickedItem;
            var msgDialog = new CommonDialog("课程编号:" + item.CourseId +
                                             "\n学期:" + item.Semester +
                                             "\n学分:" + item.CourseCredit +
                                             "\n类别:" + item.Classification +
                                             "\n是否主修:" + (item.IsMajor ? "是" : "否") +
                                             "\n是否初修:" + (item.DoLearnForFirstTime ? "是" : "否") +
                                             "\n\n平时成绩:" + item.Score1 +
                                             "\n期末成绩:" + item.Score2 +
                                             "\n综合成绩:" + item.Score)
            {
                Title = item.CourseName,
            };

            await msgDialog.ShowAsyncQueue();
        }
        private async void RenewAll_Clicked(object sender, RoutedEventArgs e)
        {
            LoadingProgressBar.Visibility = Visibility.Visible;
            var res = await app.LibraryClient.RenewAll();

            if (res == null)
            {
                res = "未知错误";
            }

            var msgDialog = new CommonDialog(res)
            {
                Title = "提示",
            };

            await msgDialog.ShowAsyncQueue();

            LoadingProgressBar.Visibility = Visibility.Collapsed;
        }
        private async void CancelReservation_Click(object sender, RoutedEventArgs e)
        {
            LoadingProgressBar2.Visibility = Visibility.Visible;
            var res = await app.SeatClient.CancelReservation(ReservationModel.Id);

            if (res.Status == "success")
            {
                await LoadReservations();
                await LoadSeat();
            }
            else
            {
                var msgDialog = new CommonDialog(res.Message)
                {
                    Title = "提示",
                };

                await msgDialog.ShowAsyncQueue();
            }
            LoadingProgressBar2.Visibility = Visibility.Collapsed;
        }
Beispiel #19
0
        private async void FromShareCode_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new InputDialog()
            {
                Title       = "请输入在线分享码",
                Placeholder = "在线分享码"
            };

            if ((await dialog.ShowAsyncQueue()) == ContentDialogResult.Primary)
            {
                try
                {
                    var code = dialog.Result;

                    if (code.Contains(":"))
                    {
                        code = code.Substring(code.IndexOf(":") + 1).Trim();
                    }

                    var content = AVObject.CreateWithoutData("TimeTable", code);
                    await content.FetchAsync();

                    var tableCourses = JsonConvert.DeserializeObject <TableCourses>(Convert.ToString(content["Content"]));
                    Models.Add(await TimeTableHelper.GenerateTimeTableModel(tableCourses));

                    app.TimeTables.Add(tableCourses);
                    SaveTimeTables();
                }
                catch (Exception err)
                {
                    var msgDialog = new CommonDialog("分享码格式错误:\n" + err.Message)
                    {
                        Title = "错误",
                    };
                    await msgDialog.ShowAsyncQueue();
                }
            }
        }
        private async void ExamScorePage_Loaded(object sender, RoutedEventArgs e)
        {
            double?diagonal = DisplayInformation.GetForCurrentView().DiagonalSizeInInches;

            //move commandbar to page bottom on small screens
            if (diagonal < 7)
            {
                topbar.Visibility             = Visibility.Collapsed;
                pageTitleContainer.Visibility = Visibility.Visible;
                bottombar.Visibility          = Visibility.Visible;
            }
            else
            {
                topbar.Visibility             = Visibility.Visible;
                pageTitleContainer.Visibility = Visibility.Collapsed;
                bottombar.Visibility          = Visibility.Collapsed;
            }

            if (!app.Assist.IsLogin)
            {
                var msgDialog = new CommonDialog("请先登录!")
                {
                    Title = "提示",
                };

                await msgDialog.ShowAsyncQueue();

                if (Frame.CanGoBack)
                {
                    Frame.GoBack();
                }
            }
            else
            {
                LoadingProgressBar.Visibility = Visibility.Visible;

                try
                {
                    var studentInfo = await app.Assist.GetStudentInfo();

                    for (int year = DateTime.Now.Year;
                         year >= Convert.ToInt32(studentInfo.Grade);
                         --year)
                    {
                        if (year == DateTime.Now.Year)
                        {
                            if (DateTime.Now.Month > 9)
                            {
                                Round.Add(new ExamRound("" + year + "-" + (year + 1) + " 秋季学期", year + ",0,0"));
                            }
                        }
                        else
                        {
                            Round.Add(new ExamRound("" + year + "-" + (year + 1) + " 春季学期", year + ",1,0"));
                            Round.Add(new ExamRound("" + year + "-" + (year + 1) + " 秋季学期", year + ",0,0"));
                        }
                    }

                    Round.Add(new ExamRound("全部学期", "0,0,0"));

                    SemesterComboBox.ItemsSource       = Round;
                    SemesterComboBox.SelectionChanged += SemesterComboBox_SelectionChanged;

                    LoadingProgressBar.Visibility = Visibility.Collapsed;

                    SemesterComboBox.SelectedItem = Round[0];
                }
                catch (Exception err)
                {
                    LoadingProgressBar.Visibility = Visibility.Collapsed;
                    var msgDialog = new CommonDialog(err.Message)
                    {
                        Title = "错误",
                    };

                    await msgDialog.ShowAsyncQueue();
                }

                // Prepare for Sharing
                DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
                dataTransferManager.DataRequested += DataTransferManager_DataRequested;
            }
        }
        private async void Login_Clicked(object sender, RoutedEventArgs e)
        {
            if (isLogining)
            {
                return;
            }
            // login
            LoginLibraryDialog loginDialog = new LoginLibraryDialog();

            if (await loginDialog.ShowAsyncQueue() == ContentDialogResult.Primary)
            {
                try
                {
                    isLogining = true;

                    LoadingProgressBar.Visibility  = Visibility.Visible;
                    LoadingProgressBar2.Visibility = Visibility.Visible;
                    LoadingProgressBar3.Visibility = Visibility.Visible;

                    app.LibraryClient.Username = loginDialog.Username;
                    app.LibraryClient.Password = loginDialog.Password;
                    var res = await app.LibraryClient.Login();

                    if (res == null)
                    {
                        await LoadBorrowedBooks();

                        app.SeatClient.Username = loginDialog.Username;
                        app.SeatClient.Password = loginDialog.Password;
                        var res2 = await app.SeatClient.Login();

                        if (res2.Status == "success")
                        {
                            await LoadReservations();
                            await LoadSeat();
                        }
                        else
                        {
                            var msgDialog = new CommonDialog(res2.Message)
                            {
                                Title = "提示",
                            };

                            await msgDialog.ShowAsyncQueue();
                        }
                    }
                    else
                    {
                        var msgDialog = new CommonDialog(res)
                        {
                            Title = "提示",
                        };

                        await msgDialog.ShowAsyncQueue();
                    }
                }
                finally
                {
                    LoadingProgressBar.Visibility  = Visibility.Collapsed;
                    LoadingProgressBar2.Visibility = Visibility.Collapsed;
                    LoadingProgressBar3.Visibility = Visibility.Collapsed;
                    isLogining = false;
                }
            }
        }
Beispiel #22
0
        private async void TimetablePage_Loaded(object sender, RoutedEventArgs e)
        {
            double?diagonal = DisplayInformation.GetForCurrentView().DiagonalSizeInInches;

            //move commandbar to page bottom on small screens
            if (diagonal < 7)
            {
                topbar.Visibility             = Visibility.Collapsed;
                pageTitleContainer.Visibility = Visibility.Visible;
                bottombar.Visibility          = Visibility.Visible;
            }
            else
            {
                topbar.Visibility             = Visibility.Visible;
                pageTitleContainer.Visibility = Visibility.Collapsed;
                bottombar.Visibility          = Visibility.Collapsed;
            }

            LoadTimeTables();
            try
            {
                // Init Import
                if (app.Assist.IsLogin)
                {
                    Semesters = await app.Assist.GetTableSemesters();

                    foreach (var semester in Semesters)
                    {
                        MenuFlyoutItem item = new MenuFlyoutItem()
                        {
                            Text = semester.Name
                        };
                        item.Click += ImportItem_Click;
                        Menu.Items.Add(item);
                    }
                }
                else
                {
                    MenuFlyoutItem loginFirst = new MenuFlyoutItem()
                    {
                        Text = "请先登录"
                    };
                    loginFirst.Click += LoginFirst_Click;
                    Menu.Items.Add(loginFirst);
                }
                Menu.Items.Add(new MenuFlyoutSeparator());
                MenuFlyoutItem fromShareCode = new MenuFlyoutItem()
                {
                    Text = "自在线/安卓分享码导入"
                };
                fromShareCode.Click += FromShareCode_Click;
                Menu.Items.Add(fromShareCode);
                MenuFlyoutItem fromOfflineShareCode = new MenuFlyoutItem()
                {
                    Text = "自离线分享码导入"
                };
                fromOfflineShareCode.Click += FromOfflineShareCode_Click;
                Menu.Items.Add(fromOfflineShareCode);
            }
            catch (Exception err)
            {
                var msgDialog = new CommonDialog(err.Message)
                {
                    Title = "错误",
                };

                await msgDialog.ShowAsyncQueue();
            }
        }
        private async void ExamArrangementPage_Loaded(object sender, RoutedEventArgs e)
        {
            double?diagonal = DisplayInformation.GetForCurrentView().DiagonalSizeInInches;

            //move commandbar to page bottom on small screens
            if (diagonal < 7)
            {
                topbar.Visibility             = Visibility.Collapsed;
                pageTitleContainer.Visibility = Visibility.Visible;
                bottombar.Visibility          = Visibility.Visible;
            }
            else
            {
                topbar.Visibility             = Visibility.Visible;
                pageTitleContainer.Visibility = Visibility.Collapsed;
                bottombar.Visibility          = Visibility.Collapsed;
            }

            if (!app.Assist.IsLogin)
            {
                var msgDialog = new CommonDialog("请先登录!")
                {
                    Title = "提示",
                };

                await msgDialog.ShowAsyncQueue();

                if (Frame.CanGoBack)
                {
                    Frame.GoBack();
                }
            }
            else
            {
                LoadingProgressBar.Visibility = Visibility.Visible;

                try
                {
                    Round = await app.Assist.GetExamRounds();

                    SemesterComboBox.ItemsSource       = Round;
                    SemesterComboBox.SelectionChanged += SemesterComboBox_SelectionChanged;

                    LoadingProgressBar.Visibility = Visibility.Collapsed;

                    if (Round.Count() > 0)
                    {
                        SemesterComboBox.SelectedItem = Round[0];
                    }
                }
                catch (Exception err)
                {
                    LoadingProgressBar.Visibility = Visibility.Collapsed;
                    var msgDialog = new CommonDialog(err.Message)
                    {
                        Title = "错误",
                    };
                    await msgDialog.ShowAsyncQueue();
                }

                // Prepare for Sharing
                DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
                dataTransferManager.DataRequested += DataTransferManager_DataRequested;
            }
        }
Beispiel #24
0
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (isLogining)
                {
                    return;
                }

                if (app.Assist.IsLogin)
                {
                    // logout
                    isLogining = true;

                    localSettings.Values[AppConstants.PASSWORD_SETTINGS] = "";
                    app.Assist.Logout();
                    LoginText.Text = "登录以启用所有功能";
                    LoadQrCode(null);

                    isLogining = false;
                }

                // login
                LoginDialog loginDialog = new LoginDialog();
                if (await loginDialog.ShowAsyncQueue() == ContentDialogResult.Primary)
                {
                    isLogining          = true;
                    app.Assist.Username = loginDialog.Username;
                    app.Assist.Password = loginDialog.Password;

                    LoginText.Text = "登录中……";
                    LoginProgressBar.Visibility = Visibility.Visible;

                    var res = await app.Assist.Login();

                    LoginProgressBar.Visibility = Visibility.Collapsed;

                    if (res == null)
                    {
                        LoginText.Text = "欢迎" + (await app.Assist.GetStudentDetails()).Name + ",点此注销";

                        SaveUser();

                        LoadQrCode(app.Assist.Username);
                    }
                    else
                    {
                        LoginText.Text = "登录以启用所有功能";
                        var msgDialog = new CommonDialog(res)
                        {
                            Title = "提示",
                        };

                        await msgDialog.ShowAsyncQueue();
                    }
                    isLogining = false;
                }
            }
            catch (Exception err)
            {
                LoginText.Text = "登录以启用所有功能";
                var msgDialog = new CommonDialog(err.Message)
                {
                    Title = "错误",
                };

                await msgDialog.ShowAsyncQueue();

                LoadQrCode(null);
            }
            finally
            {
                isLogining = false;
            }
        }