コード例 #1
0
        public List <Mediadata> getMedia(string type, int id)
        {
            List <Mediadata> result = new List <Mediadata>();
            Mediadata        record = new Mediadata(1, 2, 3, 4, "loc");

            result.Add(record);
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Here you will get the media infomration for any type of object in the database aslong as you say what type it is.
        /// </summary>
        /// <param name="type">R = Resource, S = Ship, P = Planet</param>
        /// <param name="id"></param>
        /// <returns></returns>
        public List <Mediadata> getMedia(string type, int id)
        {
            string           Query  = "";
            List <Mediadata> result = new List <Mediadata>();

            switch (type)
            {
            case "R":
                Query = string.Format("SELECT media.Media_id, media.X_size, media.Y_size, media.Lenght, media.File_loc FROM media, resourcesmedia WHERE resourcesmedia.Media_id == media.Media_id AND resourcesmedia.Resources_id == {0};", id);
                break;

            case "S":
                Query = string.Format("SELECT media.Media_id, media.X_size, media.Y_size, media.Lenght, media.File_loc FROM media, shipmedia WHERE shipmedia.Media_id == media.Media_id AND shipmedia.Ship_id == {0};", id);
                break;

            case "P":
                Query = string.Format("SELECT media.Media_id, media.X_size, media.Y_size, media.Lenght, media.File_loc FROM media, planetmedia WHERE planetmedia.Media_id == media.Media_id AND planetmedia.Planet_id == {0};", id);
                break;
            }
            if (Check())
            {
                using (SQLiteCommand command = new SQLiteCommand(Query, dbc))
                {
                    try
                    {
                        using (SQLiteDataReader rdq = command.ExecuteReader())
                        {
                            while (rdq.Read())
                            {
                                Mediadata record = new Mediadata(rdq.GetInt32(0), rdq.GetInt32(1), rdq.GetInt32(2), rdq.GetInt32(3), rdq.GetString(4));
                                result.Add(record);
                            }
                        }
                    }
                    catch (Exception ex) { Console.WriteLine("Error " + ex); }
                }
            }
            return(result);
        }