private DateTime?TryDeleteTerm(IAgent agent, IIndependenceTerm term) { if (term is UnknowAssignment) { return(null); //xthrow new Exception("UnknowAssignment can't delete from TimeBox"); } // 因为删除term之后会导致班表的工时无法参考到离线, 所以请勿变更次行顺序 var workingHours = term.SaftyGetProperty <double, IAssignment>(o => o.WorkingTotals.TotalHours); DateTime?result = null; if (_shiftDispatcherModel.DeleteShift(agent, (Term)term)) { //以下为删除成功后续处理 var dateKey = term.SaftyGetHrDate(); // 未来采用HRDate term.SaftyInvoke <IAssignment>(o => Statistic(o.NativeName, o, dateKey, -1)); result = dateKey; } return(result); }
//public static bool IsOutOfBoundary(this Term term, DateTime checkPoint, DateRange boundary) //{ // var lowestTerm = term.GetLowestTerm(); // var isDayOffOrTimeOff = term is DayOff || term is TimeOff; // var compareTime = lowestTerm == term || isDayOffOrTimeOff ? checkPoint : lowestTerm.Start; // if (compareTime < boundary.Start) // return true; // if (compareTime >= boundary.End && !lowestTerm.BelongToPrv) // return true; // return false; //} public static bool IsOutOfBoundary(this IIndependenceTerm lowestTerm, DateTime compareTime, TimeBox timeBox) { var originalStartTime = lowestTerm.Start; var insideTimeBox = originalStartTime.IsInTheRange(timeBox.Boundary.Start, timeBox.Boundary.End); if (insideTimeBox == false && lowestTerm.BelongToPrv == false) { return(true); } if (insideTimeBox && lowestTerm.BelongToPrv == true) { return(true); } var distanceBetweenCompareTimeAndBoundaryEnd = compareTime.Subtract(timeBox.Boundary.End); if (insideTimeBox == false && compareTime.IsInTheRange(timeBox.Boundary.Start, timeBox.Boundary.End) && lowestTerm.BelongToPrv == true) { return(false); } if (distanceBetweenCompareTimeAndBoundaryEnd > TimeSpan.FromHours(12)) { return(true); } if (compareTime < timeBox.Boundary.Start) { return(true); } //if (compareTime >= timeBox.Boundary.End && !lowestTerm.BelongToPrv) // return true; return(false); }
public static bool IgnoreAdherence(this IIndependenceTerm term) { return(term.IgnoreAdherence); }
//private static readonly string[] OccupationAssigned = new[] { "C", "S" }; //public static bool AnyOccupationAssigned(this IAssignment obj) //{ // return OccupationAssigned.Contains(obj.OccupyStatus); //} //public static bool CanRearrangeSeat(this IAssignment obj) //{ // return new[] { "C", "S", "X", "N" }.Contains(obj.OccupyStatus); //} //public static bool CanCancelSeatArrangement(this IAssignment obj) //{ // return new[] { "C", "S", "X", "W" }.Contains(obj.OccupyStatus); //} public static DateTime SaftyGetHrDate(this IIndependenceTerm assignment) { return(assignment.HrDate == default(DateTime) ? assignment.Start.Date : assignment.HrDate); }