public async Task NewFile(string fileUri)
        {
            var newCustomerFile = CustomerBlobAttributes.Parse(fileUri);

            _logger.LogInformation($@"Got new file via event: {newCustomerFile.TransactionType}");

            if (newCustomerFile.TransactionType == "order")
            {
                this.IsPaymentReceived = true;
            }
            else if (newCustomerFile.TransactionType == "payment")
            {
                this.IsOrderReceived = true;
            }

            _logger.LogTrace($@"Actor '{_id}' got file '{newCustomerFile.TransactionType}'");

            if (this.IsOrderReceived && this.IsPaymentReceived)
            {
                _logger.LogInformation(@"Payment received...");

                // call next step in functions with the prefix so it knows what to go grab
                await Helpers.CreateShippingLabel(newCustomerFile.OrderId, _logger);
            }
            else
            {
                _logger.LogInformation($@"Waiting for Payment.....");
            }
        }
Exemple #2
0
        public static CustomerBlobAttributes ParseEventGridPayload(dynamic eventGridItem, ILogger log)
        {
            if (eventGridItem.eventType == @"Microsoft.Storage.BlobCreated" &&
                eventGridItem.data.api == @"PutBlob" &&
                eventGridItem.data.contentType == @"application/vnd.ms-excel")
            {
                try
                {
                    var retVal = CustomerBlobAttributes.Parse((string)eventGridItem.data.url);
                    return(retVal);
                }
                catch (Exception ex)
                {
                    log.LogError(@"Error parsing Event Grid payload", ex);
                }
            }

            return(null);
        }