public Task(string reminder, DateTime startingDate, TimeSpan startingTime, bool dailyflag) { ReminderText = reminder; StartingDate = new DateTime(startingDate.Year, startingDate.Month, startingDate.Day); StartingTime = new TimeSpan(startingTime.Hours, startingTime.Minutes, 0); NotificationTime = StartingDate + StartingTime; JobKey = new JobKey(NotificationTime.ToShortDateString()); isDailyNotifed = dailyflag; }
public void Add(StorageEnvironment environment, Exception exception) { var notificationsMetadata = _notificationsMetadataTable.GetOrCreateValue(environment); if (notificationsMetadata.TryGetValue(exception.GetType(), out var notificationMetadata)) { if (DateTime.Now - notificationMetadata.Time < _updateFrequency) { return; } if (Interlocked.CompareExchange(ref notificationMetadata.IsInProgress, 1, 0) == 1) { return; } notificationMetadata.Time = DateTime.Now; } else { notificationMetadata = new NotificationTime { Time = DateTime.Now, IsInProgress = 1 }; if (notificationsMetadata.TryAdd(exception.GetType(), notificationMetadata) == false) { return; } //We are in low of memory so we want to minimize allocations notificationMetadata.Key = $"{environment}:{exception.GetType()}"; notificationMetadata.Title = $"Out of memory occurred for '{environment}'"; } var alert = AlertRaised.Create( null, notificationMetadata.Title, exception.Message, AlertType.OutOfMemoryException, NotificationSeverity.Error, notificationMetadata.Key, OutOfMemoryDetails(exception)); _notificationsCenter.Add(alert); Volatile.Write(ref notificationMetadata.IsInProgress, 0); }
public void Show(string message, NotificationPriority priority, NotificationTime time, NotificationType type) { if (currentPriority > priority) { return; } currentPriority = priority; this.MessageBlock.Text = message; PreviewShowNotification?.Invoke(this, new EventArgs()); this.Visibility = Visibility.Visible; this.type = type; hideTimer.Stop(); if (!(time == NotificationTime.Eternally)) { hideCount = (int)time; hideTimer.Start(); } }