Ejemplo n.º 1
0
        internal DutyStatusViolation(DateTimeOffset startDateTime, DateTimeOffset endDateTime, Enums.ViolationType violationType, Enums.Jurisdiction jurisdictionId)
        {
            StartDateTime = startDateTime;
            EndDateTime   = endDateTime;
            ViolationType = violationType;
            Jurisdiction jurisdiction = new Jurisdiction(jurisdictionId);

            switch (violationType)
            {
            case Enums.ViolationType.Driving:
                ViolationText = $"Driving more than {jurisdiction.DrivingHoursAllowed} hours.";
                break;

            case Enums.ViolationType.OnDuty:
                ViolationText = $"Driving after the {jurisdiction.OnDutyHoursAllowed}th hour on duty.";
                break;

            case Enums.ViolationType.Rest:
                ViolationText = $"No {jurisdiction.MinimumRestLengthHours.HoursToMinutes()}-minute rest break in the fist {jurisdiction.MaximumShiftHoursBeforeRestBreakRequired} hours";
                break;

            case Enums.ViolationType.Weekly:
                ViolationText = $"Driving after being on duty more than {jurisdiction.WeeklyOnDutyHoursAllowed} hours in the last {jurisdiction.WeeklyAuditTimeRangeDays} days.";
                break;
            }
        }
Ejemplo n.º 2
0
        private void AddViolation(DateTimeOffset endDateTime, TimeSpan durationSinceLastDailyReset, TimeSpan hoursallowed, Enums.ViolationType violationType, Jurisdiction jurisdiction)
        {
            var violationOffset = TimeSpan.FromSeconds(0);

            switch (violationType)
            {
            case Enums.ViolationType.Driving:
                violationOffset = ViolationDurationDrivingSinceLastDailyReset;
                break;

            case Enums.ViolationType.OnDuty:
                violationOffset = ViolationDurationOnDutySinceLastDailyReset;
                break;

            case Enums.ViolationType.Rest:
                violationOffset = ViolationDurationOnDutySinceLastRestBreak;
                break;

            case Enums.ViolationType.Weekly:
                violationOffset = ViolationDurationOnDutySinceLastWeeklyReset;
                break;
            }

            var violationStartDateTime = endDateTime.Subtract(durationSinceLastDailyReset - hoursallowed).Add(violationOffset);

            AddViolation(violationStartDateTime, endDateTime, violationType, jurisdiction);
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Add duty status violation for event period
        /// </summary>
        /// <param name="startDateTime">Startdatetime of violation</param>
        /// <param name="endDateTime">End date/time of violation</param>
        /// <param name="hoursAllowed">Timespan of hours allowed for violation</param>
        /// <param name="violationType">Enum of violation type</param>
        /// <param name="dutyStatusJursidiction">Jursidiction of duty status event where violation occured</param>
        /// <param name="onDutyDuration">Total Duration of on duty/driving time</param>
        internal void AddViolation(DateTimeOffset startDateTime, DateTimeOffset endDateTime, TimeSpan hoursAllowed, Enums.ViolationType violationType, Jurisdiction dutyStatusJursidiction, TimeSpan?onDutyDuration = null)
        {
            bool isAlreadyInViolation = false;

            switch (violationType)
            {
            case Enums.ViolationType.Driving:
                isAlreadyInViolation = IsAlreadyInDrivingViolation;
                onDutyDuration       = onDutyDuration ?? DurationDrivingSinceLastDailyReset;
                break;

            case Enums.ViolationType.OnDuty:
                isAlreadyInViolation = IsAlreadyInOnDutyViolation;
                onDutyDuration       = onDutyDuration ?? DurationOnDutySinceLastDailyReset;
                break;

            case Enums.ViolationType.Rest:
                isAlreadyInViolation = IsAlreadyInRestBreakViolation;
                onDutyDuration       = onDutyDuration ?? DurationOnDutySinceLastRestBreak;
                break;

            case Enums.ViolationType.Weekly:
                isAlreadyInViolation = IsAlreadyInWeeklyViolation;
                onDutyDuration       = onDutyDuration ?? DurationOnDutySinceLastWeeklyReset;
                break;
            }

            if (isAlreadyInViolation || endDateTime.Subtract(onDutyDuration.Value - hoursAllowed) < startDateTime)
            {
                AddViolation(startDateTime, endDateTime, violationType, dutyStatusJursidiction);
            }
            else
            {
                AddViolation(endDateTime, onDutyDuration.Value, hoursAllowed, violationType, dutyStatusJursidiction);
            }
        }