2011-01-06 07:17:00 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
using Tanshu.Accounts.Repository;
|
2011-01-06 07:17:00 +00:00
|
|
|
|
using System.Threading;
|
2011-02-09 12:03:22 +00:00
|
|
|
|
using Tanshu.Accounts.Contracts;
|
|
|
|
|
using Tanshu.Common.KeyboardControl;
|
2011-01-06 07:17:00 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.PointOfSale
|
|
|
|
|
{
|
|
|
|
|
class KeyboardLogin : ILogin
|
|
|
|
|
{
|
|
|
|
|
public bool LoginUser()
|
|
|
|
|
{
|
|
|
|
|
return LoginUser(true);
|
|
|
|
|
}
|
|
|
|
|
bool LoginUser(bool setThreadPrincipal)
|
|
|
|
|
{
|
2011-02-09 12:03:22 +00:00
|
|
|
|
using (LoginForm login = new LoginForm(new KeyboardControl()))
|
2011-01-06 07:17:00 +00:00
|
|
|
|
{
|
|
|
|
|
string userName;
|
|
|
|
|
login.ShowDialog();
|
|
|
|
|
bool authenticated = login.UserName(out userName);
|
|
|
|
|
if (authenticated && setThreadPrincipal)
|
|
|
|
|
SetThreadPrincipal(userName);
|
|
|
|
|
return authenticated;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool LogoutUser()
|
|
|
|
|
{
|
|
|
|
|
Session.User = null;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
static void SetThreadPrincipal(string userName)
|
|
|
|
|
{
|
|
|
|
|
if (userName.Contains(":"))
|
|
|
|
|
userName = userName.Substring(userName.IndexOf(":") + 1);
|
|
|
|
|
|
2011-01-30 07:14:05 +00:00
|
|
|
|
Session.User = UserBI.GetUserFromName(userName);
|
2011-01-06 07:17:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|