static void Main(string[] args) { if (Sanitize(args, out var requestedFolder)) { return; } var bus = new InMemoryPubSub(); var fileHandlers = new ConcurrentDictionary <string, List <Type> >(); var assemblyValidator = new AssemblyValidator(bus); var dllLoader = new NewFileTypeSubscriber(fileHandlers); var fileManager = new Manager(fileHandlers); bus.Subscribe(assemblyValidator); bus.Subscribe(dllLoader); bus.Subscribe(fileManager); var fileSystemWatcher = new FileWatcherManager(requestedFolder, bus); var startables = new List <IStartableService> { fileSystemWatcher }; startables.ForEach(x => x.Start()); Task.Run(function: () => { Console.WriteLine("Listening for Dlls or files to parse..."); while (true) { } }).Wait(); }
static void Main(string[] args) { FileWatcherManager fm = new FileWatcherManager(); fm.Init(); Console.ReadKey(); }
public void IniciarServico() { try { logger.Info("**********************************************************************"); logger.Info("**********************************************************************"); logger.Info("BrokerageProcessor v." + typeof(BrokerageProcessorSrv).Assembly.GetName().Version); logger.Info("*** IniciarServico(): BrokerageProcessor...."); _config = GerenciadorConfig.ReceberConfig <FileWatcherConfig>(); logger.Info("Config Count: " + _config.Watchers.Count); _lstFileManager = new List <FileWatcherManager>(); foreach (FileWatcherConfigItem aux in _config.Watchers) { FileWatcherManager item = new FileWatcherManager(); item.Config = aux; item.CreatePaths(); item.Start(); _lstFileManager.Add(item); } // Iniciando PdfManager PdfManager.Instance.Start(); // Iniciando TxtManager TxtManager.Instance.Start(); // Iniciando EmailManager EmailManager.Instance.Start(); //Iniciando cron scheduler scheduler.Start(); _status = ServicoStatus.EmExecucao; } catch (Exception ex) { logger.Error("Problemas no start do servico: " + ex.Message, ex); _status = ServicoStatus.Erro; throw ex; } }
public void OnStart(string[] args) { var parser = new ConfigurationManager.ConfigManager(); parser.MakeParsed(args[0]); var sourcePath = parser.SourcePath; _targetPath = parser.TargetPath; if (sourcePath == null || _targetPath == null) { throw new NullReferenceException("Error path"); } var mods = parser.GetMods(); fileManager = new FileWatcherManager(_targetPath, sourcePath, mods); fileManager.OnStart(); Thread loggerThread = new Thread(new ThreadStart(Load)); loggerThread.Start(); }
/// <summary> /// Opens a file and returns the corresponding FileWatcherViewModel /// </summary> /// <param name="info">The string location of the file</param> /// <returns>The <see cref="FileWatcherViewModel"/> for the file.</returns> public ContentViewModel OpenContent(object info, object param) { var location = info as string; if (location != null) { try { var mProjectTreeService = VEFModule.UnityContainer.Resolve(typeof(IProjectTreeService), "") as IProjectTreeService; var vm = VEFModule.UnityContainer.Resolve(typeof(FileWatcherViewModel), "") as FileWatcherViewModel; FileWatcherModel model = null;// VEFModule.UnityContainer.Resolve(typeof(FileWatcherModel), "") as FileWatcherModel; FileWatcherManager fileWatcherService = VEFModule.UnityContainer.Resolve(typeof(FileWatcherManager), "") as FileWatcherManager; IProjectTreeService pfExplorerService = VEFModule.UnityContainer.Resolve(typeof(IProjectTreeService), "") as IProjectTreeService; var fileWatcher = fileWatcherService.FileWatchers.Where(x => x.ContentID == info.ToString()); if (fileWatcher.Any()) { fileWatcherService.SelectedFileWatcher = fileWatcher.First(); fileWatcherService.SelectedFileWatcher.Open(info); } else //new fileWatcher { // fileWatcherDataModel newfileWatcher = new fileWatcherDataModel() { Name = "fileWatcher NEW", ContentID = "fileWatcherID:##:" }; // newfileWatcher.Parent = parent; if (pfExplorerService.SelectedItem is FileWatcherModel) { // pfExplorerService.SelectedItem.Items.Add(newfileWatcher); var newfileWatcher = pfExplorerService.SelectedItem as FileWatcherModel; if (newfileWatcher != null) { fileWatcherService.FileWatchers.Add(newfileWatcher); // fileWatcherService.SelectedfileWatcher = newfileWatcher; newfileWatcher.Open(-1); model = newfileWatcher; } } } //Model details if (model == null) { model = VEFModule.UnityContainer.Resolve(typeof(FileWatcherModel), "") as FileWatcherModel; } var view = VEFModule.UnityContainer.Resolve(typeof(FileWatcherView), "") as FileWatcherView; //Model details model.SetLocation(info); //Set the model and view vm.SetModel(model); vm.SetView(view); vm.Title = "FileWatcher_" + Path.GetFileName(location); (vm.View as UserControl).DataContext = model; model.Open(location); // model.Document.Text = File.ReadAllText(location); model.SetDirty(false); // mProjectTreeService.SetAsRoot(model); return(vm); } catch (Exception exception) { _loggerService.Log(exception.Message, LogCategory.Exception, LogPriority.High); _loggerService.Log(exception.StackTrace, LogCategory.Exception, LogPriority.High); return(null); } //Clear the undo stack // model.Document.UndoStack.ClearAll(); } return(null); }
protected override void OnStart(string[] args) { _fileWatcherManager = new FileWatcherManager(); _fileWatcherManager.Init(); }