public static void Main(string[] args) { var config = ConfigManager.CurrentConfig; foreach (var repoInfo in config.Folders) { using (var dbEngine = new DBreezeEngine(repoInfo.GetDatabasePath())) { var storage = new MetaDataStorage(dbEngine, new PathMatcher(repoInfo.LocalPath, repoInfo.RemotePath), false); Console.WriteLine(string.Format("Checking {0} and DB Path \"{1}\"", repoInfo.DisplayName, repoInfo.GetDatabasePath())); storage.ValidateObjectStructure(); } } foreach (var repoInfo in config.Folders) { try { using (var dbEngine = new DBreezeEngine(repoInfo.GetDatabasePath())) { var storage = new MetaDataStorage(dbEngine, new PathMatcher(repoInfo.LocalPath, repoInfo.RemotePath), false); var ignoreStorage = new IgnoredEntitiesStorage(new IgnoredEntitiesCollection(), storage); var session = SessionFactory.NewInstance().CreateSession(repoInfo, "DSS-DIAGNOSE-TOOL"); var remoteFolder = session.GetObjectByPath(repoInfo.RemotePath) as IFolder; var filterAggregator = new FilterAggregator( new IgnoredFileNamesFilter(), new IgnoredFolderNameFilter(), new InvalidFolderNameFilter(), new IgnoredFoldersFilter()); var treeBuilder = new DescendantsTreeBuilder( storage, remoteFolder, new DirectoryInfoWrapper(new DirectoryInfo(repoInfo.LocalPath)), filterAggregator, ignoreStorage); Console.WriteLine(string.Format("Creating local, stored and remote tree in \"{0}\"", Path.GetTempPath())); var trees = treeBuilder.BuildTrees(); var suffix = string.Format("{0}-{1}", repoInfo.DisplayName.Replace(Path.DirectorySeparatorChar,'_'), Guid.NewGuid().ToString()); var localTree = Path.Combine(Path.GetTempPath(), string.Format("LocalTree-{0}.dot", suffix)); var remoteTree = Path.Combine(Path.GetTempPath(), string.Format("StoredTree-{0}.dot", suffix)); var storedTree = Path.Combine(Path.GetTempPath(), string.Format("RemoteTree-{0}.dot", suffix)); trees.LocalTree.ToDotFile(localTree); trees.StoredTree.ToDotFile(remoteTree); trees.RemoteTree.ToDotFile(storedTree); Console.WriteLine(string.Format("Written to:\n{0}\n{1}\n{2}", localTree, remoteTree, storedTree)); } } catch (Exception ex) { Console.Error.WriteLine(ex.Message); } } }
private SingleStepEventQueue CreateQueue(Mock<ISession> session, IMetaDataStorage storage, ObservableHandler observer, IFileSystemInfoFactory fsFactory = null) { var manager = new SyncEventManager(); SingleStepEventQueue queue = new SingleStepEventQueue(manager); manager.AddEventHandler(observer); var connectionScheduler = new ConnectionScheduler(new RepoInfo(), queue, Mock.Of<ISessionFactory>(), Mock.Of<IAuthenticationProvider>()); manager.AddEventHandler(connectionScheduler); var changes = new ContentChanges(session.Object, storage, queue, this.maxNumberOfContentChanges, this.isPropertyChangesSupported); manager.AddEventHandler(changes); var transformer = new ContentChangeEventTransformer(queue, storage, fsFactory); manager.AddEventHandler(transformer); var ccaccumulator = new ContentChangeEventAccumulator(session.Object, queue); manager.AddEventHandler(ccaccumulator); var remoteFetcher = new RemoteObjectFetcher(session.Object, storage); manager.AddEventHandler(remoteFetcher); var localFetcher = new LocalObjectFetcher(storage.Matcher, fsFactory); manager.AddEventHandler(localFetcher); var watcher = new Strategy.WatcherConsumer(queue); manager.AddEventHandler(watcher); var localDetection = new LocalSituationDetection(); var remoteDetection = new RemoteSituationDetection(); var transmissionManager = new TransmissionManager(); var activityAggregator = new ActivityListenerAggregator(Mock.Of<IActivityListener>(), transmissionManager); var ignoreFolderFilter = new IgnoredFoldersFilter(); var ignoreFolderNameFilter = new IgnoredFolderNameFilter(); var ignoreFileNamesFilter = new IgnoredFileNamesFilter(); var invalidFolderNameFilter = new InvalidFolderNameFilter(); var filterAggregator = new FilterAggregator(ignoreFileNamesFilter, ignoreFolderNameFilter, invalidFolderNameFilter, ignoreFolderFilter); var syncMechanism = new SyncMechanism(localDetection, remoteDetection, queue, session.Object, storage, Mock.Of<IFileTransmissionStorage>(), activityAggregator, filterAggregator); manager.AddEventHandler(syncMechanism); var remoteFolder = MockSessionUtil.CreateCmisFolder(); remoteFolder.Setup(r => r.Path).Returns(this.remoteRoot); var localFolder = new Mock<IDirectoryInfo>(); localFolder.Setup(f => f.FullName).Returns(this.localRoot); var generator = new CrawlEventGenerator(storage, fsFactory); var ignoreStorage = new IgnoredEntitiesStorage(new IgnoredEntitiesCollection(), storage); var treeBuilder = new DescendantsTreeBuilder(storage, remoteFolder.Object, localFolder.Object, filterAggregator, ignoreStorage); var notifier = new CrawlEventNotifier(queue); var crawler = new DescendantsCrawler(queue, treeBuilder, generator, notifier, Mock.Of<IActivityListener>()); manager.AddEventHandler(crawler); var permissionDenied = new GenericHandleDublicatedEventsFilter<PermissionDeniedEvent, ConfigChangedEvent>(); manager.AddEventHandler(permissionDenied); var alreadyAddedFilter = new IgnoreAlreadyHandledFsEventsFilter(storage, fsFactory); manager.AddEventHandler(alreadyAddedFilter); var ignoreContentChangesFilter = new IgnoreAlreadyHandledContentChangeEventsFilter(storage, session.Object); manager.AddEventHandler(ignoreContentChangesFilter); var delayRetryAndNextSyncEventHandler = new DelayRetryAndNextSyncEventHandler(queue); manager.AddEventHandler(delayRetryAndNextSyncEventHandler); /* This is not implemented yet var failedOperationsFilder = new FailedOperationsFilter(queue); manager.AddEventHandler(failedOperationsFilder); */ var reportingFilter = new ReportingFilter(queue, ignoreFolderFilter, ignoreFileNamesFilter, ignoreFolderNameFilter, invalidFolderNameFilter, new SymlinkFilter()); manager.AddEventHandler(reportingFilter); var debugHandler = new DebugLoggingHandler(); manager.AddEventHandler(debugHandler); var movedOrRenamed = new RemoteObjectMovedOrRenamedAccumulator(queue, storage, fsFactory); manager.AddEventHandler(movedOrRenamed); return queue; }
public override void AwakeFromNib() { base.AwakeFromNib(); var config = ConfigManager.CurrentConfig; this.folderSelection.RemoveAllItems(); this.output.Editable = false; this.RunButton.Activated += (object sender, EventArgs e) => { var folder = config.Folders.Find(f => f.DisplayName == this.folderSelection.SelectedItem.Title); using (var dbEngine = new DBreezeEngine(folder.GetDatabasePath())) { var storage = new MetaDataStorage(dbEngine, new PathMatcher(folder.LocalPath, folder.RemotePath), false); try { storage.ValidateObjectStructure(); this.output.StringValue = string.Format("{0}: DB structure of {1} is fine", DateTime.Now, folder.GetDatabasePath()); } catch(Exception ex) { this.output.StringValue = ex.ToString(); } } }; this.DumpTree.Activated += (object sender, EventArgs e) => { this.output.StringValue = string.Empty; var folder = config.Folders.Find(f => f.DisplayName == this.folderSelection.SelectedItem.Title); using (var dbEngine = new DBreezeEngine(folder.GetDatabasePath())) { var storage = new MetaDataStorage(dbEngine, new PathMatcher(folder.LocalPath, folder.RemotePath), false); try { var ignoreStorage = new IgnoredEntitiesStorage(new IgnoredEntitiesCollection(), storage); var session = SessionFactory.NewInstance().CreateSession(folder, "DSS-DIAGNOSE-TOOL"); var remoteFolder = session.GetObjectByPath(folder.RemotePath) as IFolder; var filterAggregator = new FilterAggregator( new IgnoredFileNamesFilter(), new IgnoredFolderNameFilter(), new InvalidFolderNameFilter(), new IgnoredFoldersFilter()); var treeBuilder = new DescendantsTreeBuilder( storage, remoteFolder, new DirectoryInfoWrapper(new DirectoryInfo(folder.LocalPath)), filterAggregator, ignoreStorage); var trees = treeBuilder.BuildTrees(); var suffix = string.Format("{0}-{1}", folder.DisplayName.Replace(Path.DirectorySeparatorChar,'_'), Guid.NewGuid().ToString()); var localTree = Path.Combine(Path.GetTempPath(), string.Format("LocalTree-{0}.dot", suffix)); var remoteTree = Path.Combine(Path.GetTempPath(), string.Format("StoredTree-{0}.dot", suffix)); var storedTree = Path.Combine(Path.GetTempPath(), string.Format("RemoteTree-{0}.dot", suffix)); trees.LocalTree.ToDotFile(localTree); trees.StoredTree.ToDotFile(remoteTree); trees.RemoteTree.ToDotFile(storedTree); this.output.StringValue = string.Format("Written to:\n{0}\n{1}\n{2}", localTree, remoteTree, storedTree); } catch (Exception ex) { this.output.StringValue = ex.ToString(); } } }; foreach (var folder in config.Folders) { this.folderSelection.AddItem(folder.DisplayName); } }
private DescendantsCrawler CreateCrawler() { var generator = new CrawlEventGenerator(this.storage, this.fsFactory.Object); var treeBuilder = new DescendantsTreeBuilder(this.storage, this.remoteFolder.Object, this.localFolder.Object, this.filter, Mock.Of<IIgnoredEntitiesStorage>()); var notifier = new CrawlEventNotifier(this.queue.Object); return new DescendantsCrawler(this.queue.Object, treeBuilder, generator, notifier, this.listener.Object); }