/// <summary> /// Initializes a new instance of the <see cref="OccurrenceRepository"/> class. /// </summary> /// <param name="configurationSettings">Represents the application configuration.</param> /// <param name="tableRowKeyGenerator">Table row key generator.</param> public OccurrenceRepository( ConfigurationSettings configurationSettings, TableRowKeyGenerator tableRowKeyGenerator) : base( configurationSettings, PartitionKeyNames.OccurrenceDataTable.TableName, PartitionKeyNames.OccurrenceDataTable.OccurrencePartition, false) { this.tableRowKeyGenerator = tableRowKeyGenerator; }
/// <summary> /// Initializes a new instance of the <see cref="NotificationDataRepository"/> class. /// </summary> /// <param name="configuration">Represents the application configuration.</param> /// <param name="tableRowKeyGenerator">Table row key generator service.</param> /// <param name="isFromAzureFunction">Flag to show if created from Azure Function.</param> public NotificationDataRepository( IConfiguration configuration, TableRowKeyGenerator tableRowKeyGenerator, bool isFromAzureFunction = false) : base( configuration, PartitionKeyNames.NotificationDataTable.TableName, PartitionKeyNames.NotificationDataTable.DraftNotificationsPartition, isFromAzureFunction) { this.TableRowKeyGenerator = tableRowKeyGenerator; }
/// <summary> /// Initializes a new instance of the <see cref="ChannelDataRepository"/> class. /// </summary> /// <param name="logger">The logging service.</param> /// <param name="repositoryOptions">Options used to create the repository.</param> /// <param name="tableRowKeyGenerator">Table row key generator service.</param> public ChannelDataRepository( ILogger <ChannelDataRepository> logger, IOptions <RepositoryOptions> repositoryOptions, TableRowKeyGenerator tableRowKeyGenerator) : base( logger, storageAccountConnectionString: repositoryOptions.Value.StorageAccountConnectionString, tableName: ChannelDataTableName.TableName, defaultPartitionKey: ChannelDataTableName.ChannelDataPartition, ensureTableExists: repositoryOptions.Value.EnsureTableExists) { this.TableRowKeyGenerator = tableRowKeyGenerator; }
/// <summary> /// Initializes a new instance of the <see cref="NotificationDataRepository"/> class. /// </summary> /// <param name="logger">The logging service.</param> /// <param name="repositoryOptions">Options used to create the repository.</param> /// <param name="tableRowKeyGenerator">Table row key generator service.</param> public NotificationDataRepository( ILogger <NotificationDataRepository> logger, IOptions <RepositoryOptions> repositoryOptions, TableRowKeyGenerator tableRowKeyGenerator) : base( logger, storageAccountConnectionString: repositoryOptions.Value.StorageAccountConnectionString, tableName: NotificationDataTableNames.TableName, defaultPartitionKey: NotificationDataTableNames.DraftNotificationsPartition, ensureTableExists: repositoryOptions.Value.EnsureTableExists) { this.TableRowKeyGenerator = tableRowKeyGenerator; }
/// <summary> /// Initializes a new instance of the <see cref="EmployeeResourceGroupController"/> class. /// </summary> /// <param name="employeeResourceGroupRepository">Employee resource group data repository instance.</param> /// <param name="tableRowKeyGenerator">Table row key generator service.</param> /// <param name="groupMembersService">Group member service.</param> /// <param name="options">Bot filter middleware options.</param> /// <param name="localizer">The current culture's string localizer.</param> /// <param name="logger">Logs errors and information.</param> public EmployeeResourceGroupController( EmployeeResourceGroupRepository employeeResourceGroupRepository, TableRowKeyGenerator tableRowKeyGenerator, IGroupMembersService groupMembersService, IOptions <BotFilterMiddlewareOptions> options, IStringLocalizer <Strings> localizer, ILogger <EmployeeResourceGroupController> logger) { this.employeeResourceGroupRepository = employeeResourceGroupRepository ?? throw new ArgumentNullException(nameof(employeeResourceGroupRepository)); this.tableRowKeyGenerator = tableRowKeyGenerator ?? throw new ArgumentNullException(nameof(tableRowKeyGenerator)); this.groupMembersService = groupMembersService ?? throw new ArgumentNullException(nameof(groupMembersService)); this.options = options ?? throw new ArgumentNullException(nameof(options)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.localizer = localizer ?? throw new ArgumentNullException(nameof(localizer)); }
/// <summary> /// Initializes a new instance of the <see cref="EventRepository"/> class. /// </summary> /// <param name="configurationSettings">Represents the application configuration.</param> /// <param name="tableRowKeyGenerator">Table row key generator.</param> /// <param name="eventFilterCreator">Upcoming event filter.</param> /// <param name="userAadIdFilter">User AAD id.</param> public EventRepository( ConfigurationSettings configurationSettings, TableRowKeyGenerator tableRowKeyGenerator, EventFilterCreator eventFilterCreator, UserAadIdFilter userAadIdFilter) : base( configurationSettings, PartitionKeyNames.EventDataTable.TableName, PartitionKeyNames.EventDataTable.EventPartition, false) { this.tableRowKeyGenerator = tableRowKeyGenerator; this.eventFilterCreator = eventFilterCreator; this.userAadIdFilter = userAadIdFilter; }
private NotificationDataRepository CreateNotificationRepository(IConfiguration configuration) { var tableRowKeyGenerator = new TableRowKeyGenerator(); return(new NotificationDataRepository(configuration, null, tableRowKeyGenerator, isFromAzureFunction: true)); }
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); } } }
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"))); }