Extends the simple work queue with support for tracking worker status and exceptions.
Inheritance: SimpleWorkQueue
示例#1
0
 public VcsExporter(WorkQueue workQueue, Logger logger,
     RevisionAnalyzer revisionAnalyzer, ChangesetBuilder changesetBuilder,
     IVcsWrapper vcsWrapper, IDictionary<string, string> usersmap)
     : base(workQueue, logger)
 {
     this.database = revisionAnalyzer.Database;
     this.revisionAnalyzer = revisionAnalyzer;
     this.changesetBuilder = changesetBuilder;
     this.vcsWrapper = vcsWrapper;
     this.emailDictionary = new Dictionary<string, string>();
     this.usernameDictionary = new Dictionary<string, string>();
     Regex emailRegex = new Regex("(\\S.*?)\\s*<(.+)>");
     foreach (var e in usersmap)
     {
         string key = e.Key.ToLower();
         string email = e.Value.Trim();
         if (email == "")
             continue;
         Match m = emailRegex.Match(email);
         if (m.Success)
         {
             this.usernameDictionary.Add(key, m.Groups[1].Value);
             email = m.Groups[2].Value;
         }
         this.emailDictionary.Add(key, email);
     }
 }
示例#2
0
 public GitExporter(WorkQueue workQueue, Logger logger,
     RevisionAnalyzer revisionAnalyzer, ChangesetBuilder changesetBuilder)
     : base(workQueue, logger)
 {
     this.database = revisionAnalyzer.Database;
     this.revisionAnalyzer = revisionAnalyzer;
     this.changesetBuilder = changesetBuilder;
 }
示例#3
0
 public VcsExporter(WorkQueue workQueue, Logger logger,
     RevisionAnalyzer revisionAnalyzer, ChangesetBuilder changesetBuilder,
     IVcsWrapper vcsWrapper, IDictionary<string, string> emailDictionary)
     : base(workQueue, logger)
 {
     this.database = revisionAnalyzer.Database;
     this.revisionAnalyzer = revisionAnalyzer;
     this.changesetBuilder = changesetBuilder;
     this.vcsWrapper = vcsWrapper;
     this.emailDictionary = emailDictionary;
 }
示例#4
0
 public GitExporter(WorkQueue workQueue, Logger logger,
                    RevisionAnalyzer revisionAnalyzer, ChangesetBuilder changesetBuilder,
                    string repoPath, FileAnalyzer fileAnalyzer, bool inheritProjectDir = false)
     : base(workQueue, logger)
 {
     this.database          = revisionAnalyzer.Database;
     this.revisionAnalyzer  = revisionAnalyzer;
     this.changesetBuilder  = changesetBuilder;
     this.repoPath          = repoPath;
     this.fileAnalyzer      = fileAnalyzer;
     this.inheritProjectDir = inheritProjectDir;
 }
示例#5
0
 public GitExporter(
     WorkQueue workQueue, Logger logger,
     RevisionAnalyzer revisionAnalyzer,
     ChangesetBuilder changesetBuilder,
     IMessageDispatcher messageDispatcher)
     : base(workQueue, logger, messageDispatcher)
 {
     database = revisionAnalyzer.Database;
     this.revisionAnalyzer  = revisionAnalyzer;
     this.changesetBuilder  = changesetBuilder;
     this.messageDispatcher = messageDispatcher;
 }
示例#6
0
 public GitExporter(WorkQueue workQueue, Logger logger, 
     RevisionAnalyzer revisionAnalyzer, ChangesetBuilder changesetBuilder,
     string repoPath, FileAnalyzer fileAnalyzer, bool inheritProjectDir = false)
     : base(workQueue, logger)
 {
     this.database = revisionAnalyzer.Database;
     this.revisionAnalyzer = revisionAnalyzer;
     this.changesetBuilder = changesetBuilder;
     this.repoPath = repoPath;
     this.fileAnalyzer = fileAnalyzer;
     this.inheritProjectDir = inheritProjectDir;
 }
示例#7
0
 public RunInfo(
     MainForm form,
     string outputDir,
     Logger commonLogger,
     VssDatabase db,
     Encoding selectedEncoding,
     Logger errorLogger,
     WorkQueue workQueue,
     Queue <ProjectInfo> toProcess)
 {
     this.form             = form;
     this.outputDir        = outputDir;
     this.processDir       = Path.Combine(outputDir, PROCESS_DIR_NAME);
     this.logFile          = Path.Combine(this.outputDir, PROCESS_DIR_NAME + ".log");
     this.commonLogger     = commonLogger;
     this.db               = db;
     this.selectedEncoding = selectedEncoding;
     this.errorLogger      = errorLogger;
     this.workQueue        = workQueue;
     this.toProcess        = toProcess;
 }
示例#8
0
 public Worker(WorkQueue workQueue, Logger logger)
 {
     this.workQueue = workQueue;
     this.logger = logger;
 }
示例#9
0
 public ProjectAnalyzer(WorkQueue workQueue, Logger logger, VssProject vssRootProject)
     : base(workQueue, logger)
 {
     this.vssRootProject = vssRootProject;
 }
示例#10
0
 public RevisionAnalyzer(WorkQueue workQueue, Logger logger, VssDatabase database)
     : base(workQueue, logger)
 {
     this.database = database;
 }
示例#11
0
 public RevisionAnalyzer(WorkQueue workQueue, Logger logger, VssDatabase database, IMessageDispatcher messageDispatcher)
     : base(workQueue, logger, messageDispatcher)
 {
     this.Database = database;
 }
示例#12
0
 public FileAnalyzer(WorkQueue workQueue, Logger logger, ProjectAnalyzer projectAnalyzer)
     : base(workQueue, logger)
 {
     this.projectAnalyzer = projectAnalyzer;
 }
示例#13
0
 public ProjectAnalyzer(WorkQueue workQueue, Logger logger, VssProject vssRootProject)
     : base(workQueue, logger)
 {
     this.vssRootProject = vssRootProject;
 }
示例#14
0
 public ChangesetBuilder(WorkQueue workQueue, Logger logger, RevisionAnalyzer revisionAnalyzer)
     : base(workQueue, logger)
 {
     this.revisionAnalyzer = revisionAnalyzer;
 }
示例#15
0
 public FileAnalyzer(WorkQueue workQueue, Logger logger, ProjectAnalyzer projectAnalyzer)
     : base(workQueue, logger)
 {
     this.projectAnalyzer = projectAnalyzer;
 }
示例#16
0
文件: Worker.cs 项目: esskar/vss2git
 protected Worker(WorkQueue workQueue, Logger logger, IMessageDispatcher messageDispatcher)
 {
     this.workQueue         = workQueue;
     this.logger            = logger;
     this.messageDispatcher = messageDispatcher;
 }
示例#17
0
文件: Program.cs 项目: esskar/vss2git
        private static void RunFromCommandLine(ProgramOptions options)
        {
            var logger            = string.IsNullOrEmpty(options.LogFile) ? Logger.Null : new Logger(options.LogFile);
            var workQueue         = new WorkQueue(1);
            var messageDispatcher = new ConsoleLoggerMessageDispatcher(logger, options.IgnoreErrors);

            messageDispatcher.Dispatch(MessageType.Info, workQueue.LastStatus ?? "Idle", MessageChoice.Ok);

            var encoding = Encoding.GetEncoding(options.CodePage);
            var df       = new VssDatabaseFactory(options.VssDirectory)
            {
                Encoding = encoding
            };
            var db   = df.Open();
            var item = db.GetItem(options.VssProject);

            if (!(item is VssProject project))
            {
                logger.WriteLine("Error: Not a vss project.");
                return;
            }

            var revisionAnalyzer = new RevisionAnalyzer(workQueue, logger, db, messageDispatcher);

            var changesetBuilder = new ChangesetBuilder(workQueue, logger, revisionAnalyzer, messageDispatcher)
            {
                AnyCommentThreshold  = TimeSpan.FromSeconds(options.AnyCommentSeconds),
                SameCommentThreshold = TimeSpan.FromSeconds(options.SameCommentSeconds)
            };

            void OnTimer(object state)
            {
                messageDispatcher.Dispatch(MessageType.Info, workQueue.LastStatus ?? "Idle", MessageChoice.Ok);
                messageDispatcher.Dispatch(MessageType.Info, $"Files: {revisionAnalyzer.FileCount}, Revisions: {revisionAnalyzer.RevisionCount}", MessageChoice.Ok);
                messageDispatcher.Dispatch(MessageType.Info, $"Changesets: {changesetBuilder.Changesets.Count}", MessageChoice.Ok);

                var exceptions = workQueue.FetchExceptions();

                if (exceptions != null)
                {
                    foreach (var exception in exceptions)
                    {
                        var message = ExceptionFormatter.Format(exception);
                        logger.WriteLine("ERROR: {0}", message);
                        logger.WriteLine(exception);
                    }
                }
            }

            var timer = new Timer(OnTimer, null, TimeSpan.Zero, TimeSpan.FromSeconds(1));

            if (!string.IsNullOrWhiteSpace(options.VssExcludePaths))
            {
                revisionAnalyzer.ExcludeFiles = options.VssExcludePaths;
            }
            revisionAnalyzer.AddItem(project);

            changesetBuilder.BuildChangesets();

            if (!string.IsNullOrEmpty(options.GitDirectory))
            {
                var gitExporter = new GitExporter(workQueue, logger,
                                                  revisionAnalyzer, changesetBuilder, messageDispatcher);
                if (!string.IsNullOrEmpty(options.DefaultEmailDomain))
                {
                    gitExporter.EmailDomain = options.DefaultEmailDomain;
                }
                if (!string.IsNullOrEmpty(options.EmailMapFile))
                {
                    if (File.Exists(options.EmailMapFile))
                    {
                        gitExporter.EmailMapFile = options.EmailMapFile;
                    }
                    else
                    {
                        logger.WriteLine($"Warn: {options.EmailMapFile} does not exist.");
                    }
                }
                if (!string.IsNullOrEmpty(options.DefaultComment))
                {
                    gitExporter.DefaultComment = options.DefaultComment;
                }
                if (!options.TranscodeComments)
                {
                    gitExporter.CommitEncoding = encoding;
                }
                gitExporter.IgnoreErrors = options.IgnoreErrors;
                gitExporter.ExportToGit(options.GitDirectory);
            }

            workQueue.WaitIdle();
            timer.Dispose();

            messageDispatcher.Dispatch(MessageType.Info, "Done", MessageChoice.Ok);

            Application.Exit();
        }
示例#18
0
 public RevisionAnalyzer(WorkQueue workQueue, Logger logger, VssDatabase database)
     : base(workQueue, logger)
 {
     this.database = database;
 }
示例#19
0
 public ChangesetBuilder(WorkQueue workQueue, Logger logger, RevisionAnalyzer revisionAnalyzer)
     : base(workQueue, logger)
 {
     this.revisionAnalyzer = revisionAnalyzer;
 }
示例#20
0
 public Worker(WorkQueue workQueue, Logger logger)
 {
     this.workQueue = workQueue;
     this.logger    = logger;
 }
示例#21
0
 public ChangesetBuilder(WorkQueue workQueue, Logger logger, RevisionAnalyzer revisionAnalyzer, IMessageDispatcher messageDispatcher)
     : base(workQueue, logger, messageDispatcher)
 {
     this.revisionAnalyzer = revisionAnalyzer;
 }