Exemplo n.º 1
0
        public static async Task DeliveryPostage(
            [QueueTrigger(QueueNames.CommSendPostage)] MessageDispatch sendMessage,
            [Table(TableNames.CommSchedule, CommSchedulePartitionKeys.InProgress, "{RowKey}")] TableEntityAdapter <MessageSchedule> schedule,
            [Table(TableNames.CommMessage, CommMessagePartitionKeys.Created, "{MessageReference}")] TableEntityAdapter <Message> message,
            [Table(TableNames.CommSchedule)] CloudTable scheduleTable,
            [Inject] App app,
            [Inject] IScheduleIdGenerator idGenerator,
            ILogger log)
        {
            if (schedule == null)
            {
                return;
            }

            var postage = message.GetMessageOf <Postage>();

            // handle unexpected non existing message
            if (postage == null)
            {
                await schedule.MoveTo(scheduleTable, s => CommSchedulePartitionKeys.Skipped).ConfigureAwait(false);

                return;
            }

            await schedule.MarkScheduleSent(scheduleTable, app, idGenerator);
        }
Exemplo n.º 2
0
        public static async Task <IEnumerable <MessageSchedule> > CreateScheduleActivity(
            [ActivityTrigger] IEnumerable <Message> messages,
            [Table(TableNames.CommSchedule)] CloudTable scheduleTable,
            [Inject] IScheduleIdGenerator idGenerator,
            [Inject] App app,
            ILogger log)
        {
            var result = await messages.Where(m => m.DeliveryOrder == 0)
                         .Select(m => m.IsOrMap <MessageSchedule>())
                         .CreateIn(scheduleTable,
                                   m => CommSchedulePartitionKeys.Scheduled,
                                   m => idGenerator.ScheduleId(m.DeliverySchedule)
                                   );

            return(result.GetResult <MessageSchedule>());
        }