private static void EnsureInitialization() { if (_fileWatcher != null) { return; } lock (_syncRoot) { if (_fileWatcher != null) { return; } _fileWatcher = new C1FileSystemWatcher(AppDomain.CurrentDomain.BaseDirectory) { IncludeSubdirectories = true, NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite, InternalBufferSize = 32768 }; // _fileWatcher.Created += FileWatcher_Created; _fileWatcher.Changed += FileWatcher_Changed; _fileWatcher.Deleted += FileWatcher_Deleted; _fileWatcher.EnableRaisingEvents = true; } }
public void ListenToDynamicallyAddedWorkflows(Action <Guid> onWorkflowFileAdded) { Verify.IsNull(_fileWatcher, "The method has already been invoked"); Action <string> handleWorkflowAdded = name => { try { Guid workflowId; if (TryParseWorkflowId(name, out workflowId) && !_createdWorkflows.ContainsKey(workflowId)) { onWorkflowFileAdded(workflowId); } } catch (Exception ex) { Log.LogError(LogTitle, ex); } }; var fileWatcher = new C1FileSystemWatcher(_baseDirectory, "*.bin") { IncludeSubdirectories = false }; fileWatcher.Created += (sender, args) => handleWorkflowAdded(args.Name); fileWatcher.Renamed += (sender, args) => handleWorkflowAdded(args.Name); fileWatcher.EnableRaisingEvents = true; _fileWatcher = fileWatcher; }
public void Initialize() { using (_resourceLocker.Locker) { var resources = _resourceLocker.Resources; if (!GlobalInitializerFacade.IsReinitializingTheSystem) { DataEvents <IDataItemTreeAttachmentPoint> .OnAfterAdd += OnUpdateTreeAttachmentPoints; DataEvents <IDataItemTreeAttachmentPoint> .OnDeleted += OnUpdateTreeAttachmentPoints; DataEvents <IDataItemTreeAttachmentPoint> .OnStoreChanged += OnTreeAttachmentPointsStoreChange; GeneratedTypesFacade.SubscribeToUpdateTypeEvent(OnDataTypeChanged); var treeAuxiliaryAncestorProvider = new TreeAuxiliaryAncestorProvider(); var entityTokenTypes = new[] { typeof(TreeSimpleElementEntityToken), typeof(TreeFunctionElementGeneratorEntityToken), typeof(TreeDataFieldGroupingElementEntityToken), typeof(DataEntityToken), typeof(TreePerspectiveEntityToken) }; entityTokenTypes.ForEach(type => AuxiliarySecurityAncestorFacade .AddAuxiliaryAncestorProvider(type, treeAuxiliaryAncestorProvider, true)); resources.PersistentAttachmentPoints = new Dictionary <string, List <IAttachmentPoint> >(); LoadAllTrees(); InitializeTreeAttachmentPoints(); TreeSharedRootsFacade.Clear(); var fileWatcher = new C1FileSystemWatcher(TreeDefinitionsFolder, "*.xml"); fileWatcher.Created += OnReloadTrees; fileWatcher.Deleted += OnReloadTrees; fileWatcher.Changed += OnReloadTrees; fileWatcher.Renamed += OnReloadTrees; fileWatcher.EnableRaisingEvents = true; resources.FileSystemWatcher = fileWatcher; resources.RootEntityToken = ElementFacade.GetRootsWithNoSecurity().First().ElementHandle.EntityToken; } } }
private ChangeEventsSingleton() { DataEventSystemFacade.SubscribeToStoreChanged <IMethodBasedFunctionInfo>(OnDataChanged, true); DataEventSystemFacade.SubscribeToDataDeleted <IInlineFunction>(OnDataChanged, true); DataEventSystemFacade.SubscribeToStoreChanged <IInlineFunction>(OnStoreChanged, true); string folderToWatch = PathUtil.Resolve(GlobalSettingsFacade.InlineCSharpFunctionDirectory); DirectoryUtils.EnsureDirectoryExists(folderToWatch); _codeDirectoryFileSystemWatcher = new C1FileSystemWatcher(folderToWatch) { NotifyFilter = NotifyFilters.LastWrite, EnableRaisingEvents = true, IncludeSubdirectories = true }; _codeDirectoryFileSystemWatcher.Changed += OnFileWatcherEvent; }
public XmlLocalizationProvider(string directoryVirtualPath, CultureInfo defaultCulture) { _defaultCulture = defaultCulture; _directory = PathUtil.Resolve(directoryVirtualPath); if (!C1Directory.Exists(_directory)) { Log.LogVerbose(LogTitle, "Directory '{0}' does not exist", directoryVirtualPath); return; } _watcher = new C1FileSystemWatcher(_directory, "*.xml"); _watcher.Created += (sender, args) => Reset(); _watcher.Changed += (sender, args) => Reset(); _watcher.Deleted += (sender, args) => Reset(); _watcher.EnableRaisingEvents = true; }
protected FileBasedFunctionProvider(string name, string folder) { _name = name; VirtualPath = folder; PhysicalPath = PathUtil.Resolve(VirtualPath); _rootFolder = PhysicalPath.Split(Path.DirectorySeparatorChar).Last(); var watcher = new C1FileSystemWatcher(PhysicalPath, "*") { IncludeSubdirectories = true }; watcher.Created += watcher_Changed; watcher.Deleted += watcher_Changed; watcher.Changed += watcher_Changed; watcher.Renamed += watcher_Changed; watcher.EnableRaisingEvents = true; }
private static void EnsureWatcher() { if (_featureDirectoryFileSystemWatcher == null) { lock (_lock) { if (_featureDirectoryFileSystemWatcher == null) { string featureDirectoryPath = PathUtil.Resolve(GlobalSettingsFacade.PageTemplateFeaturesDirectory); _featureDirectoryFileSystemWatcher = new C1FileSystemWatcher(featureDirectoryPath, "*"); _featureDirectoryFileSystemWatcher.Changed += FeatureDirectory_Changed; _featureDirectoryFileSystemWatcher.Created += FeatureDirectory_Changed; _featureDirectoryFileSystemWatcher.Deleted += FeatureDirectory_Changed; _featureDirectoryFileSystemWatcher.Renamed += FeatureDirectory_Changed; _featureDirectoryFileSystemWatcher.EnableRaisingEvents = true; } } } }
protected FileBasedFunctionProvider(string name, string folder) { _name = name; VirtualPath = folder; PhysicalPath = PathUtil.Resolve(VirtualPath); if (!C1Directory.Exists(PhysicalPath)) { return; } string folderToWatch = PhysicalPath; try { if (ReparsePointUtils.DirectoryIsReparsePoint(folderToWatch)) { folderToWatch = ReparsePointUtils.GetDirectoryReparsePointTarget(folderToWatch); } _watcher = new C1FileSystemWatcher(folderToWatch, "*") { IncludeSubdirectories = true }; _watcher.Created += Watcher_OnChanged; _watcher.Deleted += Watcher_OnChanged; _watcher.Changed += Watcher_OnChanged; _watcher.Renamed += Watcher_OnChanged; _watcher.EnableRaisingEvents = true; } catch (Exception ex) { Log.LogWarning(LogTitle, "Failed to create a file system watcher for path '{0}'", folderToWatch); Log.LogWarning(LogTitle, ex); } }
public MasterPagePageTemplateProvider(string name, string templatesDirectoryVirtualPath, string addNewTemplateLabel, Type addNewTemplateWorkflow) { _providerName = name; _templatesDirectoryVirtualPath = templatesDirectoryVirtualPath; _templatesDirectory = PathUtil.Resolve(_templatesDirectoryVirtualPath); AddNewTemplateLabel = addNewTemplateLabel; AddNewTemplateWorkflow = addNewTemplateWorkflow; Verify.That(C1Directory.Exists(_templatesDirectory), "Folder '{0}' does not exist", _templatesDirectory); string folderToWatch = _templatesDirectory; try { if (ReparsePointUtils.DirectoryIsReparsePoint(folderToWatch)) { folderToWatch = ReparsePointUtils.GetDirectoryReparsePointTarget(folderToWatch); } _watcher = new C1FileSystemWatcher(folderToWatch, FileWatcherMask) { IncludeSubdirectories = true }; _watcher.Created += Watcher_OnChanged; _watcher.Deleted += Watcher_OnChanged; _watcher.Changed += Watcher_OnChanged; _watcher.Renamed += Watcher_OnChanged; _watcher.EnableRaisingEvents = true; } catch (Exception ex) { Log.LogWarning(LogTitle, "Failed to create a file system watcher for directory '{0}'. Provider: {1}", folderToWatch, name); Log.LogWarning(LogTitle, ex); } }
private static void EnsureWatcher() { if (_featureDirectoryFileSystemWatcher==null) { lock (_lock) { if (_featureDirectoryFileSystemWatcher == null) { string featureDirectoryPath = PathUtil.Resolve(GlobalSettingsFacade.PageTemplateFeaturesDirectory); _featureDirectoryFileSystemWatcher = new C1FileSystemWatcher(featureDirectoryPath,"*"); _featureDirectoryFileSystemWatcher.Changed += FeatureDirectory_Changed; _featureDirectoryFileSystemWatcher.Created += FeatureDirectory_Changed; _featureDirectoryFileSystemWatcher.Deleted += FeatureDirectory_Changed; _featureDirectoryFileSystemWatcher.Renamed += FeatureDirectory_Changed; _featureDirectoryFileSystemWatcher.EnableRaisingEvents = true; } } } }
private ChangeEventsSingleton() { DataEventSystemFacade.SubscribeToStoreChanged<IMethodBasedFunctionInfo>(OnDataChanged, true); DataEventSystemFacade.SubscribeToDataDeleted<IInlineFunction>(OnDataChanged, true); DataEventSystemFacade.SubscribeToStoreChanged<IInlineFunction>(OnStoreChanged, true); string folderToWatch = PathUtil.Resolve(GlobalSettingsFacade.InlineCSharpFunctionDirectory); DirectoryUtils.EnsureDirectoryExists(folderToWatch); _codeDirectoryFileSystemWatcher = new C1FileSystemWatcher(folderToWatch) { NotifyFilter = NotifyFilters.LastWrite, EnableRaisingEvents = true, IncludeSubdirectories = true }; _codeDirectoryFileSystemWatcher.Changed += OnFileWatcherEvent; }