/// <summary> /// Initializes a new instance of the <see cref="SentNotificationsController"/> class. /// </summary> /// <param name="notificationDataRepository">Notification data repository service that deals with the table storage in azure.</param> /// <param name="sentNotificationDataRepository">Sent notification data repository.</param> /// <param name="teamDataRepository">Team data repository instance.</param> /// <param name="prepareToSendQueue">The service bus queue for preparing to send notifications.</param> /// <param name="dataQueue">The service bus queue for the data queue.</param> /// <param name="dataQueueMessageOptions">The options for the data queue messages.</param> /// <param name="groupsService">The groups service.</param> /// <param name="exportDataRepository">The Export data repository instance.</param> /// <param name="appCatalogService">App catalog service.</param> /// <param name="appSettingsService">App settings service.</param> /// <param name="userAppOptions">User app options.</param> /// <param name="loggerFactory">The logger factory.</param> public SentNotificationsController( NotificationDataRepository notificationDataRepository, SentNotificationDataRepository sentNotificationDataRepository, TeamDataRepository teamDataRepository, PrepareToSendQueue prepareToSendQueue, DataQueue dataQueue, IOptions <DataQueueMessageOptions> dataQueueMessageOptions, IGroupsService groupsService, ExportDataRepository exportDataRepository, IAppCatalogService appCatalogService, IAppSettingsService appSettingsService, IOptions <UserAppOptions> userAppOptions, ILoggerFactory loggerFactory) { if (dataQueueMessageOptions is null) { throw new ArgumentNullException(nameof(dataQueueMessageOptions)); } this.notificationDataRepository = notificationDataRepository ?? throw new ArgumentNullException(nameof(notificationDataRepository)); this.sentNotificationDataRepository = sentNotificationDataRepository ?? throw new ArgumentNullException(nameof(sentNotificationDataRepository)); this.teamDataRepository = teamDataRepository ?? throw new ArgumentNullException(nameof(teamDataRepository)); this.prepareToSendQueue = prepareToSendQueue ?? throw new ArgumentNullException(nameof(prepareToSendQueue)); this.dataQueue = dataQueue ?? throw new ArgumentNullException(nameof(dataQueue)); this.forceCompleteMessageDelayInSeconds = dataQueueMessageOptions.Value.ForceCompleteMessageDelayInSeconds; this.groupsService = groupsService ?? throw new ArgumentNullException(nameof(groupsService)); this.exportDataRepository = exportDataRepository ?? throw new ArgumentNullException(nameof(exportDataRepository)); this.appCatalogService = appCatalogService ?? throw new ArgumentNullException(nameof(appCatalogService)); this.appSettingsService = appSettingsService ?? throw new ArgumentNullException(nameof(appSettingsService)); this.userAppOptions = userAppOptions?.Value ?? throw new ArgumentNullException(nameof(userAppOptions)); this.logger = loggerFactory?.CreateLogger <SentNotificationsController>() ?? throw new ArgumentNullException(nameof(loggerFactory)); }
/// <summary> /// Initializes a new instance of the <see cref="TeamsDataCapture"/> class. /// </summary> /// <param name="teamDataRepository">Team data repository instance.</param> /// <param name="userDataRepository">User data repository instance.</param> public TeamsDataCapture( TeamDataRepository teamDataRepository, UserDataRepository userDataRepository) { this.teamDataRepository = teamDataRepository; this.userDataRepository = userDataRepository; }
/// <summary> /// Initializes a new instance of the <see cref="SentNotificationsController"/> class. /// </summary> /// <param name="notificationDataRepository">Notification data repository service that deals with the table storage in azure.</param> /// <param name="notificationDelivery">Notification delivery service instance.</param> /// <param name="teamDataRepository">Team data repository instance.</param> public SentNotificationsController( NotificationDataRepository notificationDataRepository, NotificationDelivery notificationDelivery, TeamDataRepository teamDataRepository) { this.notificationDataRepository = notificationDataRepository; this.notificationDelivery = notificationDelivery; this.teamDataRepository = teamDataRepository; }
/// <summary> /// Initializes a new instance of the <see cref="TeamsDataCapture"/> class. /// </summary> /// <param name="teamDataRepository">Team data repository instance.</param> /// <param name="userDataRepository">User data repository instance.</param> /// <param name="appSettingsService">App Settings service.</param> public TeamsDataCapture( TeamDataRepository teamDataRepository, UserDataRepository userDataRepository, IAppSettingsService appSettingsService) { this.teamDataRepository = teamDataRepository ?? throw new ArgumentNullException(nameof(teamDataRepository)); this.userDataRepository = userDataRepository ?? throw new ArgumentNullException(nameof(userDataRepository)); this.appSettingsService = appSettingsService ?? throw new ArgumentNullException(nameof(appSettingsService)); }
/// <summary> /// Initializes a new instance of the <see cref="DraftNotificationsController"/> class. /// </summary> /// <param name="notificationDataRepository">Notification data repository instance.</param> /// <param name="teamDataRepository">Team data repository instance.</param> /// <param name="draftNotificationPreviewService">Draft notification preview service.</param> public DraftNotificationsController( NotificationDataRepository notificationDataRepository, TeamDataRepository teamDataRepository, DraftNotificationPreviewService draftNotificationPreviewService) { this.notificationDataRepository = notificationDataRepository; this.teamDataRepository = teamDataRepository; this.draftNotificationPreviewService = draftNotificationPreviewService; }
/// <summary> /// Initializes a new instance of the <see cref="TeamDataController"/> class. /// </summary> /// <param name="teamDataRepository">Team data repository instance.</param> /// <param name="loggerFactory">The logger factory.</param> /// <param name="groupDataService">Group data service instance.</param> public TeamDataController( TeamDataRepository teamDataRepository, ILoggerFactory loggerFactory, IGroupsService groupDataService) { this.teamDataRepository = teamDataRepository ?? throw new ArgumentNullException(nameof(teamDataRepository)); this.logger = loggerFactory?.CreateLogger <TeamDataController>() ?? throw new ArgumentNullException(nameof(loggerFactory)); this.groupDataService = groupDataService ?? throw new ArgumentNullException(nameof(groupDataService)); }
/// <summary> /// Initializes a new instance of the <see cref="DataStreamFacade"/> class. /// </summary> /// <param name="sentNotificationDataRepository">the sent notification data repository.</param> /// <param name="teamDataRepository">the team data repository.</param> /// <param name="usersService">the users service.</param> public DataStreamFacade( SentNotificationDataRepository sentNotificationDataRepository, TeamDataRepository teamDataRepository, IUsersService usersService) { this.sentNotificationDataRepository = sentNotificationDataRepository; this.teamDataRepository = teamDataRepository; this.usersService = usersService; }
/// <summary> /// Initializes a new instance of the <see cref="MetadataProvider"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="userDataRepository">User Data repository service.</param> /// <param name="teamDataRepository">Team Data repository service.</param> public MetadataProvider( IConfiguration configuration, UserDataRepository userDataRepository, TeamDataRepository teamDataRepository) { this.configuration = configuration; this.userDataRepository = userDataRepository; this.teamDataRepository = teamDataRepository; }
/// <summary> /// Initializes a new instance of the <see cref="GetTeamDataEntitiesByIdsActivity"/> class. /// </summary> /// <param name="teamDataRepository">Team Data repository.</param> /// <param name="notificationDataRepository">Notification data entity repository.</param> /// <param name="localizer">Localization service.</param> public GetTeamDataEntitiesByIdsActivity( TeamDataRepository teamDataRepository, NotificationDataRepository notificationDataRepository, IStringLocalizer <Strings> localizer) { this.teamDataRepository = teamDataRepository; this.notificationDataRepository = notificationDataRepository; this.localizer = localizer; }
/// <summary> /// Initializes a new instance of the <see cref="TeamsDataCapture"/> class. /// </summary> /// <param name="teamDataRepository">Team data repository instance.</param> /// <param name="userDataRepository">User data repository instance.</param> /// <param name="sentNotificationDataRepository">sentNotificationDataRepository Data Repository instance.</param> public TeamsDataCapture( TeamDataRepository teamDataRepository, UserDataRepository userDataRepository, SentNotificationDataRepository sentNotificationDataRepository) { this.teamDataRepository = teamDataRepository; this.userDataRepository = userDataRepository; this.sentNotificationDataRepository = sentNotificationDataRepository; }
/// <summary> /// Initializes a new instance of the <see cref="SyncTeamsActivity"/> class. /// </summary> /// <param name="teamDataRepository">Team Data repository.</param> /// <param name="sentNotificationDataRepository">Sent notification data repository.</param> /// <param name="localizer">Localization service.</param> /// <param name="notificationDataRepository">Notification data entity repository.</param> public SyncTeamsActivity( TeamDataRepository teamDataRepository, SentNotificationDataRepository sentNotificationDataRepository, IStringLocalizer <Strings> localizer, NotificationDataRepository notificationDataRepository) { this.teamDataRepository = teamDataRepository ?? throw new ArgumentNullException(nameof(teamDataRepository)); this.sentNotificationDataRepository = sentNotificationDataRepository ?? throw new ArgumentNullException(nameof(sentNotificationDataRepository)); this.localizer = localizer ?? throw new ArgumentNullException(nameof(localizer)); this.notificationDataRepository = notificationDataRepository ?? throw new ArgumentNullException(nameof(notificationDataRepository)); }
/// <summary> /// Initializes a new instance of the <see cref="DataStreamFacade"/> class. /// </summary> /// <param name="sentNotificationDataRepository">the sent notification data repository.</param> /// <param name="teamDataRepository">the team data repository.</param> /// <param name="usersService">the users service.</param> /// <param name="localizer">Localization service.</param> public DataStreamFacade( SentNotificationDataRepository sentNotificationDataRepository, TeamDataRepository teamDataRepository, IUsersService usersService, IStringLocalizer <Strings> localizer) { this.sentNotificationDataRepository = sentNotificationDataRepository; this.teamDataRepository = teamDataRepository; this.usersService = usersService; this.localizer = localizer ?? throw new ArgumentNullException(nameof(localizer)); }
/// <summary> /// Add channel data in Table Storage. /// </summary> /// <param name="teamDataRepository">The team data repository.</param> /// <param name="activity">Bot conversation update activity instance.</param> /// <returns>A task that represents the work queued to execute.</returns> public static async Task SaveTeamDataAsync( this TeamDataRepository teamDataRepository, IConversationUpdateActivity activity) { var teamDataEntity = TeamDataRepositoryExtensions.ParseTeamData(activity); if (teamDataEntity != null) { await teamDataRepository.CreateOrUpdateAsync(teamDataEntity); } }
/// <summary> /// Initializes a new instance of the <see cref="MetadataProvider"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="userDataRepository">User Data repository service.</param> /// <param name="teamDataRepository">Team Data repository service.</param> /// <param name="notificationDataRepository">Notification data repository service.</param> /// <param name="adGroupsDataRepository">AD Groups data repository service.</param> public MetadataProvider( IConfiguration configuration, UserDataRepository userDataRepository, TeamDataRepository teamDataRepository, NotificationDataRepository notificationDataRepository, ADGroupsDataRepository adGroupsDataRepository) { this.configuration = configuration; this.userDataRepository = userDataRepository; this.teamDataRepository = teamDataRepository; this.notificationDataRepository = notificationDataRepository; this.adGroupsDataRepository = adGroupsDataRepository; }
/// <summary> /// Initializes a new instance of the <see cref="DraftNotificationsController"/> class. /// </summary> /// <param name="notificationDataRepository">Notification data repository instance.</param> /// <param name="teamDataRepository">Team data repository instance.</param> /// <param name="draftNotificationPreviewService">Draft notification preview service.</param> /// <param name="localizer">Localization service.</param> /// <param name="groupsService">group service.</param> public DraftNotificationsController( NotificationDataRepository notificationDataRepository, TeamDataRepository teamDataRepository, DraftNotificationPreviewService draftNotificationPreviewService, IStringLocalizer <Strings> localizer, IGroupsService groupsService) { this.notificationDataRepository = notificationDataRepository; this.teamDataRepository = teamDataRepository; this.draftNotificationPreviewService = draftNotificationPreviewService; this.localizer = localizer; this.groupsService = groupsService; }
/// <summary> /// Initializes a new instance of the <see cref="ScheduleNotificationDelivery"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="notificationDataRepository">Notification repository service.</param> /// <param name="metadataProvider">Meta data Provider instance.</param> /// <param name="sendingNotificationCreator">SendingNotification creator.</param> /// <param name="scheduleNotificationDataRepository">Schedule Notification data repository.</param> /// <param name="teamDataRepository">TeamData Repository instance.</param> public ScheduleNotificationDelivery( IConfiguration configuration, NotificationDataRepository notificationDataRepository, MetadataProvider metadataProvider, SendingNotificationCreator sendingNotificationCreator, ScheduleNotificationDataRepository scheduleNotificationDataRepository, TeamDataRepository teamDataRepository) { this.configuration = configuration; this.notificationDataRepository = notificationDataRepository; this.metadataProvider = metadataProvider; this.sendingNotificationCreator = sendingNotificationCreator; this.scheduleNotificationDataRepository = scheduleNotificationDataRepository; this.teamDataRepository = teamDataRepository; }
/// <summary> /// Initializes a new instance of the <see cref="SyncTeamMembersActivity"/> class. /// </summary> /// <param name="teamDataRepository">Team Data repository.</param> /// <param name="memberService">Teams member service.</param> /// <param name="notificationDataRepository">Notification data repository.</param> /// <param name="sentNotificationDataRepository">Sent notification data repository.</param> /// <param name="localizer">Localization service.</param> /// <param name="userDataRepository">User Data repository.</param> public SyncTeamMembersActivity( TeamDataRepository teamDataRepository, ITeamMembersService memberService, NotificationDataRepository notificationDataRepository, SentNotificationDataRepository sentNotificationDataRepository, IStringLocalizer <Strings> localizer, UserDataRepository userDataRepository) { this.teamDataRepository = teamDataRepository ?? throw new ArgumentNullException(nameof(teamDataRepository)); this.memberService = memberService ?? throw new ArgumentNullException(nameof(memberService)); this.notificationDataRepository = notificationDataRepository ?? throw new ArgumentNullException(nameof(notificationDataRepository)); this.sentNotificationDataRepository = sentNotificationDataRepository ?? throw new ArgumentNullException(nameof(sentNotificationDataRepository)); this.localizer = localizer ?? throw new ArgumentNullException(nameof(localizer)); this.userDataRepository = userDataRepository ?? throw new ArgumentNullException(nameof(userDataRepository)); }
/// <summary> /// Remove channel data in table storage. /// </summary> /// <param name="teamDataRepository">The team data repository.</param> /// <param name="activity">Bot conversation update activity instance.</param> /// <returns>A task that represents the work queued to execute.</returns> public static async Task RemoveTeamDataAsync( this TeamDataRepository teamDataRepository, IConversationUpdateActivity activity) { var teamDataEntity = TeamDataRepositoryExtensions.ParseTeamData(activity); if (teamDataEntity != null) { var found = await teamDataRepository.GetAsync(PartitionKeyNames.TeamDataTable.TeamDataPartition, teamDataEntity.TeamId); if (found != null) { await teamDataRepository.DeleteAsync(found); } } }
/// <summary> /// Initializes a new instance of the <see cref="SentNotificationsController"/> class. /// </summary> /// <param name="notificationDataRepository">Notification data repository service that deals with the table storage in azure.</param> /// <param name="sentNotificationDataRepository">Sent notification data repository.</param> /// <param name="teamDataRepository">Team data repository instance.</param> /// <param name="prepareToSendQueue">The service bus queue for preparing to send notifications.</param> /// <param name="dataQueue">The service bus queue for the data queue.</param> /// <param name="dataQueueMessageOptions">The options for the data queue messages.</param> /// <param name="sendBatchesDataRepository">The send batches data repository.</param> /// <param name="groupsService">The groups service.</param> /// <param name="exportDataRepository">The Export data repository instance.</param> public SentNotificationsController( NotificationDataRepository notificationDataRepository, SentNotificationDataRepository sentNotificationDataRepository, TeamDataRepository teamDataRepository, PrepareToSendQueue prepareToSendQueue, DataQueue dataQueue, IOptions <DataQueueMessageOptions> dataQueueMessageOptions, SendBatchesDataRepository sendBatchesDataRepository, IGroupsService groupsService, ExportDataRepository exportDataRepository) { this.notificationDataRepository = notificationDataRepository; this.sentNotificationDataRepository = sentNotificationDataRepository; this.teamDataRepository = teamDataRepository; this.prepareToSendQueue = prepareToSendQueue; this.dataQueue = dataQueue; this.forceCompleteMessageDelayInSeconds = dataQueueMessageOptions.Value.ForceCompleteMessageDelayInSeconds; this.sendBatchesDataRepository = sendBatchesDataRepository; this.groupsService = groupsService; this.exportDataRepository = exportDataRepository; }
/// <summary> /// Initializes a new instance of the <see cref="TeamDataController"/> class. /// </summary> /// <param name="teamDataRepository">Team data repository instance.</param> public TeamDataController(TeamDataRepository teamDataRepository) { this.teamDataRepository = teamDataRepository; }
/// <summary> /// Initializes a new instance of the <see cref="TeamDataController"/> class. /// </summary> /// <param name="teamDataRepository">Team data repository instance.</param> /// <param name="configuration">configuration</param> public TeamDataController(TeamDataRepository teamDataRepository, IConfiguration configuration) { this.teamDataRepository = teamDataRepository; this.configuration = configuration; }
public async Task <IActionResult> RunAsync( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ILogger log) { // scheduleInitializationTimer = scheduleInitializationTimer ?? throw new ArgumentNullException(nameof(scheduleInitializationTimer)); //log.LogInformation($"Schedule Initialization Timer executed at: {scheduleInitializationTimer.ToString()}."); SchduleNotificationTestFunction.configuration = SchduleNotificationTestFunction.configuration ?? new ConfigurationBuilder() .AddEnvironmentVariables() .Build(); SchduleNotificationTestFunction.adaptiveCardCreator = SchduleNotificationTestFunction.adaptiveCardCreator ?? new AdaptiveCardCreator(); SchduleNotificationTestFunction.tableRowKeyGenerator = SchduleNotificationTestFunction.tableRowKeyGenerator ?? new TableRowKeyGenerator(); SchduleNotificationTestFunction.adGroupsDataRepository = SchduleNotificationTestFunction.adGroupsDataRepository ?? new ADGroupsDataRepository(SchduleNotificationTestFunction.configuration, true); SchduleNotificationTestFunction.notificationDataRepository = SchduleNotificationTestFunction.notificationDataRepository ?? new NotificationDataRepository(SchduleNotificationTestFunction.configuration, SchduleNotificationTestFunction.adGroupsDataRepository, tableRowKeyGenerator, true); SchduleNotificationTestFunction.userDataRepository = SchduleNotificationTestFunction.userDataRepository ?? new UserDataRepository(SchduleNotificationTestFunction.configuration, true); SchduleNotificationTestFunction.teamDataRepository = SchduleNotificationTestFunction.teamDataRepository ?? new TeamDataRepository(SchduleNotificationTestFunction.configuration, true); SchduleNotificationTestFunction.sendingNotificationDataRepository = SchduleNotificationTestFunction.sendingNotificationDataRepository ?? new SendingNotificationDataRepository(SchduleNotificationTestFunction.configuration, true); SchduleNotificationTestFunction.globalSendingNotificationDataRepository = SchduleNotificationTestFunction.globalSendingNotificationDataRepository ?? new GlobalSendingNotificationDataRepository(SchduleNotificationTestFunction.configuration, true); SchduleNotificationTestFunction.sentNotificationDataRepository = SchduleNotificationTestFunction.sentNotificationDataRepository ?? new SentNotificationDataRepository(SchduleNotificationTestFunction.configuration, true); SchduleNotificationTestFunction.metadataProvider = SchduleNotificationTestFunction.metadataProvider ?? new MetadataProvider(SchduleNotificationTestFunction.configuration, userDataRepository, teamDataRepository, notificationDataRepository, adGroupsDataRepository); SchduleNotificationTestFunction.sendingNotificationCreator = SchduleNotificationTestFunction.sendingNotificationCreator ?? new SendingNotificationCreator(SchduleNotificationTestFunction.configuration, notificationDataRepository, sendingNotificationDataRepository, adaptiveCardCreator); SchduleNotificationTestFunction.scheduleNotificationDelivery = SchduleNotificationTestFunction.scheduleNotificationDelivery ?? new ScheduleNotificationDelivery(SchduleNotificationTestFunction.configuration, notificationDataRepository, metadataProvider, sendingNotificationCreator, scheduleNotificationDataRepository, teamDataRepository); SchduleNotificationTestFunction.scheduleNotificationDataRepository = SchduleNotificationTestFunction.scheduleNotificationDataRepository ?? new ScheduleNotificationDataRepository(SchduleNotificationTestFunction.configuration, notificationDataRepository, metadataProvider, sendingNotificationCreator, scheduleNotificationDelivery, true); // Generate filter condition to get pending notifications. var rowKeyFilter = TableQuery.GenerateFilterConditionForDate( nameof(ScheduleNotificationDataEntity.NotificationDate), QueryComparisons.LessThanOrEqual, DateTime.UtcNow); // Get records which are pending to send notification. var pendingNotifications = await SchduleNotificationTestFunction.scheduleNotificationDataRepository.GetWithFilterAsync( rowKeyFilter); // Repeat all pending notifications. foreach (var pendingNotification in pendingNotifications) { try { log.LogInformation($"Schedule notification triggered for " + pendingNotification.NotificationId); string returnMessage = await SchduleNotificationTestFunction.scheduleNotificationDataRepository.SendNotificationandCreateScheduleAsync(pendingNotification); if (string.IsNullOrEmpty(returnMessage)) { log.LogInformation($"Schedule notification success for " + pendingNotification.NotificationId); } else { log.LogInformation($"Schedule notification failed for " + pendingNotification.NotificationId); } } catch (Exception ex) { log.LogError($"Error while sending schedule notification:" + pendingNotification.NotificationId, ex); } } return(await Task.FromResult((ActionResult) new OkObjectResult("OK"))); }
/// <summary> /// Initializes a new instance of the <see cref="TeamDataController"/> class. /// </summary> /// <param name="teamDataRepository">Team data repository instance.</param> /// <param name="configurationDataRepository">configuration data repository instance.</param> public TeamDataController(TeamDataRepository teamDataRepository, ConfigurationDataRepository configurationDataRepository) { this.teamDataRepository = teamDataRepository; this.configurationDataRepository = configurationDataRepository; }
public async Task RunAsync( [TimerTrigger("0 */30 * * * *")] TimerInfo scheduleInitializationTimer, ILogger log) { scheduleInitializationTimer = scheduleInitializationTimer ?? throw new ArgumentNullException(nameof(scheduleInitializationTimer)); log.LogInformation($"Schedule Initialization Timer executed at: {scheduleInitializationTimer.ToString()}."); CompanyCommunicatorScheduleFunction.configuration = CompanyCommunicatorScheduleFunction.configuration ?? new ConfigurationBuilder() .AddEnvironmentVariables() .Build(); CompanyCommunicatorScheduleFunction.adaptiveCardCreator = CompanyCommunicatorScheduleFunction.adaptiveCardCreator ?? new AdaptiveCardCreator(); CompanyCommunicatorScheduleFunction.tableRowKeyGenerator = CompanyCommunicatorScheduleFunction.tableRowKeyGenerator ?? new TableRowKeyGenerator(); CompanyCommunicatorScheduleFunction.adGroupsDataRepository = CompanyCommunicatorScheduleFunction.adGroupsDataRepository ?? new ADGroupsDataRepository(CompanyCommunicatorScheduleFunction.configuration, true); CompanyCommunicatorScheduleFunction.notificationDataRepository = CompanyCommunicatorScheduleFunction.notificationDataRepository ?? new NotificationDataRepository(CompanyCommunicatorScheduleFunction.configuration, CompanyCommunicatorScheduleFunction.adGroupsDataRepository, tableRowKeyGenerator, true); CompanyCommunicatorScheduleFunction.userDataRepository = CompanyCommunicatorScheduleFunction.userDataRepository ?? new UserDataRepository(CompanyCommunicatorScheduleFunction.configuration, true); CompanyCommunicatorScheduleFunction.teamDataRepository = CompanyCommunicatorScheduleFunction.teamDataRepository ?? new TeamDataRepository(CompanyCommunicatorScheduleFunction.configuration, true); CompanyCommunicatorScheduleFunction.sendingNotificationDataRepository = CompanyCommunicatorScheduleFunction.sendingNotificationDataRepository ?? new SendingNotificationDataRepository(CompanyCommunicatorScheduleFunction.configuration, true); CompanyCommunicatorScheduleFunction.globalSendingNotificationDataRepository = CompanyCommunicatorScheduleFunction.globalSendingNotificationDataRepository ?? new GlobalSendingNotificationDataRepository(CompanyCommunicatorScheduleFunction.configuration, true); CompanyCommunicatorScheduleFunction.sentNotificationDataRepository = CompanyCommunicatorScheduleFunction.sentNotificationDataRepository ?? new SentNotificationDataRepository(CompanyCommunicatorScheduleFunction.configuration, true); CompanyCommunicatorScheduleFunction.metadataProvider = CompanyCommunicatorScheduleFunction.metadataProvider ?? new MetadataProvider(CompanyCommunicatorScheduleFunction.configuration, userDataRepository, teamDataRepository, notificationDataRepository, adGroupsDataRepository); CompanyCommunicatorScheduleFunction.sendingNotificationCreator = CompanyCommunicatorScheduleFunction.sendingNotificationCreator ?? new SendingNotificationCreator(CompanyCommunicatorScheduleFunction.configuration, notificationDataRepository, sendingNotificationDataRepository, adaptiveCardCreator); CompanyCommunicatorScheduleFunction.scheduleNotificationDelivery = CompanyCommunicatorScheduleFunction.scheduleNotificationDelivery ?? new ScheduleNotificationDelivery(CompanyCommunicatorScheduleFunction.configuration, notificationDataRepository, metadataProvider, sendingNotificationCreator, scheduleNotificationDataRepository, teamDataRepository); CompanyCommunicatorScheduleFunction.scheduleNotificationDataRepository = CompanyCommunicatorScheduleFunction.scheduleNotificationDataRepository ?? new ScheduleNotificationDataRepository(CompanyCommunicatorScheduleFunction.configuration, notificationDataRepository, metadataProvider, sendingNotificationCreator, scheduleNotificationDelivery, true); // Generate filter condition to get pending notifications. var rowKeyFilter = TableQuery.GenerateFilterConditionForDate( nameof(ScheduleNotificationDataEntity.NotificationDate), QueryComparisons.LessThanOrEqual, DateTime.UtcNow); // Get records which are pending to send notification. var pendingNotifications = await CompanyCommunicatorScheduleFunction.scheduleNotificationDataRepository.GetWithFilterAsync( rowKeyFilter); // Repeat all pending notifications. foreach (var pendingNotification in pendingNotifications) { try { log.LogInformation($"Schedule notification triggered for " + pendingNotification.NotificationId); string returnMessage = await CompanyCommunicatorScheduleFunction.scheduleNotificationDataRepository.SendNotificationandCreateScheduleAsync(pendingNotification); if (string.IsNullOrEmpty(returnMessage)) { log.LogInformation($"Schedule notification success for " + pendingNotification.NotificationId); } else { log.LogInformation($"Schedule notification failed for " + pendingNotification.NotificationId); } } catch (Exception ex) { log.LogError($"Error while sending schedule notification:" + pendingNotification.NotificationId, ex); } } }