public static int CheckUserInOnlineDB(string username, string password) { int ID_Employee = -99; try { webURL = urlStr + "Synchronise.asmx"; webConURL = urlStr + "RConnection.asmx"; RConnection.RConnection OnConn = new RConnection.RConnection(); OnConn.Url = Login.webConURL; DataTable dt; dt = (DataTable)OnConn.GetLogin(username, password); if (dt.Rows.Count > 0) { ID_Employee = Convert.ToInt32(dt.Rows[0]["ServerKey"]); } //throw new ApplicationException("Online functionality not implemented yet."); //Do the Online Coding. } catch (System.Web.Services.Protocols.SoapException ex) { Logger.LogError("Error in CheckUserInOnlineDB method : " + ex.Message); ID_Employee = -99; // return false; } catch (Exception ep) { Logger.LogError("Error in CheckUserInOnlineDB method : " + ep.Message); // return false; ID_Employee = -99; } return(ID_Employee); }
public static bool verifyPassword(string username, string password) { bool result = false; try { webURL = urlStr + "Synchronise.asmx"; webConURL = urlStr + "RConnection.asmx"; if (!Login.OnLineMode) { using (CEConn localDB = new CEConn()) { string strSql; strSql = "select E.*,grp.name as Role from Employees as E inner join Master_SecurityGroups grp "; strSql += " on grp.ServerKey=E.ID_SecurityGroup "; strSql += " where E.username='******' and E.password='******'"; SqlCeDataReader sr = localDB.getReader(strSql); while (sr.Read()) { _ID = Convert.ToInt32(sr["ServerKey"]); _TagID = (String)sr["TagID"]; _EmpNo = (String)sr["EmpNo"]; _UserName = (String)sr["UserName"]; //_Password = (String)sr["Password"]; _Password = password; _RoleId = Convert.ToInt32(sr["ID_SecurityGroup"]); _Role = (String)sr["Role"]; // sr.Close(); result = true; } sr.Close(); //return false; } if (result == true) { if (ValidateUserInOnlineMode(username, password)) { return(true); } else { return(false); } } else { return(result); } } else { RConnection.RConnection OnConn = new RConnection.RConnection(); OnConn.Url = Login.webConURL; DataTable dt; dt = (DataTable)OnConn.GetLogin(username, password); if (dt.Rows.Count > 0) { _ID = Convert.ToInt32(dt.Rows[0]["ServerKey"]); _TagID = (String)dt.Rows[0]["TagID"]; _EmpNo = (String)dt.Rows[0]["EmpNo"]; _UserName = (String)dt.Rows[0]["UserName"]; //_Password = (String)dt.Rows[0]["Password"]; _Password = password; _RoleId = Convert.ToInt32(dt.Rows[0]["ID_SecurityGroup"]); _Role = (String)dt.Rows[0]["Role"]; return(true); } return(false); //throw new ApplicationException("Online functionality not implemented yet."); //Do the Online Coding. } } catch (System.Web.Services.Protocols.SoapException ex) { if (ex.Actor.ToString().ToLower().Trim() == "getlogin") { err = "Request from innvalid IP address."; } else { err = "Soap Exception"; } Logger.LogError(ex.Message); throw new Exception(ex.Message); } catch (Exception ep) { err = ep.Message; Logger.LogError(ep.Message); throw ep; } }