コード例 #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;
         }
     }
 }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: ipc57/LyncUtility
        /// <summary>
        /// Called periodically whenever there's a future state pending
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnTick(object sender, EventArgs e)
        {
            TimeSpan timeLeft = endTime - DateTime.Now;

            if (timeLeft > TimeSpan.FromSeconds(1))
            {
                // Just a boring tick, just update the time left
                timeLeftLabel.Content = timeLeft.ToString(@"hh\:mm\:ss");
            }
            else
            {
                try
                {
                    if (lyncClient.State == ClientState.SignedOut)
                    {
                        Trace.WriteLine("OnTick: Signed out, signing in");
                        //Sign in If the current client state is Signed Out
                        lyncClient.BeginSignIn(null, null, null, SignInCallback, null);
                    }
                    else if (lyncClient.State == ClientState.SignedIn)
                    {
                        Trace.WriteLine("OnTick: Timed out, signed in, setting availability");
                        SetAvailability(futureAvailability);
                    }
                    else
                    {
                        // We've no idea what's going on so just wait a bit and hope it sorts itself out
                        Trace.WriteLine("OnTick: Timed out, waiting a bit because lync client state=" + lyncClient.State);
                        endTime = DateTime.Now + TimeSpan.FromSeconds(5);
                        return;
                    }
                }
                catch (LyncClientException lyncClientException)
                {
                    Trace.WriteLine("Lync Exception: " + lyncClientException);
                }
                catch (SystemException systemException)
                {
                    if (IsLyncException(systemException))
                    {
                        // Log the exception thrown by the Lync Model API.
                        Trace.WriteLine("Lync Exception: " + systemException);
                    }
                    else
                    {
                        // Rethrow the SystemException which did not come from the Lync Model API.
                        throw;
                    }
                }
                Trace.WriteLine("OnTick: Stopping countdown timer");
                timeLeftLabel.Content = "none";
                clock.Stop();
            }
        }
コード例 #3
0
 public void SignUserIn()
 {
     try
     {
         _lyncClient.BeginSignIn(_signInAddress, _username, _password, ar =>
         {
             try
             {
                 _lyncClient.EndSignIn(ar);
                 _signInProcedureEvent.Set();
             }
             catch (LyncClientException clientExcpetion)
             {
                 string message = clientExcpetion.Message;
                 if (message.StartsWith("Generic COM Exception", StringComparison.InvariantCultureIgnoreCase))
                 {
                     _badSignInAddressIdentified = true;
                     _signInProcedureEvent.Set();
                 }
             }
             catch (Exception exc)
             {
                 Trace.WriteLine($"exception on endsignin: {exc.Message})");
             }
         }, null);
     }
     catch (ArgumentException ae)
     {
         Trace.WriteLine($"exception on beginsignin: {ae.Message})");
     }
 }
コード例 #4
0
 public void Initialize()
 {
     try
     {
         _lyncClient = LyncClient.GetClient();
         _lyncClient.StateChanged += StateChanged;
         if (_lyncClient.State == ClientState.SignedOut)
         {
             _lyncClient.BeginSignIn(
                 null,
                 null,
                 null,
                 (ar) =>
             {
                 _lyncClient.EndSignIn(ar);
             }
                 ,
                 null);
         }
         else if (_lyncClient.State == ClientState.SignedIn)
         {
             _conversationManager = _lyncClient.ConversationManager;
             _conversationManager.ConversationAdded += ConversationAdded;
         }
     }
     catch (NotStartedByUserException)
     {
         throw new Exception("Lync is not running");
     }
 }
コード例 #5
0
ファイル: LyncService.cs プロジェクト: mujiansu/Lync
        /// <summary>
        /// Signs a user in to Lync as one of two possible users. User that is
        /// signed in depends on whether side-by-side client is chosen.
        /// </summary>
        internal void SignUserIn()
        {
            //Set the sign in credentials of the user to the
            //appropriate credentials for the endpoint mode
            string userUri      = _userUri;
            string userPassword = _userPassword;

            _log.Info("SignUserIn  Start");

            _userUri = userUri;
            _lyncClient.BeginSignIn(
                userUri,
                userUri,
                userPassword,
                (ar) =>
            {
                try
                {
                    _lyncClient.EndSignIn(ar);
                    _log.Info("SignUserIn End");
                }
                catch (Exception exc)
                {
                    _log.ErrorException("SignUserIn", exc);
                }
            },
                null);
        }
コード例 #6
0
 private void SignUserIn()
 {
     try
     {
         _LyncClient.BeginSignIn(
             "*****@*****.**",
             "*****@*****.**",
             "Win2013@",
             (ar) =>
         {
             try
             {
                 _LyncClient.EndSignIn(ar);
             }
             catch (Exception exc)
             {
                 MessageBox.Show("exception on endsignin: " + exc.Message);
             }
         },
             null);
     }
     catch (ArgumentException ae)
     {
         MessageBox.Show("exception on beginsignin: " + ae.Message);
     }
 }
コード例 #7
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;
         }
     }
 }
コード例 #8
0
        /// <summary>
        /// Click event handler for SignIn button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                // Check whether the user is signed out. If signed out then sign in the user on Lync
                // else the user needs to first sign out of the Lync client and then run the application.
                if (lyncClient.State == ClientState.SignedOut)
                {
                    if (!string.IsNullOrEmpty(text_usuario.Text) && !string.IsNullOrEmpty(text_contrasena.Text))
                    {
                        // If the valid credentials are provided then sign in the user on Lync.
                        lyncClient.BeginSignIn(text_usuario.Text, text_usuario.Text, text_contrasena.Text, SignInCallback, null);
                    }

                    else
                    {
                        MessageBox.Show("Enter username and password");
                    }
                }
                else
                {
                    MessageBox.Show("Sign out of the Lync first and then sign in using this Login form.");
                }
            }

            // Displays the error message if any unknown exception or error is there.
            catch (Exception ex) { MessageBox.Show("Error:    " + ex.Message); }
        }
コード例 #9
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;
         }
     }
 }
コード例 #10
0
 /// <summary>
 /// Sign in the Lync client
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SignInButton_Click(object sender, RoutedEventArgs e)
 {
     if (_client.State != ClientState.SignedIn)
     {
         _client.BeginSignIn("*****@*****.**", "domain\\johns", "password", (ar) =>
         {
             _client.EndSignIn(ar);
         }, null);
     }
 }
コード例 #11
0
ファイル: MainWindow.xaml.cs プロジェクト: mujiansu/Lync
        private void signInButton_Click(object sender, RoutedEventArgs e)
        {
            string userUri           = signInAddressTextBox.Text;
            string domainAndUsername = usernameTextBox.Text;
            string password          = passwordBox.Password;

            if (lyncClient.State == ClientState.SignedOut)
            {
                Log("Calling BeginSignIn()");
                lyncClient.BeginSignIn(userUri, domainAndUsername, password, SignInCallback, null);
            }
        }
コード例 #12
0
 public static bool BeginSkypeSignIn()
 {
     try
     {
         lyncClient.BeginSignIn(null, null, null, SignInCallback, null);
         if (!isLoggedIn())
         {
             return(true);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     return(false);
 }
コード例 #13
0
 /// <summary>
 /// Starts the asynchronous sign in process
 /// </summary>
 private void SignUserIntoLync()
 {
     if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["UserID"].ToString()) &&
         !string.IsNullOrEmpty(ConfigurationManager.AppSettings["Password"].ToString()))
     {
         lyncClient.BeginSignIn(
             ConfigurationManager.AppSettings["UserID"].ToString(),
             ConfigurationManager.AppSettings["UserID"].ToString(),
             ConfigurationManager.AppSettings["Password"].ToString(),
             (ar) =>
         {
             lyncClient.EndSignIn(ar);
         }
             , null);
     }
 }
コード例 #14
0
        public static void SignIn(string userAtHost, string domainAndUsername, string password)
        {
            try
            {
                var uri = userAtHost;
                if (userAtHost.StartsWith("sip:"))
                {
                    uri = userAtHost.Remove(0, 4);
                }

                _client.BeginSignIn(uri, domainAndUsername, password, SignInCallback, _client);
            }
            catch (Exception)
            {
                OnSignInFailed();
            }
        }
コード例 #15
0
        public void SignIn(string user = null, string password = null)
        {
            if (client.State != ClientState.SignedOut)
            {
                throw new InvalidStateException("Skype / Lync client must be signed out in order to sign in a new user");
            }

            client.BeginSignIn(
                user,
                user,
                password,
                ar =>
            {
                client.EndSignIn(ar);
            },
                null);
        }
コード例 #16
0
 /// <summary>
 /// Signs-In on Lync.
 /// </summary>
 private void buttonSignIn_Click(object sender, EventArgs e)
 {
     try
     {
         client.BeginSignIn(textBoxSignInAddress.Text, textBoxUser.Text, textBoxPassword.Text, HandleEndSignIn, null);
     }
     catch (LyncClientException lyncClientException)
     {
         Console.WriteLine(lyncClientException);
     }
     catch (SystemException systemException)
     {
         if (LyncModelExceptionHelper.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;
         }
     }
 }