Пример #1
0
        public IList <IDAL.Model.DBFileInfo> GetFilesByTags(string tags)
        {
            IList <IDAL.Model.DBFileInfo> fileList = new List <IDAL.Model.DBFileInfo>();
            string           sqlSelectFormat       = "SELECT * FROM " + DataAccess.TABLE_NAME_FILE + (string.IsNullOrEmpty(tags) ? string.Empty : " WHERE TAG LIKE '%{0}%'");
            string           sqlSelect             = string.Format(sqlSelectFormat, tags);
            SQLiteDataReader dr = SqliteHelper.ExecuteReader(DataAccess.ConnectionStringProfile, CommandType.Text, sqlSelect, null);

            while (dr.Read())
            {
                if (dr.IsDBNull(1))
                {
                    continue;
                }
                IDAL.Model.DBFileInfo monitoredFile = IDAL.Model.DBFileInfo.Create();
                monitoredFile.ID        = dr.GetInt32(0);
                monitoredFile.Path      = dr.GetString(1);
                monitoredFile.Name      = dr.GetString(2);
                monitoredFile.Extension = dr.GetString(3);
                monitoredFile.Category  = (FileCategory)dr.GetInt32(4);
                monitoredFile.Tag       = dr.GetString(5);
                monitoredFile.ParentID  = dr.GetInt32(6);
                fileList.Add(monitoredFile);
            }
            dr.Close();
            return(fileList);
        }
Пример #2
0
        public void GetFilesUnderFolderAsync(string folderPath, Action <IList <IDAL.Model.DBFileInfo> > callback, ref bool isCancel)
        {
            IList <IDAL.Model.DBFileInfo> fileList = new List <IDAL.Model.DBFileInfo>();
            string           sqlSelectFormat       = "SELECT * FROM " + DataAccess.TABLE_NAME_FILE + (string.IsNullOrEmpty(folderPath) ? string.Empty : " WHERE PATH LIKE '%{0}%'");
            string           sqlSelect             = string.Format(sqlSelectFormat, folderPath);
            SQLiteDataReader dr = SqliteHelper.ExecuteReader(DataAccess.ConnectionStringProfile, CommandType.Text, sqlSelect, null);
            int iCount          = 0;

            while (dr.Read())
            {
                if (dr.IsDBNull(1))
                {
                    continue;
                }
                IDAL.Model.DBFileInfo monitoredFile = IDAL.Model.DBFileInfo.Create();
                monitoredFile.ID        = dr.GetInt32(0);
                monitoredFile.Path      = dr.GetString(1);
                monitoredFile.Name      = dr.GetString(2);
                monitoredFile.Extension = dr.GetString(3);
                monitoredFile.Category  = (FileCategory)dr.GetInt32(4);
                monitoredFile.Tag       = dr.GetString(5);
                monitoredFile.ParentID  = dr.GetInt32(6);
                fileList.Add(monitoredFile);
                iCount++;
                if (iCount >= 100)
                {
                    if (null != callback)
                    {
                        callback(fileList);
                        fileList.Clear();
                    }
                    iCount = 0;
                }
                Debug.WriteLine(isCancel);
                if (isCancel)
                {
                    break;
                }
            }
            dr.Close();
            if (null != callback)
            {
                callback(fileList);
            }
        }
Пример #3
0
        public bool UpdateFile(IDAL.Model.DBFileInfo file)
        {
            int    iRel      = 0;
            string sqlUpdate = string.Format(sqlUpdateFormat, file.ID);

            SQLiteParameter[] parms =
            {
                new SQLiteParameter("@PATH",      DbType.String),
                new SQLiteParameter("@NAME",      DbType.String),
                new SQLiteParameter("@EXTENSION", DbType.String),
                new SQLiteParameter("@CATEGORY",  DbType.Int32),
                new SQLiteParameter("@TAG",       DbType.String),
                new SQLiteParameter("@PARENTID",  DbType.Int32)
            };
            parms[0].Value = file.Path;
            parms[1].Value = file.Name;
            parms[2].Value = file.Extension;
            parms[3].Value = (int)file.Category;
            parms[4].Value = file.Tag;
            parms[5].Value = file.ParentID;
            iRel           = SqliteHelper.ExecuteNonQuery(DataAccess.ConnectionStringProfile, CommandType.Text, sqlUpdate, parms);

            return(iRel > 0 ? true : false);
        }
Пример #4
0
 public static bool UpdateFile(IDAL.Model.DBFileInfo file)
 {
     return(iScannedFile.UpdateFile(file));
 }