Beispiel #1
0
        public static List <RvRom> ReadRoms(uint gameId)
        {
            if (_commandRvRomReader == null)
            {
                _commandRvRomReader = new SQLiteCommand(
                    @"SELECT RomId,name,
                    type,
                    rom.size,
                    rom.crc,
                    rom.sha1,
                    rom.md5,
                    merge,status,putinzip,
                    rom.FileId,
                    files.size as fileSize,
                    files.compressedsize as fileCompressedSize,
                    files.crc as filecrc,
                    files.sha1 as filesha1,
                    files.md5 as filemd5
                FROM rom LEFT OUTER JOIN files ON files.FileId=rom.FileId WHERE GameId=@GameId ORDER BY RomId", Program.db.Connection);
                _commandRvRomReader.Parameters.Add(new SQLiteParameter("GameId"));
            }


            List <RvRom> roms = new List <RvRom>();

            _commandRvRomReader.Parameters["GameId"].Value = gameId;

            using (DbDataReader dr = _commandRvRomReader.ExecuteReader())
            {
                while (dr.Read())
                {
                    RvRom row = new RvRom
                    {
                        RomId              = Convert.ToUInt32(dr["RomId"]),
                        GameId             = gameId,
                        Name               = dr["name"].ToString(),
                        AltType            = VarFix.FixFileType(dr["type"]),
                        Size               = VarFix.FixLong(dr["size"]),
                        CRC                = VarFix.CleanMD5SHA1(dr["CRC"].ToString(), 8),
                        SHA1               = VarFix.CleanMD5SHA1(dr["SHA1"].ToString(), 40),
                        MD5                = VarFix.CleanMD5SHA1(dr["MD5"].ToString(), 32),
                        Merge              = dr["merge"].ToString(),
                        Status             = dr["status"].ToString(),
                        PutInZip           = (bool)dr["putinzip"],
                        FileId             = VarFix.FixLong(dr["FileId"]),
                        FileSize           = VarFix.FixLong(dr["fileSize"]),
                        FileCompressedSize = VarFix.FixLong(dr["fileCompressedSize"]),
                        FileCRC            = VarFix.CleanMD5SHA1(dr["fileCRC"].ToString(), 8),
                        FileSHA1           = VarFix.CleanMD5SHA1(dr["fileSHA1"].ToString(), 40),
                        FileMD5            = VarFix.CleanMD5SHA1(dr["fileMD5"].ToString(), 32)
                    };

                    roms.Add(row);
                }
                dr.Close();
            }
            return(roms);
        }