Exemplo n.º 1
0
 /// <summary>
 /// Handler for the Click event of the SignInOut Button. Used to sign in or out Lync depending on the current client state.
 /// </summary>
 public void ClientSignInOut()
 {
     //MessageBox.Show("HERE");
     try
     {
         if (_lyncClient.State == ClientState.SignedIn)
         {
             //Sign out If the current client state is Signed In
             _lyncClient.BeginSignOut(SignOutCallback, null);
         }
         else if (_lyncClient.State == ClientState.SignedOut)
         {
             //Sign in If the current client state is Signed Out
             _lyncClient.BeginSignIn(null, null, null, SignInCallback, null);
         }
     }
     catch (LyncClientException lyncClientException)
     {
         Console.WriteLine(lyncClientException);
     }
     catch (SystemException systemException)
     {
         if (IsLyncException(systemException))
         {
             // Log the exception thrown by the Lync Model API.
             Console.WriteLine("Error: " + systemException);
         }
         else
         {
             // Rethrow the SystemException which did not come from the Lync Model API.
             throw;
         }
     }
 }
 public static void ShutDown()
 {
     if (_client.State == ClientState.SignedIn)
     {
         _client.BeginSignOut(EndSignout, _client);
     }
     else
     {
         _client.BeginShutdown(EndShutdown, _client);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Handler for the Click event of the SignInOut Button. Used to sign in or out Lync depending on the current client state.
 /// </summary>
 private void SignInOutButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (lyncClient.State == ClientState.SignedIn)
         {
             //Sign out If the current client state is Signed In
             lyncClient.BeginSignOut(SignOutCallback, null);
         }
         else if (lyncClient.State == ClientState.SignedOut)
         {
             //Sign in If the current client state is Signed Out
             lyncClient.BeginSignIn(null, null, null, SignInCallback, null);
         }
     }
     catch (LyncClientException lyncClientException)
     {
         Console.WriteLine(lyncClientException);
     }
     catch (SystemException systemException)
     {
         if (IsLyncException(systemException))
         {
             // Log the exception thrown by the Lync Model API.
             Console.WriteLine("Error: " + systemException);
         }
         else
         {
             // Rethrow the SystemException which did not come from the Lync Model API.
             throw;
         }
     }
 }
Exemplo n.º 4
0
 private void _SignInOut()
 {
     try
     {
         if (_LyncClient.State == ClientState.SignedIn)
         {
             //Sign out If the current client state is Signed In
             _LyncClient.BeginSignOut(_SignOutCallback, null);
         }
         else if (_LyncClient.State == ClientState.SignedOut)
         {
             //Sign in If the current client state is Signed Out
             _LyncClient.BeginSignIn(null, null, null, _SignInCallback, null);
         }
     }
     catch (LyncClientException e)
     {
         // Console.WriteLine(lyncClientException);
     }
     catch (SystemException systemException)
     {
         if (_IsLyncException(systemException))
         {
             // Log the exception thrown by the Lync Model API.
             // Console.WriteLine("Error: " + systemException);
         }
         else
         {
             // Rethrow the SystemException which did not come from the Lync Model API.
             throw;
         }
     }
 }
Exemplo n.º 5
0
 private void signOutButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Log("Calling BeginSignOut()");
         lyncClient.BeginSignOut(signOutCallback, null);
     }
     catch (Exception ex)
     {
         Log("Signing out error: " + ex.Message);
     }
 }
Exemplo n.º 6
0
        public void SignOut()
        {
            if (client.State != ClientState.SignedIn)
            {
                throw new InvalidStateException("Skype / Lync client must be signed in in order to sign out");
            }

            client.BeginSignOut(
                ar =>
            {
                client.EndSignIn(ar);
            },
                null);
        }
        //constructor
        public ShutDown(SignIn signin)
        {
            _Client            = LyncClient.GetClient();
            _SignIn            = signin;
            _SignIn.SigningOut = true;      //set flag to indicate we're now signing out


            if (_Client.State == ClientState.SignedIn)
            {
                Object[] _asyncState = { _Client };
                _Client.BeginSignOut(SignOutCallback, _asyncState);
                MessageBox.Show("BeginSignOut method");
            }
        }
 private void _LyncClient_CredentialRequested(object sender, CredentialRequestedEventArgs e)
 {
     //If the request for credentials comes from Lync server then sign out, get new creentials
     //and sign in.
     if (e.Type == CredentialRequestedType.LyncAutodiscover)
     {
         try
         {
             _retries = _retries + 1;
             if ((_retries < 10))
             {
                 _lyncClient.BeginSignOut(ar =>
                 {
                     _lyncClient.EndSignOut(ar);
                     //Ask user for credentials and attempt to sign in again
                     SignUserIn();
                 }, null);
             }
             else
             {
                 _lyncClient.BeginSignOut(ar =>
                 {
                     _lyncClient.EndSignOut(ar);
                     _signInProcedureEvent.Set();
                 }, null);
             }
         }
         catch (Exception ex)
         {
             Trace.WriteLine($"Exception on attempt to sign in, abandoning sign in: {ex.Message}, Lync Client sign in delay");
         }
     }
     else
     {
         e.Submit(_username, _password, false);
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Raised when user's credentials are rejected by Lync or a service that
 /// Lync depends on requests credentials
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnLyncClientCredentialRequested(object sender, CredentialRequestedEventArgs e)
 {
     //If the request for credentials comes from Lync server then sign out, get new creentials
     //and sign in.
     if (e.Type == CredentialRequestedType.LyncAutodiscover)
     {
         try
         {
             _lyncClient.BeginSignOut((ar) =>
             {
                 _lyncClient.EndSignOut(ar);
                 //Ask user for credentials and attempt to sign in again
                 SignUserIn();
             }, null);
         }
         catch (Exception ex)
         {
             _log.ErrorException("OnLyncClientCredentialRequested", ex);
         }
     }
     else
     {
     }
 }
        private void Dispose(Boolean disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    _LyncClient.StateChanged -= _LyncClient_ClientStateChanged;

                    if (_thisInitializedLync == true)
                    {
                        if (_LyncClient.State == ClientState.SignedIn)
                        {
                            _LyncClient.EndSignOut(_lyncClient.BeginSignOut(null, null));
                            _LyncClient.EndShutdown(_LyncClient.BeginShutdown(null, null));
                        }
                    }
                    _lyncClient = null;
                }
                this.disposed = true;
            }
        }