using DesktopTools.BusinessLogics; using ModelTools.BusinessLogics; using ModelTools.Extensions; using ModelTools.Interfaces; using SecurityBusinessLogic.BusinessLogics; using System; using System.Collections.Generic; using System.Threading.Tasks; using System.Windows.Forms; namespace DepartmentPortalDesctop { /// /// Форма входа в систему /// public partial class FormEnter : Form { public FormEnter() { InitializeComponent(); } private void Login() { if (textBoxLogin.Text.IsEmpty()) { MessageBox.Show("Введите логин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (textBoxPassword.Text.IsEmpty()) { MessageBox.Show("Введите пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } try { var securityManager = UnityContainerConfigurator.Resolve(); Task.WaitAll(Task.Run(async () => await securityManager.LoginAsync(textBoxLogin.Text, textBoxPassword.Text))); DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { ErrorMessanger.PrintErrorMessage("При аутентфикации возникла ошибка: ", new List> { new KeyValuePair("Аутентфикация", ex.Message) }); } } private void ButtonEnter_Click(object sender, EventArgs e) => Login(); private void TextBoxPassword_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { Login(); } } } }