public WorkerLoginResult Login(string loginName, string password, string badgeCode, string stationName, WorkerFunction workerFunction) { WorkerLoginResult ret = WorkerLoginResult.Failed; try { switch (AuthenticationMode) { case AuthenticationMode.Any: ret = Login(loginName, password, stationName, workerFunction); if (ret != WorkerLoginResult.Ok) { ret = Login(badgeCode, stationName, workerFunction); } break; case AuthenticationMode.UserPassword: ret = Login(loginName, password, stationName, workerFunction); break; case AuthenticationMode.BadgeCode: ret = Login(badgeCode, stationName, workerFunction); break; } } catch (Exception ex) { ExceptionMessage = ex.Message; ret = WorkerLoginResult.Failed; } return(ret); }
public WorkerLoginResult Login(string stationName, string loginName, string password, WorkerFunction workerFunction, string connectionString) { LoadFromDbByLoginName(loginName); WorkerAuthenticator wa = new WorkerAuthenticator(AuthenticationMode.UserPassword, connectionString); WorkerLoginResult ret = wa.Login(loginName, password, string.Empty, stationName, workerFunction); if (ret == WorkerLoginResult.Ok) { UpdateLoginDateOnStation(Id, stationName, DateTime.Now); } return(ret); }
public WorkerLoginResult Login(string stationName, string badgeCode, WorkerFunction workerFunction, string connectionString) { LoadFromDbByBadgeCode(badgeCode); WorkerAuthenticator wa = new WorkerAuthenticator(AuthenticationMode.BadgeCode, connectionString); WorkerLoginResult ret = wa.Login(string.Empty, string.Empty, badgeCode, stationName, workerFunction); if (ret == WorkerLoginResult.Ok) { LoadFromDbByBadgeCode(badgeCode); UpdateLoginDateOnStation(Id, stationName, DateTime.Now); } return(ret); }
public void TestLocalUserPassword() { bool actual = false; bool expected = true; string workerLoginName = "Administrator"; string workerPassword = "******"; string stationName = "ST10"; WorkerAuthenticator wa = new WorkerAuthenticator(AuthenticationMode.UserPassword); WorkerLoginResult res = wa.Login(workerLoginName, workerPassword, string.Empty, stationName); if (res == WorkerLoginResult.Ok) { actual = true; } Assert.AreEqual(expected, actual); }
public void TestLocalBadgeCode() { bool actual = false; bool expected = true; string workerLoginName = "Administrator"; string workerBadgeCode = "12345"; string stationName = "ST10"; WorkerAuthenticator wa = new WorkerAuthenticator(AuthenticationMode.BadgeCode); WorkerLoginResult res = wa.Login(string.Empty, string.Empty, workerBadgeCode, stationName); if (wa.CurrentWorker.LoginName == workerLoginName && res == WorkerLoginResult.Ok) { actual = true; } Assert.AreEqual(expected, actual); }
public LoginResult LoginByPassword(string workerLoginName, string workerPassword, string stationName) { try { Result = Auth.Login(workerLoginName, workerPassword, string.Empty, stationName); if (!(string.IsNullOrEmpty(Auth.ExceptionMessage))) { throw new Exception(string.Format("Authenticator exception: {0}", Auth.ExceptionMessage)); } } catch (Exception ex) { throw new Exception(string.Format("{0}{1}{2}", ex.Message, Environment.NewLine, Auth.ExceptionMessage)); } return(GetLoginResult(Result)); }
public void TestRemoteBadgeCode() { bool actual = false; bool expected = true; string workerLoginName = "marco.dallera"; string workerBadgeCode = ";80380000100118208054?"; string stationName = "ST60.00"; string connectionString = "Data Source=192.168.100.250;Initial Catalog=TraMa4_520-334;User ID=TraMa;Password=trama"; WorkerAuthenticator wa = new WorkerAuthenticator(AuthenticationMode.BadgeCode, connectionString); WorkerLoginResult res = wa.Login(string.Empty, string.Empty, workerBadgeCode, stationName); if (wa.CurrentWorker.LoginName == workerLoginName && res == WorkerLoginResult.Ok) { actual = true; } Assert.AreEqual(expected, actual); }
public void TestRemoteUserPassword() { bool actual = false; bool expected = true; string workerLoginName = "marco.dallera"; string workerPassword = "******"; string stationName = "ST60.00"; string connectionString = "Data Source=192.168.100.250;Initial Catalog=TraMa4_520-334;User ID=TraMa;Password=trama"; WorkerAuthenticator wa = new WorkerAuthenticator(AuthenticationMode.UserPassword, connectionString); WorkerLoginResult res = wa.Login(workerLoginName, workerPassword, string.Empty, stationName); if (res == WorkerLoginResult.Ok) { actual = true; } Assert.AreEqual(expected, actual); }
private LoginResult GetLoginResult(WorkerLoginResult res) { switch (res) { case WorkerLoginResult.Ok: return(LoginResult.Ok); case WorkerLoginResult.Failed: return(LoginResult.Failed); case WorkerLoginResult.NotEnabled: return(LoginResult.NotEnabled); default: return(LoginResult.Failed); } }
public void TestLocalBadgeCodeKo() { bool actual = false; bool expected = true; string workerLoginName = string.Empty; string workerBadgeCode = "12345"; string stationName = "ST99C"; Init_PB139(); WorkerAuthenticator wa = new WorkerAuthenticator(AuthenticationMode.BadgeCode); WorkerLoginResult res = wa.Login(string.Empty, string.Empty, workerBadgeCode, stationName); if (wa.CurrentWorker.LoginName == workerLoginName && res == WorkerLoginResult.Failed) { actual = true; } Assert.AreEqual(expected, actual); }
public void TestLocalUserPasswordKo() { bool actual = false; bool expected = true; string workerLoginName = "FakeUser"; string workerPassword = "******"; string stationName = "ST104F"; Init_PB139(); WorkerAuthenticator wa = new WorkerAuthenticator(AuthenticationMode.UserPassword); WorkerLoginResult res = wa.Login(workerLoginName, workerPassword, string.Empty, stationName); if (res == WorkerLoginResult.Failed) { actual = true; } Assert.AreEqual(expected, actual); }
public Authenticator(AuthenticationMode authMode, string connectionString) { this.Auth = new WorkerAuthenticator(authMode, connectionString); this.Result = WorkerLoginResult.Failed; }
public Authenticator(AuthenticationMode authMode) { this.Auth = new WorkerAuthenticator(authMode, this.GetConnectionString()); this.Result = WorkerLoginResult.Failed; }