Ejemplo n.º 1
0
        public static async Task <TravelPlan> TravelBooking(
            [ActivityTrigger] TravelPlan upComingTrip,
            [Queue("YourTrips", Connection = "AzureWebJobsStorage")] IAsyncCollector <TravelPlan> trips,
            ILogger log)
        {
            log.LogInformation($"{TRAVELBOOKING}:{upComingTrip.TripName}");
            log.LogInformation($"{TRAVELBOOKING}:add booking fee 5%");
            // function custom binding for storage access - queue
            upComingTrip = WFBusinessData.AdminProcess(upComingTrip, 0.05m);
            await trips.AddAsync(upComingTrip);

            await Task.Delay(5000);

            return(upComingTrip);
        }
Ejemplo n.º 2
0
        public static async Task TravelConfirmation(
            [ActivityTrigger] TravelPlan upComingTrip,
            [Blob("tripsconfirmation", Connection = "AzureWebJobsStorage")] CloudBlobContainer container,
            ILogger log)
        {
            await container.CreateIfNotExistsAsync();

            var blobRef = container.GetBlockBlobReference($"{upComingTrip.TripName}{Guid.NewGuid().ToString()}.txt");

            // function custom binding for storage access - blob
            upComingTrip = WFBusinessData.AdminProcess(upComingTrip, 0.05m);

            await blobRef.UploadTextAsync($"Confirmation of travel trip: {upComingTrip.TripName} | {upComingTrip.TravelBy} | {upComingTrip.TravelDistance} miles | ${upComingTrip.TravelCost} Have a nice trip!");

            log.LogInformation($"{TRAVELCONFIRMATION}:{upComingTrip.TripName}");
            log.LogInformation($"{TRAVELCONFIRMATION}:add closing fee 5%");
        }
Ejemplo n.º 3
0
        public static async Task BookingRun([QueueTrigger("YourTrips", Connection = "AzureWebJobsStorage")] TravelPlan myQueueItem,
                                            [Table("TripBookings", Connection = "AzureWebJobsStorage")] IAsyncCollector <TravelPlan> tripBookings,
                                            ILogger log)
        {
            log.LogInformation($"BookingConfirmation: {myQueueItem.TripName}");

            await tripBookings.AddAsync(myQueueItem);

            // blob storage output
            if (CloudStorageAccount.TryParse(WFActivities.BLOBSTORAGECONNSTRING, out var storageAccount))
            {
                var container = storageAccount.CreateCloudBlobClient().GetContainerReference("tripsbookings");

                await container.CreateIfNotExistsAsync();

                var blobRef = container.GetBlockBlobReference($"{myQueueItem.TripName}{Guid.NewGuid().ToString()}.txt");

                log.LogInformation($"Booking receipt:{myQueueItem.TripName}");

                await blobRef.UploadTextAsync($"Receipt of travel trip: {myQueueItem.TripName} | {myQueueItem.TravelBy} | {myQueueItem.TravelDistance} miles | ${myQueueItem.TravelCost} Have a nice trip!");

                await Task.Delay(5000);
            }
        }
Ejemplo n.º 4
0
        public static async Task <TravelPlan> TravelRegistration(
            [ActivityTrigger] TravelPlan upComingTrip,
            [Table("TripOutings", Connection = "AzureWebJobsStorage")] IAsyncCollector <TravelPlan> trips,
            ILogger log)
        {
            // RowKey | PartitionKey | ETag {null}
            log.LogInformation($"{TRAVELREGISTRATION}:{upComingTrip.TripName}");
            log.LogInformation($"{TRAVELREGISTRATION}:add registration fee 10%");

            // function custom binding for storage access - table

            // table storage entity mapping (from|to runtime context business object)
            // before inserting a table entity record
            upComingTrip = WFBusinessData.AdminProcess(upComingTrip, 0.10m);
            upComingTrip.PartitionKey = "YourTrips";
            upComingTrip.RowKey       = Guid.NewGuid().ToString();
            // upComingTrip.ETag = "*";

            await trips.AddAsync(upComingTrip);

            await Task.Delay(5000);

            return(upComingTrip);
        }
Ejemplo n.º 5
0
 public static TravelPlan AdminProcess(TravelPlan trip, decimal rates)
 {
     trip.TravelCost = trip.TravelCost * (1 + rates);
     return(trip);
 }