Example #1
0
 // FolderWatcher now implements IDisposable
 // this is because it uses FileSystemWatcher
 // app has its own private variable for FolderWatcher()
 // that may be started and stopped
 public static void Stop()
 {
     if (archiver != null)
     {
         archiver.Dispose();
         archiver = null;
     }
 }
Example #2
0
        private static void Main(string[] args)
        {
            FolderWatcher watcher = new FolderWatcher();

            watcher.Start();
            System.Console.ReadKey();
            watcher.Stop();
        }
Example #3
0
        protected override void OnStart(string[] args)
        {
            var folderToWatch           = ConfigurationManager.AppSettings["FolderToWatch"];
            var fileFilter              = ConfigurationManager.AppSettings["FileFilter"];
            var folderForProcessedFiles = ConfigurationManager.AppSettings["FolderForProcessedFiles"];

            watcher = new FolderWatcher(folderToWatch, fileFilter, folderForProcessedFiles, container.GetInstance <IFileHandler>());
            watcher.Start();
        }
        private void folderChangesCallback(FolderWatcher callback)
        {
            Callbacks.raiseRegistedCallbacks(_onFileWatchEvent, new[] { callback });

            if (callback.folderWatched == getCurrentDirectory())
            {
                refreshDirectoryView();
            }
        }
Example #5
0
 //var folderWatcher = new FolderWatcher(folderToTest, fileChangeCallback);
 public static void setupFolderWatchers(string folderFor_DropQueue, string folderFor_ScanQueue,
                                        string folderFor_ScanResults)
 {
     folderWatcher_DropQueue = new FolderWatcher(resolvePathToWatchedFolder(folderFor_DropQueue),
                                                 fileChangeIn_DropQueue);
     folderWatcher_ScanQueue = new FolderWatcher(resolvePathToWatchedFolder(folderFor_ScanQueue),
                                                 fileChangeIn_ScanQueue);
     folderWatcher_ScanResults = new FolderWatcher(resolvePathToWatchedFolder(folderFor_ScanResults),
                                                   fileChangeIn_ScanResults);
 }
        static void Main(string[] args)
        {
            //RunExamlpe.Run();

            var watcher = new FolderWatcher();

            watcher.StartWatch();

            Console.ReadKey();
        }
 public MainWindowViewModel(IncognitoSettings settings, SoftwareRepository softwareRepository)
 {
     _softwareRepository = softwareRepository;
     _incognitoSettings = settings;
     this._folderWatcher = new FolderWatcher(_softwareRepository);
     this.SoftwareList = new SoftwareListViewModel(_softwareRepository);
     this.Incognito = new IncognitoViewModel(_softwareRepository, _incognitoSettings);
     this.Settings = new SettingsViewModel(_incognitoSettings);
     CloseWindowCommand = new RelayCommand(CloseWindowExecute);
     ShowWindowCommand = new RelayCommand(ShowWindowExecute, () => ShowWindowCanExecute());
     HideWindowCommand = new RelayCommand(HideWindowExecute, () => HideWindowCanExecute());
 }
Example #8
0
        public FolderView()
        {
            InitializeComponent();

            this.textBox1.ShortcutsEnabled = true;
            _ListViewItemCache             = new ListViewItem[0];

            // SuggestAppend is nice, but if you hit ctrl + A while its suggesting it just empties the textbox
            this.textBox1.AutoCompleteMode   = AutoCompleteMode.Suggest;
            this.textBox1.AutoCompleteSource = AutoCompleteSource.FileSystemDirectories;

            _iconList16.ImageSize  = new Size(16, 16);
            _iconList16.ColorDepth = ColorDepth.Depth24Bit;

            _iconList16.Images.Add(ApplicationStyles.Resources.Folder16);

            ListView_.RetrieveVirtualItem += new RetrieveVirtualItemEventHandler(listView1_RetrieveVirtualItem);
            ListView_.CacheVirtualItems   += new CacheVirtualItemsEventHandler(listView1_CacheVirtualItems);
            ListView_.ItemActivate        += ListView1_ItemActivate;
            ListView_.KeyUp += OnKeyUp;

            ListView_.SmallImageList  = _iconList16;
            ListView_.GridLines       = false;
            ListView_.VirtualMode     = true;
            ListView_.VirtualListSize = 0;
            ListView_.Sorting         = SortOrder.None;
            ListView_.FullRowSelect   = true;
            ListView_.AllowDrop       = true;

            _FolderWatcher = new FolderWatcher(PathHelper.GetScreenshotFolder());
            _FolderWatcher.WatcherNotifyFilter  = NotifyFilters.FileName | NotifyFilters.DirectoryName;
            _FolderWatcher.FilterFileExtensions = InternalSettings.Readable_Image_Formats.ToArray();
            _FolderWatcher.FileRemoved         += _FolderWatcher_FileRemoved;
            _FolderWatcher.DirectoryRemoved    += _FolderWatcher_DirectoryRemoved;
            _FolderWatcher.FileAdded           += _FolderWatcher_FileAdded;
            _FolderWatcher.DirectoryAdded      += _FolderWatcher_DirectoryAdded;
            _FolderWatcher.DirectoryRenamed    += _FolderWatcher_DirectoryRenamed;
            _FolderWatcher.FileRenamed         += _FolderWatcher_FileRenamed;
            _FolderWatcher.ItemChanged         += _FolderWatcher_ItemChanged;
            _FolderWatcher.SortOrderChanged    += _FolderWatcher_SortOrderChanged;

            ListView_.UpdateTheme();
            ListView_.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            ListView_.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

            _ListviewRefreshTimer.Tick += _ListviewRefreshTimer_Tick;
            _ListviewRefreshTimer.SetInterval(500);

            UpdateTheme();
            ApplicationStyles.UpdateThemeEvent += UpdateTheme;
        }
        public MainWindow()
        {
            InitializeComponent();


            folderWatcher      = new FolderWatcher(Log, Dispatcher);
            printerMultiplexer = new PrinterMultiplexer(Log, Dispatcher);
            fileMover          = new FileMover(Log, Dispatcher);
            // TODO Add completion detection (in the multiplexer module)

            folderWatcher.Outputs.SetOutput(FolderWatcher.NextModule, printerMultiplexer);
            printerMultiplexer.Outputs.SetOutput(PrinterMultiplexer.NextModule, fileMover);

            // Initializes some things to use in PrintButton testing.
            ticket = new PrintTicket();
        }
        private void folderChangesCallback(FolderWatcher callback)
        {
            Callbacks.raiseRegistedCallbacks(_onFileWatchEvent, new[] { callback });

            if (callback.folderWatched == getCurrentDirectory())    // if there is no parent form it means this is not being used any more
            {
                if (this.parentForm().isNull())
                {
                    folderWatcher.enabled = false;
                    "Directory Viewer not used anymore, so disabling it".info();
                }
                else
                {
                    refreshDirectoryView();
                }
            }
        }
Example #11
0
        void InitializeFolderWatchers(Dirigent.Agent.Core.Agent agent, string rootForRelativePaths)
        {
            // no local config file loaded
            if (ac.lcfg == null)
            {
                return;
            }

            foreach (var xmlCfg in ac.lcfg.folderWatcherXmls)
            {
                var fw = new FolderWatcher(xmlCfg, agent.Control, rootForRelativePaths);
                if (fw.Initialized)
                {
                    folderWatchers.Add(fw);
                }
            }
        }
Example #12
0
        public MainWindow()
        {
            InitializeComponent();

            // Initialize modules, with our logging method.
            folderWatcher = new FolderWatcher(Log, Dispatcher);
            imageReviewer = new ImageReviewer(Log, Dispatcher);
            acceptMover   = new FileMover(Log, Dispatcher);
            rejectMover   = new FileMover(Log, Dispatcher);

            // Connect the modules in their intended orders.
            folderWatcher.Outputs.SetOutput(FolderWatcher.NextModule, imageReviewer);
            imageReviewer.Outputs.SetOutput(ImageReviewer.AcceptOutput, acceptMover);
            imageReviewer.Outputs.SetOutput(ImageReviewer.RejectOutput, rejectMover);

            // Load the first image whenever it's ready.
            nextImage();
        }
        /*   private void llMode_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
         * {
         * }*/


        public void setupFolderWatched()
        {
            if (folderWatcher != null)
            {
                if (folderWatcher.folderWatched == getCurrentDirectory())
                {
                    return;
                }
                else
                {
                    folderWatcher.disable();
                }
            }

            if (cbWatchFolder.Checked)
            {
                folderWatcher = new FolderWatcher(getCurrentDirectory(), folderChangesCallback);
            }
        }
        public void test_FolderWatcher()
        {
            string folderToTest = Path.Combine(DI.config.O2TempDir, "FileWatcherDir");

            DI.log.info(folderToTest);
            string testFile = Path.Combine(folderToTest, "testFile.Txt");

            Files.checkIfDirectoryExistsAndCreateIfNot(folderToTest);
            var folderWatcher = new FolderWatcher(folderToTest, delegate { folderChangeDetected.Set(); });

            Files.WriteFileContent(testFile, "test Content");
            folderChangeDetected.WaitOne();
            List <string> filesInAffectedFolder = Files.getFilesFromDir(folderToTest);

            Assert.IsTrue(folderWatcher.file != "",
                          "(on folderWatcher obj)No Changes were detected on target folder: " + folderToTest);
            Assert.IsTrue(filesInAffectedFolder.Count > 0,
                          "(on folderWatcher obj) There were no files on target folder");
        }
        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(Properties.Settings.Default.SettingsUpgraded))
            {
                // upgrade settings from previous version
                Properties.Settings.Default.Upgrade();

                Properties.Settings.Default.SettingsUpgraded = "true";
                Properties.Settings.Default.Save();
            }

            string version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();

            lblVersion.Content = String.Format("v{0}", version);

            folderWatcher = new FolderWatcher();
            folderWatcher.CheckInterval = 1000;
            folderWatcher.Filter        = "^[^~](.*?.pptx)$";
            folderWatcher.FilterIsRegex = true;
            folderWatcher.Changed      += folderWatcher_Changed;

            string folderToWatch = Properties.Settings.Default.FolderToWatch;

            if (!String.IsNullOrEmpty(folderToWatch) && System.IO.Directory.Exists(folderToWatch))
            {
                this.SetSearchDirectory(folderToWatch);

                if (Properties.Settings.Default.AutoWatch == "true")
                {
                    this.chkWatchOnStart.IsChecked = true;
                    this.StartStopWatching();
                }

                if (Properties.Settings.Default.AutoLaunchLastFile == "true")
                {
                    this.chkAutoLaunchLastFile.IsChecked = true;

                    this.LaunchLastFile(false);
                }

                this.SetLastLaunchedFile(Properties.Settings.Default.LastLaunchedFile, Properties.Settings.Default.LastLaunchTime);
            } // else silently ignore as if the file doesn't exist in the setting.
        }
        static void Main(string[] args)
        {
            try
            {
                var folderToWatch           = ConfigurationManager.AppSettings["FolderToWatch"];
                var fileFilter              = ConfigurationManager.AppSettings["FileFilter"];
                var folderForProcessedFiles = ConfigurationManager.AppSettings["FolderForProcessedFiles"];

                var watcher = new FolderWatcher(folderToWatch, fileFilter, folderForProcessedFiles, container.GetInstance <IFileHandler>());
                watcher.Start();

                System.Console.ReadKey();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                System.Console.ReadKey();
            }
        }
Example #17
0
        /// <summary>
        /// Handle for main form loading.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UIMainForm_Load(object sender, EventArgs e)
        {
            CenterToScreen();
            LogManager.LogSource         = this.DataGridViewLogging;
            LogManager.form              = this;
            LogManager.loading           = this.pictureBoxCloud;
            this.pictureBoxCloud.Visible = false;

            this.DataGridViewLogging.DoubleClick += LoggingView_DoubleClick;
            this.DataGridViewLogging.DefaultCellStyle.SelectionBackColor = Color.FromArgb(90, 192, 255);

            directoryWatcher = new FolderWatcher();
            directoryWatcher.Run();

            directoryExist = new FileSystemWatcher()
            {
                Path = (Directory.GetParent(AppConfiguration.GetInstance.GetToMnitorDirectory)).FullName
            };
            directoryExist.Deleted            += DirectoryExist_Deleted;
            directoryExist.EnableRaisingEvents = true;
        }
Example #18
0
        public FolderWatcher WatchFolder(FolderRegistration folder, FolderEventHandler handler,
                                         FolderEventHandler changedHandler = null,
                                         FolderEventHandler removedHandler = null)
        {
            if (!DebugOptions.GetOption(null, DebugOptions.WATCHER_ENABLED))
            {
                return(null);
            }

            FolderWatcher watcher;

            if (!_folderWatchers.TryGetValue(folder, out watcher))
            {
                watcher = new FolderWatcher();
                _folderWatchers.TryAdd(folder, watcher);
            }

            watcher.Discovered += handler;
            if (changedHandler != null)
            {
                watcher.Changed += changedHandler;
            }
            if (removedHandler != null)
            {
                watcher.Removed += removedHandler;
            }

            // Check existing folders for events
            foreach (ZPushFolder existing in _allFolders)
            {
                if (folder.IsApplicable(existing.Folder))
                {
                    DispatchFolderEvent(folder, watcher, existing, EventKind.Discovered);
                }
            }

            return(watcher);
        }
Example #19
0
        public static void EnabledFeaturePages()
        {
            if (Instance == null)
            {
                return;
            }

            FolderWatcher.Init();

            SetLoadingSplashVisible(true);

            foreach (var tab in s_featureTabPages)
            {
                Instance._tabView.EnableTab(tab);
            }

            Instance._tabView.SelectedIndex = 2;

            if (ProfileManager.ActiveProfile == null)
            {
                ProfileManager.LoadProfileOrSetDefault();
            }

            if (!s_doneInitFeatures)
            {
                s_doneInitFeatures = true;

                // add control modules for other pages
                Instance._browseTabPage.Controls.Add(new BrowseModsPage());
                Instance._manageTabPage.Controls.Add(new LauncherPage());
            }

            Application.DoEvents();

            SetLoadingSplashVisible(false);
        }
 private void directoryWithScanCatNetResults__onFileWatchEvent(FolderWatcher folderWatcher)
 {
     convertCatNetFileIntoOzasmt(folderWatcher.file, directoryWithCreatedOzasmtFiles.getCurrentDirectory());
 }
Example #21
0
        public void StartWatchFolder(string folderName)
        {
            _logHelper.WriteEntry(String.Format("Starting WatchFolder ServiceViewModel for {0}", folderName), MessageType.Information);

            WatchFolderSettings watchFolderSettings = _watchFolderSettingsHelper.Settings.WatchFoldersSettings[folderName];

            // load task engines
            var pluginLoader = new PluginLoader <IPlugin>();
            var taskFactory  = new TaskFactory();

            pluginLoader.LoadPlugins(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location));

            foreach (TaskEngineSettings taskEngineSettings in watchFolderSettings.TaskEnginesSettings)
            {
                taskFactory.AddToTaskEngines((ITaskEngine)pluginLoader.GetPlugin(taskEngineSettings.TypeName));
            }

            _logHelper.WriteEntry(String.Format("{0} Task Engines detected for WatchFolder ServiceViewModel for {1}", taskFactory.TaskEngines.Count, folderName), MessageType.Information);

            if (taskFactory.TaskEngines.Count == 0)
            {
                _logHelper.WriteEntry(String.Format("{0} Task Engines detected for WatchFolder ServiceViewModel for {1}.  Stopping", taskFactory.TaskEngines.Count, folderName), MessageType.Warning);
                return;
            }

            if (!_queues.ContainsKey(folderName))
            {
                _queues[folderName] = new SyncItemQueue <FolderWatcherQueueItem>();
            }
            else
            {
                _queues.Add(folderName, new SyncItemQueue <FolderWatcherQueueItem>());
            }

            if (_exitThreadEvents.ContainsKey(folderName))
            {
                _exitThreadEvents[folderName] = new ManualResetEvent(false);
            }
            else
            {
                _exitThreadEvents.Add(folderName, new ManualResetEvent(false));
            }

            //deserialise queue from settings

            foreach (QueueStateItem queueItem in watchFolderSettings.Queue)
            {
                _queues[folderName].EnqueueSync(new FolderWatcherQueueItem {
                    Path = queueItem.Path, Time = queueItem.DateTime
                });
            }

            //var transcodeEngine = new FlacToMp3TranscodeEngine();
            //var copyFolderArtEngine = new CopyFolderArtEngine();
            //taskFactory.AddToTaskEngines(transcodeEngine);
            //taskFactory.AddToTaskEngines(copyFolderArtEngine);

            var scheduleTicker = new ScheduleTicker(watchFolderSettings.ScheduleSettings.GetSchedule(), watchFolderSettings.TimerInterval);
            var folderWatcher  = new FolderWatcher(_queues[folderName], _exitThreadEvents[folderName], folderName, "*.*", true);
            var taskScheduler  = new TaskScheduler(_queues[folderName], _exitThreadEvents[folderName], taskFactory, watchFolderSettings.InitialTaskDelay, scheduleTicker);

            if (!_producerThreads.ContainsKey(watchFolderSettings.FolderName))
            {
                _producerThreads.Add(folderName, new Thread(folderWatcher.ThreadRun)
                {
                    Name = String.Format("ProducerThread for {0}", watchFolderSettings.FolderName)
                });
            }

            if (!_consumerThreads.ContainsKey(watchFolderSettings.FolderName))
            {
                _consumerThreads.Add(folderName, new Thread(taskScheduler.ThreadRun)
                {
                    Name = String.Format("ConsumerThread for {0}", watchFolderSettings.FolderName)
                });
            }

            _producerThreads[folderName].Start();
            _consumerThreads[folderName].Start();

            _logHelper.WriteEntry(String.Format("Started WatchFolder ServiceViewModel for {0}", folderName), MessageType.Information);
        }
Example #22
0
 public Worker(ILogger <Worker> logger, FolderWatcher folderWatcher)
 {
     _logger      = logger ?? throw new ArgumentNullException(nameof(logger));
     _fileWatcher = folderWatcher ?? throw new ArgumentNullException(nameof(folderWatcher));
 }
Example #23
0
 public static void fileChangeIn_ScanResults(FolderWatcher folderWatcher)
 {
     DI.log.info("fileChangeIn_ScanResults that changed: {0}", folderWatcher.file);
 }
Example #24
0
 public static void fileChangeIn_ScanQueue(FolderWatcher folderWatcher)
 {
     Queues.ScanQueue.processScanQueueFolder();
 }
Example #25
0
 public static void fileChangeIn_DropQueue(FolderWatcher folderWatcher)
 {
     DropQueue.processDropQueueFolder();
     // DI.log.info("fileChangeIn_DropQueue that changed: {0}", folderWatcher.file);
 }
Example #26
0
        } // ~UnmanagedDatabaseState() will run here when program exists

        public static void Start()
        {
            archiver = new FolderWatcher();
            archiver.Start(@"c:\temp", "*.txt", ProcessFile);
            Console.WriteLine("Listening to c:\\temp");
        }
Example #27
0
 private void DispatchFolderEvent(FolderRegistration reg, FolderWatcher watcher, ZPushFolder folder, EventKind kind)
 {
     Logger.Instance.Debug(this, "Folder event: {0}, {1}, {2}", folder, reg, kind);
     watcher.Dispatch(folder, kind);
 }
Example #28
0
 static void StartWatcher()
 {
     FolderWatcher.StartFolderWatching(inputFolderPath, fileExtension);
     processFilesList = FolderWatcher.processFilesList;
 }