예제 #1
0
        public async void UnBookingGrade()
        {
            if (BJUTEduCenterUserinfo == null || string.IsNullOrWhiteSpace(BJUTEduCenterUserinfo.Username) || string.IsNullOrWhiteSpace(BJUTEduCenterUserinfo.Username))
            {
                await EduPageViewModel.GetUserInfo(_navigationService);

                return;
            }
            IsLoading = true;
            try
            {
                var re = await Services.MyBjutService.UnBookingGrade(_httpService, BJUTEduCenterUserinfo.Username, BJUTEduCenterUserinfo.Password);

                switch (re.Code)
                {
                case 200:
                    Services.NotityService.Notify("取消订阅成功");
                    HasBookingGrade = false;
                    GetServerStatus();
                    break;

                case 400:
                case 401:
                    Services.NotityService.Notify("提交的参数错误");
                    break;

                case 301:
                    Services.NotityService.Notify("提交的信息和订阅时不一致");
                    await EduPageViewModel.GetUserInfo(_navigationService);

                    break;

                case 500:
                    Services.NotityService.Notify("服务出错,稍后尝试");
                    break;

                default:
                    Services.NotityService.Notify("未知错误");
                    break;
                }
            }
            catch (System.Net.Http.HttpRequestException)
            {
                Services.NotityService.Notify("网络异常");
            }
            catch
            {
                Services.NotityService.Notify("其他异常");
            }

            finally
            {
                IsLoading = false;
            }
        }
예제 #2
0
        public async void RefreshSpecific()
        {
            IsLoading = true;
            try
            {
                if (EduPageViewModel.BJUTEduCenterUserinfo == null)
                {
                    await EduPageViewModel.GetUserInfo(_navigationService);

                    return;
                }
                var re = await EduPageViewModel.CoreService.GetAuthState(EduPageViewModel.HttpService, EduPageViewModel.BJUTEduCenterUserinfo.Username);

                if (re == true)
                {
                    var schoolYear = ShoolYears[SelectedSchoolYearIndex];
                    var term       = Terms[SelectedTermIndex];
                    await GetSpecificSchedule(ViewModels.EduPageViewModel.Name, EduPageViewModel.BJUTEduCenterUserinfo.Username, schoolYear, term);
                }
                else
                {
                    await Login();
                }
            }
            catch (HttpRequestException requestException)
            {
                Services.NotityService.Notify("网络错误");
            }
            catch (System.Net.WebException)
            {
                Services.NotityService.Notify("检查是否连接到校园网");
            }
            catch (Exception ex)
            {
                Services.NotityService.Notify($"其他错误:{ex.Message}");
            }
            finally
            {
                IsLoading = false;
            }
        }
예제 #3
0
        public async void BookingGrade()
        {
            if (BJUTEduCenterUserinfo == null || string.IsNullOrWhiteSpace(BJUTEduCenterUserinfo.Username) || string.IsNullOrWhiteSpace(BJUTEduCenterUserinfo.Username))
            {
                await EduPageViewModel.GetUserInfo(_navigationService);

                return;
            }

            IsLoading = true;

            try
            {
                var subResult = await _notifyHub.InitNotificationHubAsync(Services.ConfigurationSettings.HUB_NAME, Services.ConfigurationSettings.HUB_CONNEXTION_STRING, new[] { BJUTEduCenterUserinfo.Username });

                if (_notifyHub == null)
                {
                    Services.NotityService.Notify("服务初始化异常");
                    return;
                }
                if (subResult == false)
                {
                    Services.NotityService.Notify("手机推送服务开启失败");
                    return;
                }


                var re = await Services.MyBjutService.BookingGrade(_httpService, BJUTEduCenterUserinfo.Username, BJUTEduCenterUserinfo.Password);

                switch (re.Code)
                {
                case 200:

                    HasBookingGrade = true;

                    Services.NotityService.Notify("订阅成功");
                    GetServerStatus();
                    break;

                case 300:
                    Services.NotityService.Notify("账户检查不通过,请重新录入学号密码");
                    await EduPageViewModel.GetUserInfo(_navigationService);

                    break;

                case 400:
                case 401:
                    Services.NotityService.Notify("提交的参数错误");
                    break;

                case 500:
                    Services.NotityService.Notify("服务异常");
                    break;

                default:
                    Services.NotityService.Notify("未知错误");
                    break;
                }
            }
            catch (System.Net.Http.HttpRequestException)
            {
                Services.NotityService.Notify("网络异常");
            }
            catch
            {
                Services.NotityService.Notify("其他异常");
            }
            finally
            {
                IsLoading = false;
            }
        }