private void DeleteNotification(long noteID) { ScheduledNotification schedulednotification = simpleNoteHelper.GetNotificationByNoteId(noteID); NotificationScheduler.DeleteScheduledNotification(schedulednotification.SchedulingId); simpleNoteHelper.DeleteNotificationByNoteId(noteID); }
public void DeleteNotification(long noteId) { ScheduledNotification schedulednotification = databaseHelper.GetNotificationByNoteId(noteId); NotificationScheduler.DeleteScheduledNotification(schedulednotification.SchedulingId); databaseHelper.DeleteNotificationByNoteId(noteId); }
public static void Main(string[] args) { IHost host = CreateHostBuilder(args).Build(); var serviceProvider = host.Services.CreateScope().ServiceProvider; NotificationScheduler.Start(serviceProvider); host.Run(); }
public void UpdateNote(long id, string title, string content) { ScheduledNotification notification; if ((notification = simpleNoteHelper.GetNotificationByNoteId(id)) != null) { Debug.WriteLine("Deleting scheduled notification"); NotificationScheduler.DeleteScheduledNotification(notification.SchedulingId); } simpleNoteHelper.UpdateNoteAndDeleteNotification(id, title, content); }
public void UpdateNote(long id, string title, ObservableCollection <TodoNote.TodoEntry> entries) { ScheduledNotification notification; if ((notification = databaseHelper.GetNotificationByNoteId(id)) != null) { Debug.WriteLine("Deleting scheduled notification"); NotificationScheduler.DeleteScheduledNotification(notification.SchedulingId); } databaseHelper.UpdateNoteAndDeleteNotification(id, title, entries); }
protected override void OnStart() { NotificationScheduler scheduler = new NotificationScheduler(); if (!scheduler.IsScheduleExist()) { scheduler.SetSchedule(); } scheduler.SetAllAlarm(); scheduler.SetAlarm("hello", -1, DateTime.Now.AddMinutes(1)); }
public void DeleteNote(long id) { ScheduledNotification notification; if ((notification = databaseHelper.GetNotificationByNoteId(id)) != null) { Debug.WriteLine("Deleting scheduled notification"); NotificationScheduler.DeleteScheduledNotification(notification.SchedulingId); } databaseHelper.DeleteNote(id); }
public void UpdateNoteAndNotification(long id, string title, string content, string notificationTitle, DateTimeOffset dateTime) { ScheduledNotification notification; if ((notification = simpleNoteHelper.GetNotificationByNoteId(id)) != null) { Debug.WriteLine("Deleting scheduled notification"); NotificationScheduler.DeleteScheduledNotification(notification.SchedulingId); } string notificationId = ScheduleNotification(notificationTitle, dateTime); simpleNoteHelper.UpdateNoteAndNotification(id, title, content, notificationId, dateTime); }
public ActionResult CleanVotes() { try { NotificationScheduler.RemoveJobs(); _choiceService.CleanChoiceHistoryVotesDay(); } catch (Exception ex) { TempData["VoteMessage"] = ex.Message; } return(RedirectToAction("Index")); }
public MoneyTransferController( IAccountHolderAppService accountHolderAppService, UserManager userManager, IMoneyTransferAppService moneyTransferAppService, NotificationScheduler notificationScheduler, IOtpSessionAppService otpSessionAppService ) { _accountHolderAppService = accountHolderAppService; _userManager = userManager; _moneyTransferAppService = moneyTransferAppService; _notificationScheduler = notificationScheduler; _otpSessionAppService = otpSessionAppService; }
public void UpdateNote(long id, string title, string photoPath, string content) { PhotoNote photoNote = databaseHelper.GetNoteById(id) as PhotoNote; ScheduledNotification notification = photoNote.ScheduledNotification; if (notification != null) { Debug.WriteLine("Deleting scheduled notification"); NotificationScheduler.DeleteScheduledNotification(notification.SchedulingId); } if (photoNote.PhotoPath != photoPath) { DeleteImageFromLocalFolder(photoNote.PhotoPath); } databaseHelper.UpdateNoteAndDeleteNotification(id, title, content, photoPath); }
public void SchedulePushNotificationWithoutTimeZoneTest() { NotificationTest test = new NotificationTest(); NotificationScheduler <Guid> scheduler = this.CreateScheduler(test); PushNotification notification = this.CreateNotification(); NotificationAccount <Guid> account = test.AddNotificationAccount(Guid.NewGuid(), timeZone: null); DateTime deliveryDate = DateTime.UtcNow.AddDays(1); scheduler.Schedule(account.AccountId, notification, deliveryDate); DateTimeOffset expectedDeliveryDate = deliveryDate.ToDateTimeOffset("US/Eastern"); this.AssertNotificationScheduledSuccessful(test, account, notification, expectedDeliveryDate); }
public static void Main(string[] args) { var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger(); try { logger.Debug("init main"); var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var serviceProvider = scope.ServiceProvider; try { var userManager = serviceProvider.GetRequiredService <UserManager <ApplicationUser> >(); var roleManager = serviceProvider.GetRequiredService <RoleManager <IdentityRole> >(); var operatorManager = serviceProvider.GetRequiredService <IOperatorManager>(); var codeManager = serviceProvider.GetRequiredService <ICodeManager>(); var tariffManager = serviceProvider.GetRequiredService <ITariffManager>(); var stopWordManager = serviceProvider.GetRequiredService <IStopWordManager>(); var unitOfWork = serviceProvider.GetRequiredService <IUnitOfWork>(); IdentityDataInitializer.SeedData(userManager, roleManager, operatorManager, codeManager, tariffManager, stopWordManager, unitOfWork); // Start Notification scheduler NotificationScheduler.Start(scope.ServiceProvider); MailingScheduler.Start(scope.ServiceProvider); } catch (Exception ex) { logger.Error(ex, "Stopped program because of exception"); } } host.Run(); } catch (Exception ex) { //NLog: catch setup errors logger.Error(ex, "Stopped program because of exception"); throw; } finally { // Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux) NLog.LogManager.Shutdown(); } }
public SignUpController( IVerificationCodeService verificationCodeService, SmsService smsService, UserSignUpManager userSignUpManager, UserManager userManager, AccountHolderService accountHolderService, NotificationScheduler notificationScheduler, SavingsInterestManager savingsInterestManager) { _verificationCodeService = verificationCodeService; _smsService = smsService; _userSignUpManager = userSignUpManager; _userManager = userManager; _accountHolderService = accountHolderService; _notificationScheduler = notificationScheduler; _savingsInterestManager = savingsInterestManager; }
public async Task HostsAsyncProducerConsumerClassTest() { int maxSlowNotificationSize = 2; int maxNotificationQueueSize = 10; int batchSize = 20; string fastHost = "fastHost"; string slowHost = "slowHost"; var pcCollection = new NotificationScheduler(loggerTest, maxSlowNotificationSize, maxNotificationQueueSize, batchSize, 10, 1000); pcCollection.AddExecutionTime(slowHost, 2000); var notification = new NotificationData() { TxExternalId = uint256.Zero.ToBytes() }; for (int i = 0; i < maxNotificationQueueSize; i++) { pcCollection.Add(notification, fastHost); } Assert.IsFalse(pcCollection.Add(notification, fastHost)); var notificationList = await pcCollection.TakeAsync(false, CancellationToken.None); Assert.AreEqual(maxNotificationQueueSize, notificationList.Count); for (int i = 0; i < maxSlowNotificationSize; i++) { pcCollection.Add(notification, slowHost); } Assert.IsFalse(pcCollection.Add(notification, slowHost)); var idleTask = pcCollection.TakeAsync(false, CancellationToken.None); Assert.AreEqual(TaskStatus.WaitingForActivation, idleTask.Status); pcCollection.Add(notification, fastHost); Assert.AreEqual(1, idleTask.Result.Count); notificationList = await pcCollection.TakeAsync(true, CancellationToken.None); Assert.AreEqual(maxSlowNotificationSize, notificationList.Count); idleTask = pcCollection.TakeAsync(true, CancellationToken.None); Assert.AreEqual(TaskStatus.WaitingForActivation, idleTask.Status); }
public ActionResult Vote(long id) { try { NotificationScheduler.Start(); Vote vote = _voteService.RegisterVote(User.Identity.Name, id); HomeViewModel model = new HomeViewModel(); model.ScoreBoard = _voteService.GetAllTodayVotesGroupByRestaurant(); model.SetListToJson(); HungryUp.Mvc.Helpers.ScoreHub.Static_Send(model.ScoreBoardJson); } catch (Exception ex) { TempData["VoteMessage"] = ex.Message; } return(RedirectToAction("Index")); }
public void SendOverDueNotificationTest() { NotificationTest test = new NotificationTest(); INotificationChannel channel; NotificationScheduler <Guid> scheduler = this.CreateScheduler(test, out channel); DateTime deliveryDate = DateTime.UtcNow; NotificationAccount <Guid> account = test.AddNotificationAccount(Guid.NewGuid(), "US/Pacific"); PushNotification notificationToSend = this.CreateNotification(); test.NotificationRepository.GetScheduledNotifications(Arg.Any <DateTime>()).Returns(new[] { new ScheduledNotification <Guid>(account.AccountId, notificationToSend, DateTime.UtcNow) }); scheduler.SendScheduledNotifications(DateTime.UtcNow.AddDays(1)).Wait(); channel.Received().SendAsync(account, notificationToSend); test.NotificationRepository.Received().DeleteScheduledNotification(notificationToSend.Id); }
public void UpdateNoteAndNotification(long id, string title, string photoPath, string content, string notificationTitle, DateTimeOffset dateTime) { ScheduledNotification notification; if ((notification = databaseHelper.GetNotificationByNoteId(id)) != null) { Debug.WriteLine("Deleting scheduled notification"); NotificationScheduler.DeleteScheduledNotification(notification.SchedulingId); } PhotoNote photoNote = databaseHelper.GetNoteById(id) as PhotoNote; if (photoNote.PhotoPath != photoPath) { DeleteImageFromLocalFolder(photoNote.PhotoPath); } string schedulingId = ScheduleNotification(notificationTitle, dateTime); databaseHelper.UpdateNoteAndNotification(id, title, content, photoPath, schedulingId, dateTime); }
public ActionResult Index() { HomeViewModel model = new HomeViewModel(); try { model.ChoiceHistory = _choiceService.GetTodayChoiceHistory(); model.Vote = _voteService.GetTodayVote(User.Identity.Name); model.ScoreBoard = _voteService.GetAllTodayVotesGroupByRestaurant(); model.SetListToJson(); if (NotificationScheduler.TriggerAlreadySchedule()) { model.SetTimeInteval(NotificationScheduler.hour, NotificationScheduler.minute); } if (model.ChoiceHistory != null) { string message = model.ChoiceHistory.Draw ? CommonMessages.VoteFinishWithDraw : CommonMessages.VoteFinish; throw new Exception(string.Format(message, model.ChoiceHistory.Restaurant.Name)); } if (model.ChoiceHistory != null || model.Vote != null) { throw new Exception(string.Format(CommonMessages.YouAlreadyVoteToday, model.Vote.Restaurant.Name)); } model.TitleMessage = CommonMessages.ChooseYourFavorite; model.Restaurants = _restaurantService.GetWeekAvaiable(); } catch (Exception ex) { model.TitleMessage = ex.Message; } return(View(model)); }
private string ScheduleNotification(string notificationTitle, DateTimeOffset dateTime) { XmlDocument notificationStructure = NotificationBuilder.BuildNoTitleNotification(notificationTitle); return(NotificationScheduler.ScheduleNotification(notificationStructure, dateTime)); }