private void DeliverToWorkflow(FileWatcherSubscription subscription, FileSystemEventArgs fileSystemEventArgs) { try { // We can't just use the FileSystemEventArgs because it's not serializable FileWatcherEventArgs eventArgs = new FileWatcherEventArgs(fileSystemEventArgs); WorkflowInstance workflowInstance = this.runtime.GetWorkflow(subscription.WorkflowInstanceId); workflowInstance.EnqueueItem(subscription.QueueName, eventArgs, null, null); } catch (Exception e) { // Write the exception out to the Debug console and throw the exception System.Diagnostics.Debug.WriteLine(e); throw e; } }
public Guid RegisterListener(IComparable queueName, string path, string filter, NotifyFilters notifyFilter, bool includeSubdirectories) { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(); try { fileSystemWatcher.Path = path; } catch (ArgumentException) { Console.WriteLine("Path \"{0}\" not found. Please see documentation for setup steps.", path); return Guid.Empty; } fileSystemWatcher.Filter = filter; fileSystemWatcher.NotifyFilter = notifyFilter; fileSystemWatcher.IncludeSubdirectories = includeSubdirectories; fileSystemWatcher.Changed += new FileSystemEventHandler(FileSystemWatcher_Handler); fileSystemWatcher.Created += new FileSystemEventHandler(FileSystemWatcher_Handler); fileSystemWatcher.Deleted += new FileSystemEventHandler(FileSystemWatcher_Handler); fileSystemWatcher.Error += new ErrorEventHandler(FileSystemWatcher_Error); FileWatcherSubscription subscription = new FileWatcherSubscription(fileSystemWatcher, WorkflowEnvironment.WorkflowInstanceId, queueName); Guid subscriptionId = Guid.NewGuid(); lock (this.subscriptions) { this.subscriptions.Add(subscriptionId.ToString(), subscription); } // Turn the file system watcher on fileSystemWatcher.EnableRaisingEvents = true; Console.WriteLine("FileWatcherService subscription '" + subscriptionId.ToString() + "' created"); return subscriptionId; }
public Guid RegisterListener(IComparable queueName, string path, string filter, NotifyFilters notifyFilter, bool includeSubdirectories) { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(); try { fileSystemWatcher.Path = path; } catch (ArgumentException) { Console.WriteLine("Path \"{0}\" not found. Please see documentation for setup steps.", path); return(Guid.Empty); } fileSystemWatcher.Filter = filter; fileSystemWatcher.NotifyFilter = notifyFilter; fileSystemWatcher.IncludeSubdirectories = includeSubdirectories; fileSystemWatcher.Changed += new FileSystemEventHandler(FileSystemWatcher_Handler); fileSystemWatcher.Created += new FileSystemEventHandler(FileSystemWatcher_Handler); fileSystemWatcher.Deleted += new FileSystemEventHandler(FileSystemWatcher_Handler); fileSystemWatcher.Error += new ErrorEventHandler(FileSystemWatcher_Error); FileWatcherSubscription subscription = new FileWatcherSubscription(fileSystemWatcher, WorkflowEnvironment.WorkflowInstanceId, queueName); Guid subscriptionId = Guid.NewGuid(); lock (this.subscriptions) { this.subscriptions.Add(subscriptionId.ToString(), subscription); } // Turn the file system watcher on fileSystemWatcher.EnableRaisingEvents = true; Console.WriteLine("FileWatcherService subscription '" + subscriptionId.ToString() + "' created"); return(subscriptionId); }
private void DeliverToWorkflow(FileWatcherSubscription subscription, FileSystemEventArgs fileSystemEventArgs) { try { // We can't just use the FileSystemEventArgs because it's not serializable FileWatcherEventArgs eventArgs = new FileWatcherEventArgs(fileSystemEventArgs); WorkflowInstance workflowInstance = this.runtime.GetWorkflow(subscription.WorkflowInstanceId); workflowInstance.EnqueueItem(subscription.QueueName, eventArgs, null, null); } catch (Exception e) { // Write the exception out to the Debug console and throw the exception System.Diagnostics.Debug.WriteLine(e); throw e; } }