예제 #1
0
        /// <summary>
        /// When implemented in a derived class, performs the execution of the activity.
        /// </summary>
        /// <param name="context">The execution context under which the activity executes.</param>
        protected override void Execute(CodeActivityContext context)
        {
            TeamFoundationRequestContext requestContext = context.GetValue(this.TeamFoundationRequestContext);

          #if UsingILocationService
            ILocationService tfLocationService = requestContext.GetService <ILocationService>();
            Uri uriRequestContext = new Uri(tfLocationService.GetLocationData(requestContext, Guid.Empty).GetServerAccessMapping(requestContext).AccessPoint + "/" + requestContext.ServiceHost.Name);
#else
            var tfLocationService = requestContext.GetService <TeamFoundationLocationService>();
            var accessMapping     = tfLocationService.GetServerAccessMapping(requestContext);
            Uri uriRequestContext = new Uri(tfLocationService.GetHostLocation(requestContext, accessMapping));
#endif
            string     strHost = System.Environment.MachineName;
            string     strFQDN = System.Net.Dns.GetHostEntry(strHost).HostName;
            UriBuilder uriBuilderRequestContext = new UriBuilder(uriRequestContext.Scheme, strFQDN, uriRequestContext.Port, uriRequestContext.PathAndQuery);
            string     teamProjectCollectionUrl = uriBuilderRequestContext.Uri.AbsoluteUri;
            var        teamProjectCollection    = new TfsTeamProjectCollection(new Uri(teamProjectCollectionUrl));
            string     serverUri = teamProjectCollectionUrl;

            var           workItemEvent = context.GetValue(this.WorkItemChangedEvent);
            int           workItemId    = workItemEvent.CoreFields.IntegerFields.First(k => k.Name == "ID").NewValue;
            WorkItemStore workItemStore = GetWorkitemStore(serverUri);
            var           workItem      = workItemStore.GetWorkItem(workItemId);

            context.SetValue(this.ChangedFields, workItemEvent.ChangedFields);
            context.SetValue(this.WorkItem, workItem);
            context.SetValue(this.TFSCollectionUrl, serverUri);
        }
예제 #2
0
#pragma warning restore SA1306 // Field names must begin with lower-case letter

            internal Mailer(IVssRequestContext requestContext)
            {
                this.Enabled = false;
                try
                {
                    IVssRegistryService service = requestContext.GetService <IVssRegistryService>();
                    Microsoft.TeamFoundation.Framework.Server.RegistryEntryCollection registryEntryCollection = service.ReadEntriesFallThru(requestContext, this.NotificationRootPath + "/*");
                    if (registryEntryCollection["EmailEnabled"].GetValue <bool>(true))
                    {
                        this.SmtpServer  = registryEntryCollection["SmtpServer"].GetValue(string.Empty);
                        this.SmtpPort    = registryEntryCollection["SmtpPort"].GetValue <int>(-1);
                        this.EnableSsl   = registryEntryCollection["SmtpEnableSsl"].GetValue <bool>(false);
                        this.FromAddress = null;

                        string value = registryEntryCollection["EmailNotificationFromAddress"].GetValue(string.Empty);
                        if (!string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(this.SmtpServer))
                        {
                            this.FromAddress = new MailAddress(value);
                            this.Enabled     = true;
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine($"SendMail failed: {ex.Message}");
                }
            }
예제 #3
0
        private Uri GetCollectionUriFromContext(IVssRequestContext requestContext)
        {
            ILocationService service = requestContext.GetService <ILocationService>();

            return(service.GetSelfReferenceUri(requestContext, service.GetDefaultAccessMapping(requestContext)));
        }
 private Uri GetCollectionUriFromContext(IVssRequestContext requestContext)
 {
     ILocationService service = requestContext.GetService<ILocationService>();
     return service.GetSelfReferenceUri(requestContext, service.GetDefaultAccessMapping(requestContext));
 }