Пример #1
0
        private void logIn()
        {
            LoginResult result = null;
            string      lastKnownAccessToken = loadLastKnownAccessToken();

            if (!string.IsNullOrEmpty(lastKnownAccessToken))
            {
                DialogResult quickLogInResult = MessageBox.Show(
                    @"Would you like to quick log in using the same user?",
                    @"Would you like to quick log in?",
                    MessageBoxButtons.YesNo);
                if (quickLogInResult == DialogResult.Yes)
                {
                    result = FacebookService.Connect(lastKnownAccessToken);
                }
            }

            if (result == null || string.IsNullOrEmpty(result.AccessToken))
            {
                result = FacebookService.Login(k_ApplicationId, sr_RequiredPermissions);
            }

            if (string.IsNullOrEmpty(result.AccessToken))
            {
                MessageBox.Show(result.ErrorMessage);
            }
            else
            {
                this.m_LoggedInUser = result.LoggedInUser;
                this.m_UserPaths    = new UserPaths(this.m_LoggedInUser);
                saveAccessToken(result.AccessToken);
                this.initializeUserDirectory();
                this.buttonLogIn.Enabled = false;
            }
        }
        private void logIn()
        {
            LoginResult result = null;
            string lastKnownAccessToken = loadLastKnownAccessToken();

            if (!string.IsNullOrEmpty(lastKnownAccessToken))
            {
                DialogResult quickLogInResult = MessageBox.Show(
                    @"Would you like to quick log in using the same user?",
                    @"Would you like to quick log in?",
                    MessageBoxButtons.YesNo);
                if (quickLogInResult == DialogResult.Yes)
                {
                    result = FacebookService.Connect(lastKnownAccessToken);
                }
            }

            if (result == null || string.IsNullOrEmpty(result.AccessToken))
            {
                result = FacebookService.Login(k_ApplicationId, sr_RequiredPermissions);
            }

            if (string.IsNullOrEmpty(result.AccessToken))
            {
                MessageBox.Show(result.ErrorMessage);
            }
            else
            {
                this.m_LoggedInUser = result.LoggedInUser;
                this.m_UserPaths = new UserPaths(this.m_LoggedInUser);
                saveAccessToken(result.AccessToken);
                this.initializeUserDirectory();
                this.buttonLogIn.Enabled = false;
            }
        }