/// <summary> /// Processes the event. /// </summary> /// <param name="requestContext">The request context.</param> /// <param name="notificationType">Type of the notification.</param> /// <param name="notificationEventArgs">The notification event args.</param> /// <param name="statusCode">The status code.</param> /// <param name="statusMessage">The status message.</param> /// <param name="properties">The properties.</param> /// <returns></returns> public EventNotificationStatus ProcessEvent( TeamFoundationRequestContext requestContext, NotificationType notificationType, object notificationEventArgs, out int statusCode, out string statusMessage, out ExceptionPropertyCollection properties) { statusCode = 0; statusMessage = "TFSEventWorkflow executed successfully"; properties = null; // we only handle notifications if (notificationType != NotificationType.Notification) { return(EventNotificationStatus.ActionPermitted); } string strConfigFile = this.workflowRunner.ExecutionPath.FullName + ".config"; XmlConfigurator.Configure(new Uri(strConfigFile)); if (notificationEventArgs.GetType() == typeof(WorkItemChangedEvent)) { // run workflow asynchronously in a TFS job var workItemChangedEvent = (WorkItemChangedEvent)notificationEventArgs; var xmlData = WorkItemChangedEventSerializer.SerializeXml(workItemChangedEvent); this.LogInfo(string.Format("Queuing Job for WorkitemChangedEvent")); // Handle the notification by queueing the information we need for a job var jobService = requestContext.GetService <TeamFoundationJobService>(); jobService.QueueOneTimeJob( requestContext, "TFSEventWorkflow Job", "artiso.TFSEventWorkflows.TFSEventWorkflowsServerPlugin.WorkflowRunnerJob", xmlData, false); } else { // run workflow synchronously in the Server PLugin itself return(this.workflowRunner.ProcessEvent(requestContext, notificationEventArgs)); } return(EventNotificationStatus.ActionPermitted); }
public TeamFoundationJobExecutionResult Run( TeamFoundationRequestContext requestContext, TeamFoundationJobDefinition jobDefinition, DateTime queueTime, out string resultMessage) { resultMessage = string.Empty; try { string strConfigFile = this.workflowRunner.ExecutionPath.FullName + ".config"; XmlConfigurator.Configure(new Uri(strConfigFile)); AppendSuffixToLoggingPath("_JobAgent"); this.LogInfo(string.Format("Enter Job for WorkitemChangedEvent")); lock (JobLock) { XmlNode xmlData = jobDefinition.Data; WorkItemChangedEvent workItemChangedEvent = WorkItemChangedEventSerializer.DeserializeXml(xmlData); this.workflowRunner.ProcessEvent(requestContext, workItemChangedEvent); } } catch (RequestCanceledException e) { this.LogError(string.Format("Workflow cancel: "), e); return(TeamFoundationJobExecutionResult.Stopped); } catch (Exception e) { this.LogError(string.Format("Workflow error: "), e); resultMessage = e.ToString(); return(TeamFoundationJobExecutionResult.Failed); } this.LogInfo(string.Format("Leave Job for WorkitemChangedEvent")); return(TeamFoundationJobExecutionResult.Succeeded); }