コード例 #1
0
 private string FormatAction(TextElement text)
 {
     switch (Status)
         {
             case PullRequestStatus.Abandoned: return text.Abandoned;
             case PullRequestStatus.Active: return text.Reactivated;
             case PullRequestStatus.Completed: return text.Completed;
             default:
                 return $"updated status to {Status} for";
         }
 }
コード例 #2
0
        public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(TeamProjectCollection),
                ProjectUrl,
                ProjectName = transform(ProjectName),
            };

            return new[] { text.ProjectCreatedFormat.FormatWith(formatter) };
        }
コード例 #3
0
 private string FormatAction(TextElement text)
 {
     switch (Vote)
     {
         case -10: return text.VoteRejected;
         case 0: return text.VoteRescinded;
         case 10: return text.VoteApproved;
         default:
             return $"voted {Vote} on";
     }
 }
コード例 #4
0
ファイル: PushRow.cs プロジェクト: kria/TfsNotificationRelay
 public override string ToString(BotElement bot, TextElement text, Func<string, string> transform)
 {
     var formatter = new
     {
         DisplayName = transform(DisplayName), RepoUri,
         ProjectName = transform(ProjectName),
         RepoName = transform(RepoName),
         Pushed = IsForcePush ? text.ForcePushed : text.Pushed,
         UserName = transform(UserName),
         MappedUser = bot.GetMappedUser(UniqueName)
     };
     return text.PushFormat.FormatWith(formatter);
 }
コード例 #5
0
        public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(TeamProjectCollection),
                DisplayName = transform(DisplayName),
                UserName = transform(UserName),
                ProjectName = transform(ProjectName),
                ProjectUrl,
                RepoUri,
                RepoName = transform(RepoName),
                MappedUser = bot.GetMappedUser(UniqueName)
            };

            return new[] { GetFormat(text).FormatWith(formatter) };
        }
コード例 #6
0
 public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
 {
     var formatter = new
     {
         TeamProjectCollection = transform(TeamProjectCollection),
         ProjectName = transform(ProjectName),
         ReleaseDefinition = transform(ReleaseDefinition),
         ReleaseStatus = transform(ReleaseStatus.ToString()),
         ReleaseUrl,
         ReleaseName = transform(ReleaseName),
         ReleaseReason = transform(ReleaseReason.ToString()),
         CreatedBy = transform(CreatedByUniqueName),
         CreatedByDisplayName = transform(CreatedByDisplayName),
         DisplayName = transform(CreatedByDisplayName),
         CreatedOn,
         UserName = transform(UserName),
         MappedUser = bot.GetMappedUser(CreatedByUniqueName)
     };
     return new[] { text.ReleaseCreatedFormat.FormatWith(formatter) };
 }
コード例 #7
0
        public override IList<string> ToMessage(BotElement bot, TextElement text, 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),
                MappedUser = bot.GetMappedUser(UniqueName)
            };

            return new[] { text.PullRequestCreatedFormat.FormatWith(formatter) };
        }
コード例 #8
0
 public override IList<string> ToMessage(BotElement bot, TextElement text, 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(RequestedForUniqueName),
         RequestedForDisplayName = transform(RequestedForDisplayName),
         DisplayName = transform(RequestedForDisplayName),
         StartTime,
         FinishTime,
         UserName = transform(UserName),
         BuildDuration = FormatBuildDuration(text),
         DropLocation,
         NewValue = NewValue == null ? text.BuildQualityNotSet : transform(NewValue),
         OldValue = OldValue == null ? text.BuildQualityNotSet : transform(OldValue),
     };
     return new[] { text.BuildQualityChangedFormat.FormatWith(formatter) };
 }
コード例 #9
0
        public override IList<string> ToMessage(BotElement bot, TextElement text, 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 = text.CommentedOn,
                AssignedToUserName = transform(AssignedToUserName),
                MappedAssignedToUser = bot.GetMappedUser(AssignedToUniqueName),
                MappedUser = bot.GetMappedUser(UniqueName)
            };
            lines.Add(text.WorkItemchangedFormat.FormatWith(formatter));
            lines.Add(TextHelper.Truncate(Comment, Settings.DiscussionCommentMaxLength));

            return lines;
        }
コード例 #10
0
ファイル: GitRef.cs プロジェクト: kria/TfsNotificationRelay
 public static string ToString(this IEnumerable<GitRef> refs, TextElement text, Func<string, string> transform)
 {
     return string.Join(text.RefSeparator, refs.Select(r => r.ToString(text, transform)));
 }
コード例 #11
0
 public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
 {
     var formatter = new
     {
         TeamProjectCollection = transform(TeamProjectCollection),
         DisplayName = transform(DisplayName),
         ChangesetUrl,
         ChangesetId,
         Comment = transform(Comment),
         UserName = transform(UserName),
         ProjectLinks = FormatProjectLinks(text, transform),
         MappedUser = bot.GetMappedUser(UniqueName)
     };
     return new[] { text.CheckinFormat.FormatWith(formatter) };
 }
コード例 #12
0
ファイル: GitRef.cs プロジェクト: kria/TfsNotificationRelay
        public string ToString(TextElement text, Func<string, string> transform)
        {
            string pattern = Type == GitRefType.Tag ? text.TagFormat : text.BranchFormat;
            var sb = new StringBuilder();
            if (Type == GitRefType.Branch && IsNew) sb.Append("+");
            sb.Append(Name);

            return pattern.FormatWith(new
            {
                Name = transform(sb.ToString())
            });
        }
コード例 #13
0
 protected override string GetBuildFormat(TextElement text)
 {
     return string.IsNullOrEmpty(text.Build2015Format) ? text.BuildFormat : text.Build2015Format;
 }
コード例 #14
0
 private string FormatProjectLinks(TextElement text, Func<string, string> transform)
 {
     return string.Join(", ", Projects.Select(x => text.ProjectLinkFormat
         .FormatWith(new { ProjectName = transform(x.Key), ProjectUrl = x.Value })));
 }
コード例 #15
0
        public override string ToString(BotElement bot, TextElement text, Func<string, string> transform)
        {
            string formattedTime = string.IsNullOrEmpty(text.DateTimeFormat) ? AuthorTime.ToString() : AuthorTime.ToString(text.DateTimeFormat);
            var sb = new StringBuilder();
            if (Refs != null) sb.AppendFormat("{0} ", Refs.ToString(text, transform));

            sb.Append(text.CommitFormat.FormatWith(new
            {
                Action = Type == CommitRowType.Commit ? text.Commit : text.RefPointer, CommitUri,
                CommitId = transform(CommitId.ToHexString(Settings.HashLength)),
                ChangeCounts = (ChangeCounts != null) ? ChangeCountsToString(text, ChangeCounts) : "",
                AuthorTime = formattedTime,
                Author = transform(Author),
                AuthorName = transform(AuthorName),
                AuthorEmail = transform(AuthorEmail),
                Comment = transform(Comment.Truncate(Settings.CommentMaxLength, true))
            }));

            return sb.ToString();
        }
コード例 #16
0
        private string ChangeCountsToString(TextElement text, Dictionary<TfsGitChangeType, int> changeCounts)
        {
            var counters = new[] {
                new ChangeCounter(TfsGitChangeType.Add, text.ChangeCountAddFormat, 0),
                new ChangeCounter(TfsGitChangeType.Edit, text.ChangeCountEditFormat, 0),
                new ChangeCounter(TfsGitChangeType.Delete, text.ChangeCountDeleteFormat, 0),
                new ChangeCounter(TfsGitChangeType.Rename, text.ChangeCountRenameFormat, 0),
                new ChangeCounter(TfsGitChangeType.SourceRename, 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 })));
        }
コード例 #17
0
 public override IList<string> ToMessage(BotElement bot, TextElement text, 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(RequestedForUniqueName),
         RequestedForDisplayName = transform(RequestedForDisplayName),
         DisplayName = transform(RequestedForDisplayName),
         StartTime,
         FinishTime,
         UserName = transform(UserName),
         BuildDuration = FormatBuildDuration(text),
         DropLocation,
         MappedUser = bot.GetMappedUser(RequestedForUniqueName)
     };
     return new[] { GetBuildFormat(text).FormatWith(formatter), transform(BuildStatus.ToString()) };
 }
コード例 #18
0
 private string FormatAction(TextElement text)
 {
     return IsNew ? text.Created : text.Updated;
 }
コード例 #19
0
 protected abstract string GetFormat(TextElement text);
コード例 #20
0
 public abstract string ToString(BotElement bot, TextElement text, Func<string, string> transform);
コード例 #21
0
 protected string FormatBuildDuration(TextElement text)
 {
     var duration = FinishTime - StartTime;
     return string.IsNullOrEmpty(text.TimeSpanFormat) ? duration.ToString(@"hh\:mm\:ss") : duration.ToString(text.TimeSpanFormat);
 }
コード例 #22
0
 public override string ToString(BotElement bot, TextElement text, Func<string, string> transform)
 {
     return transform(Text);
 }
コード例 #23
0
 public abstract IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform);
コード例 #24
0
 public override string ToString(BotElement bot, TextElement text, Func<string, string> transform)
 {
     return String.Format("{0} {1} {2} {3}", Refs.ToString(text, transform), text.RefPointer, transform(ObjectType.ToString()), transform(NewObjectId.ToHexString()));
 }
コード例 #25
0
 protected virtual string GetBuildFormat(TextElement text)
 {
     return text.BuildFormat;
 }
コード例 #26
0
 protected override string GetFormat(TextElement text)
 {
     return text.RepositoryCreatedFormat;
 }
コード例 #27
0
        public override IList<string> ToMessage(BotElement bot, TextElement text, 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(text),
                AssignedToUserName = transform(AssignedToUserName),
                MappedAssignedToUser = bot.GetMappedUser(AssignedToUniqueName),
                MappedUser = bot.GetMappedUser(UniqueName)
            };
            lines.Add(text.WorkItemchangedFormat.FormatWith(formatter));

            var searchType = IsNew ? SearchFieldsType.Core : SearchFieldsType.Changed;
            var displayFieldsKey = IsNew ? "wiCreatedDisplayFields" : "wiChangedDisplayFields";
            var pattern = IsNew ? "{name}: {newValue}" : "{name}: " + 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;
        }
コード例 #28
0
 public override string ToString(BotElement bot, TextElement text, Func<string, string> transform)
 {
     return $"{Refs.ToString(text, transform)} {text.Deleted}";
 }
コード例 #29
0
        public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(TeamProjectCollection),
                DisplayName = transform(DisplayName),
                ProjectName = transform(ProjectName),
                RepoUri,
                RepoName = transform(RepoName),
                CommitId = transform(CommitId.ToHexString(Settings.HashLength)),
                CommitUri,
                Comment = transform(Comment),
                UserName = transform(UserName),
                PusherUserName = transform(PusherUserName),
                MappedPusherUser = bot.GetMappedUser(PusherUniqueName),
                MappedUser = bot.GetMappedUser(UniqueName)
            };

            return new[] { text.CommitCommentFormat.FormatWith(formatter), Comment };
        }