/// <summary> /// 2013.4.30, Suresh Madhesan, CR#? /// Function to added to get the usertype while login /// </summary> /// <param name="UserName"></param> /// <param name="vehicleID"></param> /// <param name="password"></param> /// <param name="companyID"></param> /// <param name="deviceToken"></param> /// <param name="deviceTime"></param> /// <param name="dateTime"></param> /// <param name="isNewLogin"></param> /// <param name="VersionNo"></param> /// <param name="UserType"></param> /// <param name="DeviceID"></param> /// <param name="GMT"></param> /// <returns></returns> /// 2013.08.07 FSWW, Ramesh M Added For CR#?... To Validate User with User type Added UserType Parameter as input /// 2013.11.27 FSWW, Ramesh M Added For CR#60210 Added deviceID in parameter /// 2013.12.04 FSWW, Ramesh M Added For CR#61305 Added GMT in parameter /// 2014.02.10 Ramesh M Added TrailerCode For CR#62211 protected String validateUser3(String UserName, String vehicleID, String password, String companyID, String deviceToken, DateTime deviceTime, DateTime dateTime, bool isNewLogin, String VersionNo, String UserType, String DeviceID, DateTime GMT, String TrailerCode, String IOSVersion = "") { Guid sessionID = new Guid(); String sUserType = null; ISession session = null; session = GetSession(); //2013.06-21 Fsww Ramesh M Added For CR#?.. To Validate application Version in Database //if (DataAccess.DALMethods.GetVersionNo(VersionNo,session)>0) //{ sUserType = ValidateUserLogin3(UserName, password, companyID, vehicleID, UserType, VersionNo); // 2014.01.28 Ramesh M Added For CR#62026 Prompt to update the version if ((VersionNo != "1.27") && ((sUserType.ToLower() == "d") || (sUserType.ToLower() == "w") || (sUserType.ToLower() == "g"))) { if (sUserType != "F") { try { Int32 userID = DataAccess.DALMethods.GetUserID(UserName, companyID, session, VersionNo); Int32 iVehicleID = DataAccess.DALMethods.GetVehicleID(vehicleID, companyID, session, VersionNo); sessionID = GetSessionDetail(UserName, password, companyID, vehicleID, deviceTime, VersionNo); // 2013-5-29, Fsww Ramesh M added for CR?.. for avoiding multiple logins,added following a line code and if condition Int32 iLoginIDCount = DataAccess.DALMethods.GetCurrentLoginIDCountByUserNameAndCustomerID(UserName, companyID, session, VersionNo); if (iLoginIDCount == 0) { if (!isNewLogin) { return(sessionID.ToString()); } else if (sessionID != Guid.Empty) { //LogOff Current session DALMethods.UpdateLoginHistory(sessionID, deviceTime, session, VersionNo); DALMethods.removeLoginSession(sessionID, session, VersionNo); } sessionID = Guid.NewGuid(); Entities.LoginHistory history = new Entities.LoginHistory(); history.LoginID = userID; history.VehicleID = iVehicleID; history.CustomerID = companyID; history.DeviceToken = deviceToken; history.DateTime = dateTime; history.IsValidToken = IsValidDevideToken(deviceToken); history.DeviceTime = deviceTime; history.SessionID = sessionID; history.DeviceID = DeviceID; // 2013.12.04 FSWW, Ramesh M Added For CR#61305 Added GMT in parameter history.GMT = GMT; // 2014.02.10 Ramesh M Added TrailerCode For CR#62211 history.TrailerCode = TrailerCode; history.IOSVersion = IOSVersion; DataAccess.DALMethods.AddLoginHistory(history, session, VersionNo); Entities.LoginSession loginSession = new Entities.LoginSession(); loginSession.SessionID = sessionID; loginSession.LoginID = userID; loginSession.CurrentVehicle = iVehicleID; loginSession.Active = true; loginSession.LogonTime = deviceTime; //TODO: Check for DeviceID //loginSession.DeviceID = ""; loginSession.DeviceID = DeviceID; loginSession.Version = VersionNo; loginSession.IOSVersion = IOSVersion; DataAccess.DALMethods.AddLoginSession(loginSession, session, VersionNo); CloseSession(session); } else { // 2013.12.09 FSWW, Ramesh M Added For CR#61409. make the session id to be empty value sessionID = Guid.Empty; sUserType = "N"; } } catch (Exception ex) { if (session != null) { CloseSession(session); } // 2013.06.24 FSWW, Ramesh M Added For CR#58976 To Add More Details about calling function in Error log file. Logging.LogError(ex, "CustomerID-" + companyID + ", SessionID-" + sessionID + "\n"); } finally { if (session != null) { CloseSession(session); } } } //} //else //{ // sUserType = "V"; //} } else { sUserType = "V"; } //2014.02.24 Ramesh M Added For CR#62406 For DriverID,VechileID,UserLoginID on login itself so the user type putted as comma return(sessionID.ToString() + "," + sUserType); }
/// <summary> /// validateUser /// Function to validate user login /// </summary> /// <param name="UserName">User name</param> /// <param name="vehicleID">Vehicle ID</param> /// <param name="password">Password</param> /// <param name="companyID">Company ID</param> /// <param name="deviceToken">Device Token</param> /// <param name="deviceTime">deviceTime</param> /// <param name="dateTime">dateTime</param> /// <param name="isNewLogin">Is New Login</param> /// <returns>SessionID</returns> protected Guid validateUser(String UserName, String vehicleID, String password, String companyID, String deviceToken, DateTime deviceTime, DateTime dateTime, bool isNewLogin, String DeviceID, DateTime GMT, String TrailerCode, String IOSVersion, String VersionNo = "") { Guid sessionID = new Guid(); ISession session = GetSession(); try { // 2013.5.6, Suresh Madhesan, CR#?, To avoid multiple logins //if (DataAccess.DALMethods.GetLoginCount(UserName, companyID, session) > 0) //{ // throw new ApplicationException(ApplicationConstants.Errors.MultipleLoginError); //} if (ValidateUserLogin(UserName, password, companyID, vehicleID, VersionNo)) { // Comment and created the session variable in the beginning of the function // 2013.5.6, Suresh Madhesan, CR#?, To avoid multiple logins //ISession session = null; //try //{ session = GetSession(); Int32 userID = DataAccess.DALMethods.GetUserID(UserName, companyID, session, VersionNo); Int32 iVehicleID = DataAccess.DALMethods.GetVehicleID(vehicleID, companyID, session, VersionNo); sessionID = GetSessionDetail(UserName, password, companyID, vehicleID, deviceTime, VersionNo); if (!isNewLogin) { return(sessionID); } else if (sessionID != Guid.Empty) { //LogOff Current session DALMethods.UpdateLoginHistory(sessionID, deviceTime, session, VersionNo); DALMethods.removeLoginSession(sessionID, session, VersionNo); } sessionID = Guid.NewGuid(); Entities.LoginHistory history = new Entities.LoginHistory(); history.LoginID = userID; history.VehicleID = iVehicleID; history.CustomerID = companyID; history.DeviceToken = deviceToken; history.DateTime = dateTime; history.IsValidToken = IsValidDevideToken(deviceToken); history.DeviceTime = deviceTime; history.SessionID = sessionID; //2013.12.19 FSWW, Ramesh M Added For CR#61549 added String DeviceID, DateTime GMT history.DeviceID = DeviceID; history.GMT = GMT; // 2014.02.10 Ramesh M Added TrailerCode For CR#62211 history.TrailerCode = TrailerCode; history.IOSVersion = IOSVersion; DataAccess.DALMethods.AddLoginHistory(history, session, VersionNo); Entities.LoginSession loginSession = new Entities.LoginSession(); loginSession.SessionID = sessionID; loginSession.LoginID = userID; loginSession.CurrentVehicle = iVehicleID; loginSession.Active = true; loginSession.LogonTime = deviceTime; //TODO: Check for DeviceID loginSession.DeviceID = DeviceID; loginSession.Version = VersionNo; loginSession.IOSVersion = IOSVersion; DataAccess.DALMethods.AddLoginSession(loginSession, session, VersionNo); CloseSession(session); } } catch (Exception ex) { if (session != null) { CloseSession(session); } // 2013.06.24 FSWW, Ramesh M Added For CR#58976 To Add More Details about calling function in Error log file. Logging.LogError(ex, "CustomerID-" + companyID + ", SessionID-" + sessionID + "\n"); throw ex; } finally { if (session != null) { CloseSession(session); } } return(sessionID); }