コード例 #1
0
        public static void Initialise()
        {
            bCancelProcess = false;
            m_indexedFileCount = 0;
            m_uiManager = null;

            SetupExtensionWhiteList();
        }
コード例 #2
0
 public static void InjectUserInterfaceManager(IFileExplorerUIManager ui)
 {
     m_uiManager = ui;
 }
コード例 #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;
        }