public static GetProfile ( int id ) : |
||
id | int | Profile ID to get |
return |
/// <summary> /// Publically accessible login, to allow calling of login via AWB startup parameters /// </summary> /// <param name="profileID">Profile ID to login to</param> public void login(int profileID) { if (profileID == -1) { return; } try { AWBProfile startupProfile = AWBProfiles.GetProfile(profileID); if (!string.IsNullOrEmpty(startupProfile.Password)) {//Get 'Saved' Password browserLogin(startupProfile.Username, startupProfile.Password); } else {//Get Password from User UserPassword password = new UserPassword(); password.SetText = "Enter password for " + startupProfile.Username; if (password.ShowDialog() == DialogResult.OK) { browserLogin(startupProfile.Username, password.GetPassword); } } } catch (Exception ex) { ErrorHandler.Handle(ex); } }
private void btnQuickLogin_Click(object sender, EventArgs e) { string user = txtUsername.Text; string password = txtPassword.Text; if (chkSaveProfile.Checked) { if (AWBProfiles.GetProfile(txtUsername.Text) != null) { MessageBox.Show("Username \"" + txtUsername.Text + "\" already exists.", "Username exists"); return; } var profile = new AWBProfile { Username = user }; if (chkSavePassword.Checked) { profile.Password = password; } AWBProfiles.AddEditProfile(profile); } AWBProfiles.LastUsedAccount = user; PerformLogin(user, password); }
private void AWBProfiles_Load(object sender, EventArgs e) { if (!DesignMode) { LoadProfiles(); } string lua = AWBProfiles.LastUsedAccount; if (!string.IsNullOrEmpty(lua)) { int id; int.TryParse(lua, out id); AWBProfile p = AWBProfiles.GetProfile(id); if (p == null) { txtUsername.Text = lua; return; } txtUsername.Text = (id > 0) ? p.Username : lua; } }
private void edit() { try { AWBProfileAdd add = new AWBProfileAdd(AWBProfiles.GetProfile(int.Parse(lvAccounts.Items[lvAccounts.SelectedIndices[0]].Text))); if (add.ShowDialog() == DialogResult.Yes) { loadProfiles(); } } catch { } }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtUsername.Text)) { MessageBox.Show("The Username cannot be blank"); } else { // warn user if profile for entered user ID already exists if (Editid == -1 && AWBProfiles.GetProfile(txtUsername.Text) != null) { if (MessageBox.Show("Username \"" + txtUsername.Text + "\" is already used in another profile. Are you sure you want to use this username again?", "Username already used in another profile", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } } AWBProfile profile = new AWBProfile { Username = txtUsername.Text }; if (chkSavePassword.Checked && !string.IsNullOrEmpty(txtPassword.Text)) { profile.Password = txtPassword.Text; } else { profile.Password = ""; } profile.DefaultSettings = txtPath.Text; int idUpload = AWBProfiles.GetIDOfUploadAccount(); if (chkUseForUpload.Checked && (idUpload != -1) && (idUpload != Editid)) { AWBProfiles.SetOtherAccountsAsNotForUpload(); } profile.UseForUpload = chkUseForUpload.Checked; profile.Notes = txtNotes.Text; profile.ID = Editid; AWBProfiles.AddEditProfile(profile); DialogResult = DialogResult.Yes; } }
/// <summary> /// Publically accessible login, to allow calling of login via AWB startup parameters /// </summary> /// <param name="profileID">Profile ID to login to</param> public void login(string profileIdOrName) { if (profileIdOrName.Length == 0) { return; } try { int profileID = -1; AWBProfile startupProfile; if (int.TryParse(profileIdOrName, out profileID)) { startupProfile = AWBProfiles.GetProfile(profileID); } else { startupProfile = AWBProfiles.GetProfile(profileIdOrName); } if (startupProfile == null) { MessageBox.Show(this.Parent, "Can't find user '" + profileIdOrName + "'.", "Command line error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (!string.IsNullOrEmpty(startupProfile.Password)) {//Get 'Saved' Password browserLogin(startupProfile.Username, startupProfile.Password); } else {//Get Password from User UserPassword password = new UserPassword(); password.SetText = "Enter password for " + startupProfile.Username; if (password.ShowDialog() == DialogResult.OK) { browserLogin(startupProfile.Username, password.GetPassword); } } } catch (Exception ex) { ErrorHandler.Handle(ex); } }
/// <summary> /// Publically accessible login, to allow calling of login via AWB startup parameters /// </summary> /// <param name="profileIdOrName">Profile ID to login to</param> public void Login(string profileIdOrName) { if (profileIdOrName.Length == 0) { return; } try { int profileID; AWBProfile startupProfile = int.TryParse(profileIdOrName, out profileID) ? AWBProfiles.GetProfile(profileID) : AWBProfiles.GetProfile(profileIdOrName); if (startupProfile == null) { MessageBox.Show(Parent, "Can't find user '" + profileIdOrName + "'.", "Command line error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (!string.IsNullOrEmpty(startupProfile.Password)) { //Get 'Saved' Password PerformLogin(startupProfile.Username, startupProfile.Password); } else { //Get Password from User UserPassword password = new UserPassword { Username = startupProfile.Username }; if (password.ShowDialog(this) == DialogResult.OK) { PerformLogin(startupProfile.Username, password.GetPassword); } } } catch (Exception ex) { ErrorHandler.HandleException(ex); } }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtUsername.Text)) { MessageBox.Show("The Username cannot be blank"); } else { if (Editid == -1 && AWBProfiles.GetProfile(txtUsername.Text) != null) { MessageBox.Show("Username \"" + txtUsername.Text + "\" already exists.", "Username exists"); return; } AWBProfile profile = new AWBProfile { Username = txtUsername.Text }; if (chkSavePassword.Checked && !string.IsNullOrEmpty(txtPassword.Text)) { profile.Password = txtPassword.Text; } profile.DefaultSettings = txtPath.Text; int idUpload = AWBProfiles.GetIDOfUploadAccount(); if (chkUseForUpload.Checked && (idUpload != -1) && (idUpload != Editid)) { AWBProfiles.SetOtherAccountsAsNotForUpload(); } profile.UseForUpload = chkUseForUpload.Checked; profile.Notes = txtNotes.Text; profile.ID = Editid; AWBProfiles.AddEditProfile(profile); DialogResult = DialogResult.Yes; } }