public static async Task SendNotificationAsync ( int contentSourceId, string contentSourceType, string subscriberId, int destinationId ) { using (var context = new TdPushNotificationContext()) { var readyNote = await context.PushNotificationItems .FirstOrDefaultAsync(n => ( n.ContentSourceId == contentSourceId && n.ContentSourceType == contentSourceType && n.SubscriberId == subscriberId && n.DestinationId == destinationId ) && ( n.DeliveryStatus == PushNotificationItemStatus.Scheduled || n.DeliveryStatus == PushNotificationItemStatus.Retrying) ); if (readyNote == null) { return; } await SendNotificationMessageAsync(context, readyNote, CancellationToken.None); await context.SaveChangesAsync(); } }
private static async Task SendNotificationMessageAsync(TdPushNotificationContext context, PushNotificationItem readyNote, CancellationToken ct) { var retryMax = context.TicketDeskPushNotificationSettings.RetryAttempts; var retryIntv = context.TicketDeskPushNotificationSettings.RetryIntervalMinutes; //find a provider for the notification destination type var provider = DeliveryProviders.FirstOrDefault(p => p.DestinationType == readyNote.Destination.DestinationType); if (provider == null) { //no provider readyNote.DeliveryStatus = PushNotificationItemStatus.NotAvailable; readyNote.ScheduledSendDate = null; } else { await provider.SendReadyMessageAsync(readyNote, retryMax, retryIntv, ct); } }
public static async Task <int> SendNextReadyNotificationAsync(CancellationToken ct) { using (var context = new TdPushNotificationContext()) { //get the next notification that is ready to send var readyNote = await context.PushNotificationItems.Include(n => n.Destination).OrderBy(n => n.ScheduledSendDate).FirstOrDefaultAsync( n => (n.DeliveryStatus == PushNotificationItemStatus.Scheduled || n.DeliveryStatus == PushNotificationItemStatus.Retrying) && n.ScheduledSendDate <= DateTimeOffset.Now, ct); if (readyNote == null) { return(0); } await SendNotificationMessageAsync(context, readyNote, ct); return(await context.SaveChangesAsync(ct)); } }
public PushNotificationSettingsController(TdPushNotificationContext noteContext, TdDomainContext domainContext) { NoteContext = noteContext; DomainContext = domainContext; }
public SubscriberPushNotificationSettingsManager(TdPushNotificationContext notificationContext) { NotificationContext = notificationContext; }
public AccountController(TicketDeskUserManager userManager, TicketDeskSignInManager signInManager, TdPushNotificationContext notificationContext) { UserManager = userManager; SignInManager = signInManager; NotificationContext = notificationContext; }
public DataManagementController(TdIdentityContext identityContext, TdPushNotificationContext pushNotificationContext) { IdentityContext = identityContext; PushNotificationContext = pushNotificationContext; }
public static async Task SendNotification ( int contentSourceId, string contentSourceType, string subscriberId, int destinationId ) { using (var context = new TdPushNotificationContext()) { var readyNote = await context.PushNotificationItems .FirstOrDefaultAsync(n => ( n.ContentSourceId == contentSourceId && n.ContentSourceType == contentSourceType && n.SubscriberId == subscriberId && n.DestinationId == destinationId ) && ( n.DeliveryStatus == PushNotificationItemStatus.Scheduled || n.DeliveryStatus == PushNotificationItemStatus.Retrying) ); if (readyNote == null) { return; } await SendNotificationMessageAsync(context, readyNote, CancellationToken.None); await context.SaveChangesAsync(); } }
public static async Task<int> SendNextReadyNotification(CancellationToken ct) { using (var context = new TdPushNotificationContext()) { //get the next notification that is ready to send var readyNote = await context.PushNotificationItems.Include(n => n.Destination).OrderBy(n => n.ScheduledSendDate).FirstOrDefaultAsync( n => (n.DeliveryStatus == PushNotificationItemStatus.Scheduled || n.DeliveryStatus == PushNotificationItemStatus.Retrying) && n.ScheduledSendDate <= DateTimeOffset.Now, ct); if (readyNote == null) { return 0; } await SendNotificationMessageAsync(context, readyNote, ct); return await context.SaveChangesAsync(ct); } }