public bool LogIn(string username, string password, out LoggedOnUserResult theLogOnObject) { UserName = username; Password = password; MsgLabel = "Invalid Username/Password!"; IsError = true; LoggedOnUserResult result = new LoggedOnUserResult(); result = sdk.LogonExternal(UserName, Password, 29); if (result.ResultInfo.ReturnCode == Datalayer.Xero.Interresolve.AquariumUserManagement.BasicCode.OK) { LoginResultDetails = result; MsgLabel = "Login Successful!"; IsError = false; theLogOnObject = LoginResultDetails; return true; } else if (result.ResultInfo.ReturnCode == BasicCode.Failed) { MsgLabel = "Error ID:" + result.ResultInfo.Errors[0].ResultCodeID + ", Description:" + result.ResultInfo.Errors[0].Description; IsError = true; theLogOnObject = null; return false; } Exception ex = new Exception("The LogIn method in the Accounts class has thrown an exception"); throw ex; }
//true if it logs in successfully public bool LoginToAquarium() { try { Account theUserAccount = new Account(); theUserResult = new LoggedOnUserResult(); LoggedOnUserResult theMethodUserResult = new LoggedOnUserResult(); if(theUserAccount.LogIn("*****@*****.**", "teenpunks", out theMethodUserResult)) { theUserResult.Username = theUserAccount.LoginResultDetails.Username; theUserResult.SessionKey = theUserAccount.LoginResultDetails.SessionKey; this.theUserResult = theMethodUserResult; return true; } else { Exception exFail = new Exception("Login to Aquarium has failed in the LoginToAquarium method"); throw exFail; } } catch (Exception ex) { throw ex; } }
/// <summary> /// Checks the Username and Password with the SDK and logs user in if authenticated /// </summary> /// <param name="username">Username</param> /// <param name="password">Password</param> /// <returns>true/false</returns> public bool LogIn(string username, string password) { UserName = username; Password = password; bool loginResult = false; MsgLabel = "Invalid Username/Password!"; IsError = true; LoggedOnUserResult result = new LoggedOnUserResult(); result = sdk.LogonExternal(UserName, Password, 29); if (result.ResultInfo.ReturnCode == AquariumUserManagement.BasicCode.OK) { SDKHelper.SetSessionDetails<AquariumUserManagement.LoggedOnUserResult>("User", result); LoginResultDetails = result; loginResult = true; MsgLabel = "Login Successful!"; IsError = false; } else if (result.ResultInfo.ReturnCode == AquariumUserManagement.BasicCode.Failed) { MsgLabel = "Error ID:" + result.ResultInfo.Errors[0].ResultCodeID + ", Description:" + result.ResultInfo.Errors[0].Description; IsError = true; } return loginResult; }