public Watcher() { // make sure that the event wait values are set RecalculateDelays(); #if DEBUG // _watcherManager = new WatcherManagerEmbeddedInterop(); // _watcherManager = new WatcherManagerInterop(); // The debug version does not use the embedded version. _watcherManager = new WatcherManagerLoadLibrary(); #else // The release function must use the embedded version. _watcherManager = new WatcherManagerEmbeddedLoadLibrary(); #endif // register for logger events right away _watcherManager.OnLogger += OnLogger; // start the task that will forever be looking for events. _eventsTask = ProcessEventsAsync(); // then run all the statistics task _statisticsTask = ProcessStatisticsAsync(); // we have not disposed _disposed = false; }
private void Manager_WatcherManagerCreatedEvent(WatcherManager sender) { Dispatcher.Invoke(() => { SaveButton.IsEnabled = true; EnablePreview.IsEnabled = true; }); }
private void btnPipeWatcher_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => { WatcherManager manager = new WatcherManager(); manager.StartPipeWatcher(7172); }); }
private void btnStartWatcher_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => { WatcherManager manager = new WatcherManager(); manager.StartTableWatcher(MQFactory.Producerconfig[0]); }); }
private void LoadWatchers(ItemsResult result) { DisposeCurrentWatcherManager(); watcherManager = WatcherManager.CreateFromTree(result.WatchingTree); watcherManager.ItemAdded += OnItemAdded; watcherManager.ItemRemoved += OnItemRemoved; watcherManager.BeginWatch(); }
private void DisposeCurrentWatcherManager() { if (watcherManager == null) { return; } watcherManager.ItemAdded -= OnItemAdded; watcherManager.ItemRemoved -= OnItemRemoved; watcherManager.Dispose(); watcherManager = null; }
static void Main(string[] args) { var section = (WatcherConfigurationSection)ConfigurationManager.GetSection(Program.SectionName); Thread.CurrentThread.CurrentUICulture = new CultureInfo(section.CurrentCulture.Type); CreateWorkDirectory(section); var watchersBuilder = new WatchersBuilder(section); var watcher = new WatcherManager(watchersBuilder, section); watcher.FilteredItem += OnFiltered; watcher.StartWatch(); Console.WriteLine(messages.EndAppInfoMessage); Console.ReadLine(); }
public Watcher() { #if DEBUG // _watcherManager = new WatcherManagerEmbeddedInterop(); // _watcherManager = new WatcherManagerInterop(); // The debug version does not use the embedded version. _watcherManager = new WatcherManagerLoadLibrary(); #else // The release function must use the embedded version. _watcherManager = new WatcherManagerEmbeddedLoadLibrary(); #endif // start the task that will forever be looking for events. _task = ProcessEventsAsync(); // we have not disposed _disposed = false; }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { Preview.Source = new BitmapImage(new Uri(@"Images\preview.png", UriKind.Relative)); //Create manager = new WatcherManager(); WatcherList.ItemsSource = manager.Watchers; //Bindings Binding watcherCountBinding = new Binding("WatcherCount") { Source = manager }; StatusWatchersCount.SetBinding(TextBlock.TextProperty, watcherCountBinding); Binding urlBinding = new Binding("Channel") { Source = manager, }; StatusMainUrl.SetBinding(TextBlock.TextProperty, urlBinding); Binding userCountBinding = new Binding("UserCount") { Source = manager, }; StatusUserCount.SetBinding(TextBlock.TextProperty, userCountBinding); //Threads tokenSource = new CancellationTokenSource(); //DPI GetDpi(); }
public void CheckWatcher(DataSetSatisfactory dataSetSatisfactory) { string path = Path.Combine(TestContext.CurrentContext.TestDirectory, @"Scripts", dataSetSatisfactory.Name); DirectoryInfo directoryInfo = new DirectoryInfo(path); Assert.IsNotNull(directoryInfo, "Scripts directory is null"); Assert.IsTrue(directoryInfo.Exists, "Scripts directory does not exist"); EngineScript engineScript = EngineScriptManager.LoadEngineScript(directoryInfo); Assert.IsNotNull(engineScript, "EngineScript not loaded properly"); if (!Directory.Exists(dataSetSatisfactory.SourceFolder)) { Directory.CreateDirectory(dataSetSatisfactory.SourceFolder); } string profilePathOrigin = Path.Combine(dataSetSatisfactory.DataRoot, @"Original", dataSetSatisfactory.ProfileName + "_Open.shp"); string profilePathSimulation = Path.Combine(dataSetSatisfactory.SourceFolder, dataSetSatisfactory.ProfileName + "_Open.shp"); File.Copy(profilePathOrigin, profilePathSimulation); string content = File.ReadAllText(profilePathSimulation); content = content.Replace(@"%SOURCEFOLDER%", dataSetSatisfactory.SourceFolder.Replace(@"\", @"\\")); File.WriteAllText(profilePathSimulation, content); ProfileFile profileFile = ProfileFile.Load(profilePathSimulation); Assert.IsNotNull(profileFile); LuaManager luaManager = new LuaManager(); Assert.IsNotNull(luaManager); bool loadEngine = luaManager.LoadEngineAndProfile(engineScript, profileFile); Assert.IsTrue(loadEngine); if (luaManager.ActiveEngine.OnOpened != null) { Assert.DoesNotThrow(() => { luaManager.ActiveEngine.OnOpened.Call(); }); } int catCount = 0; luaManager.ActiveEngine.OnCategoriesChanges += () => { catCount++; }; int snapCount = 0; luaManager.ActiveEngine.OnSnapshotsChanges += () => { snapCount++; }; int backupCount = 0; luaManager.ActiveEngine.OnAutoBackupOccurred += success => { if (success) { backupCount++; } }; if (luaManager.ActiveEngine.OnInitialized != null) { Assert.DoesNotThrow(() => { luaManager.ActiveEngine.OnInitialized.Call(); }); } Assert.IsNotNull(luaManager.ActiveEngine.Watcher); var setting = luaManager.ActiveEngine.SettingByName("IncludeAutosave"); if (setting is EngineSettingCheckbox s) { s.Value = true; } WatcherManager watcherManager = new WatcherManager(luaManager.ActiveEngine.Watcher) { IsProcessRunning = () => true }; // int backupStatus = 0; watcherManager.AutoBackupStatusChanged += () => { // backupStatus++; }; if (luaManager.ActiveEngine.OnLoaded != null) { Assert.DoesNotThrow(() => { luaManager.ActiveEngine.OnLoaded.Call(); }); } Assert.AreEqual(1, catCount); Assert.AreEqual(1, snapCount); // End of open Assert.AreEqual(AutoBackupStatus.Disabled, watcherManager.AutoBackupStatus); Thread.Sleep(100); watcherManager.SetAutoBackup(true); Assert.AreEqual(AutoBackupStatus.Enabled, watcherManager.AutoBackupStatus); string fileSource = Path.Combine(dataSetSatisfactory.DataRoot, @"Original"); string fileDest = dataSetSatisfactory.SourceFolder; foreach (var files in dataSetSatisfactory.Watchers.OrderBy(x => x.Key)) { backupCount = 0; foreach (var file in files.Value.Files) { // this engine requires file changes //using (var fileStream = File.Create(Path.Combine(fileDest, file))) //{ } //Thread.Sleep(100); using (var fileStream = File.OpenWrite(Path.Combine(fileDest, file))) { var bytes = File.ReadAllBytes(Path.Combine(fileSource, file)); fileStream.Write(bytes, 0, bytes.Length); } Thread.Sleep(100); } Thread.Sleep(500); Assert.GreaterOrEqual(backupCount, 1); Assert.AreEqual(1, luaManager.ActiveEngine.Snapshots.Count); EngineSnapshot snapshot = luaManager.ActiveEngine.Snapshots.First(); Assert.AreSame(snapshot, luaManager.ActiveEngine.LastSnapshot); Assert.AreEqual(files.Value.SnapshotSaveAt, RoundSavedAt(snapshot.SavedAt)); Assert.AreEqual(files.Value.SnapshotBuildVersion, snapshot.CustomValueByKey("BuildVersion").ToString()); Assert.AreEqual(files.Value.SnapshotSaveVersion, snapshot.CustomValueByKey("SaveVersion").ToString()); Assert.AreEqual(files.Value.SnapshotSessionName, snapshot.CustomValueByKey("SessionName").ToString()); Assert.AreEqual(files.Value.SnapshotPlayedTime, snapshot.CustomValueByKey("PlayedTime").ToString()); Assert.AreEqual(files.Value.SnapshotAutosave, snapshot.CustomValueByKey("Autosave").ToString()); luaManager.ActiveEngine.Snapshots.Clear(); foreach (var file in files.Value.Files) { File.Delete(Path.Combine(fileDest, file)); } Thread.Sleep(100); } watcherManager.Release(); luaManager.Release(); Directory.Delete(dataSetSatisfactory.SourceFolder, true); }