Exemplo n.º 1
0
        protected override void OnStart(string[] args)
        {
            if (FolderWatcherBase.IsLaunched)
            {
                throw new System.Exception("Can't start FWService. FolderWather is launched.");
            }


            _logger = new Logger(ConfigurationManager.AppSettings["LogFile"]);

            string watchFolder = ConfigurationManager.AppSettings["DefaultWatchedFolder"] ?? @"D:\epam_temp\";
            string watchFilter = ConfigurationManager.AppSettings["DefaultWatchedFilter"] ?? @"*.csv";;

            _logger.RecordEvent($"Folder: {watchFolder}");
            _logger.RecordEvent($"Filter: {watchFilter}");

            _csvThreadControl              = new CsvWorkThreadsControl();
            _csvThreadControl.SendMessage += _csvThreadControl_SendMessage;
            _logger.RecordEvent($"CSV thread controller started");

            _fswatcher = FSWVersion.CreateInstance(watchFolder, watchFilter);
            _logger.RecordEvent($"Folder Watcher created");
            _fswatcher.NewFileDetectedEvent += _fswatcher_NewFileDetectedEvent;
            Thread fwThread = new Thread(new ThreadStart(_fswatcher.Launch));

            fwThread.Start();
            _logger.RecordEvent($"Service starting. Watching folder: {watchFolder}");
        }
Exemplo n.º 2
0
        internal static void Run()
        {
            string watchFolder = ConfigurationManager.AppSettings["DefaultWatchedFolder"];
            string watchFilter = ConfigurationManager.AppSettings["DefaultWatchedFilter"];

            using (var dialog = new FolderBrowserDialog())
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    watchFolder = dialog.SelectedPath;
                }
            }

            _fswatcher = FSWVersion.CreateInstance(watchFolder, watchFilter);
            _fswatcher.NewFileDetectedEvent += FwLogger_NewFileDetectedEvent;
            Thread fwThread = new Thread(new ThreadStart(_fswatcher.Launch));

            fwThread.Start();
        }