TFS 2015警报API:为团队或TFS组创建警报

编程入门 行业动态 更新时间:2024-10-11 19:14:19
本文介绍了TFS 2015警报API:为团队或TFS组创建警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以使用TFS 2015 API或Power Shell脚本以编程方式设置团队警报/TFS组警报?我们要求创建TFS Alert的时间应大于15,然后寻找使用api/脚本而不是手动创建警报的选项.

Is it possible to setup a Team Alert / TFS Group Alert Programmatically using TFS 2015 APIs or Power Shell script? We have a requirement to create TFS Alert more then ~15 and looking for an option to create alert using api / script instead of manually.

推荐答案

据我所知,警报用于团队项目和团队项目集合级别,因此您在团队中创建的警报将列在团队项目的警报列表.对于团队项目收集级别,警报将列在所有团队项目和团队的警报列表中.

As far as I know, the alerts are used for team project and team project collection level, so the alerts that you created in a team will be listed in the team project’s alerts list. For team project collection level, the alerts will be listed in all team project and team’s alerts list.

创建警报的简单代码:

NetworkCredential cred = new NetworkCredential("[user name]", "[password]", "[domain]"); TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("[collection url]"), cred); tpc.EnsureAuthenticated(); IIdentityManagementService2 ims = tpc.GetService<IIdentityManagementService2>(); TeamFoundationIdentity identity = ims.ReadIdentity(IdentitySearchFactor.AccountName,"[user name]", MembershipQuery.None,ReadIdentityOptions.None); if(identity!=null) { string s = identity.Descriptor.Identifier; } IEventService es = tpc.GetService<IEventService>(); List<Subscription> allSubScrip = es.GetAllEventSubscriptions().ToList(); DeliveryPreference deliverPreference = new DeliveryPreference(); deliverPreference.Address = "[email address]"; deliverPreference.Schedule = DeliverySchedule.Immediate; deliverPreference.Type = DeliveryType.EmailHtml; string filter = string.Format("\"CoreFields/IntegerFields/Field[Name='ID']/NewValue\"='10'"); string eventName = string.Format("<PT N=\"A specific work item is changed API team\" />"); es.SubscribeEvent(identity.Descriptor.Identifier, "WorkItemChangedEvent", filter, deliverPreference, eventName,projectName: "[team project name]");

注意:如果您不知道如何指定过滤器,则可以在Web访问中创建示例警报,然后检查集合数据库的dbo.tbl_EventSubscription表中的记录.

Note: If you don't know how to specify filter, you could create the sample alerts in web access, then check record in dbo.tbl_EventSubscription table of the collection database.

更多推荐

TFS 2015警报API:为团队或TFS组创建警报

本文发布于:2023-11-27 21:49:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639718.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   团队   TFS   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!