示例#1
0
 public TestableServiceBusQueueMessageHandler(IServiceBusQueueMessageListener serviceBusQueueMessageListener, IVstsScheduleHandler <TestVstsMessage> handler, ServiceBusQueueMessageHandlerSettings settings, ILogger logger, ITaskClient taskClient, IBuildClient buildClient, IJobStatusReportingHelper jobStatusReportingHelper, IReleaseClient releaseClient)
     : base(serviceBusQueueMessageListener, handler, settings, logger)
 {
     this.taskClient               = taskClient;
     this.buildClient              = buildClient;
     this.releaseClient            = releaseClient;
     this.jobStatusReportingHelper = jobStatusReportingHelper;
 }
        private static async Task ReportJobProgress(VstsMessage vstsMessage, CancellationToken cancellationToken, IJobStatusReportingHelper jobStatusReportingHelper)
        {
            await Task.Delay(5000, cancellationToken);

            var message = string.Format("Job [{0}] is requested by user [{1}] with email {2}", vstsMessage.JobId, vstsMessage.RequesterName, vstsMessage.RequesterEmail);
            await jobStatusReportingHelper.ReportJobProgress(DateTime.UtcNow, message, CancellationToken.None).ConfigureAwait(false);
        }
        private async Task ReportJobStarted(VstsMessage vstsMessage, CancellationToken cancellationToken, IJobStatusReportingHelper jobStatusReportingHelper)
        {
            await Task.Delay(5000, cancellationToken);

            var message = string.Format("[{0}] started processing job session [{1}]", ServiceName, vstsMessage.JobId);

            await this.logger.LogInfo("Info", message, new Dictionary <string, string>(), CancellationToken.None);

            await jobStatusReportingHelper.ReportJobStarted(DateTime.UtcNow, message, CancellationToken.None).ConfigureAwait(false);
        }
        private async Task ReportJobCompleted(VstsMessage vstsMessage, CancellationToken cancellationToken, IJobStatusReportingHelper jobStatusReportingHelper)
        {
            await Task.Delay(5000, cancellationToken);

            var message = string.Format("[{0}] completed processing session [{1}]", ServiceName, vstsMessage.JobId);
            await jobStatusReportingHelper.ReportJobCompleted(DateTime.UtcNow, message, true, CancellationToken.None).ConfigureAwait(false);
        }