2015年TFS上的ISubscriber [英] ISubscriber on TFS 2015

查看:132
本文介绍了2015年TFS上的ISubscriber的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试为TFS 2015编写插件。 

I try write plugin for TFS 2015. 

我使用"ISubscriber" 

I use "ISubscriber" 

public EventNotificationStatus ProcessEvent(TeamFoundationRequestContext requestContext, NotificationType notificationType,
      object notificationEventArgs, out int statusCode, out string statusMessage,
      out ExceptionPropertyCollection properties) {  statusCode = 0;
      statusMessage = string.Empty;
      properties = null;
      try {
        if (notificationType == NotificationType.Notification && notificationEventArgs is WorkItemChangedEvent) {
          var notification = notificationEventArgs as WorkItemChangedEvent;

          string projectName = notification.ChangedFields.StringFields.First(p => p.ReferenceName == "System.TeamProject").NewValue;
          var createdByDisplayName = notification.CoreFields.StringFields.First(p => p.ReferenceName == "System.CreatedBy").NewValue;
          var assignedByDisplayName = notification.CoreFields.StringFields.First(p => p.ReferenceName == "System.AssignedTo").NewValue;
string s = string.Format("{0} | {1}", notification.WorkItemTitle, notification.AreaPath);
  TeamFoundationApplicationCore.Log(string.Format(" WorkItemTitle | AreaPath : {0}", s), 1602, System.Diagnostics.EventLogEntryType.Information);
          TeamFoundationApplicationCore.Log(string.Format(" CreatedBy : {0}", createdByDisplayName), 1603, System.Diagnostics.EventLogEntryType.Information);
          TeamFoundationApplicationCore.Log(string.Format(" AssignedTo : {0}", assignedByDisplayName), 1603, System.Diagnostics.EventLogEntryType.Information);

 TeamFoundationLocationService service = requestContext.GetService<TeamFoundationLocationService>();
          Uri uri = service.GetSelfReferenceUri(requestContext, service.GetDefaultAccessMapping(requestContext));
          TfsTeamProjectCollection tfsTeamProjectCollection = new TfsTeamProjectCollection(uri); } catch (Exception ex) {
        TeamFoundationApplicationCore.Log(ex.Message, 1604, System.Diagnostics.EventLogEntryType.Error);
      }
      return EventNotificationStatus.ActionPermitted;
    }

我将dll 复制到文件夹"C:\Program Files \ Microsoft Office Team Server 14.0 \ Application Tier \ Web Services \\ \\ bin \Plugins"

I copy dll  to folder "C:\Program Files\Microsoft Team Foundation Server 14.0\Application Tier\Web Services\bin\Plugins"

在我创建新的用户故事后,我检查了Windows EventLog

After i create new User Story, i check in windows EventLog

服务器安装TFS  2015 RC(服务器don'加入域名)

Server install TFS 2015 RC (Server don't join Domain)

- CreatedBy: dongnt

- CreatedBy : dongnt

-   AssignedTo:管理员  

- AssignedTo : Administrator 

服务器安装TFS Server 2015  (服务器加入域名)

Server install TFS Server 2015   (Server join Domain)

-     ; AssignedTo: |用户01%85c99e85-152f-46eb-a0b5-85b271fbee57 |

-  AssignedTo : |User 01%85c99e85-152f-46eb-a0b5-85b271fbee57|

为什么它不相同?  

why does it diffirence?  

TeamFoundationLocationService service = requestContext.GetService<TeamFoundationLocationService>(); <= service always null

推荐答案

您好,

感谢您的支持帖子。

您是否使用了哪个版本的VS来创建插件?

您将哪个Dll复制到文件夹:" C:\Program Files \ Microsoft Office Team Foundation服务器14.0 \Application Tier \Web服务\ bin \Plugins"?

Did you used which version of VS to created Plugin?
Which Dll you copied to folder: "C:\Program Files\Microsoft Team Foundation Server 14.0\Application Tier\Web Services\bin\Plugins"?

我想也许你可以用下面链接的方式提示调试这个插件库一步一步到检查发生了什么,并检查为什么服务始终为空?

http://vgaltes.com/index.php/2013/04/14/create-a-team-foundation-server-event-handler/

I think maybe you can use the way of below link prompted to debug this Plugin library step by step to check what happened and check why service is always null?
http://vgaltes.com/index.php/2013/04/14/create-a-team-foundation-server-event-handler/

谢谢,


这篇关于2015年TFS上的ISubscriber的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆