示例#1
0
        // TODO: this is displaying a Form which is not so good for unit testing or anything
        public Boolean Login()
        {
            try
            {
                //Check prekeyring.xml to see if the Dropbox credential exists.
                SecuruStik.DB.AccessToken at = PreKeyring.AccessToken;
                //If not,pop up a login window asking the user to enter his/her account && password
                if (at == null)
                {
                    this.client = new DropNet.DropNetClient(AppSetting.apiKey, AppSetting.appSecret);
                    this.client.GetToken();

                    //Ask user to enter DropBox account and password
                    SecuruStikMessageQueue.SendMessage_Splash_Hiden();
                    AuthorizeForm af = new AuthorizeForm(this.AuthorizeUrl);
                    af.ShowDialog();

                    if (af.DialogResult == DialogResult.OK)
                    {
                        return(this.GetAccessToken());
                    }
                    else if (af.DialogResult == DialogResult.Cancel)
                    {
                        return(false);
                    }
                }
                else
                {
                    this.client = new DropNet.DropNetClient(
                        AppSetting.apiKey,
                        AppSetting.appSecret,
                        at.UserToken, at.UserSecret, null);
                }
            } catch (System.Exception ex)
            {
                throw new SecuruStikException(
                          SecuruStikExceptionType.DropBoxControl_Login,
                          "Failed to Login the dropbox",
                          ex);
            }
            return(true);
        }
示例#2
0
 private void Initialization()
 {
     //Do the initial work
     try
     {
         DropBoxUser = new DBox_User();
         this.BeginInvoke(new MethodInvoker(this.Close));
     }
     catch (System.Exception ex)
     {
         SecuruStikMessageQueue.SendMessage_Splash_Hiden();
         MessageBox.Show(
             new Form {
             TopMost = true, StartPosition = FormStartPosition.CenterScreen
         },
             ex.Message, "Sorry, our program meets some mistakes...",
             System.Windows.Forms.MessageBoxButtons.OK,
             System.Windows.Forms.MessageBoxIcon.Error);
         Process.GetCurrentProcess().Kill();
     }
 }