Пример #1
0
        /// <inheritdoc />
        protected override async Task <ExecutionResult <string> > ExecuteCoreAsync(Activity activity, string arguments)
        {
            Logger.LogInformation(
                "Creating a manage link for channel '{0}' and conversation '{1}'",
                activity.ChannelId,
                activity.Conversation.Id);

            string linkId = webUtility.GenerateRandomUrlCompatibleString(linkIdLength);
            ManageConversationLink manageConversationLink = CreateManageConversationLink(activity, linkId);

            await UnitOfWork.ManageConversationLinks.AddAsync(manageConversationLink);

            await UnitOfWork.SaveChangesAsync();

            Logger.LogInformation(
                "Created the manage link '{0}' for channel '{1}' and conversation '{2}'",
                manageConversationLink.Text,
                activity.ChannelId,
                activity.Conversation.Id);

            string manageUrl = webUtility.GenerateUrl(
                applicationContext.Protocol,
                applicationContext.Host,
                "manage",
                linkId);

            return(manageUrl);
        }
        public async Task <IActionResult> Get(string manageId)
        {
            logger.LogInformation("Attempting to gather managing information for the id '{0}'", manageId);

            IActionResult          actionResult;
            ManageConversationLink manageLink = await manageConversationLinkService.GetByTextAsync(manageId);

            if (manageLink != null)
            {
                logger.LogInformation("Returning managing information for the id '{0}'", manageId);
                actionResult = Ok(GetConversationScheduledMessageModelsAsync(manageLink));
            }
            else
            {
                logger.LogInformation("No managing information has been found for the id '{0}'", manageId);
                actionResult = NotFound();
            }

            return(actionResult);
        }
Пример #3
0
        /// <inheritdoc />
        public async Task <ExecutionResult> ValidateAndMarkVisitedAsync(string manageId)
        {
            ManageConversationLink manageLink = await UnitOfWork.ManageConversationLinks.GetByTextAsync(manageId);

            if (manageLink != null && !manageLink.IsVisited && manageLink.ExpiresOn > DateTime.UtcNow)
            {
                Logger.LogInformation("Marking manage conversation id '{0}' as visited", manageId);

                manageLink.IsVisited = true;

                await UnitOfWork.SaveChangesAsync();

                return(ExecutionResult.Success());
            }

            string errorMessage =
                $"No managing information has been found for the id '{manageId}'.Either the link does not exist or is has expired";

            Logger.LogInformation(errorMessage);
            return(ExecutionResult.Error(ExecutionErrorCode.ManageConversationLinkCannotBeFound, errorMessage));
        }
        private async Task <IList <ScheduledMessageModel> > GetConversationScheduledMessageModelsAsync(ManageConversationLink manageLink)
        {
            IList <ScheduledMessageDetails> scheduledMessageDetails =
                await scheduledMessageDetailsService.GetByManageConversationLinkAsync(manageLink);

            List <ScheduledMessageModel> scheduledMessageModels
                = scheduledMessageDetails.Select(CreateScheduledMessageModel).ToList();

            return(scheduledMessageModels);
        }
        /// <inheritdoc />
        public async Task <IList <ScheduledMessageDetails> > GetByManageConversationLinkAsync(ManageConversationLink manageLink)
        {
            IList <ScheduledMessageDetails> scheduledMessageDetails =
                await UnitOfWork.ScheduledMessageDetails.GetScheduledMessageDetailsWithEventsAsync(manageLink.ChannelId, manageLink.ConversationId);

            return(scheduledMessageDetails);
        }
Пример #6
0
        /// <inheritdoc />
        public async Task <ManageConversationLink> GetByTextAsync(string text)
        {
            ManageConversationLink manageConversationLink = await UnitOfWork.ManageConversationLinks.GetByTextAsync(text);

            return(manageConversationLink);
        }