示例#1
0
        void authWindow_AuthSuccess(object sender, GetOAuthorization.AuthSuccessEventArgs e)
        {
            GetOAuthorization authWindow = sender as GetOAuthorization;

            AppController.Current.sendNotification("General info", "Authorization in progress", "", "", null);
            AppController.Current.Logger.addDebugMessage("Start Twitter auth", "");
            AppController.Current.Logger.addDebugMessage("Proxy enabled", Properties.Settings.Default.ProxyEnabled.ToString(), type: DebugMessage.DebugMessageTypes.LogMessage);
            AppController.Current.Logger.addDebugMessage("Proxy server", Properties.Settings.Default.ProxyServer, type: DebugMessage.DebugMessageTypes.LogMessage);
            AppController.Current.Logger.addDebugMessage("Proxy port", Properties.Settings.Default.ProxyPort.ToString(), type: DebugMessage.DebugMessageTypes.LogMessage);

            OAuthAccessToken accessToken = null;

            try
            {
                accessToken = authWindow.account.twitterService.GetAccessToken(e.requestToken, e.verifyKey);
            }
            catch (Exception exp)
            {
                AppController.Current.Logger.addDebugMessage(exp.Message, exp.StackTrace, type: DebugMessage.DebugMessageTypes.Twitter);
                AppController.Current.sendNotification("Error", exp.Message, exp.StackTrace, "", null);
            }

            try
            {
                authWindow.account.Token       = accessToken.Token;
                authWindow.account.TokenSecret = accessToken.TokenSecret;

                authWindow.account.verifyCredentials();
                Model.AccountTwitter newAccount = authWindow.account;
                newAccount.IsStreamingAccount = true;
                newAccount.getLists();
                newAccount.getSearches();
                newAccount.UpdateItems();
                AppController.Current.Logger.addDebugMessage("New Twitter account authoried", "", account: newAccount, type: DebugMessage.DebugMessageTypes.FirstStartWizard);
                AppController.Current.AllAccounts.Add(newAccount);
            }
            catch (Exception exp)
            {
                AppController.Current.Logger.addDebugMessage(exp.Message, exp.StackTrace, type: DebugMessage.DebugMessageTypes.Twitter);
                AppController.Current.sendNotification("Error", exp.Message, exp.StackTrace, "", null);
            }
        }
        void authWindow_AuthSuccess(object sender, GetOAuthorization.AuthSuccessEventArgs e)
        {
            AppController.Current.sendNotification("General info", "Authorization in progress", "", "", null);
            GetOAuthorization authWindow  = sender as GetOAuthorization;
            OAuthAccessToken  accessToken = null;

            try
            {
                accessToken = authWindow.account.twitterService.GetAccessToken(e.requestToken, e.verifyKey);
            }
            catch (Exception exp)
            {
                AppController.Current.sendNotification("Error", exp.Message, exp.StackTrace, "", null);
            }

            try
            {
                authWindow.account.Token       = accessToken.Token;
                authWindow.account.TokenSecret = accessToken.TokenSecret;

                authWindow.account.verifyCredentials();
                Model.AccountTwitter newAccount = authWindow.account;
                newAccount.IsStreamingAccount = true;
                newAccount.getLists();
                newAccount.getSearches();
                newAccount.UpdateItems();
                AppController.Current.AllAccounts.Add(newAccount);
                AppController.Current.saveAccountsAndViews();
                if (AppController.Current.AllViews.Count == 0)
                {
                    tabViews.IsSelected = true;
                    buttonViewAdd_Click(null, null);
                }
            }
            catch (Exception exp)
            {
                AppController.Current.sendNotification("Error", exp.Message, exp.StackTrace, "", null);
            }
        }