Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
0
        public ActionResult <VehicleLocationTimeHistoryModel> VehicleCourseLocations(string vehicleId, string startTime, string stopTime)
        {
            if (!DateTime.TryParse(startTime, null, System.Globalization.DateTimeStyles.RoundtripKind, out DateTime startDateTime))
            {
                return(BadRequest("Invalid startTime"));
            }
            if (!DateTime.TryParse(stopTime, null, System.Globalization.DateTimeStyles.RoundtripKind, out DateTime stopDateTime))
            {
                return(BadRequest("Invalid stopTime"));
            }
            if (!Guid.TryParse(vehicleId, out var guid))
            {
                return(BadRequest("Invalid vehicleId"));
            }

            var data = m_Context.VehicleLocationTimeHistory.Where(
                x => x.dateTime >= startDateTime &&
                x.dateTime <= stopDateTime &&
                x.vehicleId == guid).ToList();

            var result = new VehicleLocationTimeHistoryModel(data, m_appSettings.ProviderId);

            return(result);
        }