static public int FindDuplicateEntries(DBEngine dbEngine, DataViewModel DataModel) { using (SQLiteCommand command = new SQLiteCommand(dbEngine.SqlConnection)) { command.CommandText = DuplicateEntriesQuery; using (SQLiteDataReader reader = command.ExecuteReader()) { while (reader.Read()) { FileDetail fileDetail = new FileDetail(); fileDetail.Hash = (string)reader["Hash"];; fileDetail.FileName = (string)reader["Name"]; fileDetail.FullFilePath = (string)reader["FullName"]; fileDetail.Size = (Int64)reader["Size"]; DataModel.AddFileEntryToDataModel(fileDetail); } } return(0); } }
static public int CreateFileEntry(DBEngine dbEngine, FileInfo fileInfo, string MD5Hash) { string PreparedEntry = "INSERT INTO FileDB (Name, FullName, Hash, Size, FileExt, Directory, LastModTime) " + "VALUES (@Name, @FullName, @Hash, @Size, @FileExt, @Directory, @LastModTime);"; using (SQLiteCommand command = new SQLiteCommand(dbEngine.SqlConnection)) { command.CommandText = PreparedEntry; command.Prepare(); command.Parameters.AddWithValue("@Name", fileInfo.Name); command.Parameters.AddWithValue("@FullName", fileInfo.FullName); command.Parameters.AddWithValue("@Hash", MD5Hash); command.Parameters.AddWithValue("@Size", fileInfo.Length); command.Parameters.AddWithValue("@FileExt", fileInfo.Extension); command.Parameters.AddWithValue("@Directory", fileInfo.DirectoryName); command.Parameters.AddWithValue("@LastModTime", fileInfo.LastWriteTime.Ticks); command.Prepare(); command.ExecuteNonQuery(); } return(0); }