Ejemplo n.º 1
0
        public static string UpdateObject(string id, string inventory, string hitPoints, string position, string fuel, string damage, string lifetime)
        {
            MySqlConnection sqlConnecton = ArmaSQL.GetConnection();
            MySqlCommand    command      = sqlConnecton.CreateCommand();

            command.Parameters.AddWithValue("@id", id);
            command.Parameters.AddWithValue("@last_updated", DateTime.Now.ToString());
            command.Parameters.AddWithValue("@inventory", inventory);
            command.Parameters.AddWithValue("@hitpoints", hitPoints);
            command.Parameters.AddWithValue("@position", position);
            command.Parameters.AddWithValue("@fuel", fuel);
            command.Parameters.AddWithValue("@damage", damage);
            command.Parameters.AddWithValue("@lifetime", lifetime);
            command.CommandText = "UPDATE object_data SET inventory = @inventory, last_updated = NOW(), hitpoints = @hitpoints, position = @position, fuel = @fuel, damage = @damage, lifetime = @lifetime WHERE id = @id";

            String found = string.Empty;

            try
            {
                command.ExecuteNonQuery();
                found = "Select worked";
            }
            catch (Exception e)
            {
                found = "ERROR ArmaHive: " + e;
            }

            sqlConnecton.Close();

            return(found);
        }
Ejemplo n.º 2
0
        public string GetUser(string uuid)
        {
            string output = "[]";

            MySqlConnection connection = ArmaSQL.GetConnection();
            MySqlCommand    command    = connection.CreateCommand();
            DataTable       dataTable  = new DataTable();

            command.Parameters.AddWithValue("@uuid", uuid);
            command.CommandText = "SELECT id, name, uuid, inventory, position, medical FROM users WHERE uuid = @uuid LIMIT 1";

            using (MySqlDataAdapter adapter = new MySqlDataAdapter(command))
            {
                adapter.Fill(dataTable);
            }

            command.CommandText = null;

            if (dataTable.Rows.Count > 0)
            {
                DataRow row = dataTable.Rows[0];

                output = "[" + row["id"] + ", " + row["uuid"] + ", " + Utilities.stringToArray(row["inventory"].ToString()) + ", " + row["position"] + ", " + row["medical"] + "]";
                connection.Close();
            }

            return(output);
        }
Ejemplo n.º 3
0
        public string NewObject(string Hive, string ID, string clazz, string position, String inventory, String hitPoints, String fuel, String damage, String lifetime)
        {
            MySqlConnection sqlConnecton = ArmaSQL.GetConnection();
            MySqlCommand    command      = sqlConnecton.CreateCommand();

            command.Parameters.AddWithValue("@id", ID);
            command.Parameters.AddWithValue("@class", clazz);
            command.Parameters.AddWithValue("@position", position);
            command.Parameters.AddWithValue("@server_name", Hive);
            command.Parameters.AddWithValue("@inventory", inventory);
            command.Parameters.AddWithValue("@hitpoints", hitPoints);
            command.Parameters.AddWithValue("@fuel", fuel);
            command.Parameters.AddWithValue("@damage", damage);
            command.Parameters.AddWithValue("@lifetime", lifetime);
            command.CommandText = "INSERT INTO object_data (id, class, position, server_name, inventory, hitpoints, fuel, damage, lifetime) VALUES (@id, @class, @position, @server_name, @inventory, @hitpoints, @fuel, @damage, @lifetime)";

            String found = string.Empty;

            try
            {
                command.ExecuteNonQuery();
                long id = command.LastInsertedId;

                found = "" + id;
            }
            catch (Exception e)
            {
                found = "ERROR ArmaHive: " + e;
            }

            sqlConnecton.Close();

            return(found);
        }
Ejemplo n.º 4
0
        public string GetObjectSpawns()
        {
            MySqlCommand command = ArmaSQL.GetConnection().CreateCommand();

            DataTable dataTable = new DataTable();

            //command.Parameters.AddWithValue("@name", Hive);
            command.CommandText = "SELECT * FROM object_spawns";

            using (MySqlDataAdapter adapter = new MySqlDataAdapter(command))
            {
                adapter.Fill(dataTable);
            }

            command.CommandText = null;
            List <String> storage = new List <String>();

            foreach (DataRow row in dataTable.Rows)
            {
                storage.Add("[" + row["id"] + ", \"" + row["class"] + "\", " + row["position"] + ", " + row["dir"] + "]");
            }

            command.Connection.Close();

            return("[" + string.Join(",", storage.ToArray()) + "]");
        }
Ejemplo n.º 5
0
        public string Update(String table, String field, String fieldSet, String where, String equals)
        {
            if (field == "inventory")
            {
                fieldSet = Utilities.arrayToString(fieldSet);
            }

            return(ArmaSQL.ExecuteUpdate(table, field, fieldSet, where, equals));
        }
Ejemplo n.º 6
0
        public string Select(String table, String field, String where, String equals)
        {
            if (field == "inventory")
            {
                return(Utilities.stringToArray(ArmaSQL.GetField(table, field, where, equals)));
            }

            return(ArmaSQL.GetField(table, field, where, equals));
        }
Ejemplo n.º 7
0
        public bool TestConnection()
        {
            MySqlConnection sqlConnecton = null;

            try
            {
                sqlConnecton = ArmaSQL.GetConnection();
            }
            catch
            {
                return(false);
            }

            if (sqlConnecton != null)
            {
                sqlConnecton.Close();
            }

            return(true);
        }
Ejemplo n.º 8
0
        public string NewUser(String uuid, String name, String position, String inventory)
        {
            MySqlConnection sqlConnecton = ArmaSQL.GetConnection();
            MySqlCommand    command      = sqlConnecton.CreateCommand();

            command.CommandText = "INSERT INTO users (uuid, name, position, inventory) VALUES ('" + uuid + "', '" + name + "', '" + position + "', '" + Utilities.arrayToString(inventory) + "')";

            String found = string.Empty;

            try
            {
                command.ExecuteNonQuery();
                found = "NewUser: worked!";
            }
            catch (Exception e)
            {
                found = "ERROR ArmaHive: " + e;
            }

            sqlConnecton.Close();

            return(found);
        }
Ejemplo n.º 9
0
        public string GetObjectStorage(string Hive)
        {
            MySqlCommand command = ArmaSQL.GetConnection().CreateCommand();

            DataTable dataTable = new DataTable();

            command.Parameters.AddWithValue("@name", Hive);
            command.CommandText = "SELECT * FROM object_data WHERE server_name = @name";

            using (MySqlDataAdapter adapter = new MySqlDataAdapter(command))
            {
                adapter.Fill(dataTable);
            }

            command.CommandText = null;
            List <String> storage = new List <String>();

            foreach (DataRow row in dataTable.Rows)
            {
                if (row["inventory"].ToString().Length == 0)
                {
                    row["inventory"] = "[]";
                }

                if (row["hitpoints"].ToString().Length == 0)
                {
                    row["hitpoints"] = "[]";
                }

                storage.Add("[\"" + row["id"] + "\", \"" + row["class"] + "\", " + row["position"] + ", " + row["inventory"] + ", " + row["hitpoints"] + ", " + row["fuel"] + ", " + row["damage"] + ", " + row["lifetime"] + "]");
            }

            command.Connection.Close();

            return("[" + string.Join(",", storage.ToArray()) + "]");
        }
Ejemplo n.º 10
0
 public string Delete(String table, String where, String equals)
 {
     return(ArmaSQL.ExecuteDelete(table, where, equals));
 }
Ejemplo n.º 11
0
 public string Exists(String table, String where, String equals)
 {
     return(ArmaSQL.GetExists(table, where, equals));
 }