/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="data"></param> /// <param name="auxiliary"></param> public override bool IsSatisfied(object data, object auxiliary = null) { ResourceConstraintData cData = (ResourceConstraintData)data; bool isSatisfied = true; bool peopleMatch = false; bool timeMatchComplete = false; if (ForPerson != null && ForTimeInterval != null) { peopleMatch = ConstraintCheckHelpers.PeopleMatch(ForPerson, cData.PersonsInSchedule); timeMatchComplete = ConstraintCheckHelpers.TimeMatchComplete(ForTimeInterval.StartTime.Instant, ForTimeInterval.EndTime.Instant, (DateTime)cData.TimePeriodInSchedule.StartTime.Instant, (DateTime)cData.TimePeriodInSchedule.EndTime.Instant); if (peopleMatch && timeMatchComplete) { isSatisfied = false; MessageTemplate = "The resource is blocked for the choosen time period and selected people."; } } else if (ForPerson != null) { peopleMatch = ConstraintCheckHelpers.PeopleMatch(ForPerson, cData.PersonsInSchedule); if (peopleMatch) { isSatisfied = false; MessageTemplate = "The resource is blocked selected people."; } } else if (ForTimeInterval != null) { timeMatchComplete = ConstraintCheckHelpers.TimeMatchComplete(ForTimeInterval.StartTime.Instant, ForTimeInterval.EndTime.Instant, (DateTime)cData.TimePeriodInSchedule.StartTime.Instant, (DateTime)cData.TimePeriodInSchedule.EndTime.Instant); if (timeMatchComplete) { isSatisfied = false; MessageTemplate = "The resource is blocked for the choosen time period"; } } if (ForPeriodicTimeInterval != null) { PeriodicTimeHelper pHelper = new PeriodicTimeHelper(); List <DateTime> tempDates = pHelper.PeriodicTimeMatch(ForPeriodicTimeInterval, ForTimeInterval, (DateTime)cData.TimePeriodInSchedule.StartTime.Instant, (DateTime)cData.TimePeriodInSchedule.EndTime.Instant); if (tempDates.Count() > 0) { isSatisfied = false; string m = ""; foreach (DateTime d in tempDates) { m += d.ToString() + "\r\n"; } MessageTemplate = String.Format("The resource is blocked on the followings day(s): {0}", m); } } return(isSatisfied); }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="data"></param> /// <param name="auxiliary"></param> public override bool IsSatisfied(object data, object auxiliary = null) { bool isSatisfied = true; bool peopleMatch = false; bool timeMatchComplete = false; ResourceConstraintData cData = (ResourceConstraintData)data; List <long> personInConstraint = new List <long>(); //Case 1: Person AND Time Period restriction if ((ForPerson != null || AllUsers) && (ForTimeInterval != null || ForEver)) { if (ForPerson != null) { peopleMatch = ConstraintCheckHelpers.PeopleMatch(ForPerson, cData.PersonsInSchedule); } if (ForTimeInterval != null) { timeMatchComplete = ConstraintCheckHelpers.TimeMatchComplete(ForTimeInterval.StartTime.Instant, ForTimeInterval.EndTime.Instant, (DateTime)cData.TimePeriodInSchedule.StartTime.Instant, (DateTime)cData.TimePeriodInSchedule.EndTime.Instant); } if ((peopleMatch && timeMatchComplete) || (peopleMatch && ForEver) || (timeMatchComplete && AllUsers) || (ForEver && AllUsers)) { switch (ComparisonOperator) { case ComparisonOperator.Equals: { if (Quantity != cData.QuantityInSchedule) { isSatisfied = false; MessageTemplate = String.Format("You must book a Quantity {0} {1}.", ComparisonOperator, Quantity); } break; } } } } else if (ForPerson != null || AllUsers) { if (ForPerson != null) { peopleMatch = ConstraintCheckHelpers.PeopleMatch(ForPerson, cData.PersonsInSchedule); } if (peopleMatch || AllUsers) { switch (ComparisonOperator) { case ComparisonOperator.Equals: { if (Quantity != cData.QuantityInSchedule) { isSatisfied = false; MessageTemplate = String.Format("You must book a Quantity {0} {1}.", ComparisonOperator, Quantity); } break; } } } } else if (ForTimeInterval != null || ForEver) { if (ForTimeInterval != null) { timeMatchComplete = ConstraintCheckHelpers.TimeMatchComplete(ForTimeInterval.StartTime.Instant, ForTimeInterval.EndTime.Instant, (DateTime)cData.TimePeriodInSchedule.StartTime.Instant, (DateTime)cData.TimePeriodInSchedule.EndTime.Instant); } if (timeMatchComplete || ForEver) { switch (ComparisonOperator) { case ComparisonOperator.Equals: { if (Quantity != cData.QuantityInSchedule) { isSatisfied = false; MessageTemplate = String.Format("You must book a Quantity {0} {1}.", ComparisonOperator, Quantity); } break; } } } } //else //{ // switch (ComparisonOperator) // { // case ComparisonOperator.Equals: // { // if (Quantity != cData.Quantity) // { // isSatisfied = false; // MessageTemplate = String.Format("You must book a Quantity {0} {1}.", ComparisonOperator, Quantity); // } // break; // } // } //} return(isSatisfied); }