private static void SendExpirationNotification(ExpirationNotifier notifier, License license, FrameworkServer server, bool sentRenewalRequest) { if (license.Owners.Count == 0) { LogError($"Unable to notify license expiration for '{server.HostName}'. No contacts specified."); return; } LicenseOwner owner = license.Owners.FirstOrDefault(); try { MailAddress recipient = new MailAddress(owner.Contact); string subject = string.Format(Resource.LicenseEmailSubject, license.Solution, server.HostName); string body = sentRenewalRequest ? string.Format(Resource.LicenseEmailBodyAuto, license.Solution, server.HostName, license.ExpirationDate.ToShortDateString(), Environment.MachineName) : string.Format(Resource.LicenseEmailBodyManual, license.Solution, server.HostName, license.ExpirationDate.ToShortDateString(), Environment.MachineName); notifier.SendNotification(recipient, subject, body); } catch (FormatException ex) { // Notification recipient is not a valid email address LogDebug(ex.ToString()); } }
private static void SendExpirationNotification(ExpirationNotifier notifier, AssetReservation reservation) { try { MailAddress recipient = new MailAddress(reservation.NotificationRecipient); string reservationText = (reservation.End < DateTime.Now ? Resource.ExpiredReservationText : Resource.ExpiringReservationText); string subject = string.Format(reservationText, reservation.AssetId); string body = string.Format(Resource.ReservationEmailBody, subject, reservation.End.ToString("f")); notifier.SendNotification(recipient, subject, body); } catch (FormatException) { LogWarn($"Ignoring invalid notification recipient: {reservation.NotificationRecipient}"); } }