Example #1
0
        private async void lnklblLog_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                if (office365Contact != null &&
                    office365Contact.IsAuthenticated)
                {
                    this.rtxtResults.Text   = String.Empty;
                    this.lblUserLogged.Text = String.Empty;
                    InitilizeControls(false);
                    InitilizeSignInformation(false);
                    await office365Contact.SignOut();

                    this.office365Contact = null;
                }
                else
                {
                    office365Contact = new Office365Contact();
                    await office365Contact.EnsureExchangeClient();

                    this.lblInformation.Text = "The user is logged correctly";
                    InitilizeControls(true);
                    InitilizeSignInformation(true);
                    this.lblUserLogged.Text = String.Format("{0} {1} - ( {2} )",
                                                            office365Contact.AuthenticationInfo.IdToken.GivenName,
                                                            office365Contact.AuthenticationInfo.IdToken.FamilyName,
                                                            office365Contact.AuthenticationInfo.IdToken.Email);
                }
            }
            catch (AuthenticationFailedException ex)
            {
                this.lblInformation.Text = "Authentication failed :: " + ex.Message;
            }
            catch (Exception ex)
            {
                this.lblInformation.Text = "General Error :: " + ex.Message;
            }
        }
 private async void lnklblLog_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     try
     {
         if (office365Contact != null &&
             office365Contact.IsAuthenticated)
         {
             this.rtxtResults.Text = String.Empty;
             this.lblUserLogged.Text = String.Empty;
             InitilizeControls(false);
             InitilizeSignInformation(false);
             await office365Contact.SignOut();
             this.office365Contact = null;
         }
         else
         {
             office365Contact = new Office365Contact();
             await office365Contact.EnsureExchangeClient();
             this.lblInformation.Text = "The user is logged correctly";
             InitilizeControls(true);
             InitilizeSignInformation(true);
             this.lblUserLogged.Text = String.Format("{0} {1} - ( {2} )", 
                                                     office365Contact.AuthenticationInfo.IdToken.GivenName,
                                                     office365Contact.AuthenticationInfo.IdToken.FamilyName,
                                                     office365Contact.AuthenticationInfo.IdToken.Email);
         }
     }
     catch (AuthenticationFailedException ex)
     {
         this.lblInformation.Text = "Authentication failed :: " + ex.Message;
     }
     catch (Exception ex)
     {
         this.lblInformation.Text = "General Error :: " + ex.Message;
     }
 }