public static string GetFrequencyDisplayText(this Job job) { //SaintFX82 earned 100 gamerpoints on Xbox 360 in the past minute //SaintFX82 earned 100 gamerpoints on Xbox 360 in the past 60 minutes //SaintFX82 earned 100 gamerpoints on Xbox 360 in the past hour //SaintFX82 earned 100 gamerpoints on Xbox 360 in the past 3 hours //SaintFX82 earned 100 gamerpoints on Xbox 360 in the past day //SaintFX82 earned 100 gamerpoints on Xbox 360 in the past 2 days //SaintFX82 earned 100 gamerpoints on Xbox 360 in the past week //SaintFX82 earned 100 gamerpoints on Xbox 360 in the past 2 weeks //SaintFX82 earned 100 gamerpoints on Xbox 360 in the past month //SaintFX82 earned 100 gamerpoints on Xbox 360 in the past 2 months. JobFrequency jf = (JobFrequency)Enum.Parse(typeof(JobFrequency), job.Frequency.ToString()); return((job.FrequencyUnits > 1 ? job.FrequencyUnits.ToString() + " " : string.Empty) + jf.ToString().ToLower() + (job.FrequencyUnits > 1 ? "s" : string.Empty)); }
public static DateTime CalculateNextRunTime(this Job job) { //If summary, do once a day, otherwise every 20 minutes DateTime result = DateTime.MinValue; JobFrequency jf = (JobFrequency)Enum.Parse(typeof(JobFrequency), job.Frequency.ToString()); switch (jf) { case JobFrequency.Minute: result = DateTime.UtcNow.AddMinutes(job.FrequencyUnits); break; case JobFrequency.Hour: result = DateTime.UtcNow.AddHours(job.FrequencyUnits); break; case JobFrequency.Day: result = DateTime.UtcNow.AddDays(job.FrequencyUnits); break; case JobFrequency.Week: result = DateTime.UtcNow.AddDays(job.FrequencyUnits * 7); break; case JobFrequency.Month: result = DateTime.UtcNow.AddMonths(job.FrequencyUnits); break; } //If result is still the minimum date value, set it to 1 week for summary jobs and 60 minutes for status jobs if (result == DateTime.MinValue) { return(DateTime.UtcNow.AddMinutes((job.Type == JobTypes.Summary.GetHashCode() ? 10080 : 60))); } else { return(result); } }