Example #1
0
        public FileMetadata Add(FileMetadata fileMetadata)
        {
            using (IDocumentSession session = store.OpenSession())
            {
                session.Store(fileMetadata);
                session.SaveChanges();
            }

            return fileMetadata;
        }
Example #2
0
 public FileMetadata FindReturnMatch(FileMetadata fileMetadata)
 {
     using (IDocumentSession session = store.OpenSession())
     {
         var fileMetaDataList = session.Query<FileMetadata>()
                                 .Where(x => x.CalculatedDateTaken == fileMetadata.CalculatedDateTaken
                                 && fileMetadata.FileName == x.FileName
                                 && fileMetadata.FileSize == x.FileSize);
         //.Where(x => fileMetadata.FileName == x.FileName);
         return fileMetaDataList.Any() ? fileMetaDataList.First() : null;
     }
 }
Example #3
0
        // read storage directory, check/update database
        public void CheckUpdateDatabase(string sourceDirectoryPath)
        {
            IEnumerable<string> files = Directory.EnumerateFiles(sourceDirectoryPath, "*.*", SearchOption.AllDirectories); //Directory.GetFiles(sourceDirectoryPath);

            int totalFiles = files.Count();
            int i = 0;

            Log.Info(string.Format("Starting, {0} total files to process.", totalFiles));

            foreach (string filePath in files)
            {
                Log.Info(string.Format("Processing {1} of {2} - {0}", filePath, i, totalFiles));

                FileInfo fileInfo = new FileInfo(filePath);
                if (Configuration.SupportedExtensions.Contains(fileInfo.Extension, StringComparer.CurrentCultureIgnoreCase))
                {
                    FileMetadata fileMetadata = new FileMetadata(fileInfo);

                    FileMetadata masterFileMetadata = FindMatch(fileMetadata);

                    if (masterFileMetadata != null)
                    {
                        // record exists in database, touch record
                        Log.Info(string.Format("Record exists, touching"));
                        TouchRecord(masterFileMetadata);
                    }
                    else
                    {
                        // add record to database
                        Log.Info(string.Format("Adding to database"));
                        AddRecord(fileMetadata);
                    }
                }

                i++;
            }
        }
Example #4
0
 private void TouchRecord(FileMetadata masterFileMetadata)
 {
     MediaMetadataRepo mediaMetadataRepo = MediaMetadataRepo.Instance();
     mediaMetadataRepo.TouchRecord(masterFileMetadata.Id, CurrentAnalyzerNumber);
 }
Example #5
0
 private FileMetadata FindMatch(FileMetadata fileMetadata)
 {
     // check database for match, return match if found, null otherwise
     MediaMetadataRepo mediaMetadataRepo = MediaMetadataRepo.Instance();
     return mediaMetadataRepo.FindReturnMatch(fileMetadata);
 }
Example #6
0
 private void AddRecord(FileMetadata fileMetadata)
 {
     MediaMetadataRepo mediaMetadataRepo = MediaMetadataRepo.Instance();
     fileMetadata.AnalyzerNumber = CurrentAnalyzerNumber;
     mediaMetadataRepo.Add(fileMetadata);
 }