Пример #1
0
        public override IList <string> ToMessage(Configuration.BotElement bot, Func <string, string> transform)
        {
            var lines     = new List <string>();
            var formatter = new
            {
                TeamProjectCollection = transform(this.TeamProjectCollection),
                DisplayName           = transform(this.DisplayName),
                ProjectName           = transform(this.ProjectName),
                WiUrl               = this.WiUrl,
                WiType              = transform(this.WiType),
                WiId                = this.WiId,
                WiTitle             = transform(this.WiTitle),
                IsStateChanged      = this.IsStateChanged,
                IsAssignmentChanged = this.IsAssignmentChanged,
                AssignedTo          = transform(this.AssignedTo),
                State               = transform(this.State),
                UserName            = transform(this.UserName),
                Action              = FormatAction(bot)
            };

            lines.Add(bot.Text.WorkItemchangedFormat.FormatWith(formatter));
            lines.Add(String.Format("State: {0}", State));
            lines.Add(String.Format("AssignedTo: {0} ", AssignedTo));

            return(lines);
        }
Пример #2
0
        public override IList <string> ToMessage(Configuration.BotElement bot, Func <string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(this.TeamProjectCollection),
                ProjectName           = transform(this.ProjectName),
                BuildDefinition       = transform(this.BuildDefinition),
                BuildStatus           = transform(this.BuildStatus.ToString()),
                BuildUrl                = this.BuildUrl,
                BuildNumber             = transform(this.BuildNumber),
                BuildReason             = transform(this.BuildReason.ToString()),
                RequestedFor            = transform(this.RequestedFor),
                RequestedForDisplayName = transform(this.RequestedForDisplayName),
                DisplayName             = transform(this.RequestedForDisplayName),
                StartTime               = this.StartTime,
                FinishTime              = this.FinishTime,
                UserName                = transform(this.UserName),
                BuildDuration           = FormatBuildDuration(bot),
                DropLocation            = this.DropLocation,
                NewValue                = this.NewValue == null ? bot.Text.BuildQualityNotSet : transform(this.NewValue),
                OldValue                = this.OldValue == null ? bot.Text.BuildQualityNotSet : transform(this.OldValue)
            };

            return(new[] { bot.Text.BuildQualityChangedFormat.FormatWith(formatter) });
        }
        public override IList <string> ToMessage(Configuration.BotElement bot, Func <string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(this.TeamProjectCollection),
                ProjectUrl            = this.ProjectUrl,
                ProjectName           = transform(this.ProjectName),
            };

            return(new[] { bot.Text.ProjectCreatedFormat.FormatWith(formatter) });
        }
Пример #4
0
        private string FormatAction(Configuration.BotElement bot)
        {
            switch (Status)
            {
            case PullRequestStatus.Abandoned: return(bot.Text.Abandoned);

            case PullRequestStatus.Active: return(bot.Text.Reactivated);

            case PullRequestStatus.Completed: return(bot.Text.Completed);

            default:
                return(String.Format("updated status to {0} for", Status.ToString()));
            }
        }
Пример #5
0
        public IList <string> ToMessage(Configuration.BotElement bot, Func <string, string> transform)
        {
            var lines = this.Select(r => r.ToString(bot, transform)).ToList();

            if (lines != null && lines.Count > 0)
            {
                if (lines.Count < TotalLineCount)
                {
                    lines.Add(bot.Text.LinesSupressedFormat.FormatWith(new { Count = TotalLineCount - lines.Count }));
                }
            }

            return(lines);
        }
        public override IList <string> ToMessage(Configuration.BotElement bot, Func <string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(this.TeamProjectCollection),
                DisplayName           = transform(this.DisplayName),
                UserName    = transform(this.UserName),
                ProjectName = transform(this.ProjectName),
                RepoUri     = this.RepoUri,
                RepoName    = transform(this.RepoName)
            };

            return(new[] { bot.Text.RepositoryCreatedFormat.FormatWith(formatter) });
        }
        private string FormatAction(Configuration.BotElement bot)
        {
            switch (Vote)
            {
            case -10: return(bot.Text.VoteRejected);

            case 0: return(bot.Text.VoteRescinded);

            case 10: return(bot.Text.VoteApproved);

            default:
                return(String.Format("voted {0} on", Vote));
            }
        }
        public override IList <string> ToMessage(Configuration.BotElement bot, Func <string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(this.TeamProjectCollection),
                DisplayName           = transform(this.DisplayName),
                ChangesetUrl          = this.ChangesetUrl,
                ChangesetId           = this.ChangesetId,
                Comment      = transform(this.Comment),
                UserName     = transform(this.UserName),
                ProjectLinks = FormatProjectLinks(bot, transform)
            };

            return(new[] { bot.Text.CheckinFormat.FormatWith(formatter) });
        }
Пример #9
0
        public override IList <string> ToMessage(Configuration.BotElement bot, Func <string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(this.TeamProjectCollection),
                Status      = transform(this.Status.ToString()),
                DisplayName = transform(this.DisplayName),
                ProjectName = transform(this.ProjectName),
                RepoUri     = this.RepoUri,
                RepoName    = transform(this.RepoName),
                PrId        = this.PrId,
                PrUrl       = this.PrUrl,
                PrTitle     = transform(this.PrTitle),
                UserName    = transform(this.UserName),
                Action      = FormatAction(bot)
            };

            return(new[] { bot.Text.PullRequestStatusUpdateFormat.FormatWith(formatter) });
        }
Пример #10
0
        public override IList <string> ToMessage(Configuration.BotElement bot, Func <string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(this.TeamProjectCollection),
                DisplayName           = transform(this.DisplayName),
                ProjectName           = transform(this.ProjectName),
                RepoUri          = this.RepoUri,
                RepoName         = transform(this.RepoName),
                PrId             = this.PrId,
                PrUrl            = this.PrUrl,
                PrTitle          = transform(this.PrTitle),
                UserName         = transform(this.UserName),
                SourceBranchName = transform(this.SourceBranch.Name),
                TargetBranchName = transform(this.TargetBranch.Name)
            };

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

            lines.Add(bot.Text.WorkItemchangedFormat.FormatWith(formatter));

            lines.Add(Comment);

            return(lines);
        }
Пример #12
0
        public override IList <string> ToMessage(Configuration.BotElement bot, Func <string, string> transform)
        {
            var lines     = new List <string>();
            var formatter = new
            {
                TeamProjectCollection = transform(this.TeamProjectCollection),
                DisplayName           = transform(this.DisplayName),
                ProjectName           = transform(this.ProjectName),
                WiUrl               = this.WiUrl,
                WiType              = transform(this.WiType),
                WiId                = this.WiId,
                WiTitle             = transform(this.WiTitle),
                IsStateChanged      = this.IsStateChanged,
                IsAssignmentChanged = this.IsAssignmentChanged,
                AssignedTo          = transform(this.AssignedTo),
                State               = transform(this.State),
                UserName            = transform(this.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);
        }
        protected string FormatBuildDuration(Configuration.BotElement bot)
        {
            var duration = FinishTime - StartTime;

            return(String.IsNullOrEmpty(bot.Text.TimeSpanFormat) ? duration.ToString(@"hh\:mm\:ss") : duration.ToString(bot.Text.TimeSpanFormat));
        }
Пример #14
0
 private string FormatAction(Configuration.BotElement bot)
 {
     return(IsNew ? bot.Text.Created : bot.Text.Updated);
 }
 private string FormatProjectLinks(Configuration.BotElement bot, Func <string, string> transform)
 {
     return(String.Join(", ", Projects.Select(x => bot.Text.ProjectLinkFormat
                                              .FormatWith(new { ProjectName = transform(x.Key), ProjectUrl = x.Value }))));
 }
Пример #16
0
 public abstract IList <string> ToMessage(Configuration.BotElement bot, Func <string, string> transform);