2022-03-18 22:38:52 +04:00
using ToolsModule.BusinessLogics ;
using ToolsModule.Extensions ;
using ToolsModule.Interfaces ;
2021-03-26 20:09:52 +04:00
using System ;
2021-03-28 00:23:01 +04:00
using System.Collections.Generic ;
2021-03-26 20:09:52 +04:00
using System.Threading.Tasks ;
using System.Windows.Forms ;
namespace DepartmentPortalDesctop
{
/// <summary>
/// Форма входа в систему
/// </summary>
public partial class FormEnter : Form
{
public FormEnter ( )
{
InitializeComponent ( ) ;
}
2021-03-29 23:16:11 +04:00
private void ButtonEnter_Click ( object sender , EventArgs e )
2021-03-26 20:09:52 +04:00
{
2021-03-28 00:26:26 +04:00
if ( textBoxLogin . Text . IsEmpty ( ) )
{
MessageBox . Show ( "Введите логин" , "Ошибка" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
if ( textBoxPassword . Text . IsEmpty ( ) )
{
MessageBox . Show ( "Введите пароль" , "Ошибка" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
2021-03-26 20:09:52 +04:00
try
{
2021-03-28 19:48:15 +04:00
var securityManager = DependencyManager . Instance . Resolve < ISecurityManager > ( ) ;
2021-03-28 10:23:26 +04:00
Task . WaitAll ( Task . Run ( async ( ) = > await securityManager . LoginAsync ( textBoxLogin . Text , textBoxPassword . Text ) ) ) ;
2021-03-26 20:09:52 +04:00
DialogResult = DialogResult . OK ;
Close ( ) ;
}
catch ( Exception ex )
{
2021-04-02 20:53:03 +04:00
DialogResult = DialogResult . Cancel ;
2021-03-28 00:23:01 +04:00
ErrorMessanger . PrintErrorMessage ( "При аутентфикации возникла ошибка: " , new List < KeyValuePair < string , string > > { new KeyValuePair < string , string > ( "Аутентфикация" , ex . Message ) } ) ;
2021-03-26 20:09:52 +04:00
}
}
}
}