private static void Purge() { try { var sql1 = "Select coalesce(Count(\"SerialNumberKeeperId\")) FROM \"EnrollKiosk\".\"SerialNumberKeeper\";"; var check = _repository.RepositoryContext().Database.SqlQuery <int>(sql1).ToList(); if (check.IsNullOrEmpty()) { return; } if (check[0] > 100) { sql1 = "Delete FROM \"EnrollKiosk\".\"SerialNumberKeeper\";"; _repository.RepositoryContext().Database.ExecuteSqlCommand(sql1); } } catch (Exception ex) { BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message); } }
public bool DeleteUserRolesByRole(int roleId, out string msg) { try { var sql1 = String.Format( "Delete FROM \"ICASWebAdmin\".\"UserRole\" WHERE \"RoleId\" = {0}", roleId); msg = ""; return(_repository.RepositoryContext().Database.ExecuteSqlCommand(sql1) > 0); } catch (Exception ex) { msg = ex.Message; BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message); return(false); } }
private ClientStation GetStation(string stationId) { try { var sql = new StringBuilder(); sql.Append(string.Format("SELECT * FROM \"EnrollKiosk\".\"ClientStation\" WHERE \"StationId\" = '{0}'", stationId)); var retVal = _repository.RepositoryContext() .Database.SqlQuery <ClientStation>(sql.ToString()).ToList(); if (retVal.IsNullOrEmpty()) { return(null); } return(retVal[0]); } catch (Exception ex) { BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message); return(null); } }
private bool IsDuplicate(string roleName, out string msg) { try { var sql1 = String.Format( "Select * FROM \"EnrollKiosk\".\"Role\" WHERE lower(\"Name\") = lower('{0}')", roleName.Replace("'", "''")); var check = _repository.RepositoryContext().Database.SqlQuery <Role>(sql1).ToList(); msg = ""; if (check.IsNullOrEmpty()) { return(false); } msg = "Duplicate Error! Item already exist"; return(true); } catch (Exception ex) { msg = "Error: " + ex.Message; BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message); return(true); } }
private bool doesBeneficiaryInfoExist(int surnameHashed, int dobHashed, int mobileHashed, int othernameHashed, int firstnameHashed, int sex, int calType, out string msg) { try { var sql = new StringBuilder(); sql.Append(string.Format("SELECT * FROM \"EnrollKiosk\".\"Beneficiary\" WHERE 1 = 1")); if (Math.Abs(surnameHashed) > 0) { sql.Append(string.Format(" AND \"SurnameHashed\" = {0}", surnameHashed)); } if (Math.Abs(dobHashed) > 0) { sql.Append(string.Format(" AND \"DateOfBirthHashed\" = {0}", dobHashed)); } if (Math.Abs(mobileHashed) > 0) { sql.Append(string.Format(" AND \"MobileNoHashed\" = {0}", mobileHashed)); } if (Math.Abs(firstnameHashed) > 0) { sql.Append(string.Format(" AND \"FirstNameHashed\" = {0}", firstnameHashed)); } if (Math.Abs(othernameHashed) > 0) { sql.Append(string.Format(" AND \"OtherNameHashed\" = {0}", othernameHashed)); } if (sex > 0 && sex < 3) { sql.Append(string.Format(" AND \"Sex\" = {0}", sex)); } var retVal = _repository.RepositoryContext() .Database.SqlQuery <Beneficiary>(sql.ToString()).ToList(); if (retVal.IsNullOrEmpty()) { msg = ""; return(false); } if (calType == 2) { if (retVal.Count == 1) { msg = ""; return(false); } } msg = ""; return(true); } catch (Exception ex) { msg = ex.Message; BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message); return(true); } }