public async Task OnNewInitiative(InitiativeCreatedEventArgs initiativeCreatedEventArgs, CancellationToken cancellationToken) { EnsureArg.IsNotNull(initiativeCreatedEventArgs); EnsureArg.IsNotNull(initiativeCreatedEventArgs.Initiative); var owner = initiativeCreatedEventArgs.Owner; await FireWebHooksAsync(initiativeCreatedEventArgs.Initiative, WebhookEvents.Created, cancellationToken : cancellationToken); }
protected virtual async Task OnNewInitiative(InitiativeCreatedEventArgs e, CancellationToken token) { var initiative = e.Initiative; var owner = e.Owner; using (LogContext.PushProperty("InitiativeId", initiative.Id)) { _logger.Information("Begin OnNewInitiative for initiative {InitiativeId}", initiative.Id); Stopwatch watch = new Stopwatch(); watch.Start(); PersonData personData; try { personData = await GetPersonData(owner.GetEmail()); } catch (Exception err) { _logger.Error(err, "Unable to get PersonData for {InitiativeId} from {EmailAddress}: {ErrorMessage}", initiative.Id, owner.GetEmail(), err.Message); throw; } string workOrderId; try { workOrderId = await CreateWorkOrder(initiative, personData); } catch (Exception err) { _logger.Error(err, "Unable to get create a workOrder for initiative {InitiativeId} from {EmailAddress}: {ErrorMessage}", initiative.Id, owner.GetEmail(), err.Message); throw; } DateTime?eta; try { _initiativeStatusEtaService.Authenticate(e.Owner); eta = await _initiativeStatusEtaService.GetStatusEtaFromNowUtcAsync(InitiativeStatus.Submit); } catch (Exception err) { _logger.Error(err, "Unable to get ETA for Submitted status"); throw; } await SendWorkOrderCreatedMessage(initiative, owner, workOrderId, eta, e.SkipEmailNotification); _logger.Information("Processed OnNewInitiative for initiative {InitiativeId} in {ElapsedMilliseconds}ms", initiative.Id, watch.ElapsedMilliseconds); } }
public Task SendInitiativeCreatedAsync(InitiativeCreatedEventArgs args) { // Not applicable to Remedy tests throw new System.NotImplementedException(); }