Пример #1
0
 public override Folder Add(Folder folderToAdd)
 {
     folderToAdd.FolderId = folderIndex++;
       using (var indexService = new IndexService(directoryIndexWriter)) {
     IndexResult indexResult = indexService.IndexEntity(folderToAdd, new FolderIndexDefinition());
       }
       return folderToAdd;
 }
Пример #2
0
 public override Folder Add(Folder folderToAdd)
 {
     folderToAdd.FolderId = folderIndex++;
       string folderJson = JsonConvert.SerializeObject(folderToAdd);
       using (var stream = new System.IO.StreamWriter(pathToJsonFile, append: true)) {
     stream.WriteLine(folderJson);
     stream.Close();
       }
       //Folders.Add(folderToAdd);
       return folderToAdd;
 }
Пример #3
0
 public override Folder Add(Folder folderToAdd)
 {
     folderToAdd.FolderId = folderIndex++;
       folders.Add(folderToAdd);
       if (reachedBatchSize != null) {
     numberOfFoldersInCurrentBatch++;
     if (batchSize != 0 && numberOfFoldersInCurrentBatch >= batchSize) {
       reachedBatchSize(folders);
       numberOfFoldersInCurrentBatch = 0;
       folders.Clear();
     }
       }
       return folderToAdd;
 }
Пример #4
0
        public void ScanFolder(System.IO.DirectoryInfo directoryInfo, FolderToScan folderToScan, int? parentFolderId = null)
        {
            try {
            var folder = new Folder {
              Name = directoryInfo.Name,
              Path = directoryInfo.FullName.Replace(folderToScan.AbsolutePath, folderToScan.PathAlias),
              ParentFolderId = parentFolderId
            };
            folderRepository.Add(folder);
            Logger.Trace("Added folder " + folder.Path);

            var fileInfos = directoryInfo.EnumerateFiles("*", System.IO.SearchOption.TopDirectoryOnly);
            var files = new List<Models.File>();

            foreach (var fileInfo in fileInfos) {
              try {
            var file = new Models.File {
              Name = fileInfo.Name,
              Path = fileInfo.FullName.Replace(folderToScan.AbsolutePath, folderToScan.PathAlias),
              Size = fileInfo.Length,
              FolderId = folder.FolderId,
              CreatedTime = fileInfo.CreationTime,
              LastAccessTime = fileInfo.LastAccessTime,
              LastWriteTime = fileInfo.LastWriteTime
            };
            files.Add(file);
            Logger.Trace("Added file " + file.Name);
              } catch (System.IO.PathTooLongException ex) {
            // TODO: Handle these (very common) errors
              } catch (Exception ex) {
            Logger.ErrorException("Error scanning file " + fileInfo.FullName, ex);
              }
            }
            fileRepository.Add(files);

            foreach (var subDirectory in directoryInfo.EnumerateDirectories("*", System.IO.SearchOption.TopDirectoryOnly)) {
              ScanFolder(subDirectory, folderToScan, parentFolderId = folder.FolderId);
            }
              } catch (System.IO.PathTooLongException ex) {
            // TODO: Handle these (very common) errors
              } catch (Exception ex) {
            Logger.ErrorException("Error scanning directory " + directoryInfo.FullName, ex);
              }
        }
Пример #5
0
 public abstract Folder Add(Folder folderToAdd);