Esempio n. 1
0
        /// <summary>
        /// Gets view reflections data.
        /// </summary>
        /// <param name="reflectionId">reflectionId.</param>
        /// <returns>A task that represents the work queued to execute.</returns>
        public async Task <ViewReflectionsEntity> GetViewReflectionsData(Guid reflectionId)
        {
            _telemetry.TrackEvent("GetViewReflectionsData");

            try
            {
                ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry);
                FeedbackDataRepository   feedbackDataRepository   = new FeedbackDataRepository(_configuration, _telemetry);
                ViewReflectionsEntity    viewReflectionsEntity    = new ViewReflectionsEntity();
                QuestionsDataRepository  questionsDataRepository  = new QuestionsDataRepository(_configuration, _telemetry);

                // Get reflection data
                ReflectionDataEntity refData = await reflectionDataRepository.GetReflectionData(reflectionId) ?? null;

                Dictionary <int, List <FeedbackDataEntity> > feedbackData = await feedbackDataRepository.GetReflectionFeedback(reflectionId) ?? null;

                List <QuestionsDataEntity> questions = await questionsDataRepository.GetQuestionsByQID(refData.QuestionID) ?? null;

                viewReflectionsEntity.ReflectionData = refData;
                viewReflectionsEntity.FeedbackData   = feedbackData;
                viewReflectionsEntity.Question       = questions.Find(x => x.QuestionID == refData.QuestionID);
                return(viewReflectionsEntity);
            }
            catch (Exception ex)
            {
                _telemetry.TrackException(ex);
                return(null);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Updates reflection message id.
 /// </summary>
 /// <param name="reflectionDataEntity">reflectionDataEntity.</param>
 /// <returns>Null.</returns>
 public async Task UpdateReflectionMessageIdAsync(ReflectionDataEntity reflectionDataEntity)
 {
     _telemetry.TrackEvent("SaveReflectionMessageIdAsync");
     try
     {
         ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry);
         await reflectionDataRepository.CreateOrUpdateAsync(reflectionDataEntity);
     }
     catch (Exception ex)
     {
         _telemetry.TrackException(ex);
     }
 }
        /// <summary>
        /// On Teams Task Module Submit Async.
        /// </summary>
        /// <param name="turnContext">turnContext.</param>
        /// <param name="taskModuleRequest">taskModuleRequest.</param>
        /// <param name="cancellationToken">cancellationToken.</param>
        /// <returns>.</returns>
        protected override async Task <TaskModuleResponse> OnTeamsTaskModuleSubmitAsync(ITurnContext <IInvokeActivity> turnContext, TaskModuleRequest taskModuleRequest, CancellationToken cancellationToken)
        {
            ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry);
            QuestionsDataRepository  questiondatarepository   = new QuestionsDataRepository(_configuration, _telemetry);
            FeedbackDataRepository   feedbackDataRepository   = new FeedbackDataRepository(_configuration, _telemetry);

            try
            {
                TaskInfo taskInfo = JsonConvert.DeserializeObject <TaskInfo>(taskModuleRequest.Data.ToString());
                var      reply    = Activity.CreateMessageActivity();

                // Check if message id is present in reflect data
                ReflectionDataEntity reflectData = await reflectionDataRepository.GetReflectionData(taskInfo.reflectionID);

                QuestionsDataEntity question = await questiondatarepository.GetQuestionData(reflectData.QuestionID);

                Dictionary <int, List <FeedbackDataEntity> > feedbacks = await feedbackDataRepository.GetReflectionFeedback(taskInfo.reflectionID);

                var adaptiveCard = _cardHelper.FeedBackCard(feedbacks, taskInfo.reflectionID, question.Question);

                Attachment attachment = new Attachment()
                {
                    ContentType = AdaptiveCard.ContentType,
                    Content     = adaptiveCard
                };
                reply.Attachments.Add(attachment);
                if (reflectData.MessageID == null)
                {
                    var result = turnContext.SendActivityAsync(reply, cancellationToken);
                    reflectData.MessageID = result.Result.Id;

                    // update messageid in reflection table
                    await reflectionDataRepository.InsertOrMergeAsync(reflectData);
                }
                else
                {
                    reply.Id = reflectData.MessageID;
                    await turnContext.UpdateActivityAsync(reply);
                }
                return(null);
            }
            catch (System.Exception e)
            {
                _telemetry.TrackException(e);
                Console.WriteLine(e.Message.ToString());
                return(null);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Save Edit Recursion Data Async.
        /// </summary>
        /// <param name="reflection">reflection.</param>
        /// <returns>.</returns>
        public async Task SaveEditRecurssionDataAsync(RecurssionScreenData reflection)
        {
            try
            {
                _telemetry.TrackEvent("SaveEditRecurssionDataAsync");
                ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry);
                RecurssionDataRepository recurssionDataRepository = new RecurssionDataRepository(_configuration, _telemetry);
                var reflectiondata = await reflectionDataRepository.GetReflectionData(reflection.RefID);

                var recurssion = await recurssionDataRepository.GetRecurssionData(reflectiondata.RecurrsionID);

                ReflectionDataEntity reflectionDataEntity = new ReflectionDataEntity();
                RecurssionDataEntity recurssionDataEntity = new RecurssionDataEntity();
                var reflectionid = Guid.NewGuid();
                var recurrsionid = Guid.NewGuid();
                reflectionDataEntity = reflectiondata;
                reflectionDataEntity.ReflectionID   = reflectionid;
                reflectionDataEntity.RefCreatedDate = DateTime.Now;
                reflectionDataEntity.RecurrsionID   = recurrsionid;
                reflectionDataEntity.RowKey         = Guid.NewGuid().ToString();
                await reflectionDataRepository.CreateAsync(reflectionDataEntity);

                recurssionDataEntity = recurssion;
                recurssionDataEntity.ReflectionID              = reflectionid;
                recurssionDataEntity.CreatedDate               = DateTime.Now;
                recurssionDataEntity.RecurssionID              = recurrsionid;
                recurssionDataEntity.RecursstionType           = reflection.RecurssionType;
                recurssionDataEntity.CustomRecurssionTypeValue = reflection.CustomRecurssionTypeValue;
                recurssionDataEntity.RowKey            = Guid.NewGuid().ToString();
                recurssionDataEntity.NextExecutionDate = reflection.NextExecutionDate;
                await recurssionDataRepository.CreateAsync(recurssionDataEntity);

                recurssion.NextExecutionDate = null;
                await recurssionDataRepository.CreateOrUpdateAsync(recurssion);
            }
            catch (Exception ex)
            {
                _telemetry.TrackException(ex);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Save Reflection data in Table Storage based on different conditions.
        /// </summary>
        /// <param name="taskInfo">This parameter is a ViewModel.</param>
        /// <returns>Null.</returns>
        public async Task SaveReflectionDataAsync(TaskInfo taskInfo)
        {
            _telemetry.TrackEvent("SaveReflectionDataAsync");
            try
            {
                ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry);
                QuestionsDataRepository  questionsDataRepository  = new QuestionsDataRepository(_configuration, _telemetry);

                if (taskInfo != null)
                {
                    taskInfo.reflectionID = Guid.NewGuid();
                    taskInfo.recurssionID = Guid.NewGuid();
                    if (taskInfo.questionID == null)
                    {
                        taskInfo.questionID = Guid.NewGuid();
                    }

                    ReflectionDataEntity reflectEntity = new ReflectionDataEntity
                    {
                        ReflectionID     = taskInfo.reflectionID,
                        PartitionKey     = PartitionKeyNames.ReflectionDataTable.ReflectionDataPartition,
                        RowKey           = taskInfo.reflectionRowKey,
                        CreatedBy        = taskInfo.postCreateBy,
                        CreatedByEmail   = taskInfo.postCreatedByEmail,
                        RefCreatedDate   = DateTime.Now,
                        QuestionID       = taskInfo.questionID,
                        Privacy          = taskInfo.privacy,
                        RecurrsionID     = taskInfo.recurssionID,
                        ChannelID        = taskInfo.channelID,
                        MessageID        = taskInfo.messageID,
                        SendNowFlag      = taskInfo.postSendNowFlag,
                        IsActive         = taskInfo.IsActive,
                        ReflectMessageId = taskInfo.reflectMessageId,
                        TenantId         = taskInfo.teantId,
                        ServiceUrl       = taskInfo.serviceUrl,
                        ScheduleId       = taskInfo.scheduleId
                    };
                    await reflectionDataRepository.InsertOrMergeAsync(reflectEntity);

                    if (await questionsDataRepository.IsQuestionAlreadyPresent(taskInfo.question, taskInfo.postCreatedByEmail) == false)
                    {
                        await SaveQuestionsDataAsync(taskInfo);
                    }
                    else
                    {
                        var ques = await questionsDataRepository.GetQuestionData(taskInfo.questionID);

                        taskInfo.questionRowKey = ques.RowKey;
                    }

                    if (!(taskInfo.postSendNowFlag == true))
                    {
                        await SaveRecurssionDataAsync(taskInfo);
                    }
                }
            }
            catch (Exception ex)
            {
                _telemetry.TrackException(ex);
            }
        }
        /// <summary>
        /// On message activity sync.
        /// </summary>
        /// <param name="turnContext">turnContext.</param>
        /// <param name="cancellationToken">cancellationToken.</param>
        /// <returns>.</returns>
        protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            _telemetry.TrackEvent("OnMessageActivityAsync");

            try
            {
                FeedbackDataRepository   feedbackDataRepository   = new FeedbackDataRepository(_configuration, _telemetry);
                ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry);
                RecurssionDataRepository recurssionDataRepository = new RecurssionDataRepository(_configuration, _telemetry);
                QuestionsDataRepository  questiondatarepository   = new QuestionsDataRepository(_configuration, _telemetry);

                if (turnContext.Activity.Value != null)
                {
                    var response = JsonConvert.DeserializeObject <UserfeedbackInfo>(turnContext.Activity.Value.ToString());
                    var reply    = Activity.CreateMessageActivity();
                    if (response.type == ReflectConstants.SaveFeedBack)
                    {
                        var name = (turnContext.Activity.From.Name).Split();
                        response.userName = name[0] + ' ' + name[1];
                        response.emailId  = await _dbHelper.GetUserEmailId(turnContext);

                        // Check if this is user's second feedback
                        FeedbackDataEntity feebackData = await feedbackDataRepository.GetReflectionFeedback(response.reflectionId, response.emailId);

                        if (feebackData != null && response.emailId == feebackData.FeedbackGivenBy)
                        {
                            feebackData.Feedback = response.feedbackId;
                            await feedbackDataRepository.CreateOrUpdateAsync(feebackData);
                        }
                        else
                        {
                            await _dbHelper.SaveReflectionFeedbackDataAsync(response);
                        }

                        try
                        {
                            // Check if message id is present in reflect data
                            ReflectionDataEntity reflectData = await reflectionDataRepository.GetReflectionData(response.reflectionId);

                            QuestionsDataEntity question = await questiondatarepository.GetQuestionData(reflectData.QuestionID);

                            Dictionary <int, List <FeedbackDataEntity> > feedbacks = await feedbackDataRepository.GetReflectionFeedback(response.reflectionId);

                            var      adaptiveCard = _cardHelper.FeedBackCard(feedbacks, response.reflectionId, question.Question);
                            TaskInfo taskInfo     = new TaskInfo();
                            taskInfo.question     = question.Question;
                            taskInfo.postCreateBy = reflectData.CreatedBy;
                            taskInfo.privacy      = reflectData.Privacy;
                            taskInfo.reflectionID = reflectData.ReflectionID;
                            Attachment attachment = new Attachment()
                            {
                                ContentType = AdaptiveCard.ContentType,
                                Content     = adaptiveCard
                            };
                            reply.Attachments.Add(attachment);
                            if (reflectData.MessageID == null)
                            {
                                var result = turnContext.SendActivityAsync(reply, cancellationToken);
                                reflectData.MessageID = result.Result.Id;
                                // update message-id in reflection table
                                await reflectionDataRepository.InsertOrMergeAsync(reflectData);
                            }
                            else
                            {
                                reply.Id = reflectData.MessageID;
                                await turnContext.UpdateActivityAsync(reply);
                            }
                        }
                        catch (System.Exception e)
                        {
                            _telemetry.TrackException(e);
                            Console.WriteLine(e.Message.ToString());
                        }
                    }
                }
                else
                {
                    await turnContext.SendActivityAsync(MessageFactory.Text($"Hello from Olga."), cancellationToken);
                }
            }
            catch (Exception ex)
            {
                _telemetry.TrackException(ex);
            }
        }
        /// <summary>
        /// On Teams Messaging Extension Submit Action Async.
        /// </summary>
        /// <param name="turnContext">turnContext.</param>
        /// <param name="action">action.</param>
        /// <param name="cancellationToken">cancellationToken.</param>
        /// <returns>.</returns>
        protected override async Task <MessagingExtensionActionResponse> OnTeamsMessagingExtensionSubmitActionAsync(ITurnContext <IInvokeActivity> turnContext, MessagingExtensionAction action, CancellationToken cancellationToken)
        {
            _telemetry.TrackEvent("OnTeamsMessagingExtensionSubmitActionAsync");
            ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry);

            try
            {
                TaskInfo taskInfo = JsonConvert.DeserializeObject <TaskInfo>(action.Data.ToString());
                switch (taskInfo.action)
                {
                case "reflection":
                    return(await OnTeamsMessagingExtensionFetchTaskAsync(turnContext, action, cancellationToken));

                case "sendAdaptiveCard":
                    try
                    {
                        var name = (turnContext.Activity.From.Name).Split();
                        taskInfo.postCreateBy       = name[0] + ' ' + name[1];
                        taskInfo.postCreatedByEmail = await _dbHelper.GetUserEmailId(turnContext);

                        taskInfo.channelID        = turnContext.Activity.TeamsGetChannelId();
                        taskInfo.postSendNowFlag  = (taskInfo.executionTime == "Send now") ? true : false;
                        taskInfo.IsActive         = true;
                        taskInfo.questionRowKey   = Guid.NewGuid().ToString();
                        taskInfo.recurrsionRowKey = Guid.NewGuid().ToString();
                        taskInfo.reflectionRowKey = Guid.NewGuid().ToString();
                        taskInfo.serviceUrl       = turnContext.Activity.ServiceUrl;
                        taskInfo.teantId          = turnContext.Activity.Conversation.TenantId;
                        taskInfo.scheduleId       = Guid.NewGuid().ToString();
                        await _dbHelper.SaveReflectionDataAsync(taskInfo);

                        if (taskInfo.postSendNowFlag == true)
                        {
                            var typingActivity = MessageFactory.Text(string.Empty);
                            typingActivity.Type = ActivityTypes.Typing;
                            await turnContext.SendActivityAsync(typingActivity);

                            var adaptiveCard = _cardHelper.CreateNewReflect(taskInfo);
                            var message      = MessageFactory.Attachment(new Attachment {
                                ContentType = AdaptiveCard.ContentType, Content = adaptiveCard
                            });
                            var resultid = await turnContext.SendActivityAsync(message, cancellationToken);

                            ReflectionDataEntity reflectData = await reflectionDataRepository.GetReflectionData(taskInfo.reflectionID);

                            reflectData.ReflectMessageId = resultid.Id;
                            await reflectionDataRepository.InsertOrMergeAsync(reflectData);

                            try
                            {
                                var feedbackCard = _cardHelper.FeedBackCard(new Dictionary <int, List <FeedbackDataEntity> >(), taskInfo.reflectionID, taskInfo.question);

                                Attachment attachmentfeedback = new Attachment()
                                {
                                    ContentType = AdaptiveCard.ContentType,
                                    Content     = feedbackCard,
                                };
                                using var connector = new ConnectorClient(new Uri(reflectData.ServiceUrl), _configuration["MicrosoftAppId"], _configuration["MicrosoftAppPassword"]);

                                var conversationId = $"{reflectData.ChannelID};messageid={reflectData.ReflectMessageId}";
                                var replyActivity  = MessageFactory.Attachment(new Attachment {
                                    ContentType = AdaptiveCard.ContentType, Content = feedbackCard
                                });
                                replyActivity.Conversation = new ConversationAccount(id: conversationId);
                                var resultfeedback = await connector.Conversations.SendToConversationAsync((Activity)replyActivity, cancellationToken);

                                reflectData.MessageID = resultfeedback.Id;
                                // update messageid in reflection table
                                await reflectionDataRepository.InsertOrMergeAsync(reflectData);
                            }
                            catch (System.Exception e)
                            {
                                _telemetry.TrackException(e);
                                Console.WriteLine(e.Message.ToString());
                            }
                        }
                        return(null);
                    }
                    catch (Exception ex)
                    {
                        _telemetry.TrackException(ex);
                        return(null);
                    }

                case "ManageRecurringPosts":
                    var postCreatedByEmail = await _dbHelper.GetUserEmailId(turnContext);

                    var response = new MessagingExtensionActionResponse()
                    {
                        Task = new TaskModuleContinueResponse()
                        {
                            Value = new TaskModuleTaskInfo()
                            {
                                Height = 600,
                                Width  = 780,
                                Title  = "Track how you're feeling every day.",
                                Url    = this._configuration["BaseUri"] + "/ManageRecurringPosts/" + postCreatedByEmail + "?pathfromindex=true"
                            },
                        },
                    };
                    return(response);

                case "OpenDetailfeedback":
                    var responsefeedback = new MessagingExtensionActionResponse()
                    {
                        Task = new TaskModuleContinueResponse()
                        {
                            Value = new TaskModuleTaskInfo()
                            {
                                Height = 600,
                                Width  = 780,
                                Title  = "Track how you're feeling every day.",
                                Url    = this._configuration["BaseUri"] + "/openReflectionFeedback/" + taskInfo.reflectionID + "/" + taskInfo.feedback,
                            },
                        },
                    };
                    return(responsefeedback);

                case "removeposts":
                    try
                    {
                        var activity = Activity.CreateMessageActivity();
                        if (taskInfo.isDelete)
                        {
                            var messageId = await _dbHelper.RemoveReflectionId(taskInfo.messageID);

                            if (messageId != null)
                            {
                                await turnContext.DeleteActivityAsync(messageId);
                            }
                            await turnContext.DeleteActivityAsync(taskInfo.messageID);

                            activity.Text = "This post has been removed";
                            await turnContext.SendActivityAsync(activity);

                            return(null);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    catch (Exception ex)
                    {
                        _telemetry.TrackException(ex);
                        return(null);
                    }

                default:
                    return(null);
                }
                ;
            }
            catch (Exception ex)
            {
                _telemetry.TrackException(ex);
                return(null);
            }
        }
        /// <summary>
        /// On Teams Task Module Fetch Async.
        /// </summary>
        /// <param name="turnContext">turnContext.</param>
        /// <param name="taskModuleRequest">taskModuleRequest.</param>
        /// <param name="cancellationToken">cancellationToken.</param>
        /// <returns>.</returns>
        protected override async Task <TaskModuleResponse> OnTeamsTaskModuleFetchAsync(ITurnContext <IInvokeActivity> turnContext, TaskModuleRequest taskModuleRequest, CancellationToken cancellationToken)
        {
            _telemetry.TrackEvent("OnTeamsTaskModuleFetchAsync");
            try
            {
                ReflctionData            reldata = JsonConvert.DeserializeObject <ReflctionData>(taskModuleRequest.Data.ToString());
                FeedbackDataRepository   feedbackDataRepository   = new FeedbackDataRepository(_configuration, _telemetry);
                ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry);
                RecurssionDataRepository recurssionDataRepository = new RecurssionDataRepository(_configuration, _telemetry);
                QuestionsDataRepository  questiondatarepository   = new QuestionsDataRepository(_configuration, _telemetry);
                var response = new UserfeedbackInfo();
                var name     = (turnContext.Activity.From.Name).Split();
                response.userName = name[0] + ' ' + name[1];
                response.emailId  = await _dbHelper.GetUserEmailId(turnContext);

                var reflectionid = reldata.datajson.ReflectionId;
                var feedbackId   = reldata.datajson.FeedbackId;
                response.reflectionId = reflectionid;
                response.feedbackId   = feedbackId;

                // Check if this is user's second feedback
                FeedbackDataEntity feebackData = await feedbackDataRepository.GetReflectionFeedback(response.reflectionId, response.emailId);

                TaskInfo taskInfo = new TaskInfo();
                if (response.feedbackId != 0)
                {
                    if (feebackData != null && response.emailId == feebackData.FeedbackGivenBy)
                    {
                        feebackData.Feedback = response.feedbackId;
                        await feedbackDataRepository.CreateOrUpdateAsync(feebackData);
                    }
                    else
                    {
                        await _dbHelper.SaveReflectionFeedbackDataAsync(response);
                    }

                    try
                    {
                        // Check if message id is present in reflect data
                        ReflectionDataEntity reflectData = await reflectionDataRepository.GetReflectionData(response.reflectionId);

                        QuestionsDataEntity question = await questiondatarepository.GetQuestionData(reflectData.QuestionID);

                        Dictionary <int, List <FeedbackDataEntity> > feedbacks = await feedbackDataRepository.GetReflectionFeedback(response.reflectionId);

                        var adaptiveCard = _cardHelper.FeedBackCard(feedbacks, response.reflectionId, question.Question);

                        taskInfo.question     = question.Question;
                        taskInfo.postCreateBy = reflectData.CreatedBy;
                        taskInfo.privacy      = reflectData.Privacy;
                        taskInfo.reflectionID = reflectData.ReflectionID;
                        Attachment attachment = new Attachment()
                        {
                            ContentType = AdaptiveCard.ContentType,
                            Content     = adaptiveCard,
                        };
                        var reply = Activity.CreateMessageActivity();
                        reply.Attachments.Add(attachment);
                        if (reflectData.MessageID == null)
                        {
                            var result = turnContext.SendActivityAsync(reply, cancellationToken);
                            reflectData.MessageID = result.Result.Id;

                            // update messageid in reflection table
                            await reflectionDataRepository.InsertOrMergeAsync(reflectData);
                        }
                        else
                        {
                            reply.Id = reflectData.MessageID;
                            await turnContext.UpdateActivityAsync(reply);
                        }
                    }
                    catch (System.Exception e)
                    {
                        _telemetry.TrackException(e);
                        Console.WriteLine(e.Message.ToString());
                    }
                }

                return(new TaskModuleResponse
                {
                    Task = new TaskModuleContinueResponse
                    {
                        Value = new TaskModuleTaskInfo()
                        {
                            Height = 600,
                            Width = 600,
                            Title = "Track how you're feeling every day.",
                            Url = reldata.data.URL + reflectionid + '/' + feedbackId + '/' + response.userName,
                        },
                    },
                });
            }
            catch (Exception ex)
            {
                _telemetry.TrackException(ex);
                return(null);
            }
        }
        /// <summary>
        /// RunJob.
        /// </summary>
        /// <param name="state">state.</param>
        private async void RunJob(object state)
        {
            _telemetry.TrackEvent("RunJob");
            try
            {
                ChannelAccount   channelAccount = new ChannelAccount(_configuration["MicrosoftAppId"]);
                Attachment       attachment     = new Attachment();
                TeamsChannelData channelData    = new TeamsChannelData()
                {
                    Notification = new NotificationInfo(true)
                };
                RecurssionDataRepository recurssionDataRepository = new RecurssionDataRepository(_configuration, _telemetry);
                ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry);
                QuestionsDataRepository  questiondatarepository   = new QuestionsDataRepository(_configuration, _telemetry);

                var recurssionData = await recurssionDataRepository.GetAllRecurssionData();

                foreach (RecurssionDataEntity recurssionDataEntity in recurssionData)
                {
                    var reflectionData = await reflectionDataRepository.GetReflectionData(recurssionDataEntity.ReflectionID);

                    var question = await questiondatarepository.GetQuestionData(reflectionData.QuestionID);

                    TaskInfo taskInfo = new TaskInfo();
                    taskInfo.question     = question.Question;
                    taskInfo.postCreateBy = reflectionData.CreatedBy;
                    taskInfo.privacy      = reflectionData.Privacy;
                    taskInfo.reflectionID = reflectionData.ReflectionID;
                    var        newPostCard           = _cardHelper.CreateNewReflect(taskInfo);
                    Attachment newPostCardAttachment = new Attachment()
                    {
                        ContentType = AdaptiveCard.ContentType,
                        Content     = newPostCard
                    };
                    var        PostCardFeedback           = _cardHelper.FeedBackCard(new Dictionary <int, List <FeedbackDataEntity> >(), taskInfo.reflectionID, taskInfo.question);;
                    Attachment PostCardFeedbackAttachment = new Attachment()
                    {
                        ContentType = AdaptiveCard.ContentType,
                        Content     = PostCardFeedback
                    };
                    var proactiveNotification = await new ProactiveMessageHelper(_configuration).SendChannelNotification(channelAccount, reflectionData.ServiceUrl, reflectionData.ChannelID, "", newPostCardAttachment);
                    if (proactiveNotification.IsSuccessful && proactiveNotification.MessageId != null)
                    {
                        reflectionData.ReflectMessageId = proactiveNotification.MessageId.Split("=")[1];
                        var feedbackproactivemessage = await new ProactiveMessageHelper(_configuration).SendChannelNotification(channelAccount, reflectionData.ServiceUrl, reflectionData.ChannelID, "", PostCardFeedbackAttachment, reflectionData.ReflectMessageId);
                        if (feedbackproactivemessage.IsSuccessful && proactiveNotification.MessageId != null)
                        {
                            reflectionData.MessageID = feedbackproactivemessage.MessageId;
                            await _dbHelper.UpdateReflectionMessageIdAsync(reflectionData);
                        }
                    }

                    var calculatedNextExecutionDateTime = _dbHelper.GetCalculatedNextExecutionDateTimeAsync(recurssionDataEntity);
                    recurssionDataEntity.NextExecutionDate = null;
                    await recurssionDataRepository.CreateOrUpdateAsync(recurssionDataEntity);

                    if (calculatedNextExecutionDateTime != null)
                    {
                        ReflectionDataEntity newreflectionDataEntity = new ReflectionDataEntity();
                        RecurssionDataEntity newRecurssionDataEntity = new RecurssionDataEntity();
                        var reflectionid = Guid.NewGuid();
                        var recurrsionid = Guid.NewGuid();
                        newreflectionDataEntity                = reflectionData;
                        newreflectionDataEntity.RowKey         = Guid.NewGuid().ToString();
                        newreflectionDataEntity.ReflectionID   = reflectionid;
                        newreflectionDataEntity.RefCreatedDate = DateTime.Now;
                        newreflectionDataEntity.RecurrsionID   = recurrsionid;
                        await reflectionDataRepository.CreateAsync(newreflectionDataEntity);

                        newRecurssionDataEntity                   = recurssionDataEntity;
                        newRecurssionDataEntity.RowKey            = Guid.NewGuid().ToString();
                        newRecurssionDataEntity.ReflectionID      = reflectionid;
                        newRecurssionDataEntity.CreatedDate       = DateTime.Now;
                        newRecurssionDataEntity.RecurssionID      = recurrsionid;
                        newRecurssionDataEntity.NextExecutionDate = calculatedNextExecutionDateTime;
                        await recurssionDataRepository.CreateAsync(newRecurssionDataEntity);
                    }
                }
            }
            catch (Exception ex)
            {
                _telemetry.TrackException(ex);
            }
        }