public override IList<string> ToMessage(BotElement bot, Func<string, string> transform)
        {
            var lines = new List<string>();
            var formatter = new
            {
                TeamProjectCollection = transform(TeamProjectCollection),
                DisplayName = transform(DisplayName),
                ProjectName = transform(ProjectName),
                WiUrl,
                WiType = transform(WiType),
                WiId,
                WiTitle = transform(WiTitle),
                IsStateChanged,
                IsAssignmentChanged,
                AssignedTo = transform(AssignedTo),
                State = transform(State),
                UserName = transform(UserName),
                Action = FormatAction(bot)
            };
            lines.Add(bot.Text.WorkItemchangedFormat.FormatWith(formatter));

            var searchType = IsNew ? SearchFieldsType.Core : SearchFieldsType.Changed;
            var displayFieldsKey = IsNew ? "wiCreatedDisplayFields" : "wiChangedDisplayFields";
            var pattern = IsNew ? "{name}: {newValue}" : "{name}: " + bot.Text.WorkItemFieldTransitionFormat;

            foreach (var fieldId in bot.GetCsvSetting(displayFieldsKey, Defaults.WorkItemFields))
            {
                var field = GetUnifiedField(fieldId, searchType);
                if (field != null)
                    lines.Add(pattern.FormatWith(field));
            }

            return lines;
        }
        public override IList<string> ToMessage(BotElement bot, Func<string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(TeamProjectCollection),
                ProjectUrl,
                ProjectName = transform(ProjectName),
            };

            return new[] { bot.Text.ProjectCreatedFormat.FormatWith(formatter) };
        }
Ejemplo n.º 3
0
 public override string ToString(BotElement bot, Func<string, string> transform)
 {
     var formatter = new
     {
         DisplayName = transform(DisplayName), RepoUri,
         ProjectName = transform(ProjectName),
         RepoName = transform(RepoName),
         Pushed = IsForcePush ? bot.Text.ForcePushed : bot.Text.Pushed,
         UserName = transform(UserName)
     };
     return bot.Text.PushFormat.FormatWith(formatter);
 }
        public override IList<string> ToMessage(BotElement bot, Func<string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(TeamProjectCollection),
                DisplayName = transform(DisplayName),
                UserName = transform(UserName),
                ProjectName = transform(ProjectName),
                RepoUri,
                RepoName = transform(RepoName)
            };

            return new[] { bot.Text.RepositoryCreatedFormat.FormatWith(formatter) };
        }
 public override IList<string> ToMessage(BotElement bot, Func<string, string> transform)
 {
     var formatter = new
     {
         TeamProjectCollection = transform(TeamProjectCollection),
         DisplayName = transform(DisplayName),
         ChangesetUrl,
         ChangesetId,
         Comment = transform(Comment),
         UserName = transform(UserName),
         ProjectLinks = FormatProjectLinks(bot, transform)
     };
     return new[] { bot.Text.CheckinFormat.FormatWith(formatter) };
 }
        public override IList<string> ToMessage(BotElement bot, Func<string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(TeamProjectCollection),
                DisplayName = transform(DisplayName),
                ProjectName = transform(ProjectName),
                RepoUri,
                RepoName = transform(RepoName),
                PrId,
                PrUrl,
                PrTitle = transform(PrTitle),
                UserName = transform(UserName),
                SourceBranchName = transform(SourceBranch.Name),
                TargetBranchName = transform(TargetBranch.Name)
            };

            return new[] { bot.Text.PullRequestCreatedFormat.FormatWith(formatter) };
        }
        public override IList<string> ToMessage(BotElement bot, Func<string, string> transform)
        {
            var lines = new List<string>();
            var formatter = new
            {
                TeamProjectCollection = transform(TeamProjectCollection),
                DisplayName = transform(DisplayName),
                ProjectName = transform(ProjectName),
                AreaPath = transform(AreaPath),
                WiUrl,
                WiType = transform(WiType),
                WiId,
                WiTitle = transform(WiTitle),
                UserName = transform(UserName),
                Action = bot.Text.CommentedOn
            };
            lines.Add(bot.Text.WorkItemchangedFormat.FormatWith(formatter));
            lines.Add(TextHelper.Truncate(Comment, Settings.DiscussionCommentMaxLength));

            return lines;
        }
 public override IList<string> ToMessage(BotElement bot, Func<string, string> transform)
 {
     var formatter = new
     {
         TeamProjectCollection = transform(TeamProjectCollection),
         ProjectName = transform(ProjectName),
         BuildDefinition = transform(BuildDefinition),
         BuildStatus = transform(BuildStatus.ToString()),
         BuildUrl,
         BuildNumber = transform(BuildNumber),
         BuildReason = transform(BuildReason.ToString()),
         RequestedFor = transform(RequestedFor),
         RequestedForDisplayName = transform(RequestedForDisplayName),
         DisplayName = transform(RequestedForDisplayName),
         StartTime,
         FinishTime,
         UserName = transform(UserName),
         BuildDuration = FormatBuildDuration(bot),
         DropLocation
     };
     return new[] { bot.Text.BuildFormat.FormatWith(formatter), transform(BuildStatus.ToString()) };
 }
Ejemplo n.º 9
0
        private string ChangeCountsToString(BotElement bot, Dictionary<TfsGitChangeType, int> changeCounts)
        {
            var counters = new[] {
                new ChangeCounter(TfsGitChangeType.Add, bot.Text.ChangeCountAddFormat, 0),
                new ChangeCounter(TfsGitChangeType.Edit, bot.Text.ChangeCountEditFormat, 0),
                new ChangeCounter(TfsGitChangeType.Delete, bot.Text.ChangeCountDeleteFormat, 0),
                new ChangeCounter(TfsGitChangeType.Rename, bot.Text.ChangeCountRenameFormat, 0),
                new ChangeCounter(TfsGitChangeType.SourceRename, bot.Text.ChangeCountSourceRenameFormat, 0)
            };

            foreach (var changeCount in changeCounts)
            {
                // renamed files will also show up as Rename or Rename+Edit, so don't count them twice
                if (changeCount.Key == (TfsGitChangeType.Delete | TfsGitChangeType.SourceRename)) continue;

                foreach (var counter in counters.Where(c => changeCount.Key.HasFlag(c.Type)))
                {
                    counter.Count += changeCount.Value;
                }
            }

            return string.Join(", ", counters.Where(c => c.Count > 0).Select(c => c.Format.FormatWith(new {c.Count })));
        }