Exemplo n.º 1
0
        /// <summary>
        /// このクラスでの実行すること。
        /// </summary>
        /// <param name="runChildren"></param>
        public override void Run(bool runChildren)
        {
            //App認証の場合
            if (SetTwitterApiKeys.UseAppOnlyAutherentcation || AppOnlyAuthentication != null)
            {
                if (AppOnlyAuthentication == null)
                {
                    AppOnlyAuthentication = new AppOnlyAuthentication();
                }
                AppOnlyAuthentication.SetUp(this);
                token = OAuth2.GetToken(AppOnlyAuthentication.ConsumerKey, AppOnlyAuthentication.ConsumerSecret);
            }
            else
            {
                //普通の認証の場合
                if (GetOAuthTokens() == null)
                {
                    var session = OAuth.Authorize(ConsumerKey, ConsumerSecret);
                    ReportManage.Report(this, "PINがありません。ブラウザに表示されているPINの値を入力してください。PIN=\"(表示されているPIN)\" とTwitterLoginクラスに情報を追加してください");
                    System.Diagnostics.Process.Start(session.AuthorizeUri.ToString());

                    Task reportProgressTask = Task.Factory.StartNew(() =>
                    {
                        PinDialog pin = new PinDialog();
                        if (pin.ShowDialog() == true)
                        {
                            var tokens = session.GetTokens(pin.PIN);


                            TokenData td = new TokenData()
                            {
                                ConsumerKey       = ConsumerKey,
                                ConsumerSecret    = ConsumerSecret,
                                AccessToken       = tokens.AccessToken,
                                AccessTokenSecret = tokens.AccessTokenSecret
                            };
                            this.Token     = new Tokens(tokens);
                            this.TokenData = td;
                            System.Xaml.XamlServices.Save(tokenSettingFileName, td);
                        }
                        else
                        {
                            return;
                        }
                    },
                                                                    CancellationToken.None,
                                                                    TaskCreationOptions.None,
                                                                    RawlerLib.UIData.UISyncContext);
                    reportProgressTask.Wait();
                }
            }
            base.Run(runChildren);
        }
Exemplo n.º 2
0
        /// <summary>
        /// このクラスでの実行すること。
        /// </summary>
        /// <param name="runChildren"></param>
        public override void Run(bool runChildren)
        {
            //App認証の場合
            if (SetTwitterApiKeys.UseAppOnlyAutherentcation || AppOnlyAuthentication != null)
            {
                if(AppOnlyAuthentication == null)
                {
                    AppOnlyAuthentication = new AppOnlyAuthentication();
                }
                AppOnlyAuthentication.SetUp(this);
                token = OAuth2.GetToken(AppOnlyAuthentication.ConsumerKey, AppOnlyAuthentication.ConsumerSecret);
            }
            else
            {
                //普通の認証の場合
                if (GetOAuthTokens() == null)
                {
                    var session = OAuth.Authorize(ConsumerKey, ConsumerSecret);
                    ReportManage.Report(this, "PINがありません。ブラウザに表示されているPINの値を入力してください。PIN=\"(表示されているPIN)\" とTwitterLoginクラスに情報を追加してください");
                    System.Diagnostics.Process.Start(session.AuthorizeUri.ToString());

                    Task reportProgressTask = Task.Factory.StartNew(() =>
                    {
                        PinDialog pin = new PinDialog();
                        if (pin.ShowDialog() == true)
                        {
                            var tokens = session.GetTokens(pin.PIN);

                            TokenData td = new TokenData()
                            {
                                ConsumerKey = ConsumerKey,
                                ConsumerSecret = ConsumerSecret,
                                AccessToken = tokens.AccessToken,
                                AccessTokenSecret = tokens.AccessTokenSecret
                            };
                            this.Token = new Tokens(tokens);
                            this.TokenData = td;
                            System.Xaml.XamlServices.Save(tokenSettingFileName, td);
                        }
                        else
                        {
                            return;
                        }

                    },
             CancellationToken.None,
             TaskCreationOptions.None,
             RawlerLib.UIData.UISyncContext);
                    reportProgressTask.Wait();

                }
            }
            base.Run(runChildren);
        }