Esempio n. 1
0
		/// <summary>Obtm todos os utilizadores com a role passada</summary>
		public override int[] getUsers( int role )
		{
			string query = string.Format("select IDUsers from Users inner join UserRoles on Users.IDUsers = UserRoles.IDUser where UserRoles.IDRoles = {0}", role);
			HttpContext.Current.Trace.Write("MySQL","Query String: " + query);
			
			return fetchUsersIds( MySqlUtility.getQuery(query) );
		}
Esempio n. 2
0
        /// <summary>Obtm todos os scans de um planeta</summary>
        public override Scan[] GetScans(Planet scanner)
        {
            string  query = string.Format("SELECT * FROM Scans WHERE SourcePlanetId={0} ORDER BY Id DESC LIMIT 0, 40", scanner.Id);
            DataSet ds    = MySqlUtility.getQuery(query);

            return(DataSetToScans(ds));
        }
Esempio n. 3
0
		/// <summary>Obtm todos ordenados por Ranking</summary>
		public override User[] getUsersRanking()
		{
			int count = 50;
		
			string query = string.Format("select * from Users order by user_rank desc limit 0, {0}", count);
			DataSet ds = MySqlUtility.getQuery(query);

			return PopulateUserRankings(count, ds, "IDUsers");
		}
Esempio n. 4
0
        /// <summary>Obtm um scan dado o seu id</summary>
        public override Scan GetScan(int id)
        {
            string  query = string.Format("SELECT * FROM Scans WHERE Id={0}", id);
            DataSet ds    = MySqlUtility.getQuery(query);

            if (ds.Tables[0].Rows.Count == 0)
            {
                return(null);
            }
            return(DataSetToScans(ds)[0]);
        }
Esempio n. 5
0
		/// <summary>Retorna as roles de um User dado o seu ID</summary>
		public string[] getRoles( int id )
		{
			string query = string.Format("SELECT roles_roleName FROM `UserRoles` inner join `Roles` on UserRoles.IDRoles=Roles.IDRoles WHERE UserRoles.IDUser={0}", id);
			DataSet ds = MySqlUtility.getQuery(query);
			
			string[] roles = new string[ds.Tables[0].Rows.Count];
			int i = 0;
			
			foreach( DataRow row in ds.Tables[0].Rows ) {
				roles[i++] = row[0].ToString();
			}
			
			return roles;
		}
Esempio n. 6
0
        /// <summary>Obtm todos os scans de um jogador em todos os planetas</summary>
        public override Scan[] GetScans(Ruler ruler)
        {
            StringWriter writer = new StringWriter();

            writer.Write("SELECT * FROM Scans WHERE SourcePlanetId={0}", ruler.Planets[0].Id);
            for (int i = 1; i < ruler.Planets.Length; ++i)
            {
                writer.Write(" or SourcePlanetId={0} ", ruler.Planets[i].Id);
            }
            writer.Write(" ORDER BY Id DESC LIMIT 0, 60");

            DataSet ds = MySqlUtility.getQuery(writer.ToString());

            return(DataSetToScans(ds));
        }
Esempio n. 7
0
		/// <summary>Obtm todos ordenados por Ranking</summary>
		public override IList getInactiveUsers()
		{
			DateTime now = DateTime.Now;
			
			int m = now.Month - 1;
			if( m <= 0 ) {
				m = 12;
			}
		
			string query = string.Format("select * from Users where user_ruler_id!=-1 and user_lastlogin <  '{0}-{1}-{2}'", now.Year, GetNumber(m), GetNumber(now.Day));
			Log.log(query);
			DataSet ds = MySqlUtility.getQuery(query);

			return PopulateUserRankings(ds.Tables[0].Rows.Count, ds, "IDUsers");
		}
Esempio n. 8
0
		public override void setAllianceMembers( AllianceInfo info ){
			string query = string.Format("SELECT * FROM `Users` where abs(user_alliance_id) = {0}", info.Id);
			DataSet ds = MySqlUtility.getQuery(query);
			ArrayList all = PopulateUsers(ds, "IDUsers");
			
			ArrayList members = new ArrayList();
			ArrayList wannabe = new ArrayList();
			
			foreach( User user in all ) {
				if( user.AllianceId < 0 ) {
					wannabe.Add(user);
				} else {
					members.Add(user);
				}
			}
			
			info.Members = members;
			info.Wannabe = wannabe;
		}
Esempio n. 9
0
        public override AllianceInfo Get(int id)
        {
            DataSet alliances = MySqlUtility.getQuery("select * from Alliance where alliance_id=" + id);

            return((AllianceInfo)FromDataSet(alliances)[0]);
        }
Esempio n. 10
0
        /// <summary>Obtém as notícias existentes</summary>
        protected override NewsList GetNewsFromDB()
        {
            DataSet ds = MySqlUtility.getQuery("SELECT * FROM News ORDER BY Date DESC LIMIT 0, 10");

            return(NewsFromDataSet(ds));
        }