示例#1
0
        public void Scan(Folder folder)
        {
            if (folder == null) throw new ArgumentNullException("folder");

            var dir = _fileSystem.GetDirectory(folder.Path);
            if (!dir.Exists) return;

            var filter = _keyValueStore.Get<string>("autoadd.filter");
            var files = dir.GetFiles(filter, folder.RecursiveSearch ? SearchScope.Recursive : SearchScope.Current);

            foreach (var file in files)
            {
                var fileName = file.Path.GetFilename().FullPath;

                if (!string.IsNullOrEmpty(folder.Pattern)
                    && !Regex.IsMatch(fileName, folder.Pattern)) continue;

                if (_autoAddRepository.GetHistoryByPath(file.Path.FullPath) != null) continue;
                
                AddFile(file);

                if (folder.RemoveSourceFile)
                {
                    file.Delete();
                }
            }
        }
示例#2
0
        public Folder CreateFolder(Folder folder)
        {
            if (folder == null) throw new ArgumentNullException("folder");

            _autoAddRepository.CreateFolder(folder);
            return folder;
        }
示例#3
0
 public void UpdateFolder(Folder folder)
 {
     var query = @"update AutoAdd_Folder set Path = @Path, Pattern = @Pattern, RemoveSourceFile = @RemoveSourceFile, RecursiveSearch = @RecursiveSearch, AutoStart = @AutoStart where Id = @Id";
     _connection.Execute(query, folder);
 }
示例#4
0
 public void CreateFolder(Folder folder)
 {
     var query = @"insert into AutoAdd_Folder (Path, Pattern, RemoveSourceFile, RecursiveSearch, AutoStart) values (@Path, @Pattern, @RemoveSourceFile, @RecursiveSearch, @AutoStart); select last_insert_rowid();";
     folder.Id = _connection.Query<int>(query, folder).First();
 }
示例#5
0
 public void UpdateFolder(Folder folder)
 {
     if (folder == null) throw new ArgumentNullException("folder");
     _autoAddRepository.UpdateFolder(folder);
 }