Ejemplo n.º 1
0
        public static List <c_Object> getImagesAll(SQLiteConnection sqlc)
        {
            List <c_Object> lco = new List <c_Object>();

            if (sqlc.State != System.Data.ConnectionState.Open)
            {
                return(null);
            }

            SQLiteCommand sqlComm = new SQLiteCommand();

            sqlComm.Connection  = sqlc;
            sqlComm.CommandText = "SELECT * FROM images";

            SQLiteDataReader r = sqlComm.ExecuteReader();

            while (r.Read())
            {
                string _title    = r.GetString(1);
                string _desc     = r.GetString(2);
                string _image    = r.GetString(3);
                string _tags     = r.GetString(4);
                string _savedate = r.GetString(5);

                c_Object obj = new c_Object(_title, _desc, _image, _tags, _savedate);
                lco.Add(obj);
            }

            //c_Object obj = new c_Object();
            return(lco);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// //TODO:ADD SUMMARY
        /// </summary>
        /// <param name="sqlc"></param>
        /// <param name="title"></param>
        /// <param name="like"></param>
        /// <returns></returns>
        public static List <c_Object> getImagesByTitle(SQLiteConnection sqlc, string title, bool like)
        {
            List <c_Object> lco = new List <c_Object>();

            if (sqlc.State != System.Data.ConnectionState.Open)
            {
                return(null);
            }

            SQLiteCommand sqlComm = new SQLiteCommand();

            sqlComm.Connection = sqlc;
            if (like)
            {
                sqlComm.CommandText = string.Format("SELECT * FROM images WHERE title like '%{0}%'", title);
            }
            else
            {
                sqlComm.CommandText = string.Format("SELECT * FROM images WHERE title='{0}'", title);
            }
            SQLiteDataReader r = sqlComm.ExecuteReader();

            while (r.Read())
            {
                string _title    = r.GetString(1);
                string _desc     = r.GetString(2);
                string _image    = r.GetString(3);
                string _tags     = r.GetString(4);
                string _savedate = r.GetString(5);

                c_Object obj = new c_Object(_title, _desc, _image, _tags, _savedate);
                lco.Add(obj);
            }

            //c_Object obj = new c_Object();
            return(lco);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// //TODO:ADD SUMMARY
        /// </summary>
        /// <param name="sqlc"></param>
        /// <param name="date"></param>
        /// <param name="like"></param>
        /// <returns></returns>
        public static List <c_Object> getImagesByDate(SQLiteConnection sqlc, string date)
        {
            List <c_Object> lco = new List <c_Object>();

            date = date.Replace("/", "");
            string[] dates = date.Split('|');


            if (sqlc.State != System.Data.ConnectionState.Open)
            {
                return(null);
            }

            SQLiteCommand sqlComm = new SQLiteCommand();

            sqlComm.Connection = sqlc;

            sqlComm.CommandText = string.Format("SELECT * FROM images WHERE save_date between '{0}' and '{1}'", dates[0], dates[1]);

            SQLiteDataReader r = sqlComm.ExecuteReader();

            while (r.Read())
            {
                string _title    = r.GetString(1);
                string _desc     = r.GetString(2);
                string _image    = r.GetString(3);
                string _tags     = r.GetString(4);
                string _savedate = r.GetString(5);

                c_Object obj = new c_Object(_title, _desc, _image, _tags, _savedate);
                lco.Add(obj);
            }

            //c_Object obj = new c_Object();
            return(lco);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// //TODO:ADD SUMMARY 2
        /// </summary>
        /// <param name="sqlc"></param>
        /// <param name="tags"></param>
        /// <returns></returns>
        public static List <c_Object> getImagesByTags(SQLiteConnection sqlc, string[] tags)
        {
            List <c_Object> lco      = new List <c_Object>();
            List <int>      ids      = new List <int>();
            string          idString = "";

            if (sqlc.State != System.Data.ConnectionState.Open)
            {
                return(null);
            }

            SQLiteCommand sqlComm = new SQLiteCommand();

            sqlComm.Connection = sqlc;

            sqlComm.CommandText = "SELECT id, tags FROM images";
            SQLiteDataReader r1 = sqlComm.ExecuteReader();

            while (r1.Read())
            {
                int    id     = r1.GetInt32(0);
                string tagStr = r1.GetString(1);

                foreach (string s in tags)
                {
                    if (tagStr.ToLower().Split(';').Contains(s.ToLower()))
                    {
                        ids.Add(id);
                    }
                }
            }

            r1.Close();

            if (ids.Count > 0)
            {
                foreach (int i in ids)
                {
                    idString += i + ",";
                }
                idString = idString.Trim(',');

                sqlComm.CommandText = string.Format("SELECT * FROM images WHERE id IN ( {0} )", idString);

                SQLiteDataReader r = sqlComm.ExecuteReader();
                while (r.Read())
                {
                    string _title    = r.GetString(1);
                    string _desc     = r.GetString(2);
                    string _image    = r.GetString(3);
                    string _tags     = r.GetString(4);
                    string _savedate = r.GetString(5);

                    c_Object obj = new c_Object(_title, _desc, _image, _tags, _savedate);
                    lco.Add(obj);
                }
            }

            //c_Object obj = new c_Object();
            return(lco);
        }