public void SetUserInfoEx(UserInfoEx info) { bigAvatarPanel.BackgroundImage = info.AvatarBig; smallAvatarPanel.BackgroundImage = info.AvatarSmall; aboutRichTextBox.Text = info.About; ContactListUtils.UnpackContacts(info.Contacts, contactsListView); }
public UserInfoEx GetUserInfo() { var result = new UserInfoEx(); var rows = userInfoFastGrid.GetRowValues <Cortege2 <string, string> >(false).ToList(); result.Id = rows.FirstOrDefault(pair => pair.a == "ID").b.ToInt(0); result.AvatarBig = bigAvatarPanel.BackgroundImage as Bitmap; result.AvatarSmall = smallAvatarPanel.BackgroundImage as Bitmap; result.About = aboutRichTextBox.Text; result.Contacts = ContactListUtils.PackContacts(contactsListView); return(result); }
private void EditExisting() { var login = AccountStatus.Instance.Login; if (string.IsNullOrEmpty(login)) { return; } if (string.IsNullOrEmpty(oldPassword)) { return; } if (editedUser == null) { return; } if (editedAccount == null) { return; } // собрать данные var user = new PlatformUser { Email = tbEmail.Text, Login = tbLogin.Text, Name = tbName.Text, Surname = tbSurname.Text, Patronym = tbPatronym.Text, Phone1 = tbPhone1.Text, Phone2 = tbPhone2.Text, Description = tbDescription.Text, Password = tbPassword.Text }; var maxLeverage = tbMaxLeverage.Text.ToFloatUniform(); bool loginIsBusy; var resp = MainForm.serverProxyTrade.proxy.ModifyUserAndAccount(login, oldPassword, user, editedAccount.ID, maxLeverage, out loginIsBusy); if (loginIsBusy) { MessageBox.Show(string.Format(Localizer.GetString("MessageLoginInUse"), user.Login)); return; } if (resp == AuthenticationResponse.AccountInactive || resp == AuthenticationResponse.InvalidAccount || resp == AuthenticationResponse.WrongPassword || resp == AuthenticationResponse.ServerError) { var msg = Localizer.GetString("MessageUnableToUpdate") + " - " + EnumFriendlyName <AuthenticationResponse> .GetString(resp); MessageBox.Show(msg, Localizer.GetString("TitleError")); } // обновить дополнительные данные о пользователе try { var userInfoExSource = new UserInfoExCache(TradeSharpAccountStatistics.Instance.proxy, TerminalEnvironment.FileCacheFolder); var info = new UserInfoEx { Id = editedUser.ID, AvatarBig = bigAvatarPanel.BackgroundImage as Bitmap, AvatarSmall = smallAvatarPanel.BackgroundImage as Bitmap, About = aboutRichTextBox.Text, Contacts = ContactListUtils.PackContacts(contactsListView) }; userInfoExSource.SetUserInfo(info); } catch (Exception ex) { MessageBox.Show(Localizer.GetString("TitleServerError"), Localizer.GetString("TitleError")); Logger.Info("Ошбика при записи дополнительной информации о пользователе", ex); return; } MessageBox.Show(Localizer.GetString("MessageDataSuccessfulyUpdated"), Localizer.GetString("TitleConfirmation"), MessageBoxButtons.OK, MessageBoxIcon.Asterisk); }
private void LoadData() { // загрузить данные о пользователе и счете editedAccount = AccountStatus.Instance.AccountData; if (editedAccount == null) { return; } // валюта... var indexCurx = cbCurrency.Items.IndexOf(editedAccount.Currency); if (indexCurx < 0) { indexCurx = cbCurrency.Items.Add(editedAccount.Currency); } cbCurrency.SelectedIndex = indexCurx; // баланс... cbDepoSize.Text = editedAccount.Equity.ToStringUniformMoneyFormat(false); // макс плечо... tbMaxLeverage.Text = editedAccount.MaxLeverage.ToStringUniform(); // получить данные о пользователе... var login = AccountStatus.Instance.Login; if (string.IsNullOrEmpty(login)) { return; } var password = UserSettings.Instance.GetPasswordForLogin(login); oldPassword = password; var passwordPrompt = Localizer.GetString("MessageEnterOldPassword"); while (true) { if (string.IsNullOrEmpty(password)) { DialogResult rst; password = Dialogs.ShowInputDialog(passwordPrompt, "", true, out rst); if (rst == DialogResult.Cancel) { return; } oldPassword = password; } var resp = MainForm.serverProxyTrade.proxy.GetUserDetail(login, password, out editedUser); if (resp == AuthenticationResponse.AccountInactive || resp == AuthenticationResponse.InvalidAccount || resp == AuthenticationResponse.ServerError) { MessageBox.Show(EnumFriendlyName <AuthenticationResponse> .GetString(resp)); return; } if (resp == AuthenticationResponse.WrongPassword) { password = string.Empty; passwordPrompt = Localizer.GetString("MessageWrongPwrdEnterAgain"); continue; } if (editedUser != null) { break; } } // показать данные пользователя tbEmail.Text = editedUser.Email; tbLogin.Text = editedUser.Login; tbPatronym.Text = editedUser.Patronym; tbName.Text = editedUser.Name; tbSurname.Text = editedUser.Surname; tbPhone1.Text = editedUser.Phone1; tbPhone2.Text = editedUser.Phone2; tbDescription.Text = editedUser.Description; tbPassword.Text = editedUser.Password; ShowSignallerOptions(editedUser); // получить дополнительные данные о пользователе try { var userInfoExSource = new UserInfoExCache(TradeSharpAccountStatistics.Instance.proxy, TerminalEnvironment.FileCacheFolder); var info = userInfoExSource.GetUserInfo(editedUser.ID); if (info != null) { bigAvatarPanel.BackgroundImage = info.AvatarBig; smallAvatarPanel.BackgroundImage = info.AvatarSmall; aboutRichTextBox.Text = info.About; ContactListUtils.UnpackContacts(info.Contacts, contactsListView); } } catch (Exception ex) { MessageBox.Show(Localizer.GetString("TitleServerError"), Localizer.GetString("TitleError"), MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.Info("Ошбика при чтении дополнительной информации о пользователе", ex); } }