Exemplo n.º 1
0
 private static void ViolationPercentage(List <string> latLongs, ParkingRegulation regulation,
                                         ParkingEvent parkingEvent)
 {
     foreach (var latLong in latLongs)
     {
         if (IsPointInPolygon4(new List <PointF>
         {
             new PointF(
                 float.Parse(regulation.Coodrinate1.Split(':')[0]),
                 float.Parse(regulation.Coodrinate1.Split(':')[1])),
             new PointF(
                 float.Parse(regulation.Coodrinate2.Split(':')[0]),
                 float.Parse(regulation.Coodrinate2.Split(':')[1])),
             new PointF(
                 float.Parse(regulation.Coodrinate3.Split(':')[0]),
                 float.Parse(regulation.Coodrinate3.Split(':')[1])),
             new PointF(
                 float.Parse(regulation.Coodrinate4.Split(':')[0]),
                 float.Parse(regulation.Coodrinate4.Split(':')[1]))
         }.ToArray(),
                               new PointF(float.Parse(latLong.Split(':')[0]),
                                          float.Parse(latLong.Split(':')[1]))))
         {
             parkingEvent.MatchRate += 25;
         }
     }
 }
Exemplo n.º 2
0
        private static bool IsStreetSweeping(ParkingRegulation regulation, ParkingEvent parkingEvent,
                                             GeViolation geViolation, PredixContext context, Customer customer)
        {
            bool isVoilation = false;

            if (parkingEvent.EventType.Equals("PKOUT"))
            {
                using (var innerContext = new PredixContext())
                {
                    var inEvent = innerContext.GeViolations.FirstOrDefault(x =>
                                                                           x.ObjectUid == parkingEvent.Properties.ObjectUid &&
                                                                           x.LocationUid == parkingEvent.LocationUid);
                    if (inEvent?.ParkinTime != null)
                    {
                        inEvent.ParkoutTime      = parkingEvent.Timestamp.ToUtcDateTimeOrNull().ToTimeZone(customer.TimezoneId);
                        inEvent.EventOutDateTime =
                            parkingEvent.Timestamp.ToUtcDateTimeOrNull().ToTimeZone(customer.TimezoneId);
                        inEvent.ViolationDuration = (long)parkingEvent.Timestamp.ToUtcDateTimeOrNull().ToTimeZone(customer.TimezoneId)
                                                    .Subtract(inEvent.ParkinTime.Value).TotalMinutes;
                        inEvent.StreetSweeping   = true;
                        inEvent.ModifiedDateTime = parkingEvent.Timestamp.ToUtcDateTimeOrNull().ToTimeZone(customer.TimezoneId);
                        inEvent.IsException      = true;
                        inEvent.UserAction       = "Missed_Violation";
                        innerContext.SaveChanges();
                        return(true);
                    }
                }
                return(false);
            }
            if (parkingEvent.Timestamp.ToUtcDateTimeOrNull().ToTimeZone(customer.TimezoneId).TimeOfDay >= regulation.StartTime &&
                parkingEvent.Timestamp.ToUtcDateTimeOrNull().ToTimeZone(customer.TimezoneId).TimeOfDay <= regulation.EndTime)
            {
                Commentary.Print("*** StreetWeeping Violation");

                isVoilation = true;
                geViolation.StreetSweeping = true;
                geViolation.ObjectUid      = parkingEvent.Properties.ObjectUid;
                geViolation.LocationUid    = parkingEvent.LocationUid;
                if (parkingEvent.EventType.Equals("PKIN"))
                {
                    geViolation.EventInDateTime =
                        parkingEvent.Timestamp.ToUtcDateTimeOrNull().ToTimeZone(customer.TimezoneId);
                    geViolation.ParkinTime = parkingEvent.Timestamp.ToUtcDateTimeOrNull().ToTimeZone(customer.TimezoneId);
                }

                if (parkingEvent.EventType.Equals("PKOUT"))
                {
                    geViolation.EventOutDateTime =
                        parkingEvent.Timestamp.ToUtcDateTimeOrNull().ToTimeZone(customer.TimezoneId);
                    geViolation.ParkoutTime = parkingEvent.Timestamp.ToUtcDateTimeOrNull().ToTimeZone(customer.TimezoneId);
                }

                geViolation.RegulationId  = regulation.RegualationId;
                geViolation.ViolationType = regulation.ViolationType;

                context.GeViolations.Add(geViolation);
            }

            return(isVoilation);
        }