コード例 #1
0
        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            _sr.InteractiveTask(() =>
            {
                int ret;

                _sr.Procedure = null;
                var local     = new LogoutProcedure();

                try
                {
                    ret = local.Step1();
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    ApiVendor.SetRenew(null);
                    SubwindowNavigator.Navigate(SubwindowPage.LoggedOut);
                }
            });
            _sr.InteractiveTask(() => SubwindowNavigator.Navigate(SubwindowPage.LoggedOut));
        }
コード例 #2
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     _sr.InteractiveTask(() =>
     {
         SubwindowNavigator.Navigate(SubwindowPage.LoggedIn);
     });
 }
コード例 #3
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var username = Username.Text;

            _sr.InteractiveTask(() =>
            {
                int ret;

                _sr.Procedure = null;
                var local     = new LoginProcedure();

                try
                {
                    ret = local.Step1(username, Helper.GetTrace());
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    _sr.Procedure = local;
                    SubwindowNavigator.Navigate(SubwindowPage.Login2);
                }
            });
        }
コード例 #4
0
        public AccountManagement()
        {
            sr = new SubwindowRouter();

            InitializeComponent();
            this.DataContext = sr;

            SubwindowNavigator.PrepareDefaultPage(sr, AccountFrame, Dispatcher);
        }
コード例 #5
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            _sr.Username = Username.Text;

            _sr.InteractiveTask(() =>
            {
                SubwindowNavigator.Navigate(SubwindowPage.RecoveryEntry);
            });
        }
コード例 #6
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            var password = Password.Password.ToCharArray();

            _sr.InteractiveTask(() =>
            {
                int ret = 00_0000;

                try
                {
                    if (!(_sr.Procedure is LoginProcedure local))
                    {
                        ret = 02_0009;
                        goto FAIL;
                    }

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step2(Encoding.UTF8.GetBytes(password));

                    byte[] token = null;

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step3(out token);

                    _sr.RenewToken = token;

                    if (!CheckVendor.NotValidResponseCode(ret))
                    {
                        var prof     = new ProfileProcedure();
                        ret          = prof.Step2(out var status);
                        _sr.Username = status.Username;
                        _sr.Dispname = status.DisplayName;
                    }
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                FAIL:
                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    _sr.Procedure = null;
                    SubwindowNavigator.Navigate(SubwindowPage.LoggedIn);
                }
            });
        }
コード例 #7
0
        public PageRecoveryAccount1(SubwindowRouter sr)
        {
            _sr = sr;
            InitializeComponent();

            _sr.InteractiveTask(() =>
            {
                int ret;

                if (!SubwindowDataCollector.Collect(5 * 60 * 1000, out var service, out var character))
                {
                    Growl.Error("等待超时,请返回上一页重试");
                }

                _sr.Procedure = null;
                var local     = new RecoveryProcedure();

                try
                {
                    if (string.IsNullOrEmpty(_sr.Username))
                    {
                        ret = 02_0009;
                        goto FAIL;
                    }

                    ret = local.Step1(_sr.Username, service, character, Helper.GetTrace());
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                FAIL:
                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    _sr.Procedure = local;
                    SubwindowNavigator.Navigate(SubwindowPage.Recovery2);
                }
            });
        }
コード例 #8
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var password = OldPassword.Password.ToCharArray();

            _sr.InteractiveTask(() =>
            {
                int ret;

                _sr.Procedure = null;
                var local     = new ChangeProcedure();

                try
                {
                    if (string.IsNullOrEmpty(_sr.Username))
                    {
                        ret = 02_0009;
                        goto FAIL;
                    }

                    ret = local.Step1(_sr.Username, Helper.GetTrace());

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step2(Encoding.UTF8.GetBytes(password));

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step3();
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                FAIL:
                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    _sr.Procedure = local;
                    SubwindowNavigator.Navigate(SubwindowPage.Change2);
                }
            });
        }
コード例 #9
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            var email = Email.Text;

            _sr.InteractiveTask(() =>
            {
                if (CheckVendor.NotValidEmail(email))
                {
                    Growl.Error("无效邮件地址");
                    return;
                }

                _sr.Email = email;

                SubwindowNavigator.Navigate(SubwindowPage.RecoveryEmail2);
            });
        }
コード例 #10
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var displayName = DisplayName.Text;

            _sr.InteractiveTask(() =>
            {
                int ret;

                _sr.Procedure = null;
                var local     = new ProfileProcedure();

                try
                {
                    ret = local.Step1(displayName, Helper.GetTrace(), null);

                    AccountStatus status = null;

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step2(out status);

                    if (!CheckVendor.NotValidResponseCode(ret) && status != null)
                    {
                        displayName = status.DisplayName;
                    }
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    Growl.Success("成功修改显示名称");
                    _sr.Dispname = displayName;
                    SubwindowNavigator.Navigate(SubwindowPage.LoggedIn);
                }
            });
        }
コード例 #11
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            _sr.InteractiveTask(() =>
            {
                try
                {
                    var path = Helper.GetMilFilePathRaw(".consent");

                    using (new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
                    {
                        File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden);
                    }
                }
                catch
                {
                    Growl.Warning("无法创建标记文件,您未来可能需要再次阅读此内容");
                }


                SubwindowNavigator.Navigate(SubwindowPage.LoggedOut);
            });
        }
コード例 #12
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            var code = VerifyCode.Text;

            _sr.InteractiveTask(() =>
            {
                int ret;

                try
                {
                    if (!(_sr.Procedure is RecoveryProcedure local))
                    {
                        ret = 02_0009;
                        goto FAIL;
                    }

                    ret = local.Step2(code);
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                FAIL:
                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    SubwindowNavigator.Navigate(SubwindowPage.Recovery2);
                }
            });
        }
コード例 #13
0
        public PageRegister1(SubwindowRouter sr)
        {
            _sr = sr;
            InitializeComponent();

            _sr.InteractiveTask(() =>
            {
                _sr.Service   = null;
                _sr.Character = null;

                if (!SubwindowDataCollector.Collect(5 * 60 * 1000, out _sr.Service, out _sr.Character))
                {
                    Growl.Error("等待超时,请返回上一页重试");

                    return;
                }

                if (_sr.Service != null && _sr.Character != null)
                {
                    SubwindowNavigator.Navigate(SubwindowPage.Register2);
                }
            });
        }
コード例 #14
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            var password    = NewPassword.Password.ToCharArray();
            var passconfirm = NewConfirm.Password.ToCharArray();

            _sr.InteractiveTask(() =>
            {
                int ret = 00_0000;

                if (!password.SequenceEqual(passconfirm))
                {
                    Growl.Error("密码输入不一致");
                    return;
                }

                if (password.Length < 8)
                {
                    Growl.Error("请使用八位及以上长度的密码");
                    return;
                }

                if (!password.Intersect("0123456789".ToCharArray()).Any())
                {
                    Growl.Error("密码应包含数字");
                    return;
                }

                if (!password.Intersect("ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray()).Any())
                {
                    Growl.Error("密码应包含大写字母");
                    return;
                }

                if (!password.Intersect("abcdefghijklmnopqrstuvwxyz".ToCharArray()).Any())
                {
                    Growl.Error("密码应包含小写字母");
                    return;
                }

                try
                {
                    if (!(_sr.Procedure is ChangeProcedure local))
                    {
                        ret = 02_0009;
                        goto FAIL;
                    }

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step4(Encoding.UTF8.GetBytes(password));

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step5();

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step6();

                    byte[] token = null;

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step7(out token);

                    _sr.RenewToken = token;
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                FAIL:
                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    _sr.Procedure = null;
                    Growl.Success("成功修改密码");
                    SubwindowNavigator.Navigate(SubwindowPage.LoggedIn);
                }
            });
        }
コード例 #15
0
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     _sr.InteractiveTask(() => SubwindowNavigator.Navigate(SubwindowPage.RecoveryEmail1));
 }
コード例 #16
0
 private void Button_Click_2(object sender, System.Windows.RoutedEventArgs e)
 {
     _sr.InteractiveTask(() => SubwindowNavigator.Navigate(SubwindowPage.Change1));
 }
コード例 #17
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var password    = NewPassword.Password.ToCharArray();
            var passconfirm = NewConfirm.Password.ToCharArray();
            var username    = Username.Text;
            var display     = DisplayName.Text;
            var email       = Email.Text;

            _sr.InteractiveTask(() =>
            {
                int ret;


                if (!password.SequenceEqual(passconfirm))
                {
                    Growl.Error("密码输入不一致");
                    return;
                }

                if (password.Length < 8)
                {
                    Growl.Error("请使用八位及以上长度的密码");
                    return;
                }

                if (!password.Intersect("0123456789".ToCharArray()).Any())
                {
                    Growl.Error("密码应包含数字");
                    return;
                }

                if (!password.Intersect("ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray()).Any())
                {
                    Growl.Error("密码应包含大写字母");
                    return;
                }

                if (!password.Intersect("abcdefghijklmnopqrstuvwxyz".ToCharArray()).Any())
                {
                    Growl.Error("密码应包含小写字母");
                    return;
                }

                _sr.Procedure = null;
                var local     = new RegisterProcedure();

                try
                {
                    ret = local.Step1(_sr.Service, _sr.Character, username, display, email,
                                      Encoding.UTF8.GetBytes(password), Helper.GetTrace());

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step2();

                    byte[] token = null;

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step3(out token);

                    _sr.RenewToken = token;

                    if (!CheckVendor.NotValidResponseCode(ret))
                    {
                        var prof     = new ProfileProcedure();
                        ret          = prof.Step2(out var status);
                        _sr.Username = status.Username;
                        _sr.Dispname = status.DisplayName;
                    }
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    Growl.Success("欢迎," + (!string.IsNullOrWhiteSpace(_sr.Dispname) ? _sr.Dispname : _sr.Username));
                    SubwindowNavigator.Navigate(SubwindowPage.LoggedIn);
                }
            });
        }
コード例 #18
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     _sr.InteractiveTask(() => SubwindowNavigator.Navigate(SubwindowPage.Consent));
 }