Beispiel #1
0
        public Watcher(DirSyncroWatcher watcherConfig)
        {
            this.watcherConfig = watcherConfig;
            this.watcherId     = watcherConfig.Name;
            if (!string.IsNullOrEmpty(watcherConfig.Include))
            {
                includeList = new List <Regex>();
                foreach (string s in watcherConfig.Include.Split(';'))
                {
                    includeList.Add(Utility.WildcardMatch(s.Trim().ToLower(), true));
                }
            }
            else if (!string.IsNullOrEmpty(watcherConfig.Exclude))
            {
                excludeList = new List <Regex>();
                foreach (string s in watcherConfig.Exclude.Split(';'))
                {
                    excludeList.Add(Utility.WildcardMatch(s.Trim().ToLower(), true));
                }
            }

            fileWatcher      = new FileSystemWatcher();
            fileWatcher.Path = watcherConfig.SourceDirectory;
            fileWatcher.IncludeSubdirectories = true;
            fileWatcher.NotifyFilter          = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;

            fileWatcher.Created += new FileSystemEventHandler(FileEvent);
            //fileWatcher.Renamed += new RenamedEventHandler(RenamedEvent);
            fileWatcher.Changed += new FileSystemEventHandler(FileEvent);
            //fileWatcher.Deleted += new FileSystemEventHandler(DeletedEvent);
            if (watcherConfig.Enabled)
            {
                fileWatcher.EnableRaisingEvents = true;
            }
        }
Beispiel #2
0
 public SyncMessage(DirSyncroWatcher watcherConfig, List <Regex> includeList, List <Regex> excludeList)
 {
     this.timeStamp   = DateTime.UtcNow;
     this.sourcePath  = new DirectoryInfo(watcherConfig.SourceDirectory);
     this.includeList = includeList;
     this.excludeList = excludeList;
     this.versions    = watcherConfig.Versions;
     this.settling    = TimeSpan.FromSeconds(watcherConfig.Settling);
     this.retention   = TimeSpan.FromDays(watcherConfig.Retention);
 }
Beispiel #3
0
 public SyncMessage(FileSystemEventArgs eventType, DirSyncroWatcher watcherConfig, List <Regex> includeList, List <Regex> excludeList)
 {
     this.timeStamp   = DateTime.UtcNow;
     this.changeType  = eventType.ChangeType;
     this.sourceFile  = new FileInfo(eventType.FullPath);
     this.sourcePath  = new DirectoryInfo(watcherConfig.SourceDirectory);
     this.includeList = includeList;
     this.excludeList = excludeList;
     this.versions    = watcherConfig.Versions;
     this.settling    = TimeSpan.FromSeconds(watcherConfig.Settling);
     this.retention   = TimeSpan.FromDays(watcherConfig.Retention);
 }