using Disco.Models.UI.Config.JobPreferences; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace Disco.Web.Areas.Config.Models.JobPreferences { public class IndexModel : ConfigJobPreferencesIndexModel { public int LongRunningJobDaysThreshold { get; set; } public int StaleJobMinutesThreshold { get; set; } public List> LongRunningJobDaysThresholdOptions() { var options = new List>() { new KeyValuePair(1, "1 Day"), new KeyValuePair(2, "2 Days"), new KeyValuePair(3, "3 Days"), new KeyValuePair(4, "4 Days"), new KeyValuePair(5, "5 Days"), new KeyValuePair(6, "6 Days"), new KeyValuePair(7, "1 Week"), new KeyValuePair(14, "2 Weeks"), new KeyValuePair(21, "3 Weeks"), new KeyValuePair(28, "4 Weeks"), new KeyValuePair(35, "5 Weeks"), new KeyValuePair(42, "6 Weeks"), new KeyValuePair(49, "7 Weeks"), new KeyValuePair(56, "8 Weeks") }; var current = this.LongRunningJobDaysThreshold; if (!options.Any(o => o.Key == current)) { options.Add(new KeyValuePair(current, string.Format("{0} Days", current))); options = options.OrderBy(o => o.Key).ToList(); } return options; } public List> StaleJobMinutesThresholdOptions() { var options = new List>() { new KeyValuePair(0, ""), new KeyValuePair(15, "15 minutes"), new KeyValuePair(30, "30 minutes"), new KeyValuePair(60, "1 hour"), new KeyValuePair(60 * 2, "2 hours"), new KeyValuePair(60 * 4, "4 hours"), new KeyValuePair(60 * 8, "8 hours"), new KeyValuePair(60 * 24, "1 day"), new KeyValuePair(60 * 24 * 2, "2 days"), new KeyValuePair(60 * 24 * 3, "3 days"), new KeyValuePair(60 * 24 * 4, "4 days"), new KeyValuePair(60 * 24 * 5, "5 days"), new KeyValuePair(60 * 24 * 6, "6 days"), new KeyValuePair(60 * 24 * 7, "1 week"), new KeyValuePair(60 * 24 * 7 * 2, "2 weeks"), new KeyValuePair(60 * 24 * 7 * 3, "3 weeks"), new KeyValuePair(60 * 24 * 7 * 4, "4 weeks"), new KeyValuePair(60 * 24 * 7 * 5, "5 weeks"), new KeyValuePair(60 * 24 * 7 * 6, "6 weeks"), new KeyValuePair(60 * 24 * 7 * 7, "7 weeks"), new KeyValuePair(60 * 24 * 7 * 8, "8 weeks") }; var current = this.StaleJobMinutesThreshold; if (!options.Any(o => o.Key == current)) { options.Add(new KeyValuePair(current, string.Format("{0} Minutes", current))); options = options.OrderBy(o => o.Key).ToList(); } return options; } } }