Exemple #1
0
        public string GetCarPoint(string id, string type)
        {
            string sn        = "";
            string startTime = "";
            string endTime   = "";
            string Url       = new DataItemDetailBLL().GetItemValue("IOTUrl");

            switch (type)
            {
            case "0":
                break;

            case "1":
                break;

            case "2":
                break;

            case "3":
                var visitcar = visitbll.GetEntity(id);
                sn = visitcar.GPSID;
                if (visitcar.InTime != null)
                {
                    startTime = Convert.ToDateTime(visitcar.InTime).ToString("yyyy-MM-ddTHH:mm:ss");
                }
                else
                {
                    startTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
                }

                if (visitcar.OutTime != null)
                {
                    endTime = Convert.ToDateTime(visitcar.InTime).ToString("yyyy-MM-ddTHH:mm:ss");
                }
                else
                {
                    endTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
                }

                break;

            case "4":
                var opercar = operbll.GetEntity(id);
                sn = opercar.GpsId;
                if (opercar.Getdata != null)
                {
                    startTime = Convert.ToDateTime(opercar.Getdata).ToString("yyyy-MM-ddTHH:mm:ss");
                }
                else
                {
                    startTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
                }

                if (opercar.OutDate != null)
                {
                    endTime = Convert.ToDateTime(opercar.OutDate).ToString("yyyy-MM-ddTHH:mm:ss");
                }
                else
                {
                    endTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
                }
                break;

            case "5":
                var hazardouscar = hazarbll.GetEntity(id);
                sn = hazardouscar.GPSID;
                if (hazardouscar.InTime != null)
                {
                    startTime = Convert.ToDateTime(hazardouscar.InTime).ToString("yyyy-MM-ddTHH:mm:ss");
                }
                else
                {
                    startTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
                }

                if (hazardouscar.OutTime != null)
                {
                    endTime = Convert.ToDateTime(hazardouscar.InTime).ToString("yyyy-MM-ddTHH:mm:ss");
                }
                else
                {
                    endTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
                }
                break;
            }
            string          json      = "{\"sn\": \"" + sn + "\",\"startTime\": \"" + startTime + "\",\"endTime\": \"" + endTime + "\"}";
            string          msg       = HttpCommon.HttpPostJson(Url + "/services/app/GpsCar/GetDeviceGpsData", json);
            IotCar          car       = JsonConvert.DeserializeObject <IotCar>(msg);
            GpsList         gps       = new GpsList();
            List <GpsPoint> PointList = new List <GpsPoint>();

            foreach (var carGpsData in car.result)
            {
                GpsPoint point = new GpsPoint();
                point.X = Convert.ToDouble(carGpsData.Latitude);
                point.Y = Convert.ToDouble(carGpsData.Longitude);
                point.Z = 200;
                PointList.Add(point);
            }

            gps.ID   = id;
            gps.data = PointList;
            return(gps.ToJson());
        }
        public ActionResult GetFormJson(string keyValue)
        {
            var data = visitcarbll.GetEntity(keyValue);

            return(ToJsonResult(data));
        }