Exemplo n.º 1
0
        public IEnumerable <MediaType> GetMediaTypes()
        {
            SQLiteConnection connection = GetConnectionForTable("azusa.mediaTypes");
            SQLiteCommand    cmd        = connection.CreateCommand();

            cmd.CommandText = "SELECT * FROM azusa.mediaTypes";
            SQLiteDataReader dataReader = cmd.ExecuteReader();

            while (dataReader.Read())
            {
                MediaType mt = new MediaType();
                mt.Id                  = dataReader.GetInt32(0);
                mt.ShortName           = dataReader.GetString(1);
                mt.LongName            = dataReader.GetString(2);
                mt.GraphData           = dataReader.GetBoolean(3);
                mt.DateAdded           = dataReader.GetDateTime(4);
                mt.Icon                = dataReader.GetByteArray(5);
                mt.IgnoreForStatistics = dataReader.GetBoolean(6);
                if (!dataReader.IsDBNull(8))
                {
                    mt.HasFilesystem = dataReader.GetBoolean(8);
                }
                yield return(mt);
            }
            dataReader.Dispose();
            cmd.Dispose();
        }
Exemplo n.º 2
0
        public IEnumerable <FilesystemMetadataEntity> GetFilesystemMetadata(int currentMediaId, bool dirs)
        {
            if (getFilesystemMetadataCommand == null)
            {
                getFilesystemMetadataCommand             = GetConnectionForTable("azusa.filesysteminfo").CreateCommand();
                getFilesystemMetadataCommand.CommandText =
                    "SELECT * FROM azusa.filesysteminfo " +
                    "WHERE mediaid = @mediaid " +
                    "AND isdirectory = @isdirectory " +
                    "ORDER BY parent ASC";
                getFilesystemMetadataCommand.Parameters.Add("@mediaid", DbType.Int32);
                getFilesystemMetadataCommand.Parameters.Add("@isdirectory", DbType.Boolean);
            }

            getFilesystemMetadataCommand.Parameters["@mediaid"].Value     = currentMediaId;
            getFilesystemMetadataCommand.Parameters["@isdirectory"].Value = dirs;
            SQLiteDataReader dataReader = getFilesystemMetadataCommand.ExecuteReader();

            while (dataReader.Read())
            {
                FilesystemMetadataEntity child = new FilesystemMetadataEntity();
                child.Id          = dataReader.GetInt64(0);
                child.MediaId     = dataReader.GetInt32(1);
                child.DateAdded   = dataReader.GetDateTime(2);
                child.IsDirectory = dataReader.GetBoolean(3);
                child.FullName    = dataReader.GetString(4);
                if (!dataReader.IsDBNull(5))
                {
                    child.Size = dataReader.GetInt64(5);
                }
                if (!dataReader.IsDBNull(6))
                {
                    child.Modified = dataReader.GetDateTime(6);
                }
                if (!dataReader.IsDBNull(7))
                {
                    child.Header = dataReader.GetByteArray(7);
                }

                child.ParentId = dataReader.GetInt64(8);
                yield return(child);
            }
            dataReader.Close();
        }
Exemplo n.º 3
0
        public Media GetMediaById(int o)
        {
            if (getMediaByIdCommand == null)
            {
                SQLiteConnection connection = GetConnectionForTable("azusa.media");
                getMediaByIdCommand             = connection.CreateCommand();
                getMediaByIdCommand.CommandText = "SELECT * FROM azusa.media WHERE id=@id";
                getMediaByIdCommand.Parameters.Add(new SQLiteParameter("@id", DbType.Int32));
            }

            getMediaByIdCommand.Parameters["@id"].Value = o;
            SQLiteDataReader ndr = getMediaByIdCommand.ExecuteReader();

            if (!ndr.Read())
            {
                ndr.Dispose();
                return(null);
            }
            Media m = new Media();

            m.Id = ndr.GetInt32(0);
            m.RelatedProductId = ndr.GetInt32(1);
            m.Name             = ndr.GetString(2);
            m.MediaTypeId      = ndr.GetInt32(3);

            if (!ndr.IsDBNull(4))
            {
                m.SKU = ndr.GetString(4);
            }

            if (!ndr.IsDBNull(5))
            {
                m.DumpStorageSpaceId = ndr.GetInt32(5);
            }

            if (!ndr.IsDBNull(6))
            {
                m.DumpStorageSpacePath = ndr.GetString(6);
            }

            if (!ndr.IsDBNull(7))
            {
                m.MetaFileContent = ndr.GetString(7);
            }

            if (!ndr.IsDBNull(8))
            {
                m.DateAdded = ndr.GetDateTime(8);
            }

            if (!ndr.IsDBNull(9))
            {
                m.GraphDataContent = ndr.GetString(9);
            }

            if (!ndr.IsDBNull(10))
            {
                m.CueSheetContent = ndr.GetString(10);
            }

            if (!ndr.IsDBNull(11))
            {
                m.ChecksumContent = ndr.GetString(11);
            }

            if (!ndr.IsDBNull(12))
            {
                m.PlaylistContent = ndr.GetString(12);
            }

            if (!ndr.IsDBNull(13))
            {
                m.CdTextContent = ndr.GetByteArray(13);
            }

            if (!ndr.IsDBNull(14))
            {
                m.LogfileContent = ndr.GetString(14);
            }

            if (!ndr.IsDBNull(15))
            {
                m.MdsContent = ndr.GetByteArray(15);
            }

            m.isSealed = ndr.GetBoolean(16);

            if (!ndr.IsDBNull(17))
            {
                m.DateUpdated = ndr.GetDateTime(17);
            }

            if (!ndr.IsDBNull(18))
            {
                m.FauxHash = ndr.GetInt64(18);
            }

            ndr.Dispose();
            return(m);
        }
Exemplo n.º 4
0
        public Product GetProductById(int id)
        {
            SQLiteConnection connection = GetConnectionForTable("azusa.products");
            SQLiteCommand    cmd        = connection.CreateCommand();

            cmd.CommandText = "SELECT * FROM azusa.products WHERE id = @id";
            cmd.Parameters.Add("@id", DbType.Int32);
            cmd.Parameters["@id"].Value = id;
            SQLiteDataReader ndr    = cmd.ExecuteReader();
            Product          result = null;

            if (ndr.Read())
            {
                result         = new Product();
                result.Id      = ndr.GetInt32(0);
                result.InShelf = ndr.GetInt32(1);
                result.Name    = ndr.GetString(2);
                result.Picture = ndr.GetByteArray(3);


                if (!ndr.IsDBNull(4))
                {
                    result.Price = ndr.GetDouble(4);
                }

                if (!ndr.IsDBNull(5))
                {
                    result.BoughtOn = ndr.GetDateTime(5);
                }

                if (!ndr.IsDBNull(6))
                {
                    result.Sku = ndr.GetString(6);
                }

                if (!ndr.IsDBNull(7))
                {
                    result.PlatformId = ndr.GetInt32(7);
                }

                if (!ndr.IsDBNull(8))
                {
                    result.SupplierId = ndr.GetInt32(8);
                }

                if (!ndr.IsDBNull(9))
                {
                    result.CountryOfOriginId = ndr.GetInt32(9);
                }

                result.Screenshot = ndr.GetByteArray(10);

                if (!ndr.IsDBNull(11))
                {
                    result.DateAdded = ndr.GetDateTime(11);
                }

                result.Consistent = ndr.GetBoolean(12);

                if (!ndr.IsDBNull(13))
                {
                    result.NSFW = ndr.GetBoolean(13);
                }

                result.Complete = ndr.GetBoolean(14);
            }
            ndr.Dispose();
            cmd.Dispose();
            return(result);
        }