public void Push(FileBehavior file) { FileValuePair last = Items.LastOrDefault(); // If same filename: must be save with different fileDT (LastWriteTime) if(last == null || file.fullPath != last.file.fullPath || (file.fileDT - last.file.fileDT).TotalMilliseconds > 400) { Items.Add(new FileValuePair(file)); NotificationManager.Inform("Added: " + file.fullPath); collectionGrows.Invoke(); } else { NotificationManager.Inform("Doublet detected: " + file.fullPath); } }
public static void DBBinarySerialize(FileBehavior target) { MemoryStream ms = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(ms, target); SQLiteConnection db = new SQLiteConnection(Init.Singleton.sqliteConnectionString); db.Open(); SQLiteCommand command = new SQLiteCommand(db); command.CommandText = "INSERT INTO stack(filename, binaryfile) VALUES ('" + target.fullPath + "', @blob)"; command.Parameters.Add("@blob", DbType.Binary).Value = ms.ToArray(); command.ExecuteNonQuery(); db.Close(); ms.Close(); }
private void writeHistoryEntry(FileBehavior file) { string datetime = file.sysTime.ToString("yyyy-MM-dd HH:mm:ss"); if(!(file is FileIgnored) && !(file is FileRenamed) && !(file is FileDeleted) && !(file is FileMissing)) { object res = Init.Singleton.sqlite.SingleResult("SELECT filepath, datetime FROM history WHERE lower(filepath) = '" + file.fullPath.ToLower() + "'"); if(res != null) { Init.Singleton.sqlite.ExecNoResult("UPDATE history SET datetime = '" + datetime + "', type = '"+ file.GetType().Name +"' WHERE lower(filepath) = '" + file.fullPath.ToLower() + "' "); } else { Init.Singleton.sqlite.ExecNoResult("INSERT INTO history(filepath, datetime, type) VALUES ('" + file.fullPath + "', '" + datetime + "', '"+ file.GetType().Name +"')"); } } else if(file is FileRenamed) { Init.Singleton.sqlite.ExecNoResult("UPDATE history SET filepath = '" + file.fullPath + "', type = '"+ ((FileRenamed)file).subtype.GetType().Name +"' WHERE lower(filepath) = '" + ((FileRenamed)file).oldPath.ToLower() + "' "); } else if(file is FileDeleted) { Init.Singleton.sqlite.ExecNoResult("DELETE FROM history WHERE lower(filepath) = '" + file.fullPath.ToLower() + "' "); } }
public FileRenamed(string op, string fp) : base(fp, WatcherChangeTypes.Renamed) { oldPath = op; subtype = Filter(fullPath, WatcherChangeTypes.Renamed); }
public int flag; // 0 => base, 1 => processing, -1 => to delete #endregion Fields #region Constructors public FileValuePair(FileBehavior f) { file = f; flag = 0; }