Пример #1
0
        private void button_activate_Click(object sender, EventArgs e)
        {
            button_activate.Enabled = false;
            var newCredentials = AuthFlow.CreateCredentialsFromVerifierCode(textbox_usertoken.Text, authenticationContext);

            Log.Http("Access Token = {0}", newCredentials.AccessToken);
            Log.Http("Access Token Secret = {0}", newCredentials.AccessTokenSecret);

            string consumerKey    = textbox_consumertoken.Text;
            string consumerSecret = textbox_consumersecret.Text;
            string accessToken    = newCredentials.AccessToken;
            string accessSecret   = newCredentials.AccessTokenSecret;

            var parser = new INIParser("Globals.ini");

            parser.SetValue("Authenticate", "ConsumerKey", consumerKey);
            parser.SetValue("Authenticate", "CconsumerSecret", consumerSecret);
            parser.SetValue("Authenticate", "AccessToken", accessToken);
            parser.SetValue("Authenticate", "AccessSecret", accessSecret);
            parser.Save( );

            Globals.Instance.Initialize(consumerKey, consumerSecret, accessToken, accessSecret);

            Result = true;

            this.Close( );
        }
Пример #2
0
        static void Body( )
        {
            #region Initialize Program

            Log.Init( );
            InitDirectories( );

            var    setting        = new INIParser("Globals.ini");
            var    AuthData       = "Authenticate";
            string consumerKey    = setting.GetValue(AuthData, "ConsumerKey");
            string consumerSecret = setting.GetValue(AuthData, "CconsumerSecret");
            string accessToken    = setting.GetValue(AuthData, "AccessToken");
            string accessSecret   = setting.GetValue(AuthData, "AccessSecret");
            if (
                string.IsNullOrEmpty(consumerKey) ||
                string.IsNullOrEmpty(consumerSecret) ||
                string.IsNullOrEmpty(accessToken) ||
                string.IsNullOrEmpty(accessSecret))
            {
                Log.Error(LogHeader, "유저 인증 정보를 찾을 수 없습니다. 토큰 발급 창으로 이동합니다.");
                var frm = new Display.Authenticate();
                frm.ShowDialog( );
                if (frm.Result == true)
                {
                }
                else
                {
                    Log.Error(LogHeader, "유저 인증에 실패했습니다. 프로그램을 종료합니다.");
                    Exit( );
                    return;
                }
            }
            else
            {
                //TODO: User가 null일 경우의 대처
                Globals.Instance.Initialize(consumerKey, consumerSecret, accessToken, accessSecret);
            }
            #endregion

            SetDebugParams( );

            Globals.Instance.OwnerID = long.Parse(setting.GetValue("AppInfo", "OwnerID"));
            StringSetsManager.LoadStringsets("Stringsets");
            ModuleManager.Initialize( );
            ModuleManager.LoadAllModules("Modules");

            new Display.AppConsole( ).ShowDialog( );

            foreach (var module in ModuleManager.Modules)
            {
                var parser = new INIParser(Path.Combine("Modules", module.Name + ".ini"));
                module.SaveSettings(parser);
                parser.Save( );
            }
            Exit( );
        }