private void buttonConnect_Click(object sender, RoutedEventArgs e) { try { if (proxy == null) { callback = new ICallback(); InstanceContext cntx = new InstanceContext(callback); proxy = new SVC.ServiceCliniqueClient(cntx); string servicePath = proxy.Endpoint.ListenUri.AbsolutePath; string serviceListenPort = proxy.Endpoint.Address.Uri.Port.ToString(); ////////////////////////*************a supprimer***************/////// //this.localClient = new SVC.Client(); //this.localClient.UserName = txtMotDePasse.Password; proxy.Endpoint.Address = new EndpointAddress("net.tcp://" + loginTxtBoxIP.Text.ToString() + ":" + serviceListenPort + servicePath); // proxy.Open(); var oper = authentification(proxy, txtMotDePasse.Password); if (oper == true) { this.localClient = new SVC.Client(); this.localClient.UserName = Membership.UserName; this.localClient.Actif = Convert.ToBoolean(Membership.Actif); // this.localClient.Status = true; proxy.TestConnect(localClient.UserName); TestConnecttCompleted(); } } else { HandleProxy(); } } ///// catch (Exception ex) { // // loginLabelStatus.Content = "Offline"; //Confirmer.IsEnabled = false; string Mess = "Error: " + ex.Message; textBlockss.Content = Mess; textBlockss.Foreground = Brushes.Red; textBlockss.Visibility = Visibility.Visible; // MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show(ex.Message, Medicus.Properties.Resources.SiteWeb, MessageBoxButton.OK, MessageBoxImage.Stop); } }
private void txtMotDePasse_KeyUp(object sender, KeyEventArgs e) { try { if (loginTxtBoxIP.Text != "") { if (e.Key != System.Windows.Input.Key.Enter) { return; } // your event handler here e.Handled = true; if (proxy == null) { callback = new ICallback(); InstanceContext cntx = new InstanceContext(callback); proxy = new SVC.ServiceCliniqueClient(cntx); string servicePath = proxy.Endpoint.ListenUri.AbsolutePath; string serviceListenPort = proxy.Endpoint.Address.Uri.Port.ToString(); ////////////////////////*************a supprimer***************/////// //this.localClient = new SVC.Client(); //this.localClient.UserName = txtMotDePasse.Password; proxy.Endpoint.Address = new EndpointAddress("net.tcp://" + loginTxtBoxIP.Text.ToString() + ":" + serviceListenPort + servicePath); // proxy.Open(); var oper = authentification(proxy, txtMotDePasse.Password); if (oper == true) { this.localClient = new SVC.Client(); this.localClient.UserName = Membership.UserName; this.localClient.Actif = Convert.ToBoolean(Membership.Actif); proxy.TestConnect(localClient.UserName); TestConnecttCompleted(); } } else { HandleProxy(); } } } catch (Exception ex) { MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show(ex.Message, Medicus.Properties.Resources.SiteWeb, MessageBoxButton.OK, MessageBoxImage.Stop); } }
private void HandleProxy() { try { if (proxy != null) { switch (this.proxy.State) { case CommunicationState.Closed: proxy = null; break; case CommunicationState.Closing: break; case CommunicationState.Created: break; case CommunicationState.Faulted: proxy.Abort(); proxy = null; Confirmer.IsEnabled = false; textBlockss.Content = "User Hors ligne "; textBlockss.Visibility = Visibility.Visible; break; case CommunicationState.Opened: if (connectionok == true) { DXWindowMain cl = new DXWindowMain(proxy, Membership, callback, localClient); cl.Show(); using (StreamWriter writer = new StreamWriter(System.Environment.CurrentDirectory + "/IPTEXTE.txt", false)) { writer.WriteLine(loginTxtBoxIP.Text); } downloadlogo(proxy); this.Close(); } else { proxy.Abort(); proxy = null; } break; case CommunicationState.Opening: break; default: break; } } } catch (Exception ex) { MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show(ex.Message, Medicus.Properties.Resources.SiteWeb, MessageBoxButton.OK, MessageBoxImage.Stop); } }