public void Run(string[] args) { var linksFile = ConsoleHelpers.GetOrReadArgument(0, "Links file", args); var fileToIndex = ConsoleHelpers.GetOrReadArgument(1, "File to index", args); if (!File.Exists(linksFile)) Console.WriteLine("Entered links file does not exists."); else if (!File.Exists(fileToIndex)) Console.WriteLine("Entered file to index does not exists."); else { var cancellationSource = ConsoleHelpers.HandleCancellation(); using (var memoryManager = new UInt64LinksMemoryManager(linksFile, UInt64LinksMemoryManager.DefaultLinksSizeStep * 16)) using (var links = new UInt64Links(memoryManager)) { var syncLinks = new SynchronizedLinks<ulong>(links); UnicodeMap.InitNew(syncLinks); var sequences = new Sequences(syncLinks); var fileIndexer = new FileIndexer(syncLinks, sequences); //fileIndexer.IndexAsync(fileToIndex, cancellationSource.Token).Wait(); fileIndexer.IndexSync(fileToIndex, cancellationSource.Token); } } ConsoleHelpers.PressAnyKeyToContinue(); }
public void IndexFilmWithYearInTitle(string filename, string expectedTitle, int expectedYear) { var indexed = FileIndexer.IndexFilmFiles(new [] { filename }, 0).Single(); Assert.AreEqual(expectedTitle, indexed.Title, "Title is not the same"); Assert.AreEqual(expectedYear, indexed.Year, "Year is not the same"); }
public InterpreterEngine(MainForm parent) { _parent = parent; _fileIndexer = new FileIndexer(); _systemBrowser = new SystemBrowser(); _menuEngine = new MenuEngine(parent); _plugins = new List <InterpreterPlugin>(); //_special_keywords = new string[] { @"!this", @"!clipboard", @"!actproc", @"!desktop", @"!explorer" }; _indexer_timer = new System.Timers.Timer(); _indexer_timer.Elapsed += new System.Timers.ElapsedEventHandler(_indexer_timer_Elapsed); _indexer_timer.AutoReset = true; LoadIndex(); if (SettingsManager.Instance.GetSystemOptionsInfo().UpdateTime > 0) { BuildIndex(); _indexer_timer.Interval = 1000 * 60 * SettingsManager.Instance.GetSystemOptionsInfo().UpdateTime; _indexer_timer.Start(); } _automation_timer = new System.Timers.Timer(); _automation_timer.Elapsed += new System.Timers.ElapsedEventHandler(_automation_timer_Elapsed); _automation_timer.Interval = 5000; _automation_timer.AutoReset = true; _automation_timer.Start(); _auto_update_timer = new System.Timers.Timer(); _auto_update_timer.Elapsed += new System.Timers.ElapsedEventHandler(_auto_update_timer_Elapsed); _auto_update_timer.Interval = 15000; _auto_update_timer.AutoReset = true; _auto_update_timer.Start(); _commandCache = new PluginCommandCache(30); }
private async Task StartIndexing(CancellationToken ct, bool onlyNewFiles = false) { if (_fileList == null || !_fileList.Any()) { return; } try { var fi = new FileIndexer(ct); var stopwatch = Stopwatch.StartNew(); await Task.Run(() => fi.StartIndexing(_fileList, IndexingProgress, onlyNewFiles), ct); stopwatch.Stop(); _duration = stopwatch.Elapsed; IndexingFinished(); } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK); } finally { _cts.Dispose(); _cts = null; } }
private async void btnSave_Click(object sender, EventArgs e) { if (dgFilesSelected.SelectedRows.Count == 0) { return; } if (txtAlbum.Text.Equals(Constants.MultipleValues) && txtArtist.Text.Equals(Constants.MultipleValues) && txtGenre.Text.Equals(Constants.MultipleValues) && txtTrackNumber.Text.Equals(Constants.MultipleValues) && txtTrackTitle.Text.Equals(Constants.MultipleValues) && txtYear.Text.Equals(Constants.MultipleValues)) { return; } this.Enabled = false; gbMetaTags.Enabled = false; var metaTagsService = new MetaTagsService(); await metaTagsService.SetMetaTags(Files); var cts = new CancellationTokenSource(30000); var fi = new FileIndexer(cts.Token); await Task.Run(() => fi.StartIndexing(Files.Select(x => x.Id), null), cts.Token); this.Enabled = true; gbMetaTags.Enabled = true; MessageBox.Show(this, "Saved succesfully!", "Meta tags saved", MessageBoxButtons.OK); }
public MetalXTexture(string fullName) : base() { //SizePixel = sz; FileIndexer = new FileIndexer(fullName); Name = FileIndexer.FileName; TextureData = System.IO.File.ReadAllBytes(FileIndexer.FullName); }
public void IndexEpisodes(string filename, string expectedName, int expectedSeason, int expectedEpisode) { var indexed = FileIndexer.IndexEpisodeFiles(new [] { filename }, 0).Single(); Assert.AreEqual(expectedName, indexed.Name); Assert.AreEqual(expectedSeason, indexed.SeasonNumber); Assert.AreEqual(expectedEpisode, indexed.EpisodeNumber); }
static LibraryService() { var scope = ApplicationServiceBase.App.GetScope(); m_fileIndexer = scope.ServiceProvider.GetRequiredService <FileIndexer>(); m_loggerFactory = scope.ServiceProvider.GetRequiredService <ILoggerFactory>(); m_logger = m_loggerFactory.CreateLogger(nameof(LibraryService)); m_fileIndexer.IndexChanged += FileIndexerOnIndexChanged; }
/// <summary> /// Creates new search engine instance /// </summary> /// <param name="settings">Engine settings object</param> /// <returns>New search engine instance</returns> public static ISearchEngine New(SearchEngineSettings settings) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } var eventReactor = new EventReactor(); var fileParserProvider = new FileParserProvider(settings); var filesVersionsRegistry = new FilesVersionsRegistry(); var index = new Index.Index(); var indexer = new FileIndexer(eventReactor, fileParserProvider, index, filesVersionsRegistry, settings); var indexEjector = new IndexEjector(eventReactor, filesVersionsRegistry); var indexUpdater = new IndexUpdater(eventReactor, indexer, filesVersionsRegistry); var watchersCollection = new PathWatchersCollection(); var fileSupervisor = new FileSupervisor( eventReactor, new FileSystemEventsProcessor( new FileSystemEventHandler( new CreateEventHandler(indexer), new ChangeEventHandler(indexUpdater), new DeleteEventHandler(eventReactor, indexEjector, watchersCollection), new RenameEventHandler( eventReactor, new FilePathActualizer(filesVersionsRegistry), watchersCollection ) ) ), watchersCollection, new PathPoller( new DeadPathDetector( watchersCollection, new PathRemover(eventReactor, watchersCollection, indexEjector) ), watchersCollection ) ); var searcher = new Searcher(index); var indexCleaner = new IndexCleaner(eventReactor, index, filesVersionsRegistry, settings); var scheduler = new Scheduler(indexCleaner, settings); return(new SearchEngine(eventReactor, indexer, indexEjector, fileSupervisor, searcher, scheduler)); }
protected override Clue MakeClueImpl([NotNull] FileMetadata input, Guid accountId) { if (input == null) { throw new ArgumentNullException(nameof(input)); } var clue = _factory.Create(EntityType.Files.File, input.PathLower, accountId); clue.ValidationRuleSuppressions.Add(Constants.Validation.Rules.DATA_001_File_MustBeIndexed); var data = clue.Data.EntityData; var value = input.AsFile; if (value.Name != null) { data.Name = value.Name; data.DisplayName = value.Name; data.Properties[DropBoxVocabulary.File.ItemName] = value.Name; } data.DocumentSize = (long)value.Size; data.ModifiedDate = value.ServerModified; try { var url = _uriBuilder.GetUri(value); data.Uri = url; data.Properties[DropBoxVocabulary.File.EditUrl] = url.ToString().Replace("www.dropbox.com/", "www.dropbox.com/ow/msft/edit/").Replace("?preview=", "/").Replace("+", "%20"); } catch (Exception exc) { _log.Warn(() => "Could not create ShareTask Dropbox File", exc); //Handle error } data.Properties[DropBoxVocabulary.File.Bytes] = value.Size.PrintIfAvailable(); data.Properties[DropBoxVocabulary.File.ClientMTime] = value.ClientModified.PrintIfAvailable(); if (value.PathLower != null) { data.Properties[DropBoxVocabulary.File.Path] = value.PathLower.PrintIfAvailable(); _factory.CreateOutgoingEntityReference(clue, EntityType.Files.Directory, "Parent", value, "/" + VirtualPathUtility.GetDirectory(value.PathLower).Trim(_trimChars)); } data.Properties[DropBoxVocabulary.File.Rev] = value.Rev.PrintIfAvailable(); if (value.Rev != null) { data.Revision = value.Rev.ToString(CultureInfo.InvariantCulture); } data.Properties[DropBoxVocabulary.File.ParentSharedFolderId] = value.ParentSharedFolderId.PrintIfAvailable(); _factory.CreateOutgoingEntityReference(clue, EntityType.Provider.Root, EntityEdgeType.ManagedIn, _providerRoot, _providerRoot.OriginEntityCode.Value); var shouldIndexFile = _jobData.FileSizeLimit == null || _jobData.FileSizeLimit.Value == 0 || (long)value.Size < _jobData.FileSizeLimit.Value; var client = _clientFactory.CreateNew(_jobData); if (shouldIndexFile) { try { var indexer = new FileIndexer(client, _state, _context); Task.Run(() => indexer.Index(value, clue).ConfigureAwait(false)); } catch (OperationCanceledException) { } catch (Exception exc) { _log.Warn(() => "Could not index Dropbox File", exc); //Handle error } } if (data.PreviewImage == null) { var extension = string.Empty; try { extension = new FileInfo(input.Name).Extension; } catch (ArgumentException) { } var allowedExtensions = new[] { ".jpg", ".jpeg", ".tif", ".tiff", ".png", ".gif", ".bmp" }.ToHashSet(); if (!string.IsNullOrEmpty(extension) && allowedExtensions.Contains(extension.ToLowerInvariant())) { try { var thumbnail = client.GetThumbnailAsync(value.PathLower, ThumbnailFormat.Jpeg.Instance, ThumbnailSize.W1024h768.Instance).Result; var bytes = thumbnail.GetContentAsByteArrayAsync().Result; var rawDataPart = new RawDataPart { Type = "/RawData/PreviewImage", MimeType = CluedIn.Core.FileTypes.MimeType.Jpeg.Code, FileName = "preview_{0}".FormatWith(data.OriginEntityCode.Key), RawDataMD5 = FileHashUtility.GetMD5Base64String(bytes), RawData = Convert.ToBase64String(bytes) }; clue.Details.RawData.Add(rawDataPart); data.PreviewImage = new ImageReferencePart(rawDataPart); } catch (OperationCanceledException) { } catch (DropboxException exc) { _log.Warn(new { FileExtention = extension }, () => "Could not get thumbnail from Dropbox: " + extension, exc); } } } return(clue); }