internal void AccountUpdate(AdminUpdateAccount.UpdateAccountArg arg) { if (UOClient != null && Status == ConnectionStatus.Connected) { UOClient.Send(new AdminUpdateAccount(ClientVersion.vAdminClient, arg)); } }
private void FormSave_Click(object sender, RoutedEventArgs e) { AccountResult account; if (TryGetAccount(FormUsername.Content as string, out account)) { bool OKpass = false; bool OKaccess = false; string newPass = FormPassword.Text; if (!string.IsNullOrWhiteSpace(newPass)) { OKpass = true; } UoClientSDK.AccessLevel newAccessLevel; if (Enum.TryParse(FormAccessLevel.Text, out newAccessLevel)) { OKaccess = true; } bool newBanned = FormBanned.IsChecked ?? false; if (!OKpass || !OKaccess) { string message = "Please fix the following errors:"; if (!OKpass) { message += "\nPassword is required."; } if (!OKaccess) { message += "\nAccess Level is not valid."; } MessageBox.Show(message, "Save Account Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { bool passChanged = newPass != account.Password; bool accessChanged = newAccessLevel != account.AccessLevel; bool bannedChanged = newBanned != account.Banned; if (passChanged || accessChanged || bannedChanged) { string message = string.Format("The following parameters for account {0} will be updated:", account.Username); if (passChanged) { message += string.Format("\n\tPassword -> {0}", newPass); } if (accessChanged) { message += string.Format("\n\tAccess Level -> {0}", newAccessLevel.ToString()); } if (bannedChanged) { message += string.Format("\n\tAccount will be {0}", newBanned ? "Banned" : "Unbanned"); } if (MessageBox.Show(message, "Confirm account update", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation) == MessageBoxResult.OK) { if (OnAccountUpdate != null) { AdminUpdateAccount.UpdateAccountArg arg = new AdminUpdateAccount.UpdateAccountArg() { Username = account.Username, Password = newPass, AccessLevel = newAccessLevel, Banned = newBanned, AddressRestrictions = account.AddressRestrictions, }; OnAccountUpdate(arg); account.Password = "******"; account.AccessLevel = newAccessLevel; account.Banned = newBanned; Accounts[account.Username] = account; EnableFormEdit = false; if (bannedChanged) { OnResults(Accounts.Values.ToArray()); } } else { MessageBox.Show("Save OK, but not implemented."); } } } else { MessageBox.Show("Nothing changed!"); } } } }