Exemple #1
0
        public ActionResult getAlertData(Guid ID)
        {
            alertData         AD  = alertService.getAlertData(ID);
            extendedAlertData EAD = new extendedAlertData();

            EAD.alert                 = AD.alert;
            EAD.alertGeoFences        = AD.alertGeoFences;
            EAD.alertVehicles         = AD.alertVehicles;
            EAD.extendedAlertFences   = new List <PolygonService.polygonData>();
            EAD.extendedAlertVehicles = new List <Vehicle>();


            foreach (alertGeoFence gf in AD.alertGeoFences)
            {
                PolygonService.polygonData poly = new PolygonService.polygonData();
                poly = polygonService.getPolygons().Where(p => p.geoFenceID == gf.GeoFenceID).FirstOrDefault();
                EAD.extendedAlertFences.Add(poly);
            }

            foreach (alertVehicle av in AD.alertVehicles)
            {
                Vehicle v = new Vehicle();
                v = truckService.getAllVehicles(true).Where(vh => vh.extendedData.ID == av.VehicleID).FirstOrDefault();
                EAD.extendedAlertVehicles.Add(v);
            }

            return(Json(EAD, JsonRequestBehavior.AllowGet));
        }
        public ActionResult addFence(string type, string polyName, string notes, string geofenceID, string geoFence, string radius)
        {
            PolygonService.polygonData   polygon  = new PolygonService.polygonData();
            List <PolygonService.LatLon> LatLongs = new List <PolygonService.LatLon>();

            polygon.geoType    = type;
            polygon.polyName   = polyName;
            polygon.notes      = notes;
            polygon.geoFenceID = new Guid(geofenceID);

            string[] coords = geoFence.Split(',');
            foreach (string s in coords)
            {
                string[] latlong         = s.Split('^');
                PolygonService.LatLon LL = new PolygonService.LatLon();
                LL.Lat = Convert.ToDouble(latlong[0]);
                LL.Lon = Convert.ToDouble(latlong[1]);
                LatLongs.Add(LL);
            }
            polygon.radius   = (type == "circle") ? Convert.ToDouble(radius) : 0;
            polygon.geoFence = LatLongs;

            var success = polygonService.addPolygon(polygon);

            return(Json(success, JsonRequestBehavior.AllowGet));
        }