Hpdi.Vss2Git.RevisionAnalyzer.AddItem C# (CSharp) Метод

AddItem() публичный Метод

public AddItem ( VssProject project ) : void
project VssProject
Результат void
        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);

                int excludedProjects = 0;
                int 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);
            });
        }

Usage Example

Пример #1
0
        private void DumpUsers()
        {
            var        df   = new VssDatabaseFactory(vssDirTextBox.Text);
            var        db   = df.Open();
            var        path = vssProjectTextBox.Text;
            VssProject project;

            try
            {
                project = db.GetItem(path) as VssProject;
            }
            catch (VssPathException ex)
            {
                MessageBox.Show(ex.Message, "Invalid project path",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (project == null)
            {
                MessageBox.Show(path + " is not a project", "Invalid project path",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            var emailDictionary = ReadDictionaryFile("e-mail dictionary", db.BasePath, emailPropertiesFileName);

            AdvancedTaskbar.EnableItermediate();
            this.statusTimer.Enabled = true;
            this.emailMap.Enabled    = false;
            this.goButton.Enabled    = false;
            this.cancelButton.Text   = "Cancel";
            revisionAnalyzer         = new RevisionAnalyzer(workQueue, logger, db);
            if (!string.IsNullOrEmpty(excludeTextBox.Text))
            {
                revisionAnalyzer.ExcludeFiles = excludeTextBox.Text;
            }
            revisionAnalyzer.AddItem(project);
            workQueue.AddLast(delegate(object work)
            {
                foreach (var dateEntry in revisionAnalyzer.SortedRevisions)
                {
                    foreach (Revision revision in dateEntry.Value)
                    {
                        var user = revision.User.ToLower();
                        if (emailDictionary.ContainsKey(user))
                        {
                            continue;
                        }
                        emailDictionary.Add(user, "");
                    }
                }
                string propsPath = Path.Combine(db.BasePath, emailPropertiesFileName);
                WriteDictionaryFile(emailDictionary, propsPath);
                this.BeginInvoke((MethodInvoker) delegate
                {
                    MessageBox.Show(this, string.Format(emailUserNamesListMessage, propsPath),
                                    emailUserNamesListCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                });
            });
        }
All Usage Examples Of Hpdi.Vss2Git.RevisionAnalyzer::AddItem