Пример #1
0
        public PatrolLastLocationDTO RecommendCar(double lat, double lon)
        {
            int maxAllowedTimeInMin = 10;

            int.TryParse(ConfigurationManager.AppSettings["MaxAllowedTimeMins"], out maxAllowedTimeInMin);
            var currentSession = GetActiveSession();

            if (currentSession.MaxAllowedTimeMin.HasValue)
            {
                maxAllowedTimeInMin = currentSession.MaxAllowedTimeMin.Value;
            }
            DoIterate(currentSession.SessionName);
            var carRec    = _client.recommendCar(currentSession.SessionName, lon, lat, maxAllowedTimeInMin * 60 * 1000);
            var crispCars = _client.getCars(currentSession.SessionName);
            var patrols   = new PatrolsDAL().GetPatrolsList(null);

            if (crispCars != null && patrols != null && crispCars.Any() && patrols.Any())
            {
                var crispCar = crispCars.FirstOrDefault(x => x.id == carRec);
                var p        = patrols.FirstOrDefault(x => x.PatrolId.ToString() == crispCar.id);
                if (p != null)
                {
                    p.IsRecommended = true;
                }
                return(p);
            }
            return(null);
        }
Пример #2
0
        public List <PatrolLastLocationDTO> PositionsCars()
        {
            var  res         = new List <PatrolLastLocationDTO>();
            var  sessionName = GetActiveSession().SessionName;
            bool bMax        = false;

            bool.TryParse(ConfigurationManager.AppSettings["IsCrispBMax"], out bMax);
            DoIterate(sessionName);
            var locations    = _client.getLocations(sessionName, bMax);
            var allLocations = _client.getNodes(sessionName);
            var allPatrols   = new PatrolsDAL().GetPatrolsList(null);
            var allCars      = _client.getCars(sessionName);

            if (locations != null && locations.Any() && allLocations != null && allLocations.Any() && allPatrols != null && allPatrols.Any() && allCars != null && allCars.Any())
            {
                int index = 0;
                foreach (var item in locations)
                {
                    var location = allLocations.FirstOrDefault(x => x.id == item);
                    var patrol   = allPatrols.FirstOrDefault(x => x.PatrolId.ToString() == allCars[index].id);
                    if (patrol != null)
                    {
                        patrol.Longitude     = location.X;
                        patrol.Latitude      = location.Y;
                        patrol.IsRecommended = true;
                        res.Add(patrol);
                    }
                    index++;
                }
            }
            return(res);
        }
Пример #3
0
        public List <PatrolLastLocationDTO> GetPatrolsETA(double latitude, double longitude)
        {
            var res = new List <PatrolLastLocationDTO>();

            try
            {
                var sessionName = GetActiveSession().SessionName;
                DoIterate(sessionName);
                res = new PatrolsDAL().GetPatrolsList(null);
                var allCars = _client.getCars(sessionName);
                if (allCars != null && allCars.Any())
                {
                    foreach (var item in allCars)
                    {
                        var patrol = res.FirstOrDefault(x => x.PatrolId.ToString() == item.id);
                        if (patrol != null)
                        {
                            var time = _client.getETA(sessionName, longitude, latitude, item.id);
                            patrol.ETATime = time;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(res);
        }
        public bool UpdatePatrolLocations()
        {
            var allPatrolsLocations = GetPatrolsLocations();

            if (allPatrolsLocations != null && allPatrolsLocations.Any())
            {
                var res = new PatrolsDAL().UpdatePatrolLocation(allPatrolsLocations.ToList());
                new CrsipServices().PrepareCars();
                return(res);
            }
            return(false);
        }
Пример #5
0
        public void PrepareCars()
        {
            var patrols = new PatrolsDAL().GetPatrolsList(1);

            HandleCars(patrols);
        }