private void connect() { try { authClient_ = new AuthentificationService.AuthentificationDomainServiceSoapClient(); AuthentificationService.QueryResultOfUser result = authClient_.Login(login_, password_, true, ""); if (result.RootResults != null && result.RootResults.Count() > 0) { currentUser_ = result.RootResults.First(); Debug.WriteLine("You're logged in ! " + currentUser_.Name); FeedsVM.CurrentUser = currentUser_; FeedsVM.init(); LoginViewVisibility = Visibility.Hidden; FeedsViewVisibility = Visibility.Visible; } else { MessageBox.Show("Wrong password or bad login. Please try again."); } } catch (Exception e) { Debug.WriteLine("Login failure : " + e.Message); } }
void authClient__LogoutCompleted(object sender, AuthentificationService.LogoutCompletedEventArgs e) { Login = null; Password = null; FeedsVM.SelectedArticles = null; FeedsVM.SelectedChannels = null; FeedsVM.UnreadArticles = null; FeedsVM.UnsubChannels = null; FeedsVM.UriChannel = null; FeedsVM.SubChannels = null; FeedsVM.ArticleLink = null; FeedsVM.CurrentUser = null; authClient_ = null; }
public MainViewModel() { login_ = "*****@*****.**"; password_ = "test!"; selected_tab_ = 0; connect_ = new RelayCommand(param => this.connect()); FeedsVM = new FeedsViewModel(); authClient_ = new AuthentificationService.AuthentificationDomainServiceSoapClient(); authClient_.LoginCompleted += new EventHandler <AuthentificationService.LoginCompletedEventArgs>(authClient_LoginCompleted); authClient_.LogoutCompleted += new EventHandler <AuthentificationService.LogoutCompletedEventArgs>(authClient__LogoutCompleted); if (instance_ == null) { instance_ = this; } }
private void authClient_LoginCompleted(object sender, AuthentificationService.LoginCompletedEventArgs e) { try { if (!e.Cancelled) { if (e.Error == null) { if (e.Result.RootResults != null && e.Result.RootResults.Count > 0) { AuthentificationService.AuthentificationDomainServiceSoapClient authClient = (AuthentificationService.AuthentificationDomainServiceSoapClient)sender; currentUser_ = e.Result.RootResults.First(); cookie_ = authClient.CookieContainer; Debug.WriteLine("Your logged in ! " + currentUser_.Name); FeedsVM.CurrentUser = currentUser_; FeedsVM.MainVM = this; FeedsVM.init(); NavigationService.Navigate(new Uri("/View/RssReader.xaml", UriKind.Relative)); } else { System.Windows.MessageBox.Show("An error occured please try again."); } } else { Debug.WriteLine("Error : " + e.Error.Message); System.Windows.MessageBox.Show("An error occured please try again."); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }