コード例 #1
0
ファイル: DBHelper.cs プロジェクト: modulexcite/DriveIndexer
        public static List<FileTypeData> ReadWhiteListedFileTypes()
        {
            List<FileTypeData> list = new List<FileTypeData>();

            try
            {
                string sql = "select FileTypeId, FileGroupId, FileType, FileTypeDesc, ifnull(IncludeInDriveScan,0) as IncludeInDriveScan FROM FileType where IncludeInDriveScan = 1";
                SQLiteCommand command = new SQLiteCommand(sql, LocalSqllite.m_sqlLiteConnection);
                SQLiteDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    FileTypeData data = new FileTypeData();
                    data.m_fileTypeId = reader["FileTypeId"].ToString();
                    data.m_fileGroupId = reader["FileGroupId"].ToString();
                    data.m_fileType = reader["FileType"].ToString();
                    data.m_fileTypeDesc = reader["FileTypeDesc"].ToString();
                    data.m_includeInDriveScan = reader["IncludeInDriveScan"].ToString();

                    list.Add(data);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return list;
        }
コード例 #2
0
        private void AddCheckBoxControl(FileTypeData fileType )
        {
            flowLayoutPanel1.AutoScroll = true;

            CheckBox cb = new CheckBox();
            cb.Text = string.Format("{0} ({1})", fileType.m_fileType, fileType.m_fileTypeDesc);
            cb.Checked = Convert.ToBoolean(Convert.ToInt32( fileType.m_includeInDriveScan) );
            cb.AutoSize = true;

            // associate the fileType object with this tickbox.
            cb.Tag = fileType;

            // wire up the event handler when someone ticks/unticks the box.
            cb.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged);

            flowLayoutPanel1.Controls.Add(cb);
        }
コード例 #3
0
ファイル: DBHelper.cs プロジェクト: modulexcite/DriveIndexer
        public static bool WriteFileToDatabase(DrivePartitionData data, System.IO.FileInfo fi, FileTypeData extensionInfo, IFileExplorerUIManager ui)
        {
            bool bSuccessInsert = false;

            try
            {
                string dirName = GetDirectoryName(fi);

                StringBuilder sqlStatement = new StringBuilder();

                string fileExists = CheckFileExists(data, fi);
                if (fileExists == "")
                {
                    // if (ui != null)
                    //    ui.OutputFileScanned(string.Format("Hashing File: {0} (Size: {1})", fi.Name, fi.Length));
                    string hash = ""; // GetFileHash(fi.FullName);

                    // insert statment
                    sqlStatement.AppendLine("INSERT OR IGNORE INTO FileIndex ( DriveId, PartitionId, FileName, FileExtension, FilePath, FileSize, FileTypeId, FileGroupId, FileTag, FileHash, UserComment ) VALUES ( ");
                    sqlStatement.AppendLine(string.Format("'{0}'", data.PhysicalDrive.DriveId));
                    sqlStatement.AppendLine(string.Format(",'{0}'", data.PartitionId));
                    sqlStatement.AppendLine(string.Format(",'{0}'", fi.Name.Replace("'","''")));
                    sqlStatement.AppendLine(string.Format(",'{0}'", fi.Extension));
                    sqlStatement.AppendLine(string.Format(",'{0}'", dirName.Replace("'", "''")));
                    sqlStatement.AppendLine(string.Format(",'{0}'", fi.Length));
                    sqlStatement.AppendLine(string.Format(",'{0}'", extensionInfo.m_fileTypeId));
                    sqlStatement.AppendLine(string.Format(",'{0}'", extensionInfo.m_fileGroupId));
                    sqlStatement.AppendLine(string.Format(",'{0}'", ""));
                    sqlStatement.AppendLine(string.Format(",'{0}'", hash));
                    sqlStatement.AppendLine(string.Format(",'{0}'", ""));
                    sqlStatement.AppendLine(");");

                    bSuccessInsert = LocalSqllite.ExecSQLCommand(sqlStatement.ToString());

                    //Console.WriteLine(string.Format("{0}: {1}", hash, fi.FullName));
                    if (ui != null)
                        ui.OutputFileScanned(string.Format("Indexing File: {0}", fi.Name));
                }
                else
                {
                    //Console.WriteLine(string.Format("Skipping File (Already Indexed): {0}", fi.Name));
                    if (ui != null)
                        ui.OutputFileScanned(string.Format("Skipping File (Already Indexed): {0}", fi.FullName));
                }
                //else
                //{
                //    // update statment
                //    sqlStatement.AppendLine("UPDATE PhysicalDrivePartitions SET ");
                //    sqlStatement.AppendLine(string.Format("VolumeSerialNumber = '{0}'", data.VolumeSerialNumber));
                //    sqlStatement.AppendLine(string.Format("Name = '{0}'", data.Name));
                //    sqlStatement.AppendLine(string.Format("Caption = '{0}'", data.Caption));
                //    sqlStatement.AppendLine(string.Format("Description = '{0}'", data.Description));
                //    sqlStatement.AppendLine(string.Format("DeviceID = '{0}'", data.DeviceID));
                //    sqlStatement.AppendLine(string.Format("DriveType = '{0}'", data.DriveType));
                //    sqlStatement.AppendLine(string.Format("FileSystem = '{0}'", data.FileSystem));
                //    sqlStatement.AppendLine(string.Format("FreeSpace = '{0}'", data.FreeSpace));
                //    sqlStatement.AppendLine(string.Format("Size = '{0}'", data.Size));
                //    sqlStatement.AppendLine(string.Format("UserComment = '{0}'", data.UserComment));
                //    sqlStatement.AppendLine(string.Format("WHERE DriveId = '{0}'", partitionId));
                //}
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return bSuccessInsert;
        }