Exemple #1
0
        private async Task Send(string eventType, string subject, LicensePlateData data)
        {
            // Get the API URL and the API key from settings.
            var uri = ConfigurationManager.AppSettings["eventGridTopicEndpoint"];
            var key = ConfigurationManager.AppSettings["eventGridTopicKey"];

            _log.Info($"Sending license plate data to the {eventType} Event Grid type");

            var events = new List <Event <LicensePlateData> >
            {
                new Event <LicensePlateData>()
                {
                    Data      = data,
                    EventTime = DateTime.UtcNow,
                    EventType = eventType,
                    Id        = Guid.NewGuid().ToString(),
                    Subject   = subject
                }
            };

            _client.DefaultRequestHeaders.Clear();
            _client.DefaultRequestHeaders.Add("aeg-sas-key", key);
            await _client.PostAsJsonAsync(uri, events);

            _log.Info($"Sent the following to the Event Grid topic: {events[0]}");
        }
Exemple #2
0
 public async Task SendLicensePlateData(LicensePlateData data)
 {
     // Will send to one of two routes, depending on success.
     // Event listeners will filter and act on events they need to
     // process (save to database, move to manual checkup queue, etc.)
     if (data.LicensePlateFound)
     {
         await Send("savePlateData", "TollBooth/CustomerService", data);
     }
     else
     {
         await Send("queuePlateForManualCheckup", "TollBooth/CustomerService", data);
     }
 }
Exemple #3
0
 public async Task SendLicensePlateData(LicensePlateData data)
 {
     // Will send to one of two routes, depending on success.
     // Event listeners will filter and act on events they need to
     // process (save to database, move to manual checkup queue, etc.)
     if (data.LicensePlateFound)
     {
         // 3: Modify send method to include the proper eventType name value for saving plate data.
         await Send("savePlateData", "TollBooth/CustomerService", data);
     }
     else
     {
         // 4: Modify send method to include the proper eventType name value for queuing plate for manual review.
         await Send("queuePlateForManualCheckup", "TollBooth/CustomerService", data);
     }
 }
 public async Task SendLicensePlateData(LicensePlateData data)
 {
     // Will send to one of two routes, depending on success.
     // Event listeners will filter and act on events they need to
     // process (save to database, move to manual checkup queue, etc.)
     if (data.LicensePlateFound)
     {
         // TODO 3: Modify send method to include the proper eventType name value for saving plate data.
         // COMPLETE: await Send(...);
     }
     else
     {
         // TODO 4: Modify send method to include the proper eventType name value for queuing plate for manual review.
         // COMPLETE: await Send(...);
     }
 }
Exemple #5
0
        private async Task Send(string eventType, string subject, LicensePlateData data)
        {
            _log.LogInformation($"Sending license plate data to the {eventType} Event Grid type");

            var events = new List <EventGridEvent>()
            {
                new EventGridEvent()
                {
                    Data        = data,
                    EventTime   = DateTime.UtcNow,
                    EventType   = eventType,
                    Id          = Guid.NewGuid().ToString(),
                    Subject     = subject,
                    DataVersion = "v1"
                }
            };
            await _client.PublishEventsAsync(_topicHostname, events);

            _log.LogInformation($"Sent the following to the Event Grid topic: {events[0]}");
        }