public void OnChanged(object source, FileSystemEventArgs e)
        {
            if (!ProcessedFiles.ContainsKey(e.Name))
            {
                Console.WriteLine("{0} : Copying {1}", DateTime.Now, e.Name);
                if (File.Exists(string.Format("{0}{1}", DeployLocation, e.Name)))
                {
                    File.Delete(string.Format("{0}{1}", DeployLocation, e.Name));
                }

                Thread.Sleep(100);
                if (File.Exists(WatchLocation + e.Name))
                {
                    File.Copy(string.Format("{0}{1}", WatchLocation, e.Name),
                              string.Format("{0}{1}", DeployLocation, e.Name));

                    ProcessedFiles.Add(e.Name, File.GetLastWriteTime(WatchLocation + e.Name));
                }
                else
                {
                    Console.WriteLine("{0} : The file {1} does not exist. We cannot copy it.", DateTime.Now, e.Name);
                }
            }
            else
            {
                DateTime outDate;
                ProcessedFiles.TryGetValue(e.Name, out outDate);
                if (ProcessedFiles.ContainsKey(e.Name) && File.GetLastWriteTime(WatchLocation + e.Name) > outDate)
                {
                    AddToBeProcessed(e.Name);
                }
            }
        }
Ejemplo n.º 2
0
        public void AddItem(VssProject project)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }
            else if (project.Database != Database)
            {
                throw new ArgumentException("Project database mismatch", "project");
            }

            rootProjects.AddLast(project);

            PathMatcher exclusionMatcher = null;

            if (!string.IsNullOrEmpty(ExcludeFiles))
            {
                var excludeFileArray = ExcludeFiles.Split(
                    new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                exclusionMatcher = new PathMatcher(excludeFileArray);
            }

            workQueue.AddLast(delegate(object work)
            {
                logger.WriteSectionSeparator();
                LogStatus(work, "Building revision list");

                logger.WriteLine("Root project: {0}", project.Path);
                logger.WriteLine("Excluded files: {0}", ExcludeFiles);

                var excludedProjects = 0;
                var excludedFiles    = 0;
                var stopwatch        = Stopwatch.StartNew();
                VssUtil.RecurseItems(project,
                                     delegate(VssProject subproject)
                {
                    if (workQueue.IsAborting)
                    {
                        return(RecursionStatus.Abort);
                    }

                    var path = subproject.Path;
                    if (exclusionMatcher != null && exclusionMatcher.Matches(path))
                    {
                        logger.WriteLine("Excluding project {0}", path);
                        ++excludedProjects;
                        return(RecursionStatus.Skip);
                    }

                    ProcessItem(subproject, path, exclusionMatcher);
                    ++projectCount;
                    return(RecursionStatus.Continue);
                },
                                     delegate(VssProject subproject, VssFile file)
                {
                    if (workQueue.IsAborting)
                    {
                        return(RecursionStatus.Abort);
                    }

                    var path = file.GetPath(subproject);
                    if (exclusionMatcher != null && exclusionMatcher.Matches(path))
                    {
                        logger.WriteLine("Excluding file {0}", path);
                        ++excludedFiles;
                        return(RecursionStatus.Skip);
                    }

                    // only process shared files once (projects are never shared)
                    if (!ProcessedFiles.Contains(file.PhysicalName))
                    {
                        ProcessedFiles.Add(file.PhysicalName);
                        ProcessItem(file, path, exclusionMatcher);
                        ++fileCount;
                    }
                    return(RecursionStatus.Continue);
                });
                stopwatch.Stop();

                logger.WriteSectionSeparator();
                logger.WriteLine("Analysis complete in {0:HH:mm:ss}", new DateTime(stopwatch.ElapsedTicks));
                logger.WriteLine("Projects: {0} ({1} excluded)", projectCount, excludedProjects);
                logger.WriteLine("Files: {0} ({1} excluded)", fileCount, excludedFiles);
                logger.WriteLine("Revisions: {0}", revisionCount);
            });
        }
 public void AddProcessedFile(string file)
 {
     ProcessedFiles.Add(file);
 }