private void Login()
        {

            var uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            LoginHelper.LoginAsync(HostUrl, Name, Password).ContinueWith(task =>
                {
                    AuthenticationResult authResult = task.Result;
                    if (authResult.Status)
                    {
                        Error = String.Empty;

                        var viewModel = new MainViewModel(Name);
                        var main = new MainWindow() { DataContext = viewModel };
                        main.Show();
                        LoginSuccess(this, null);
                    }
                    Error = "Invalid login or password!";
                }, uiScheduler);
        }
Пример #2
0
        private void Login()
        {
            var uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            LoginHelper.LoginAsync(HostUrl, Name, Password).ContinueWith(task =>
            {
                AuthenticationResult authResult = task.Result;
                if (authResult.StatusCode == HttpStatusCode.OK)
                {
                    Error = String.Empty;

                    var viewModel = new MainViewModel(Name, authResult.AuthCookie);
                    var main = new MainWindow() { DataContext = viewModel };
                    main.Closed += viewModel.OnViewClosed;
                    main.Show();
                    LoginSuccess(this, null);
                }
                else
                {
                    Error = authResult.Error;
                }
            }, uiScheduler);
        }