/// <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); } }
/// <summary> /// Remove reflection id based in messageid /// </summary> /// <param name="reflectionMessageId">reflectionMessageId</param> /// <returns>messageid.</returns> public async Task <string> RemoveReflectionId(string reflectionMessageId) { string messageId = null; try { _telemetry.TrackEvent("RemoveMessageId"); ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry); FeedbackDataRepository feedbackDataRepository = new FeedbackDataRepository(_configuration, _telemetry); var reflection = await reflectionDataRepository.GetReflectionData(reflectionMessageId); messageId = reflection.MessageID; var feedbackCount = await feedbackDataRepository.GetFeedbackonRefId(reflection.ReflectionID); await feedbackDataRepository.DeleteAsync(feedbackCount); await reflectionDataRepository.DeleteAsync(reflection); } catch (Exception ex) { _telemetry.TrackException(ex); } return(messageId); }
/// <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); } }
/// <summary> /// Get the data from the Recurrence able storage based on the email id. /// </summary> /// <param name="email">email id of the creator of the reflection.</param> /// <returns>RecurssionScreenData model.</returns> public async Task <List <RecurssionScreenData> > GetRecurrencePostsDataAsync(string email) { _telemetry.TrackEvent("GetRecurrencePostsDataAsync"); try { ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry); QuestionsDataRepository questionsDataRepository = new QuestionsDataRepository(_configuration, _telemetry); RecurssionDataRepository recurssionDataRepository = new RecurssionDataRepository(_configuration, _telemetry); List <ReflectionDataEntity> allActiveRefs = await reflectionDataRepository.GetAllActiveReflection(email); List <Guid?> allActiveRefIDs = allActiveRefs.Select(c => c.ReflectionID).ToList(); List <Guid?> allActiveQuestionIDs = allActiveRefs.Select(c => c.QuestionID).ToList(); List <QuestionsDataEntity> allQuestionsData = await questionsDataRepository.GetAllQuestionData(allActiveQuestionIDs); List <RecurssionDataEntity> allRecurssionData = await recurssionDataRepository.GetAllRecurssionData(allActiveRefIDs); List <RecurssionScreenData> screenData = new List <RecurssionScreenData>(); foreach (var rec in allRecurssionData) { RecurssionScreenData recurssionScreenData = new RecurssionScreenData(); recurssionScreenData.RefID = rec.ReflectionID; var reflection = await reflectionDataRepository.GetReflectionData(rec.ReflectionID); recurssionScreenData.CreatedBy = reflection.CreatedBy; recurssionScreenData.RefCreatedDate = reflection.RefCreatedDate; recurssionScreenData.Privacy = reflection.Privacy; recurssionScreenData.Question = allQuestionsData.Where(c => c.QuestionID.ToString() == reflection.QuestionID.ToString()).Select(d => d.Question).FirstOrDefault().ToString(); recurssionScreenData.ExecutionDate = rec.ExecutionDate; recurssionScreenData.ExecutionTime = rec.ExecutionTime; recurssionScreenData.NextExecutionDate = rec.NextExecutionDate; recurssionScreenData.RecurssionType = rec.RecursstionType; recurssionScreenData.CustomRecurssionTypeValue = rec.CustomRecurssionTypeValue; recurssionScreenData.ScheduleId = rec.ScheduleId; if (recurssionScreenData.RecurssionType != null && recurssionScreenData.NextExecutionDate != null) { screenData.Add(recurssionScreenData); } } return(screenData); } catch (Exception ex) { _telemetry.TrackException(ex); return(null); } }
/// <summary> /// Delete recurrence data based on the reflection id /// </summary> /// <param name="reflectionId">reflectionId.</param> /// <returns>Null.</returns> public async Task DeleteRecurrsionDataAsync(Guid reflectionId) { try { _telemetry.TrackEvent("DeleteRecurrsionDataAsync"); ReflectionDataRepository reflectionDataRepository = new ReflectionDataRepository(_configuration, _telemetry); RecurssionDataRepository recurssionDataRepository = new RecurssionDataRepository(_configuration, _telemetry); var reflection = await reflectionDataRepository.GetReflectionData(reflectionId); var recurssion = await recurssionDataRepository.GetRecurssionData(reflection.RecurrsionID); await recurssionDataRepository.DeleteAsync(recurssion); await reflectionDataRepository.DeleteAsync(reflection); } catch (Exception ex) { _telemetry.TrackException(ex); } }
/// <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); } }
/// <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); } }