/// <summary>Obtm um scan dado o seu id</summary> public override Scan GetScan(int id) { string query = string.Format("SELECT scans_id,scans_data FROM OrionsBelt_Scans WHERE scans_id = {0} LIMIT 10;", id.ToString()); DataSet ds = PostGreServerUtility.getFromDBWithQuery(query); return(DataSetToScans(ds)[0]); }
/// <summary> /// Verfica se existe um user com o mail e pass passados /// </summary> public override bool checkUser( string mail, string pass ) { pass = hashPassword(pass); Log.log("checkUser({0}, {1})", mail, pass); string query = string.Format("select orionsbelt_userscheckuser('{0}','{1}')", mail, pass); DataSet ds = PostGreServerUtility.getFromDBWithQuery(query); return !(ds.Tables[0].Rows[0][0] is DBNull); }
/// <summary>Obtm todos os utilizadores com a role passada</summary> public override int[] getUsers( int role ) { //(PostGre.PostGreParam [] p = new PostGreParam[1]; //p[0] = new PostGreParam(role,NpgsqlDbType.Integer); //DataSet ds = PostGreServerUtility.getFromDB("OrionsBelt_UsersGetUsersIdByRole",p); DataSet ds = PostGreServerUtility.getFromDBWithQuery(string.Format("SELECT user_id FROM OrionsBelt_UserRoles WHERE roles_id ={0}",role)); return fetchUsersIds( ds ); }
/// <summary>Obtm todos os scans de um planeta</summary> public override Scan[] GetScans(Planet scanner) { //DataSet ds = PostGreServerUtility.getFromDB("OrionsBelt_GetScansByPlanetId", parameters ); string query = string.Format("SELECT scans_id,scans_data FROM OrionsBelt_Scans WHERE scans_sourcePlanetId={0} ORDER BY scans_id DESC LIMIT 40;", scanner.Id.ToString()); DataSet ds = PostGreServerUtility.getFromDBWithQuery(query); return(DataSetToScans(ds)); }
/// <summary>Obtém todos os scans de um jogador em todos os planetas</summary> public override Scan[] GetScans(Ruler ruler) { StringWriter writer = new StringWriter(); writer.Write("scans_sourcePlanetId={0}", ruler.Planets[0].Id); for (int i = 1; i < ruler.Planets.Length; ++i) { writer.Write(" or scans_sourcePlanetId={0} ", ruler.Planets[i].Id); } string query = string.Format("SELECT scans_id,scans_data FROM OrionsBelt_Scans WHERE {0} LIMIT {1}", writer.ToString( ), 40); DataSet ds = PostGreServerUtility.getFromDBWithQuery(query); return(DataSetToScans(ds)); }
/// <summary> /// carrega todas as excepes ocorridas para um array de excepes /// </summary> /// <returns></returns> public override ExceptionInfo[] load() { //DataSet dataset = PostGreServerUtility.getAllFromDB("OrionsBelt_ExceptionLogLoad"); string query = "SELECT * FROM OrionsBelt_ExceptionLog ORDER BY exceptionLog_date DESC;"; DataSet dataset = PostGreServerUtility.getFromDBWithQuery(query); int i = 0, count = dataset.Tables[0].Rows.Count; ExceptionInfo[] exceptions = new ExceptionInfo[count]; foreach (DataRow row in dataset.Tables[0].Rows) { _exception = row; exceptions[i++] = new ExceptionInfo( (int)getField(0), (string)getField(1), (DateTime)getField(4), (string)getField(2), (string)getField(3) ); } return(exceptions); }