public void UpdateWatcherForm(int id, string name, string whitelist, bool generateVideoThumbnails, bool scanSubdirectories) { var foundWatcher = Watchers.Find(id); if (foundWatcher == null) { return; } foundWatcher.Name = name; foundWatcher.Whitelist = Watcher.ExtensionStringToHash(whitelist); foundWatcher.GenerateVideoThumbnails = generateVideoThumbnails; foundWatcher.ScanSubdirectories = scanSubdirectories; SaveChanges(); }
public Watcher AddWatcherForm(string name, string dir, string whitelist, bool generateVideoThumbnails, bool scanSubdirectories) { var watcher = new Watcher { Name = name, Directory = dir, Whitelist = Watcher.ExtensionStringToHash(whitelist), GenerateVideoThumbnails = generateVideoThumbnails, ScanSubdirectories = scanSubdirectories }; Watchers.Add(watcher); SaveChanges(); return(watcher); }
private void MaybeUpdateWatcher() { bool whitelistChanged = !_orignalWhitelist.SetEquals(Watcher.ExtensionStringToHash(ExtensionTextBox.Text)); if (_orignalName != NameTextBox.Text || whitelistChanged || _originalScanBool != scanSubdirectoriesBox.Checked || _originalVideoBool != GenerateVideoThumbnailsBox.Checked) { using (var ctx = new FilesContext()) { ctx.UpdateWatcherForm(_watcher.Id, NameTextBox.Text, ExtensionTextBox.Text, scanSubdirectoriesBox.Checked, scanSubdirectoriesBox.Checked); } if (_originalScanBool != scanSubdirectoriesBox.Checked || whitelistChanged) { Console.WriteLine("restart"); _watcherMonitor.RestartById(_watcher.Id); } } }
protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity <Watcher>() .Property(b => b.Whitelist) .HasDefaultValue(new HashSet <string>()); modelBuilder.Entity <Watcher>() .Property(b => b.Enabled) .HasDefaultValue(true); modelBuilder.Entity <Watcher>() .Property(b => b.GenerateVideoThumbnails) .HasDefaultValue(true); modelBuilder.Entity <Watcher>() .Property(b => b.ScanSubdirectories) .HasDefaultValue(true); modelBuilder.Entity <File>() .Property(b => b.CreatedTime) .HasDefaultValueSql("CURRENT_TIMESTAMP"); modelBuilder.Entity <File>() .Property(b => b.TimesAccessed) .HasDefaultValue(0); modelBuilder.Entity <File>() .Property(b => b.Directory_fts) .HasDefaultValue(""); modelBuilder.Entity <File>() .Property(b => b.Name_fts) .HasDefaultValue(""); modelBuilder.Entity <File>() .Property(b => b.Name_tokenized_fts) .HasDefaultValue(""); modelBuilder.Entity <File>() .Property(b => b.Extension_fts) .HasDefaultValue(""); modelBuilder.Entity <File>() .Property(b => b.Custom_fts) .HasDefaultValue(new ObservableHashSet <string>()) .HasConversion( h => File.EnumToTagString(h), s => File.TagStringToHash(s)); modelBuilder.Entity <File>() .Property(b => b.XMPTags_fts) .HasConversion( h => File.EnumToTagString(h), s => File.TagStringToHash(s)); modelBuilder.Entity <File>() .Property(b => b.Comment) .HasDefaultValue(""); modelBuilder.Entity <File>() .HasIndex(b => b.FullName); modelBuilder.Entity <File>() .HasIndex(b => new { b.FullName, b.WatcherId }) .IsUnique(); modelBuilder.Entity <File>() .HasIndex(b => b.Directory); modelBuilder.Entity <File>() .HasIndex(b => b.CreatedTime); modelBuilder.Entity <File>() .HasIndex(b => b.FileCreatedTime); modelBuilder.Entity <File>() .HasIndex(b => b.FileModifiedTime); modelBuilder.Entity <File>() .HasIndex(b => b.LastChangeTime); modelBuilder.Entity <File>() .HasIndex(b => b.LastUseTime); modelBuilder.Entity <File>() .HasIndex(b => b.TimesAccessed); modelBuilder.Entity <Watcher>() .Property(b => b.Whitelist) .HasConversion( h => Watcher.HashToExtensionString(h), s => Watcher.ExtensionStringToHash(s)); modelBuilder.Entity <Watcher>() .Property(b => b.ShortcutKeys) .HasConversion( v => (int)v, v => (Keys)v); }