Esempio n. 1
0
        private LocationHistory GetPageLocationHistory(DateTime startDate, DateTime stopDate, bool isCourse, int page, int count, ref int totalCount)
        {
            totalCount = m_Context.VehicleLocationTimeHistory.Where(
                x => x.dateTime >= startDate &&
                x.dateTime <= stopDate)
                         .Count();


            var data = m_Context.VehicleLocationTimeHistory.Where(
                x => x.dateTime >= startDate &&
                x.dateTime <= stopDate)
                       .OrderBy(x => x.sequence)
                       .Skip((page - 1) * count)
                       .Take(count)
                       .ToList();

            LocationHistory locHistory;

            if (isCourse)
            {
                locHistory = new CoarseVehicleLocationTimeHistoryModel(data, m_appSettings.ProviderId);
            }
            else
            {
                locHistory = new VehicleLocationTimeHistoryModel(data, m_appSettings.ProviderId);
            }

            return(locHistory);
        }
Esempio n. 2
0
        private LocationHistory GetPageLatestCourseLocationHistory(bool isCourse, int page, int count, ref int totalCount)
        {
            totalCount = m_Context.VehicleLocationTimeHistory
                         .GroupBy(l => l.vehicleId, (key, g) => g.OrderByDescending(e => e.dateTime).FirstOrDefault())
                         .Count();


            var data = m_Context.VehicleLocationTimeHistory
                       .GroupBy(l => l.vehicleId, (key, g) => g.OrderByDescending(e => e.dateTime).FirstOrDefault())
                       .OrderBy(x => x.sequence)
                       .Skip((page - 1) * count)
                       .Take(count)
                       .ToList();

            LocationHistory locHistory;

            if (isCourse)
            {
                locHistory = new CoarseVehicleLocationTimeHistoryModel(data, m_appSettings.ProviderId);
            }
            else
            {
                locHistory = new VehicleLocationTimeHistoryModel(data, m_appSettings.ProviderId);
            }
            return(locHistory);
        }
Esempio n. 3
0
        public ActionResult <DriverAvailability> Get(string driverId, DateTime startTime, DateTime stopTime)
        {
            if (!Guid.TryParse(driverId, out var guid))
            {
                return(BadRequest("Invalid driverId"));
            }

            var driver = m_Context.Driver.FirstOrDefault(c => c.Id == guid);

            if (driver == null)
            {
                return(NotFound("driverId Not Found"));
            }

            var courseLocationHistory =
                m_Context.VehicleLocationTimeHistory.Where(c => c.driverId == guid && c.dateTime >= startTime && c.dateTime <= stopTime);
            var dutyStatusLogs       = m_Context.LogEvent.Where(c => c.driverId == guid && c.dateTime >= startTime && c.dateTime <= stopTime);
            var vehicleFlaggedEvents =
                m_Context.VehicleFlaggedEvent.Where(c => c.driverId == guid && c.eventStart >= startTime && c.eventEnd <= stopTime);
            var locationhistoryModel = new CoarseVehicleLocationTimeHistoryModel(courseLocationHistory.ToList(), m_appSettings.ProviderId);

            var model = new DriverAvailability
            {
                CoarseVehicleLocationTimeHistory = locationhistoryModel,
                LogEvents            = LogEventsToLogEventModel(dutyStatusLogs.ToList()).ToArray(),
                VehicleFlaggedEvents = VehicleFlaggedEventsToVehicleFlaggedEventsModel(vehicleFlaggedEvents.ToList()).ToArray()
            };

            return(model);
        }
Esempio n. 4
0
        private LocationHistory GetCourseLocationHistory(DateTime startDate, DateTime stopDate, bool isCourse)
        {
            var data = m_Context.VehicleLocationTimeHistory.Where(
                x => x.dateTime >= startDate &&
                x.dateTime <= stopDate)
                       .ToList();

            LocationHistory locHistory;

            if (isCourse)
            {
                locHistory = new CoarseVehicleLocationTimeHistoryModel(data, m_appSettings.ProviderId);
            }
            else
            {
                locHistory = new VehicleLocationTimeHistoryModel(data, m_appSettings.ProviderId);
            }
            return(locHistory);
        }