예제 #1
0
        private Session getAdjacentSession(Session session, bool previousSession)
        {
            SQLiteConnection conn = getOpenConnection();
            string           sql;

            if (previousSession == true)
            {
                sql = "SELECT * FROM Sessions WHERE Start <= @start AND ID != @id ORDER BY Start DESC LIMIT 1";
            }
            else
            {
                sql = "SELECT * FROM Sessions WHERE Start > @start AND ID != @id ORDER BY Start ASC LIMIT 1";
            }
            SQLiteCommand command = new SQLiteCommand(sql, conn);

            command.Parameters.Add(new SQLiteParameter("@start", formatDateTimeForDatabase(session.start)));
            command.Parameters.Add(new SQLiteParameter("@id", session.id));
            SQLiteDataAdapter adaptor = new SQLiteDataAdapter(command);
            DataSet           ds      = new DataSet();

            adaptor.Fill(ds);
            conn.Close();
            if (ds.Tables[0].Rows.Count == 1)
            {
                return(DatabaseResultMapper.rowToSession(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        //--------------------------------------------------------------------------------
        //
        //      summary info
        //
        //--------------------------------------------------------------------------------

        internal List <Tag> getTags()
        {
            SQLiteConnection  conn    = getOpenConnection();
            string            sql     = "SELECT * FROM Tags ORDER BY TagLabel ASC";
            SQLiteCommand     command = new SQLiteCommand(sql, conn);
            SQLiteDataAdapter adaptor = new SQLiteDataAdapter(command);
            DataSet           ds      = new DataSet();

            adaptor.Fill(ds);
            conn.Close();
            List <Tag> result = new List <Tag>();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DataRow row = ds.Tables[0].Rows[i];
                result.Add(DatabaseResultMapper.rowToTag(row));
            }
            return(result);
        }