void _ProcessMessages(MessageCollection messages, IRule rule, object target) { if (messages == RuleSuccess) { return; } Violations.Add(rule, target, messages); }
// Helper method to add a violation with no calls. public void AddViolation(ViolationLevel level, String description) { Violation v = new Violation(); v.m_level = level; v.m_endpoint = Endpoint; v.m_summary = description; Violations.Add(v); }
// Helper method to add a violation with a single call public void AddViolation(ViolationLevel level, String description, ServiceCallItem call) { Violation v = new Violation(); v.m_level = level; v.m_endpoint = Endpoint; v.m_summary = description; v.m_violatingCalls.Add(call); Violations.Add(v); }
// Helper method to add a violation with a list of calls to the list. public void AddViolation(ViolationLevel level, String description, IEnumerable <ServiceCallItem> calls) { Violation v = new Violation(); v.m_level = level; v.m_endpoint = Endpoint; v.m_summary = description; v.m_violatingCalls.AddRange(calls); Violations.Add(v); }
protected SourceAnalysisTest() { var settings = Path.GetFullPath(StyleCopSettingsFilePath); var addinPaths = new List <string>(); Console = new StyleCopConsole(settings, false, null, addinPaths, true); Console.ViolationEncountered += (sender, args) => Violations.Add(args.Violation); Console.OutputGenerated += (sender, args) => Output.Add(args.Output); }
private void Process() { NeedsRegularization = false; IsHoliday = CheckIfHoliday(); IsWeekEnd = AppliedPolicy.IsWeekend(Date); if (IsHoliday && IsPresent) { Violations.Add(WorkTimeViolation.GetViolation(WorkTimeViolationType.WorkingOnHoliday, AllAccessEvents)); } if (IsWeekEnd && IsPresent) { Violations.Add(WorkTimeViolation.GetViolation(WorkTimeViolationType.WorkingOnWeekend, AllAccessEvents)); } if (IsHoliday || IsWeekEnd) { return; } if (IsPresent) { CalculateTimeSpan_Gym(); CalculateTimeSpan_Recreation(); CalculateTimeSpan_OutsidePremises(); CompensateForApprovedLeave(); CompensateForBlockRegularization(); //Calculation of work time should be after all the other calculations CalculateTimeSpan_Work(); AppliedPolicy.Validate(WorkTimeRules.GymnasiumUsageRule); AppliedPolicy.Validate(WorkTimeRules.RecreationUsageRule); AppliedPolicy.Validate(WorkTimeRules.TotalWorkHoursPerDayRule); AppliedPolicy.Validate(WorkTimeRules.WorkStartEndTimingRule); } else { if (ApprovedLeave == null) { //No leave applied yet and is absent Violations.Add(WorkTimeViolation.GetViolation(WorkTimeViolationType.AbsentWithoutLeave)); } if (ApprovedLeave != null && ApprovedLeave.IsHalfDay) { //Half day leave applied and is absent Violations.Add(WorkTimeViolation.GetViolation(WorkTimeViolationType.AbsentWithHalfDayLeave)); } } FlaggedForSevereViolation = Violations.Where(v => v.Level == ViolationLevel.Severe).ToList().Count > 0; }
public static Violations GetViolations(Error[] errors) { Violations violations = new Violations(errors.Length); foreach (Error error in errors) { List <Location> locations = null; if (!violations.TryGetValue(error.Violation, out locations)) { locations = new List <Location>(); violations.Add(error.Violation, locations); } locations.Add(error.Location); } return(violations); }
public static Violations GetViolations(Error[] errors) { Violations violations = new Violations(errors.Length); foreach (Error error in errors) { List<Location> locations = null; if (!violations.TryGetValue(error.Violation, out locations)) { locations = new List<Location>(); violations.Add(error.Violation, locations); } locations.Add(error.Location); } return violations; }
private void CompensateForApprovedLeave() { if (ApprovedLeave == null) { LeaveTimeCompensation = TimeSpan.FromHours(0); return; } if (ApprovedLeave.IsHalfDay) { LeaveTimeCompensation = TimeSpan.FromHours(4.5); } else { LeaveTimeCompensation = TimeSpan.FromHours(9.0); if (IsPresent) { Violations.Add(WorkTimeViolation.GetViolation(WorkTimeViolationType.WorkingOnLeaveDay, AllAccessEvents)); } } }
private void CalculateTimeSpan_Gym() { var swipes = SwipesAtAccessPoint("Gym").OrderBy(x => x.EventTime).ToList(); if (swipes.Count % 2 == 1) { Violations.Add(WorkTimeViolation.GetViolation(WorkTimeViolationType.OddAccessEvents_Gymnasium, swipes)); } else { TimeSpan gymnasiumTime = TimeSpan.FromDays(0); for (int i = 1; i < swipes.Count; i += 2) { var a = swipes[i].EventTime; var b = swipes[i + 1].EventTime; gymnasiumTime += (b - a); } GymnasiumTimeSpan = gymnasiumTime; } }
private void AddViolation(DateTimeOffset startDateTime, DateTimeOffset endDateTime, Enums.ViolationType violationType, Jurisdiction jurisdiction) { switch (violationType) { case Enums.ViolationType.Driving: ViolationDurationDrivingSinceLastDailyReset = ViolationDurationDrivingSinceLastDailyReset.Add(endDateTime.Subtract(startDateTime)); break; case Enums.ViolationType.OnDuty: ViolationDurationOnDutySinceLastDailyReset = ViolationDurationOnDutySinceLastDailyReset.Add(endDateTime.Subtract(startDateTime)); break; case Enums.ViolationType.Rest: ViolationDurationOnDutySinceLastRestBreak = ViolationDurationOnDutySinceLastRestBreak.Add(endDateTime.Subtract(startDateTime)); break; case Enums.ViolationType.Weekly: ViolationDurationOnDutySinceLastWeeklyReset = ViolationDurationOnDutySinceLastWeeklyReset.Add(endDateTime.Subtract(startDateTime)); break; } Violations.Add(new DutyStatusViolation(startDateTime, endDateTime, violationType, jurisdiction.JurisdictionId)); }
private void CalculateTimeSpan_OutsidePremises() { var swipes = SwipesAtAccessPoint("Main Entry").OrderBy(x => x.EventTime).ToList(); if (swipes.Count % 2 == 1) { Violations.Add(WorkTimeViolation.GetViolation(WorkTimeViolationType.OddAccessEvents_PremisesEntry, swipes)); } else { TimeSpan outPremisesTime = TimeSpan.FromDays(0); if (swipes.Count > 2) { for (int i = 1; i < swipes.Count; i += 2) { var a = swipes[i].EventTime; var b = swipes[i + 1].EventTime; outPremisesTime += (b - a); } } OutsidePremisesTimeSpan = outPremisesTime; } }
/// <summary> /// Handles encountered violations. /// </summary> private void OnViolationEncountered(object sender, ViolationEventArgs e) { Violations.Add(e.Violation.Rule.Name); }