public override TimerJobSchedule GetInterval(IGlobalConfigurationWidgetStore dataStore) { var data = dataStore.Get <TimerJobSchedule>(AppGuid); if (data == null || data.Value == null) { return(new TimerJobSchedule(5)); } return(data.Value); }
public override TimerJobSchedule GetInterval(IGlobalConfigurationWidgetStore dataStore) { var data = dataStore.Get <TimerJobSchedule>(AppGuid); if (data == null || data.Value == null || (data.Value.Cron.IsEmpty() && data.Value.IntervalInHours.GetValueOrDefault() == 0 && data.Value.IntervalInMinutes.GetValueOrDefault() == 0)) { return(new TimerJobSchedule(60)); } return(data.Value); }
public override TimerJobSchedule GetInterval(IGlobalConfigurationWidgetStore dataStore) { var data = dataStore.Get <TimerJobSchedule>(AppGuid); if (data == null || data.Value == null || (data.Value.Cron.IsEmpty() && data.Value.IntervalInHours.GetValueOrDefault() == 0 && data.Value.IntervalInMinutes.GetValueOrDefault() == 0)) { int interval = GeminiApp.Config.EmailAlertsPollInterval.ToInt(); return(new TimerJobSchedule(interval == 0 ? 5 : interval)); } return(data.Value); }
public override TimerJobSchedule GetInterval(IGlobalConfigurationWidgetStore dataStore) { var data = dataStore.Get<TimerJobSchedule>(AppGuid); if (data == null || data.Value == null || (data.Value.Cron.IsEmpty() && data.Value.IntervalInHours.GetValueOrDefault() == 0 && data.Value.IntervalInMinutes.GetValueOrDefault() == 0)) { int interval = GeminiApp.Config.EmailAlertsPollInterval.ToInt(); return new TimerJobSchedule(interval == 0 ? 5 : interval); } return data.Value; }
public override TimerJobSchedule GetInterval(IGlobalConfigurationWidgetStore dataStore) { var data = dataStore.Get<TimerJobSchedule>(AppGuid); if (data == null || data.Value == null || (data.Value.Cron.IsEmpty() && data.Value.IntervalInHours.GetValueOrDefault() == 0 && data.Value.IntervalInMinutes.GetValueOrDefault() == 0)) { // Default interval for timer app return new TimerJobSchedule(5); } return data.Value; }
/// <summary> /// This method unlocks the user /// It sets the user.entity.locked status to false, when the next run time is greater than the unlock time. /// </summary> /// <param name="issueManager"></param> /// <param name="entity"></param> public void UnlockUser(IssueManager issueManager, User entity, DateTime currentTime) { try { IGlobalConfigurationWidgetStore dataStore = issueManager.GeminiContext.GlobalConfigurationWidgetStore; int intervalMinutes = Convert.ToInt32(GetInterval(dataStore).IntervalInMinutes); DateTime timeToUnlock = GetUnlockTime(entity); DateTime nextRunTime = currentTime + new TimeSpan(0, intervalMinutes, 0); if (timeToUnlock < nextRunTime) { UserManager userManager = new UserManager(GeminiApp.Cache(), GeminiApp.UserContext(), issueManager.GeminiContext); entity.Locked = false; userManager.Update(entity); LogDebugMessage("Benutzer: " + entity.Fullname + " entsperrt."); } } catch (Exception exception) { GeminiApp.LogException(exception, false, exception.Message); } }
/// <summary> /// This method sends the E-mail with the appropriate user language. /// First is to get the locked timestamp and the last run time from the app. /// To send an email the locked timestamp has to be greater than the last run time app. /// </summary> /// <param name="entity"></param> /// <param name="language"></param> public void SendMail(User entity, DateTime currentTime, DateTime unlockTime, IssueManager issueManager) { string log; IGlobalConfigurationWidgetStore dataStore = issueManager.GeminiContext.GlobalConfigurationWidgetStore; int intervalMinutes = Convert.ToInt32(GetInterval(dataStore).IntervalInMinutes); string language = entity.Language; DateTime lockedTimeStamp = entity.Revised.ToLocalTime(); DateTime lastRunTime = currentTime - new TimeSpan(0, intervalMinutes, 0); if (lockedTimeStamp > lastRunTime) { LogDebugMessage("Benutzer: " + entity.Fullname + " gesperrt."); string timeToUnlock = unlockTime.ToString(@"HH\:mm"); KeyValueConfigurationElement mailbodyLanguageSettings = GetAppConfigSettings(string.Concat("mailbody_", language)); KeyValueConfigurationElement mailSubjectLanguageSettings = GetAppConfigSettings(string.Concat("mailSubject_", language)); if (mailbodyLanguageSettings == null || mailSubjectLanguageSettings == null) { UserManager usermanager = new UserManager(issueManager); List <UserDto> users = usermanager.GetActiveUsers(); foreach (UserDto user in users) { if (user.IsGlobalAdmin) { if (!EmailHelper.Send(GeminiApp.Config, "Unlock User App: failure in App.config file", string.Concat(@"<style> div.container { background-color: #ffffff; } div.container p { font-family: Arial; font-size: 14px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; color: #000000; background-color: #ffffff; } </style> <div class='container'> <p>Please create a key for mailbody_ and mailSubject_ in app.config file for user language >>", language, @"</p><p></p><p>Also Unlock user: ", entity.Username, "</p></div>"), user.Entity.Email, string.Empty, true, out log)) { GeminiApp.LogException(new Exception(log) { Source = "Notification" }, false); } LogDebugMessage("E-Mail Benachrichtigung an " + entity.Fullname + " versendet."); } } } else { string mailBody = string.Format(mailbodyLanguageSettings.Value, GetAppConfigSettings("unlockTime").Value, "(" + timeToUnlock + ")"); if (!EmailHelper.Send(GeminiApp.Config, string.Concat(mailSubjectLanguageSettings.Value), mailBody, entity.Email, string.Empty, true, out log)) { GeminiApp.LogException(new Exception(log) { Source = "Notification" }, false); } LogDebugMessage("E-Mail Benachrichtigung an " + entity.Fullname + " versendet."); } } }
public override void SetInterval(IGlobalConfigurationWidgetStore dataStore, TimerJobSchedule schedule) { dataStore.Save <TimerJobSchedule>(AppGuid, schedule); }