/// <summary>Contructor.</summary> /// <param name="path">File path to monitor</param> /// <param name="ttl">Cache time-to-live</param> /// <param name="items">Items to watch</param> public FileSystemCache(string path, double ttl, List <FileSystemEntry> items) { CheckAndAddPath(path); this.ttl = ttl; this.path = path; watchedItems = items; try { watcher = WatcherFactory.CreateWatcher(path, new WatcherDelegates() { ChangedHandler = OnFileChange, CreatedHandler = OnFileCreated, DeletedHandler = OnFileDeleted, RenamedHandler = OnFileRenamed }); watcher.EnableRaisingEvents = true; CreateTimer(); timer.Start(); creationTime = DateTime.UtcNow; } catch (Exception e) { lock (_lock) { watchedPaths.Remove(path); } timer.Stop(); throw e; } }
/// <summary>Constuctor.</summary> /// <param name="path">File path to monitor</param> /// <param name="ttl">Cache time-to-live</param> public FileSystemCache(string path, double ttl) { CheckAndAddPath(path); Partial = true; this.ttl = ttl; this.path = path; watchedItems = new List <FileSystemEntry>(10); try { watcher = WatcherFactory.CreateWatcher(path, new WatcherDelegates() { ChangedHandler = OnFileChange, CreatedHandler = OnFileCreated, DeletedHandler = OnFileDeleted, RenamedHandler = OnFileRenamed }); watcher.EnableRaisingEvents = true; } catch (Exception e) // catching exception because we are re-throwing it { lock (_lock) { watchedPaths.Remove(path); } throw e; } CreateTimer(); timer.Start(); creationTime = DateTime.UtcNow; }
public IFbWatcher <TModel> CreateWatcher <TModel>() where TModel : IModel, new() { var factory = new WatcherFactory <TModel>(); var watcherOptions = new WatcherOptions(TestsContext.MainDbConnectionString, TestsContext.TempDbConnectionString); return(factory.CreateWatcher(watcherOptions)); }
private TaskInfo CreateTaskInfo(string filter, GatheringPointsInfo gInfo, WatcherType type = WatcherType.NONE) { try { var taskInfo = new TaskInfo(); if (gInfo != null && ConfigInfo != null) { taskInfo.Filter = filter; taskInfo.Index = gInfo.NO; } taskInfo.Watcher = WatcherFactory.CreateWatcher(gInfo, ConfigInfo, FtpInfo, SetFilter(filter), type); taskInfo.ProcessingTask = new Task(StartProcessing, taskInfo, TaskCreationOptions.LongRunning); return(taskInfo); } catch (Exception ex) { AppEvents.Instance.OnUpdateScreen("Error : " + ex.Message); return(null); } }
public WatcherBL() { IWatcher = WatcherFactory.CreateWatcher(); }