public string printToConsole(SQLiteDataReader readerDB, int index)
        {
            if (readerDB.IsDBNull(index))
            {
                //return "NULL";
                return "";
            }
            else
            {
                String dataObject = readerDB.GetFieldType(index).ToString();
                switch (dataObject)
                {
                    case "System.Int32":
                        return readerDB.GetInt32(index).ToString();
                    case "System.DateTime":
                        DateTime date = readerDB.GetDateTime(index);
                        return Convert.ToString(date);
                    case "System.String":
                        return readerDB.GetString(index);
                    default:
                        return "Unknown";
                }
            }

        }
        public string[] getLatestMsgFromUser(string uid)
        {
            this.clearCmd();
            string username = this.getUsernameById(Convert.ToInt16(uid));
            string[] msgAr = new string[3];
            msgAr[0] = username;

            cmd.CommandText="Select msg,sendTimestamp from msgLog where userid="+uid+" ORDER BY sendTimestamp DESC LIMIT 0,1";

            reader=cmd.ExecuteReader();
            reader.Read();
            msgAr[1] = Convert.ToString(reader.GetDateTime(1));
            msgAr[2] = reader.GetString(0);
            return msgAr;
        }
        //
        // 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;
        }
        private Entry ReadEntryAuthorVote(SQLiteDataReader reader)
        {
            Entry entry = new Entry();
            entry.ID = reader.GetInt32(0);
            if (!reader.IsDBNull(1))
            {
                entry.ID = reader.GetInt32(1);
            }
            else
            {
                entry.ParentID = null;
            }
            entry.AccountID = reader.GetInt32(2);
            entry.Title = reader.GetString(3);
            entry.Contents = reader.GetString(4);
            entry.Timestamp = reader.GetDateTime(5);

            entry.Author = new Account();
            entry.Author.ID = entry.AccountID;
            entry.Author.Name = reader.GetString(6);
            entry.Author.Email = reader.GetString(7);

            if (reader.IsDBNull(9))
            {
                entry.Vote = 0;
                entry.AuthorVote = false;
                entry.AuthorVoteUp = false;
                entry.AuthorVoteDown = false;
            }
            else
            {
                int vote = reader.GetInt32(9);
                entry.AuthorVote = true;
                if (vote > 0)
                {
                    entry.AuthorVoteUp = true;
                    entry.AuthorVoteDown = false;
                }
                else
                {
                    entry.AuthorVoteUp = false;
                    entry.AuthorVoteDown = true;
                }
            }

            return entry;
        }
        private Entry ReadEntryAuthor(SQLiteDataReader reader)
        {
            Entry entry = new Entry();
            entry.ID = reader.GetInt32(0);
            if (!reader.IsDBNull(1))
            {
                entry.ParentID = reader.GetInt32(1);
            }
            else
            {
                entry.ParentID = null;
            }
            entry.AccountID = reader.GetInt32(2);
            entry.Title = reader.GetString(3);
            entry.Contents = reader.GetString(4);
            entry.Timestamp = reader.GetDateTime(5);

            entry.Author = new Account();
            entry.Author.ID = entry.AccountID;
            entry.Author.Name = reader.GetString(6);
            entry.Author.Email = reader.GetString(7);

            return entry;
        }
 private Account ReadAccount(SQLiteDataReader reader)
 {
     Account account = new Account();
     account.ID = reader.GetInt32(0);
     account.Name = reader.GetString(1);
     account.Email = reader.GetString(2);
     account.Password = reader.GetString(3);
     account.PasswordSalt = reader.GetString(4);
     //account.Score = reader.GetInt32(5);
     account.Timestamp = reader.GetDateTime(6);
     return account;
 }
Exemple #7
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);
        }
Exemple #8
0
 private Qso LoadFromDataReader(SQLiteDataReader dr)
 {
     Qso q = new Qso();
     q.Band = (Band)Enum.Parse(typeof(Band), dr.GetString(dr.GetOrdinal("band")));
     q.Callsign = dr.GetString(dr.GetOrdinal("callsign"));
     q.Mode = (Mode)Enum.Parse(typeof(Mode), dr.GetString(dr.GetOrdinal("mode")));
     q.Operator = dr.GetString(dr.GetOrdinal("operator"));
     q.QsoTime = dr.GetDateTime(dr.GetOrdinal("qsotime"));
     return q;
 }
        public string[] getLatestMsgLog()
        {
            this.clearCmd();
            List<string> msgLogList=new List<string>();
            int AllowedMsgAmount = (int)ServerConfigManager.MyConfigs["MaxPullMsgLogAmount"];
            cmd.CommandText = "Select * from msgLog ORDER BY sendTimestamp ASC LIMIT "+AllowedMsgAmount.ToString()+";";
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                msgLogList.Add( System.Uri.EscapeDataString(this.getUsernameById(reader.GetInt16(1)))+","+System.Uri.EscapeDataString(Convert.ToString(reader.GetDateTime(3)))+","+System.Uri.EscapeDataString(reader.GetString(2)));
            }

            return msgLogList.ToArray();
        }
 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);
 }
Exemple #11
0
        private static void ReadQueryResult(QueryResolution resolution, SQLiteDataReader reader, List<KeyValuePair<DateTime, decimal>> values)
        {
            switch (resolution)
            {
                case QueryResolution.All:
                    var date = reader.GetDateTime(0);
                    var value = reader.GetDecimal(1);
                    values.Add(new KeyValuePair<DateTime, decimal>(date, value));
                    break;

                default:
                    var rawDate = Convert.ToString(reader["GroupedDate"]);

                    // Partial time resolutions will cause the raw date to have a minute value
                    // of :0 instead of :00, which will cause parsing errors, so try and fix that
                    if (rawDate.EndsWith(":0"))
                        rawDate += "0";

                    var resolutionDate = DateTime.Parse(rawDate);
                    var resolutionValue = reader.GetDecimal(reader.GetOrdinal("Value"));
                    values.Add(new KeyValuePair<DateTime, decimal>(resolutionDate, resolutionValue));
                    break;
            }
        }