-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Multiple event rules per bot. - Filtering on team project, repository and build definition namee. - XSD to get intellisense in app.config. - Event handler refactoring - common base class.
- Loading branch information
Showing
19 changed files
with
415 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Tfs2Slack - http://github.com/kria/Tfs2Slack | ||
* | ||
* Copyright (C) 2014 Kristian Adrup | ||
* | ||
* This file is part of Tfs2Slack. | ||
* | ||
* Tfs2Slack is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. See included file COPYING for details. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DevCore.Tfs2Slack.Configuration | ||
{ | ||
public class EventRuleCollection : ConfigurationElementCollection, | ||
IEnumerable<EventRuleElement> | ||
{ | ||
protected override ConfigurationElement CreateNewElement() | ||
{ | ||
return new EventRuleElement(); | ||
} | ||
|
||
protected override object GetElementKey(ConfigurationElement element) | ||
{ | ||
return element; | ||
} | ||
public EventRuleElement this[int index] | ||
{ | ||
get { return (EventRuleElement)BaseGet(index); } | ||
} | ||
|
||
public new IEnumerator<EventRuleElement> GetEnumerator() | ||
{ | ||
int count = base.Count; | ||
for (int i = 0; i < count; i++) | ||
{ | ||
yield return base.BaseGet(i) as EventRuleElement; | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Tfs2Slack - http://github.com/kria/Tfs2Slack | ||
* | ||
* Copyright (C) 2014 Kristian Adrup | ||
* | ||
* This file is part of Tfs2Slack. | ||
* | ||
* Tfs2Slack is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. See included file COPYING for details. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DevCore.Tfs2Slack.Configuration | ||
{ | ||
public class EventRuleElement : ConfigurationElement | ||
{ | ||
[ConfigurationProperty("events", IsRequired = true)] | ||
public TfsEvents Events | ||
{ | ||
get { return (TfsEvents)this["events"]; } | ||
} | ||
|
||
[ConfigurationProperty("notify")] | ||
public bool Notify | ||
{ | ||
get { return (bool)this["notify"]; } | ||
} | ||
|
||
[ConfigurationProperty("teamProject")] | ||
public string TeamProject | ||
{ | ||
get { return (string)this["teamProject"]; } | ||
} | ||
|
||
[ConfigurationProperty("gitRepository")] | ||
public string GitRepository | ||
{ | ||
get { return (string)this["gitRepository"]; } | ||
} | ||
|
||
[ConfigurationProperty("buildDefinition")] | ||
public string BuildDefinition | ||
{ | ||
get { return (string)this["buildDefinition"]; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Tfs2Slack - http://github.com/kria/Tfs2Slack | ||
* | ||
* Copyright (C) 2014 Kristian Adrup | ||
* | ||
* This file is part of Tfs2Slack. | ||
* | ||
* Tfs2Slack is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. See included file COPYING for details. | ||
*/ | ||
|
||
using Microsoft.TeamFoundation.Framework.Server; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DevCore.Tfs2Slack.EventHandlers | ||
{ | ||
public abstract class BaseHandler : IEventHandler | ||
{ | ||
protected static Configuration.SettingsElement settings = Configuration.Tfs2SlackSection.Instance.Settings; | ||
protected static Configuration.TextElement text = Configuration.Tfs2SlackSection.Instance.Text; | ||
|
||
protected abstract IList<string> _ProcessEvent(TeamFoundationRequestContext requestContext, object notificationEventArgs, Configuration.BotElement bot); | ||
|
||
public IList<string> ProcessEvent(TeamFoundationRequestContext requestContext, object notificationEventArgs, Configuration.BotElement bot) | ||
{ | ||
IList<string> lines = _ProcessEvent(requestContext, notificationEventArgs, bot); | ||
if (lines != null && lines.Count > 0) | ||
{ | ||
IList<string> sendLines = lines; | ||
if (lines != null && lines.Count > settings.MaxLines) | ||
{ | ||
int supressedLines = lines.Count - settings.MaxLines; | ||
lines = lines.Take(settings.MaxLines).ToList(); | ||
lines.Add(text.LinesSupressedFormat.FormatWith(new { Count = supressedLines })); | ||
} | ||
} | ||
|
||
return lines; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.