using System; using System.Collections.Generic; using System.Linq; using System.Text; using Tanshu.Accounts.Repository; using System.Threading; using Tanshu.Accounts.Contracts; using Tanshu.Common.KeyboardControl; namespace Tanshu.Accounts.PointOfSale { class KeyboardLogin : ILogin { //private static readonly Tanshu.Logging.SqlLogger log = new Tanshu.Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public bool LoginUser() { return LoginUser(true); } bool LoginUser(bool setThreadPrincipal) { using (LoginForm login = new LoginForm(new KeyboardControl())) { 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) { //log.Warn(string.Format("User Login: '{0}'", userName)); if (userName.Contains(":")) userName = userName.Substring(userName.IndexOf(":") + 1); Session.User = UserBI.GetUserFromName(userName); } } }