コード例 #1
0
ファイル: TrackingManager.cs プロジェクト: chitonaha/TrackMe
        private IList<RouteDTO> GetRouteByDeviceId(int deviceId)
        {
            IList<RouteDTO> routes = new List<RouteDTO>();

            IList<TrackDTO> tracks = UnitOfWork.TrackRepository.GetAllTracksByDeviceId(deviceId);
            Device device = UnitOfWork.DeviceRepository.GetByID(deviceId);
            string deviceType = device != null ? TrackMe.Support.Helpers.EnumHelper.GetDescription((TrackMe.Model.Enums.DeviceType)device.DeviceTypeId) : string.Empty;

            TrackDTO origin = tracks.FirstOrDefault();
            TrackDTO destination = tracks.LastOrDefault();

            RouteDTO route = new RouteDTO();

            int index = 0;
            foreach (TrackDTO track in tracks)
            {
                if (index % 8 == 0)
                {
                    if (index > 0)
                        route.Destination = track;

                    route = new RouteDTO();
                    route.DeviceId = deviceId;
                    route.DeviceType = deviceType;
                    route.Origin = track;
                    route.WayPoints = new List<TrackDTO>();

                    routes.Add(route);
                    //
                }

                route.WayPoints.Add(track);

                index++;
            }

            if (route.Destination == null)
                route.Destination = destination;

            return routes;
        }
コード例 #2
0
ファイル: TrackingManager.cs プロジェクト: chitonaha/TrackMe
        public IList<RouteDTO> GetRoutesByTrackFromAndTrackTo(int trackFrom, int trackTo, int deviceId)
        {
            IList<RouteDTO> routes = new List<RouteDTO>();

            IList<TrackDTO> tracks = UnitOfWork.TrackRepository.GetAllTracksByTrackFromAndTrackTo(trackFrom, trackTo, deviceId);

            TrackDTO destination = tracks.LastOrDefault();
            string deviceType = TrackMe.Support.Helpers.EnumHelper.GetDescription(destination.DeviceType);

            RouteDTO route = new RouteDTO();

            int index = 0;
            foreach (TrackDTO track in tracks)
            {
                if (index % 8 == 0)
                {
                    if (index > 0)
                        route.Destination = track;

                    route = new RouteDTO();
                    route.DeviceId = deviceId;
                    route.DeviceType = deviceType;
                    route.Origin = track;
                    route.WayPoints = new List<TrackDTO>();

                    routes.Add(route);
                }
                else
                {
                    if (index < tracks.Count)
                        route.WayPoints.Add(track);
                }

                index++;
            }

            if (route.Destination == null)
                route.Destination = destination;

            return routes;
        }