public static void UpdateEDD() { //one mass update per time lock (_lockEDD) { if (DateTime.Compare(_EDDDate, DefectBase.LastGlobalModifier) > 0) { return; } //cache all vacations List <DefectBase> vacs = Vacations.EnumCloseVacations(DateTime.Today, 365); DefectBase d = new DefectBase(); foreach (var u in DefectUser.Enum()) { if (!u.ACTIVE) { continue; } string sid = u.ID.ToString(); List <DateTime> vacDates = new List <DateTime>(); foreach (var v in vacs) { if (v.AUSER == sid) { vacDates.Add(DateTime.ParseExact(v.DATE, IdBasedObject.defDateFormat, CultureInfo.InvariantCulture)); } } DateTime dat = DateTime.Today.AddDays(1); foreach (var task in d.EnumPlan(u.ID)) { while (dat.DayOfWeek == DayOfWeek.Saturday || dat.DayOfWeek == DayOfWeek.Sunday) { dat = dat.AddDays(1); } while (vacDates.Exists(x => dat.Date.CompareTo(x) == 0)) { dat = dat.AddDays(1); } int hours = Math.Max(task.ESTIM - task.SPENT, 0) + dat.Hour; dat = dat.AddHours(-dat.Hour); int days = hours / 8; hours = hours % 8; dat = dat.AddDays(days); dat = dat.AddHours(hours); task.SetEDD(dat.Date); } } _EDDDate = DateTime.Now; } }
public List <DefectUser> gettaskusers() { return(DefectUser.Enum()); }