Exemplo n.º 1
0
        private async Task SendEventNotofication(ITurnContext turnContext, string eventMessage)
        {
            PasswordNotfications notifications = await _passwordNotificationsPropertyAccessor.GetAsync(turnContext, () => new PasswordNotfications());

            PasswordEventNotification passwordEventNotification = JsonConvert.DeserializeObject <PasswordEventNotification>(eventMessage);

            PasswordNotfications.NotificationData eventUserData = notifications[passwordEventNotification.PasswordEvent.UserID];

            await SendNotificationsAsync(turnContext.Adapter, AppId, eventUserData, passwordEventNotification);
        }
Exemplo n.º 2
0
 private async Task SendNotificationsAsync(
     BotAdapter adapter,
     string botId,
     PasswordNotfications.NotificationData notification,
     PasswordEventNotification passwordEventNotification,
     CancellationToken cancellationToken = default(CancellationToken)
     )
 {
     await adapter.ContinueConversationAsync(botId, notification.Conversation, CreateCallback(notification, passwordEventNotification), cancellationToken);
 }
Exemplo n.º 3
0
        // Creates the turn logic to use for the proactive message.
        private BotCallbackHandler CreateCallback(PasswordNotfications.NotificationData notification, PasswordEventNotification passwordEventNotification)
        {
            return(async(turnContext, token) =>
            {
                // Get the job log from state, and retrieve the job.
                PasswordNotfications notifications = await _passwordNotificationsPropertyAccessor.GetAsync(turnContext, () => new PasswordNotfications());

                // Set the new property
                await _passwordNotificationsPropertyAccessor.SetAsync(turnContext, notifications);

                // Now save it into the JobState
                await _notificationState.SaveChangesAsync(turnContext);

                // Send the user a proactive confirmation message.
                await turnContext.SendActivityAsync($"Password for {notification.UserID} is about to expire on {passwordEventNotification.PasswordEvent.PasswordExpirationDate}.");
            });
        }