/// <summary> /// Actualized current active contacts usage and create reminder about ends of limit. /// </summary> /// <param name="userConnection">User connection instance.</param> public void ActualizeActiveContactsWithReminding(UserConnection userConnection) { var licensePackageName = GetActualLicensePackageName(userConnection); var activeContactsWarningThreshold = (int)CoreSysSettings.GetValue(userConnection, _activeContactsWarningThresholdSettingsCode); var licHelper = userConnection.LicHelper; var maxValue = (double)licHelper.GetLicPackageMaxConditionCount(licensePackageName); var lastValue = (double)licHelper.GetLicPackageCurrentConditionResult(licensePackageName); licHelper.ActualizeLicPackageOperationsByNamePattern(licensePackageName); var newValue = (double)licHelper.GetLicPackageCurrentConditionResult(licensePackageName); var leftActiveContacts = maxValue - newValue; var leftPercent = leftActiveContacts / maxValue * 100; if ((leftPercent <= activeContactsWarningThreshold) & (newValue != lastValue)) { var recipientIds = GetNotificationRecipients(userConnection); var licenceExceded = newValue >= maxValue; var licenseExceededSubject = GetLczString(userConnection, "ActiveContactsExceededNotificationSubject"); var licenceAlmostOverSubject = GetLczString(userConnection, "ActiveContactsAlmostOverNotificationSubject"); var remindingSubjectCaption = licenceExceded ? licenseExceededSubject : string.Format(licenceAlmostOverSubject, activeContactsWarningThreshold); CreateRemindings(userConnection, recipientIds, remindingSubjectCaption); } }
/// <summary> /// Sets up delayed notification jobs. /// </summary> protected virtual void SetupDelayedNotificationJobs() { if (UserConnection.GetIsFeatureEnabled("DelayedNotification")) { int notifierPeriod = SystemSettings.GetValue(UserConnection, "DelayedNotifyingExecutionPeriod", DefaultNotifierExecutionPeriod); ScheduleJob <DelayedNotifying>(notifierPeriod); int cleanerPeriod = SystemSettings.GetValue(UserConnection, "DelayedNotificationCleaningExecutionPeriod", DefaultCleanerExecutionPeriod); ScheduleJob <DelayedNotificationCleaning>(cleanerPeriod); } else { RemoveJob <DelayedNotifying>(); RemoveJob <DelayedNotificationCleaning>(); } }