Example #1
0
        static void ProcessQueueItem()
        {
            FileSystemEventArgs eventQueueItem = null;

            if (EventQueue.TryDequeue(out eventQueueItem))
            {
                foreach (var item in Items)
                {
                    var pipe         = new PvcPipe();
                    var relativePath = PvcUtil.PathRelativeToCurrentDirectory(eventQueueItem.FullPath);

                    // if eventQueueItem.FullPath matches any items or their additional files, re-run that pipeline
                    var matchingFiles   = pipe.FilterPaths(item.Globs);
                    var additionalFiles = pipe.FilterPaths(item.AdditionalFiles);

                    if (matchingFiles.Contains(relativePath) || additionalFiles.Contains(relativePath))
                    {
                        var newStreams = new List <PvcStream>();

                        // if its an 'additional file' match we need to run on the whole matching set to find the 'real'
                        // file that should be processed. Same if it was a deletion event.
                        if (additionalFiles.Contains(relativePath) || eventQueueItem.ChangeType == WatcherChangeTypes.Deleted)
                        {
                            newStreams.AddRange(matchingFiles.Select(x => PvcUtil.PathToStream(x)));
                        }
                        // otherwise we run against only the changed item
                        else
                        {
                            newStreams.Add(PvcUtil.PathToStream(eventQueueItem.FullPath));
                        }

                        pipe.streams = newStreams;

                        newStreams.ForEach(x => Console.WriteLine("Processing pipeline for '{0}'", x.StreamName.Magenta()));
                        var stopwatch = new Stopwatch();
                        stopwatch.Start();

                        foreach (var pipeline in item.Pipeline)
                        {
                            try
                            {
                                pipe = pipeline(pipe);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                            }
                        }

                        stopwatch.Stop();
                        Console.WriteLine("Finished pipeline processing in {0}", stopwatch.Elapsed.Humanize().White());

                        newStreams.ForEach(x => x.UnloadStream());
                    }
                }
            }
        }
Example #2
0
        static void ProcessQueueItem()
        {
            FileSystemEventArgs eventQueueItem = null;
            if (EventQueue.TryDequeue(out eventQueueItem))
            {
                foreach (var item in Items)
                {
                    var pipe = new PvcPipe();
                    var relativePath = PvcUtil.PathRelativeToCurrentDirectory(eventQueueItem.FullPath);

                    // if eventQueueItem.FullPath matches any items or their additional files, re-run that pipeline
                    var matchingFiles = pipe.FilterPaths(item.Globs);
                    var additionalFiles = pipe.FilterPaths(item.AdditionalFiles);

                    if (matchingFiles.Contains(relativePath) || additionalFiles.Contains(relativePath))
                    {
                        var newStreams = new List<PvcStream>();

                        // if its an 'additional file' match we need to run on the whole matching set to find the 'real'
                        // file that should be processed. Same if it was a deletion event.
                        if (additionalFiles.Contains(relativePath) || eventQueueItem.ChangeType == WatcherChangeTypes.Deleted)
                        {
                            newStreams.AddRange(matchingFiles.Select(x => PvcUtil.PathToStream(x)));
                        }
                        // otherwise we run against only the changed item
                        else
                        {
                            newStreams.Add(PvcUtil.PathToStream(eventQueueItem.FullPath));
                        }

                        pipe.streams = newStreams;

                        newStreams.ForEach(x => Console.WriteLine("Processing pipeline for '{0}'", x.StreamName.Magenta()));
                        var stopwatch = new Stopwatch();
                        stopwatch.Start();

                        foreach (var pipeline in item.Pipeline)
                        {
                            try
                            {
                                pipe = pipeline(pipe);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                            }
                        }

                        stopwatch.Stop();
                        Console.WriteLine("Finished pipeline processing in {0}", stopwatch.Elapsed.Humanize().White());

                        newStreams.ForEach(x => x.UnloadStream());
                    }
                }
            }
        }
Example #3
0
        public PvcPipe Watch(params string[] additionalFiles)
        {
            var pipe = new PvcPipe()
            {
                streams = this.streams,
                globs   = this.globs
            };

            PvcWatcher.RegisterWatchPipe(this.globs, this.pipeline, additionalFiles.ToList());

            return(pipe);
        }
Example #4
0
        public PvcPipe Watch(params string[] additionalFiles)
        {
            var pipe = new PvcPipe()
            {
                streams = this.streams,
                globs = this.globs
            };

            PvcWatcher.RegisterWatchPipe(this.globs, this.pipeline, additionalFiles.ToList());

            return pipe;
        }