예제 #1
0
 public override File Add(File fileToAdd)
 {
     fileToAdd.FileId = fileIndex++;
       using (var indexService = new IndexService(directoryIndexWriter)) {
     IndexResult indexResult = indexService.IndexEntity(fileToAdd, new FileIndexDefinition());
       }
       return fileToAdd;
 }
예제 #2
0
 public override File Add(File fileToAdd)
 {
     fileToAdd.FileId = fileIndex++;
       string fileJson = JsonConvert.SerializeObject(fileToAdd);
       using (var stream = new System.IO.StreamWriter(pathToJsonFile, append: true)) {
     stream.WriteLine(fileJson);
     stream.Close();
       }
       return fileToAdd;
 }
예제 #3
0
 public override File Add(File fileToAdd)
 {
     fileToAdd.FileId = fileIndex++;
       files.Add(fileToAdd);
       if (reachedBatchSize != null) {
     numberOfFilesInCurrentBatch++;
     if (batchSize != 0 && numberOfFilesInCurrentBatch >= batchSize) {
       reachedBatchSize(files);
       numberOfFilesInCurrentBatch = 0;
       files.Clear();
     }
       }
       return fileToAdd;
 }
예제 #4
0
파일: Scanner.cs 프로젝트: andyjmay/Gopher
        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 File Add(File fileToAdd);