Example #1
0
 public static object ReadBoolean(SQLiteDataReader reader, int idx)
 {
     try
     {
         if (reader.IsDBNull(idx))
             return false;
         else
             return reader.GetBoolean(idx);
     }
     catch (Exception)
     {
         return false;
     }
 }
Example #2
0
    internal DbChannel(SQLiteDataReader r, IDictionary<string, int> field, DataRoot dataRoot, Dictionary<long, string> providers, Satellite sat, Transponder tp)
    {
      var chType = r.GetInt32(field["chType"]);
      this.SignalSource = DbSerializer.ChTypeToSignalSource(chType);

      this.RecordIndex = r.GetInt64(field["SRV.srvId"]);
      this.OldProgramNr = r.GetInt32(field["major"]);
      this.FreqInMhz = (decimal)r.GetInt32(field["freq"]) / 1000;
      this.ChannelOrTransponder = 
        (this.SignalSource & SignalSource.DvbT) == SignalSource.DvbT ? LookupData.Instance.GetDvbtTransponder(this.FreqInMhz).ToString() :
        (this.SignalSource & SignalSource.DvbC) == SignalSource.DvbC ? LookupData.Instance.GetDvbcTransponder(this.FreqInMhz).ToString() :
        (this.SignalSource & SignalSource.Sat) == SignalSource.DvbS ? LookupData.Instance.GetAstraTransponder((int)this.FreqInMhz).ToString() :
        "";
      this.Name = DbSerializer.ReadUtf16(r, 6);
      this.Hidden = r.GetBoolean(field["hidden"]);
      this.Encrypted = r.GetBoolean(field["scrambled"]);
      this.Lock = r.GetBoolean(field["lockMode"]);
      this.Skip = !r.GetBoolean(field["numSel"]);

      if (sat != null)
      {
        this.Satellite = sat.Name;
        this.SatPosition = sat.OrbitalPosition;
      }
      if (tp != null)
      {
        this.Transponder = tp;
        this.SymbolRate = tp.SymbolRate;
      }

      if ((this.SignalSource & SignalSource.Digital) != 0)
        this.ReadDvbData(r, field, dataRoot, providers);
      else
        this.ReadAnalogData(r, field);

      base.IsDeleted = this.OldProgramNr == -1;
    }
        internal FateRecord(SQLiteDataReader rpReader)
        {
            ID = rpReader.GetInt64("time");

            var rMasterInfo = KanColleGame.Current.MasterInfo;
            var rMasterID = rpReader.GetInt32("master_id");
            IsEquipment = rpReader.GetBoolean("is_equipment");
            if (!IsEquipment)
                Ship = rMasterInfo.Ships[rMasterID];
            else
                Equipment = rMasterInfo.Equipment[rMasterID];

            Level = rpReader.GetInt32("level");
            Proficiency = rpReader.GetInt32("proficiency");

            Fate = (Fate)rpReader.GetInt32("fate");
        }
        /// <summary>
        /// Runs query to check for presence of submitted username / password combination in database.
        /// Returns true and keeps connection open for further use if valid; returns false and closes connection if invalid. 
        /// </summary>
        /// <returns>loggedIn</returns>
        public bool LogIn()
        {
            //connection = new SQLiteConnection("Data Source=testdb.sqlite;Version=3;");//Connect to database, open, and run command. 
            //connection.Open();
            // replaced your connection with the one I'm certain has the right location. It returns an open connection.
            connection = DbSetupManager.GetConnection();
            command = new SQLiteCommand(sql, connection);
            reader = command.ExecuteReader();//I'm assuming this sets up a cursor behind the scenes, which the reader uses to cycle through returned rows.            

            if (!reader.Read())//Not sure if this is a valid use, since I can't test it. Basically, if the query returns no rows, the login fails.
            {               
                loggedIn = false;
                LogOut();//Closes the connection, since it's no longer needed. 
            }

            else//A row was returned, so login was successful. 
            {
                isAdmin = reader.GetBoolean(5);
                loggedIn = true;
            }
            
            connection.Close(); 
            return loggedIn;
        }
Example #5
0
        private static NPC createNPC(SQLiteDataReader reader)
        {
            SQLiteCommand command;

            if (!reader.Read()) {
                return null;
            }

            NPC npc = new NPC();
            npc.permanent = true;
            npc.id = reader.GetInt32(0);
            npc.name = reader["name"].ToString();
            npc.city = reader["city"].ToString();
            if (!reader.IsDBNull(3) && !reader.IsDBNull(4) && !reader.IsDBNull(5)) {
                npc.pos.x = reader.GetInt32(3);
                npc.pos.y = reader.GetInt32(4);
                npc.pos.z = reader.GetInt32(5);
            }
            npc.image = Image.FromStream(reader.GetStream(6));
            npc.job = reader.IsDBNull(7) ? "" : reader.GetString(7);
            if (npc.image.RawFormat.Guid == ImageFormat.Gif.Guid) {
                int frames = npc.image.GetFrameCount(FrameDimension.Time);
                if (frames == 1) {
                    Bitmap new_bitmap = new Bitmap(npc.image);
                    new_bitmap.MakeTransparent();
                    npc.image.Dispose();
                    npc.image = new_bitmap;
                }
            }

            // special case for rashid: change location based on day of the week
            if (npc != null && npc.name == "Rashid") {
                command = new SQLiteCommand(String.Format("SELECT city, x, y, z FROM RashidPositions WHERE day='{0}'", DateTime.Now.DayOfWeek.ToString()), mainForm.conn);
                reader = command.ExecuteReader();
                if (reader.Read()) {
                    npc.city = reader["city"].ToString();
                    npc.pos.x = reader.GetInt32(1);
                    npc.pos.y = reader.GetInt32(2);
                    npc.pos.z = reader.GetInt32(3);
                }
            }
            command = new SQLiteCommand(String.Format("SELECT itemid, value FROM SellItems WHERE vendorid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemSold sellItem = new ItemSold();
                sellItem.itemid = reader.GetInt32(0);
                sellItem.npcid = npc.id;
                sellItem.price = reader.GetInt32(1);
                npc.sellItems.Add(sellItem);
            }
            command = new SQLiteCommand(String.Format("SELECT itemid, value FROM BuyItems WHERE vendorid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemSold buyItem = new ItemSold();
                buyItem.itemid = reader.GetInt32(0);
                buyItem.npcid = npc.id;
                buyItem.price = reader.GetInt32(1);
                npc.buyItems.Add(buyItem);
            }
            command = new SQLiteCommand(String.Format("SELECT spellid,knight,druid,paladin,sorcerer FROM SpellNPCs WHERE npcid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                SpellTaught t = new SpellTaught();
                t.npcid = npc.id;
                t.spellid = reader.GetInt32(0);
                t.knight = reader.GetBoolean(1);
                t.druid = reader.GetBoolean(2);
                t.paladin = reader.GetBoolean(3);
                t.sorcerer = reader.GetBoolean(4);
                npc.spellsTaught.Add(t);
            }

            command = new SQLiteCommand(String.Format("SELECT DISTINCT questid FROM QuestNPCs WHERE npcid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                Quest q = getQuest(reader.GetInt32(0));
                npc.involvedQuests.Add(q);
            }

            command = new SQLiteCommand(String.Format("SELECT destination,cost,notes FROM NPCDestinations WHERE npcid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                Transport t = new Transport();
                t.destination = reader.GetString(0);
                t.cost = reader.GetInt32(1);
                t.notes = reader.GetString(2);
                npc.transportOffered.Add(t);
            }
            return npc;
        }
Example #6
0
        private static Mount createMount(SQLiteDataReader reader)
        {
            if (!reader.Read()) {
                return null;
            }

            Mount mount = new Mount();
            mount.permanent = true;
            mount.id = reader.GetInt32(0);
            mount.title = reader.GetString(1);
            mount.name = reader.GetString(2);

            int tameitem = reader.IsDBNull(3) ? DATABASE_NULL : reader.GetInt32(3);
            if (tameitem > 0) mount.tameitemid = tameitem;
            else mount.tameitemid = -1;
            int tamecreature = reader.IsDBNull(4) ? DATABASE_NULL : reader.GetInt32(4);
            if (tamecreature > 0) mount.tamecreatureid = tamecreature;
            else mount.tamecreatureid = -1;
            mount.speed = reader.GetInt32(5);
            mount.tibiastore = reader.GetBoolean(6);
            mount.image = Image.FromStream(reader.GetStream(7));

            return mount;
        }
Example #7
0
        private static Item createItem(SQLiteDataReader reader)
        {
            SQLiteCommand command;

            if (!reader.Read()) {
                return null;
            }

            Item item = new Item();
            item.permanent = true;
            item.id = reader.GetInt32(0);
            item.displayname = reader.GetString(1);
            item.actual_value = reader.IsDBNull(2) ? DATABASE_NULL : reader.GetInt64(2);
            item.vendor_value = reader.IsDBNull(3) ? DATABASE_NULL : reader.GetInt64(3);
            item.stackable = reader.GetBoolean(4);
            item.capacity = reader.IsDBNull(5) ? DATABASE_NULL : reader.GetFloat(5);
            item.category = reader.IsDBNull(6) ? "Unknown" : reader.GetString(6);
            item.discard = reader.GetBoolean(7);
            item.convert_to_gold = reader.GetBoolean(8);
            item.look_text = reader.IsDBNull(9) ? String.Format("You see a {0}.", item.displayname) : reader.GetString(9);
            item.title = reader.GetString(10);
            item.currency = reader.IsDBNull(11) ? DATABASE_NULL : reader.GetInt32(11);
            item.image = Image.FromStream(reader.GetStream(12));
            if (item.image.RawFormat.Guid == ImageFormat.Gif.Guid) {
                int frames = item.image.GetFrameCount(FrameDimension.Time);
                if (frames == 1) {
                    Bitmap new_bitmap = new Bitmap(item.image);
                    new_bitmap.MakeTransparent();
                    item.image.Dispose();
                    item.image = new_bitmap;
                }
            }

            command = new SQLiteCommand(String.Format("SELECT vendorid, value FROM SellItems WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemSold sellItem = new ItemSold();
                sellItem.itemid = item.id;
                sellItem.npcid = reader.GetInt32(0);
                sellItem.price = reader.GetInt32(1);
                item.sellItems.Add(sellItem);
            }
            command = new SQLiteCommand(String.Format("SELECT vendorid, value FROM BuyItems WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemSold buyItem = new ItemSold();
                buyItem.itemid = item.id;
                buyItem.npcid = reader.GetInt32(0);
                buyItem.price = reader.GetInt32(1);
                item.buyItems.Add(buyItem);
            }
            command = new SQLiteCommand(String.Format("SELECT creatureid, percentage, min, max FROM CreatureDrops WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemDrop itemDrop = new ItemDrop();
                itemDrop.itemid = item.id;
                itemDrop.creatureid = reader.GetInt32(0);
                itemDrop.percentage = reader.IsDBNull(1) ? DATABASE_NULL : reader.GetFloat(1);
                if (itemDrop.percentage > 100) {
                    itemDrop.min = 1;
                    itemDrop.max = (int)(itemDrop.percentage / 100.0 * 2.0);
                    itemDrop.percentage = 100;
                } else {
                    itemDrop.min = Math.Max(reader.GetInt32(2), 1);
                    itemDrop.max = Math.Max(reader.GetInt32(3), itemDrop.min);
                }

                item.itemdrops.Add(itemDrop);
            }
            command = new SQLiteCommand(String.Format("SELECT questid FROM QuestRewards WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                item.rewardedBy.Add(getQuest(reader.GetInt32(0)));
            }
            command = new SQLiteCommand(String.Format("SELECT property, value FROM ItemProperties WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                string property = reader.GetString(0);
                switch(property) {
                    case "Voc":
                        item.vocation = reader.GetString(1);
                        break;
                    case "Level":
                        item.level = reader.GetInt32(1);
                        break;
                    case "Def":
                        item.defensestr = reader["value"].ToString();
                        if (!int.TryParse(item.defensestr, out item.defense)) {
                            item.defense = int.Parse(item.defensestr.Split(' ')[0]);
                        }
                        break;
                    case "Attrib":
                        item.attrib = reader.GetString(1);
                        break;
                    case "Atk":
                        item.attack = reader.GetInt32(1);
                        break;
                    case "Atk+":
                        item.atkmod = reader.GetInt32(1);
                        break;
                    case "Hit+":
                        string str = reader["value"].ToString();
                        int.TryParse(str, out item.hitmod);
                        break;
                    case "Arm":
                        item.armor = reader.GetInt32(1);
                        break;
                    case "Range":
                        item.range = reader.GetInt32(1);
                        break;
                    case "Type":
                        item.type = reader.GetString(1);
                        break;
                }
            }

            return item;
        }
Example #8
0
        private static Creature createCreature(SQLiteDataReader reader)
        {
            SQLiteCommand command;

            if (!reader.Read()) {
                return null;
            }

            Creature cr = new Creature();
            cr.permanent = true;
            cr.id = reader.GetInt32(0);
            cr.displayname = reader["name"].ToString();
            cr.health = reader.IsDBNull(2) ? DATABASE_NULL : reader.GetInt32(2);
            cr.experience = reader.IsDBNull(3) ? DATABASE_NULL : reader.GetInt32(3);
            cr.maxdamage = reader.IsDBNull(4) ? DATABASE_NULL : reader.GetInt32(4);
            cr.summoncost = reader.IsDBNull(5) ? DATABASE_NULL : reader.GetInt32(5);
            cr.illusionable = reader.GetBoolean(6);
            cr.pushable = reader.GetBoolean(7);
            cr.pushes = reader.GetBoolean(8);
            cr.res_phys = reader.IsDBNull(9) ? 100 : reader.GetInt32(9);
            cr.res_holy = reader.IsDBNull(10) ? 100 : reader.GetInt32(10);
            cr.res_death = reader.IsDBNull(11) ? 100 : reader.GetInt32(11);
            cr.res_fire = reader.IsDBNull(12) ? 100 : reader.GetInt32(12);
            cr.res_energy = reader.IsDBNull(13) ? 100 : reader.GetInt32(13);
            cr.res_ice = reader.IsDBNull(14) ? 100 : reader.GetInt32(14);
            cr.res_earth = reader.IsDBNull(15) ? 100 : reader.GetInt32(15);
            cr.res_drown = reader.IsDBNull(16) ? 100 : reader.GetInt32(16);
            cr.res_lifedrain = reader.IsDBNull(17) ? 100 : reader.GetInt32(17);
            cr.paralysable = reader.GetBoolean(18);
            cr.senseinvis = reader.GetBoolean(19);
            cr.abilities = reader.IsDBNull(20) ? DATABASE_STRING_NULL : reader["abilities"].ToString();
            cr.title = reader[21].ToString();
            cr.speed = reader.IsDBNull(22) ? DATABASE_NULL : reader.GetInt32(22);
            cr.armor = reader.IsDBNull(23) ? DATABASE_NULL : reader.GetInt32(23);
            cr.boss = reader.GetInt32(24) > 0;
            if (reader.IsDBNull(25)) {
                return null;
            }
            cr.image = Image.FromStream(reader.GetStream(25));

            command = new SQLiteCommand(String.Format("SELECT skinitemid, knifeitemid, percentage FROM Skins WHERE creatureid={0}", cr.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                Skin skin = new Skin();
                skin.dropitemid = reader.GetInt32(0);
                skin.skinitemid = reader.GetInt32(1);
                skin.percentage = reader.IsDBNull(2) ? DATABASE_NULL : reader.GetFloat(2);
                cr.skin = skin;
            }

            command = new SQLiteCommand(String.Format("SELECT itemid, percentage, min, max FROM CreatureDrops WHERE creatureid={0}", cr.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemDrop itemDrop = new ItemDrop();
                itemDrop.creatureid = cr.id;
                itemDrop.itemid = reader.GetInt32(0);
                itemDrop.percentage = reader.IsDBNull(1) ? DATABASE_NULL : reader.GetFloat(1);
                if (itemDrop.percentage > 100) {
                    itemDrop.min = 1;
                    itemDrop.max = (int)(itemDrop.percentage / 100.0 * 2.0);
                    itemDrop.percentage = 100;
                } else {
                    itemDrop.min = Math.Max(reader.GetInt32(2), 1);
                    itemDrop.max = Math.Max(reader.GetInt32(3), itemDrop.min);
                }
                cr.itemdrops.Add(itemDrop);
            }

            return cr;
        }
Example #9
0
        private static Spell createSpell(SQLiteDataReader reader)
        {
            SQLiteCommand command;

            if (!reader.Read()) {
                return null;
            }

            Spell spell = new Spell();
            spell.permanent = true;
            spell.id = reader.GetInt32(0);
            spell.name = reader["name"].ToString();
            spell.words = reader["words"].ToString();
            spell.element = reader.IsDBNull(3) ? "Unknown" : reader.GetString(3);
            spell.cooldown = reader.IsDBNull(4) ? DATABASE_NULL : reader.GetInt32(4);
            spell.premium = reader.GetBoolean(5);
            spell.promotion = reader.GetBoolean(6);
            spell.levelrequired = reader.GetInt32(7);
            spell.goldcost = reader.GetInt32(8);
            spell.manacost = reader.GetInt32(9);
            spell.knight = reader.GetBoolean(10);
            spell.paladin = reader.GetBoolean(11);
            spell.sorcerer = reader.GetBoolean(12);
            spell.druid = reader.GetBoolean(13);
            spell.image = Image.FromStream(reader.GetStream(14));

            command = new SQLiteCommand(String.Format("SELECT npcid, knight, druid, paladin, sorcerer FROM SpellNPCs WHERE spellid={0}", spell.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                SpellTaught t = new SpellTaught();
                t.npcid = reader.GetInt32(0);
                t.spellid = spell.id;
                t.knight = reader.GetBoolean(1);
                t.druid = reader.GetBoolean(2);
                t.paladin = reader.GetBoolean(3);
                t.sorcerer = reader.GetBoolean(4);
                spell.teachNPCs.Add(t);
            }
            return spell;
        }
Example #10
0
        private static Outfit createOutfit(SQLiteDataReader reader)
        {
            SQLiteCommand command;
            if (!reader.Read()) {
                return null;
            }

            Outfit outfit = new Outfit();
            outfit.permanent = true;
            outfit.id = reader.GetInt32(0);
            outfit.title = reader.GetString(1);
            outfit.name = reader.GetString(2);
            outfit.premium = reader.GetBoolean(3);
            outfit.tibiastore = reader.GetBoolean(4);

            // Outfit Images
            command = new SQLiteCommand(String.Format("SELECT male, addon, image FROM OutfitImages WHERE outfitid={0}", outfit.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                bool male = reader.GetBoolean(0);
                int addon = reader.GetInt32(1);
                Image image = Image.FromStream(reader.GetStream(2));

                if (male) {
                    outfit.maleImages[addon] = image;
                } else {
                    outfit.femaleImages[addon] = image;
                }
            }

            command = new SQLiteCommand(String.Format("SELECT questid FROM QuestOutfits WHERE outfitid={0}", outfit.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                outfit.questid = reader.GetInt32(0);
            }

            return outfit;
        }
        //
        // GetUserFromReader
        //    A helper function that takes the current row from the SQLiteDataReader
        // and hydrates a MembershipUser from the values. Called by the 
        // MembershipUser.GetUser implementation.
        //

        private MembershipUser GetUserFromReader(SQLiteDataReader reader)
        {
            if (reader.GetString(1)=="") return null;
            object providerUserKey=null;
            string strGooid=Guid.NewGuid().ToString();
            if (reader.GetValue(0).ToString().Length > 0)
                providerUserKey = new Guid(reader.GetValue(0).ToString());
            else
                providerUserKey = new Guid(strGooid);
            string username = reader.GetString(1);
            string email = reader.GetString(2);

            string passwordQuestion = "";
            if (reader.GetValue(3) != DBNull.Value)
                passwordQuestion = reader.GetString(3);

            string comment = "";
            if (reader.GetValue(4) != DBNull.Value)
                comment = reader.GetString(4);

            bool tmpApproved = (reader.GetValue(5) == null);
             bool isApproved=false;
            if(tmpApproved)
            isApproved = reader.GetBoolean(5);

        bool tmpLockedOut = (reader.GetValue(6) == null);
        bool isLockedOut = false;
            if(tmpLockedOut)
            isLockedOut = reader.GetBoolean(6);

        DateTime creationDate = DateTime.Now;
            try
            {
                if (reader.GetValue(6) != DBNull.Value)
                    creationDate = reader.GetDateTime(7);
            }
            catch { }

            DateTime lastLoginDate = DateTime.Now;
            try
            {
                if (reader.GetValue(8) != DBNull.Value)
                    lastLoginDate = reader.GetDateTime(8);
            }
            catch { }

            DateTime lastActivityDate = DateTime.Now;
            try
            {
                if (reader.GetValue(9) != DBNull.Value)
                    lastActivityDate = reader.GetDateTime(9);
            }
            catch { }
            DateTime lastPasswordChangedDate = DateTime.Now;
            try
            {
                if (reader.GetValue(10) != DBNull.Value)
                    lastPasswordChangedDate = reader.GetDateTime(10);
            }
            catch { }

            DateTime lastLockedOutDate = DateTime.Now;
            try
            {
                if (reader.GetValue(11) != DBNull.Value)
                    lastLockedOutDate = reader.GetDateTime(11);
            }
            catch { }

            MembershipUser u = new MembershipUser(this.Name,
                                                  username,
                                                  providerUserKey,
                                                  email,
                                                  passwordQuestion,
                                                  comment,
                                                  isApproved,
                                                  isLockedOut,
                                                  creationDate,
                                                  lastLoginDate,
                                                  lastActivityDate,
                                                  lastPasswordChangedDate,
                                                  lastLockedOutDate);

            return u;
        }
Example #12
0
        private Game GetGameFromData(SQLiteDataReader reader)
        {
            int itemID = -1;
            if (reader["id"] != DBNull.Value)
                itemID = reader.GetInt32(0);

            int itemCategoryID = -1;
            if (reader["category_id"] != DBNull.Value)
                itemCategoryID = reader.GetInt32(1);

            string itemTitle = string.Empty;
            if (reader["title"] != DBNull.Value)
                itemTitle = reader.GetString(2);

            int itemYear = -1;
            if (reader["year"] != DBNull.Value)
                itemYear = reader.GetInt32(3);

            string itemDeveloper = string.Empty;
            if (reader["developer"] != DBNull.Value)
                itemDeveloper = reader.GetString(4);

            string itemSetupExePath = string.Empty;
            if (reader["setup_exe_path"] != DBNull.Value)
                itemSetupExePath = reader.GetString(5);

            string itemDirectory = string.Empty;
            if (reader["directory"] != DBNull.Value)
                itemDirectory = reader.GetString(6);

            string itemDBConfigPath = string.Empty;
            if (reader["db_config_path"] != DBNull.Value)
                itemDBConfigPath = reader.GetString(7);

            string itemDosExePath = string.Empty;
            if (reader["dos_exe_path"] != DBNull.Value)
                itemDosExePath = reader.GetString(8);

            string itemCDPath = string.Empty;
            if (reader["cd_path"] != DBNull.Value)
                itemCDPath = reader.GetString(9);

            bool itemCDImage = false;
            if (reader["cd_image"] != DBNull.Value)
                itemCDImage = reader.GetBoolean(10);

            bool itemUseIOCTL = false;
            if (reader["use_IOCTL"] != DBNull.Value)
                itemUseIOCTL = reader.GetBoolean(11);

            bool itemMountAsFloppy = false;
            if (reader["mount_as_floppy"] != DBNull.Value)
                itemMountAsFloppy = reader.GetBoolean(12);

            string itemAdditionalCommands = string.Empty;
            if (reader["additional_commands"] != DBNull.Value)
                itemAdditionalCommands = reader.GetString(13);

            bool itemNoConfig = false;
            if (reader["no_config"] != DBNull.Value)
                itemNoConfig = reader.GetBoolean(14);

            bool itemInFullScreen = false;
            if (reader["in_full_screen"] != DBNull.Value)
                itemInFullScreen = reader.GetBoolean(15);

            bool itemNoConsole = false;
            if (reader["no_console"] != DBNull.Value)
                itemNoConsole = reader.GetBoolean(16);

            bool itemQuitOnExit = false;
            if (reader["quit_on_exit"] != DBNull.Value)
                itemQuitOnExit = reader.GetBoolean(17);

            string itemImagePath = string.Empty;
            if (reader["image_path"] != DBNull.Value)
                itemImagePath = reader.GetString(18);

            DateTime itemCreatedAt = DateTime.MinValue;
            if (reader["created_at"] != DBNull.Value)
                itemCreatedAt = reader.GetDateTime(19);

            DateTime itemUpdatedAt = DateTime.MinValue;
            if (reader["updated_at"] != DBNull.Value)
                itemUpdatedAt = reader.GetDateTime(20);

            string itemPlatform = string.Empty;
            if (reader["platform"] != DBNull.Value)
                itemPlatform = reader.GetString(21);

            string itemReleasedIn = string.Empty;
            if (reader["released_in"] != DBNull.Value)
                itemReleasedIn = reader.GetString(22);

            string itemPublisher = string.Empty;
            if (reader["publisher"] != DBNull.Value)
                itemPublisher = reader.GetString(23);

            string itemThemes = string.Empty;
            if (reader["themes"] != DBNull.Value)
                itemThemes = reader.GetString(24);

            string itemPerspectives = string.Empty;
            if (reader["perspectives"] != DBNull.Value)
                itemPerspectives = reader.GetString(25);

            string itemDosBoxVersion = string.Empty;
            if (reader["dosbox_version"] != DBNull.Value)
                itemDosBoxVersion = reader.GetString(26);

            string itemVote = string.Empty;
            if (reader["vote"] != DBNull.Value)
                itemVote = reader.GetString(27);

            string itemDescription = string.Empty;
            if (reader["description"] != DBNull.Value)
                itemDescription = reader.GetString(28);

            return new Game(itemID, itemCategoryID, itemTitle, itemYear, itemDeveloper,
                               itemSetupExePath, itemDirectory, itemDBConfigPath, itemDosExePath,
                               itemCDPath, itemCDImage, itemUseIOCTL, itemMountAsFloppy,
                               itemAdditionalCommands, itemNoConfig, itemInFullScreen,
                               itemNoConsole, itemQuitOnExit, itemImagePath, itemCreatedAt, itemUpdatedAt,
                               itemPlatform, itemReleasedIn, itemPublisher, itemThemes,
                               itemPerspectives, itemDosBoxVersion, itemVote, itemDescription);
        }
        private StoredBlock ReadBlock(SQLiteDataReader reader)
        {
            int col = 0;

            StoredBlockBuilder blockBuilder = new StoredBlockBuilder();

            byte[] headerBytes = ReadBytes(reader, col++);
            blockBuilder.Header = BlockHeader.Read(new BitcoinStreamReader(new MemoryStream(headerBytes)));
            blockBuilder.Hash = ReadBytes(reader, col++);
            blockBuilder.Height = reader.GetInt32(col++);
            blockBuilder.TotalWork = reader.GetDouble(col++);
            blockBuilder.HasContent = reader.GetBoolean(col++);
            blockBuilder.IsInBestHeaderChain = reader.GetBoolean(col++);
            blockBuilder.IsInBestBlockChain = reader.GetBoolean(col++);

            StoredBlock block = blockBuilder.Build();

            return block;
        }
 public static void Read(this Beatmap beatmap, SQLiteDataReader reader)
 {
     int i = 1;
     beatmap.TitleRoman = reader.GetString(i); i++;
     beatmap.ArtistRoman = reader.GetString(i); i++;
     beatmap.TitleUnicode = reader.GetString(i); i++;
     beatmap.ArtistUnicode = reader.GetString(i); i++;
     beatmap.Creator = reader.GetString(i); i++;
     beatmap.DiffName = reader.GetString(i); i++;
     beatmap.Mp3Name = reader.GetString(i); i++;
     beatmap.Md5 = reader.GetString(i); i++;
     beatmap.OsuFileName = reader.GetString(i); i++;
     beatmap.MaxBpm = reader.GetDouble(i); i++;
     beatmap.MinBpm = reader.GetDouble(i); i++;
     beatmap.Tags = reader.GetString(i); i++;
     beatmap.State = reader.GetByte(i); i++;
     beatmap.Circles = (short)reader.GetInt32(i); i++;
     beatmap.Sliders = (short)reader.GetInt32(i); i++;
     beatmap.Spinners = (short)reader.GetInt32(i); i++;
     beatmap.EditDate = reader.GetDateTime(i); i++;
     beatmap.ApproachRate = (float)reader.GetDouble(i); i++;
     beatmap.CircleSize = (float)reader.GetDouble(i); i++;
     beatmap.HpDrainRate = (float)reader.GetDouble(i); i++;
     beatmap.OverallDifficulty = (float)reader.GetDouble(i); i++;
     beatmap.SliderVelocity = reader.GetDouble(i); i++;
     beatmap.DrainingTime = reader.GetInt32(i); i++;
     beatmap.TotalTime = reader.GetInt32(i); i++;
     beatmap.PreviewTime = reader.GetInt32(i); i++;
     beatmap.MapId = reader.GetInt32(i); i++;
     beatmap.MapSetId = reader.GetInt32(i); i++;
     beatmap.ThreadId = reader.GetInt32(i); i++;
     beatmap.MapRating = reader.GetInt32(i); i++;
     beatmap.Offset = (short)reader.GetInt32(i); i++;
     beatmap.StackLeniency = (float)reader.GetDouble(i); i++;
     beatmap.Mode = reader.GetByte(i); i++;
     beatmap.Source = reader.GetString(i); i++;
     beatmap.AudioOffset = (short)reader.GetInt32(i); i++;
     beatmap.LetterBox = reader.GetString(i); i++;
     beatmap.Played = reader.GetBoolean(i); i++;
     beatmap.LastPlayed = reader.GetDateTime(i); i++;
     beatmap.IsOsz2 = reader.GetBoolean(i); i++;
     beatmap.Dir = reader.GetString(i); i++;
     beatmap.LastSync = reader.GetDateTime(i); i++;
     beatmap.DisableHitsounds = reader.GetBoolean(i); i++;
     beatmap.DisableSkin = reader.GetBoolean(i); i++;
     beatmap.DisableSb = reader.GetBoolean(i); i++;
     beatmap.BgDim = reader.GetInt16(i); i++;
     beatmap.Somestuff = reader.GetInt16(i); i++;
     beatmap.VideoDir = reader.GetString(i);
 }