Example #1
0
    public static void Login(Action<string, string> callback)
    {
      var json = StorageIo.ReadTextFile(LOGIN_HELPER_FILE);
      if (string.IsNullOrEmpty(json))
      {
        var client = new DropNetClient(AppSetting.DROPBOX_API_KEY,
                                       AppSetting.DROPBOX_API_SECRET);
        client.LoginAsync(
          "*****@*****.**",
          "emfkqqkrtm",
          (login) =>
          {
            string[] credintial = new string[]
            {
              login.Token,
              login.Secret
            };
            var jsonsaving = JsonConvert.SerializeObject(credintial);
            StorageIo.WriteTextFile(LOGIN_HELPER_FILE, jsonsaving);

            ThreadUtil.UiCall(() => callback(login.Token, login.Secret));
          },
          (err) =>
          {
            MessageBox.Show("err happened:" + err.Response);
          }
        );

        return;
      }

      string[] info = JsonConvert.DeserializeObject<string[]>(json);
      callback(info[0], info[1]);
    }
Example #2
0
        private void PerformLogin()
        {
            if (!Network.CheckNetwork())
                return;

            progBusy.IsBusy = true;

            var client = new DropNetClient(
                DropBoxInfo.KEY, DropBoxInfo.SECRET);

            client.LoginAsync(txtEmail.Text, txtPassword.Password,
                LoginCompleted, LoginFailed);
        }
Example #3
0
    /// <summary>
    /// Sign-in button clicked
    /// </summary>
    /// <param name="sender">Event sender</param>
    /// <param name="e">Event parameter</param>
    void OnSigninClicked(
          object sender,
          ManipulationCompletedEventArgs e)
    {
      if (false == UiUtils.IsTapped(e))
        return;

      var email = _email.Text.Trim();
      var password = _password.Password.Trim();
      var folder = _folder.Text.Trim();

      if (string.IsNullOrEmpty(email))
      {
        MessageBox.Show("Please enter e-mail");
        _email.Focus();
        return;
      }

      if (string.IsNullOrEmpty(password))
      {
        MessageBox.Show("Please enter your password");
        _password.Focus();
        return;
      }

      if (string.IsNullOrEmpty(folder))
      {
        MessageBox.Show("Please enter your sync folder name");
        _folder.Focus();
        return;
      }

      VisualStateManager.GoToState(this, VS_SIGNING, true);

      _dropboxclient = new DropNetClient(AppSetting.DROPBOX_API_KEY,
                                         AppSetting.DROPBOX_API_SECRET);
      _dropboxclient.LoginAsync(email, password,
          (userlogin) =>
          {
            var usertoken = userlogin.Token;
            var secret = userlogin.Secret;

            VisualStateManager.GoToState(this, VS_NORMAL, true);

            if (SigninSucceeded != null)
            {
              SigninSucceeded(this,
                              new DropboxSigninEventArgs
                              {
                                UserToken = usertoken,
                                UserSecret = secret,
                                RemoteFolderName = folder
                              });

              ClearControl();
            }
          },
          (error) =>
          {
            var errormsg = ExtractErrorMessage(error);
            VisualStateManager.GoToState(this, VS_NORMAL, true);
            if (SigninFailed != null)
              SigninFailed(this,
                           new DropboxSigninEventArgs
                           {
                             ErrorMessage = errormsg
                           });
          });

    }