/// <inheritdoc/> public void RunSchedule() { var executingServer = ServerController.GetExecutingServerName(); var scheduleItem = SchedulingController.GetSchedule(this.GetSchedulerTypeFullName(), executingServer); if (scheduleItem != null) { SchedulingProvider.Instance().RunScheduleItemNow(scheduleItem, true); if (SchedulingProvider.SchedulerMode == SchedulerMode.TIMER_METHOD) { SchedulingProvider.Instance().ReStart("Change made to schedule."); } } }
private void ChangeScheduledTasksServerAffinity() { try { var firstEnabledServer = ServerController.GetEnabledServers().OrderBy(x => x.KeyID).FirstOrDefault(); var serverName = ServerController.GetServerName(firstEnabledServer); // Move all the tasks to the first enagbled server var scheduleItems = SchedulingController.GetSchedule(); var movedSchedules = new List <string>(); foreach (var item in scheduleItems) { if (item.TypeFullName == "DotNetNuke.Azure.AppService.AppServiceServerChecker, DotNetNuke.Azure.AppService") { if (item.Servers != Null.NullString) { item.Servers = Null.NullString; SchedulingProvider.Instance().UpdateSchedule(item); movedSchedules.Add(item.FriendlyName); } } else if (item.Servers != $",{serverName},") { item.Servers = $",{serverName},"; SchedulingProvider.Instance().UpdateSchedule(item); movedSchedules.Add(item.FriendlyName); } } if (movedSchedules.Count() > 0) { Logger.Info($"Changed schedules '{string.Join(",", movedSchedules)}' to '{serverName}'"); var log = new LogInfo { LogTypeKey = EventLogController.EventLogType.SCHEDULE_UPDATED.ToString() }; log.AddProperty("Updated schedules", string.Join(",", movedSchedules)); log.AddProperty("Changed to server", serverName); LogController.Instance.AddLog(log); } } catch (Exception ex) { var message = $"Error changing server affinity: {ex.Message}"; ScheduleHistoryItem.AddLogNote(message); Exceptions.LogException(ex); } }
public HttpResponseMessage GetScheduleItems(string serverName = "") { try { List <ScheduleItem> scheduleviews; if (string.IsNullOrEmpty(serverName) || serverName == Localization.GetString("All")) { scheduleviews = SchedulingController.GetSchedule(); } else { scheduleviews = SchedulingController.GetSchedule(serverName); } foreach (var item in scheduleviews.Where(x => x.NextStart == Null.NullDate)) { if (item.ScheduleStartDate != Null.NullDate) { item.NextStart = item.ScheduleStartDate; } } var arrSchedule = scheduleviews.ToArray(); var response = new { Success = true, Results = arrSchedule.Select(v => new { v.ScheduleID, v.FriendlyName, v.Enabled, RetryTimeLapse = _controller.GetTimeLapse(v.RetryTimeLapse, v.RetryTimeLapseMeasurement), NextStart = (v.Enabled && !Null.IsNull(v.NextStart)) ? v.NextStart.ToString() : "", Frequency = _controller.GetTimeLapse(v.TimeLapse, v.TimeLapseMeasurement) }), TotalResults = arrSchedule.Count() }; return(Request.CreateResponse(HttpStatusCode.OK, response)); } catch (Exception exc) { Logger.Error(exc); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public ConsoleResultModel Run() { var lstSchedule = SchedulingController.GetSchedule(); List <TaskModel> lst = new List <TaskModel>(); foreach (ScheduleItem task in lstSchedule) { if (TaskId == task.ScheduleID) { lst.Add(new TaskModel(task)); break; } } return(new ConsoleResultModel(string.Format("{0} task{1} found", lst.Count, (lst.Count != 1 ? "s" : ""))) { data = lst }); }
public IEnumerable <ScheduleItem> GetScheduleItems(bool?enabled, string serverName = "", string taskName = "") { try { IEnumerable <ScheduleItem> scheduleviews; if (string.IsNullOrEmpty(serverName) || serverName == Localization.GetString("All")) { scheduleviews = SchedulingController.GetSchedule(); } else { scheduleviews = SchedulingController.GetSchedule(serverName); } if (!string.IsNullOrEmpty(taskName)) { scheduleviews = scheduleviews.Where(item => item.FriendlyName.IndexOf(taskName, StringComparison.OrdinalIgnoreCase) >= 0); } if (enabled.HasValue) { scheduleviews = scheduleviews.Where(item => item.Enabled == enabled.Value); } var scheduleItems = scheduleviews as IList <ScheduleItem> ?? scheduleviews.ToList(); foreach (var item in scheduleItems.Where(x => x.NextStart == Null.NullDate) .Where(item => item.ScheduleStartDate != Null.NullDate)) { item.NextStart = item.ScheduleStartDate; } return(scheduleItems); } catch (Exception exc) { Logger.Error(exc); return(null); } }
public ConsoleResultModel Run() { var lstSchedule = SchedulingController.GetSchedule(); List <TaskModelBase> lst = new List <TaskModelBase>(); if (!string.IsNullOrEmpty(TaskName)) { var search = TaskName.Replace("*", ".*"); var query = from task in lstSchedule where Regex.Match(task.FriendlyName, search, RegexOptions.IgnoreCase).Success select task; foreach (ScheduleItem task in query) { if (!Enabled.HasValue || Enabled == task.Enabled) { lst.Add(new TaskModelBase(task)); } } } else { foreach (ScheduleItem task in lstSchedule) { // By default, if Enabled is not specified, return all scheduled tasks. if (!Enabled.HasValue || (Enabled == task.Enabled)) { lst.Add(new TaskModelBase(task)); } } } return(new ConsoleResultModel(string.Format("{0} task{1} found", lst.Count, (lst.Count != 1 ? "s" : ""))) { data = lst }); }
protected void OnGridNeedDataSource(object sender, GridNeedDataSourceEventArgs e) { List <ScheduleItem> scheduleviews; if (ddlServerName.SelectedIndex == 0) { scheduleviews = SchedulingController.GetSchedule(); } else { scheduleviews = SchedulingController.GetSchedule(ddlServerName.SelectedValue); } foreach (var item in scheduleviews.Where(x => x.NextStart == Null.NullDate)) { if (item.ScheduleStartDate != Null.NullDate) { item.NextStart = item.ScheduleStartDate; } } var arrSchedule = scheduleviews.ToArray(); dgSchedule.DataSource = arrSchedule; }
public ConsoleResultModel Run() { var taskToUpdate = SchedulingController.GetSchedule(Convert.ToInt32(TaskId)); List <TaskModel> lst = new List <TaskModel>(); if (taskToUpdate != null) { taskToUpdate.Enabled = (bool)Enabled; var _with1 = taskToUpdate; SchedulingController.UpdateSchedule(_with1.ScheduleID, _with1.TypeFullName, _with1.TimeLapse, _with1.TimeLapseMeasurement, _with1.RetryTimeLapse, _with1.RetryTimeLapseMeasurement, _with1.RetainHistoryNum, _with1.AttachToEvent, _with1.CatchUpEnabled, _with1.Enabled, _with1.ObjectDependencies, _with1.Servers, _with1.FriendlyName); var updatedTask = SchedulingController.GetSchedule(Convert.ToInt32(TaskId)); if (updatedTask != null) { lst.Add(new TaskModel(updatedTask)); } } return(new ConsoleResultModel(string.Format("{0} task{1} updated", lst.Count, (lst.Count != 1 ? "s" : ""))) { data = lst }); }