public IHttpActionResult SaveGps(string Latitude, string Longitude, int deviceid, string devicename) { try { using (kernels1_itiEntities DB = new kernels1_itiEntities()) { DATA.VehicleTracking gps = new VehicleTracking(); gps.Latitude = Latitude; gps.Longitude = Longitude; gps.deviceid = deviceid; gps.DeviceTime = devicename; TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"); DateTime timeUtc = DateTime.UtcNow; DateTime result = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, timeZoneInfo); gps.updatedDate = result; DB.VehicleTrackings.Add(gps); DB.SaveChanges(); } var response = new { Success = true, Message = "GPS Coorinates saved Successfully", }; return(Ok(response)); } catch (Exception) { return(Content(HttpStatusCode.BadRequest, "Error Found")); } }
void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e) { // txtLatitude.Text = e.Position.Location.Latitude.ToString("0.000"); //show the coordinates in the text boxes and format //txtLongitude.Text = e.Position.Location.Longitude.ToString("0.000"); // value to string //map1.Center = new GeoCoordinate(e.Position.Location.Latitude, e.Position.Location.Longitude); // update map to current location map1.SetView(new GeoCoordinate(e.Position.Location.Latitude, e.Position.Location.Longitude), 16); // automatically set map view to gps //map1.SetView(map1.Center, 12, e.Position.Location.Course); // automatically set map view to gps Pushpin p = new Pushpin(); p.Location = new GeoCoordinate(e.Position.Location.Latitude, e.Position.Location.Longitude); map1.Children.Add(p); //http://www.codeproject.com/Tips/437785/Bing-Maps-in-Windows-Phone submitTime = DateTime.Now; try { cam.FlashMode = FlashMode.Off; cam.Resolution = new Size(200, 200); cam.CaptureImage(); } catch (Exception ex) { this.Dispatcher.BeginInvoke(delegate() { txtMessage.Text = ex.Message; }); } VehicleTracking vLoc = new VehicleTracking() { vehicle_id = "fleet_1", //add location info,data latitude = e.Position.Location.Latitude, longitude = e.Position.Location.Longitude, time = submitTime //altitude = e.Position.Location.Altitude, //vehicleHeading = e.Position.Location.Course }; lat = e.Position.Location.Latitude; lon = e.Position.Location.Longitude; vt.Add(vLoc); //add vehicle location to vehicle list if (vt.Count > 5) //every 15 positions update webservice accordingly { vhs.SetArrayOfVehicleTrackingAsync(vt.ToArray()); //convert list to array vt.Clear(); //clear items so that resources are refreshed } vhs.GetCurrentVehicleTrackingAsync(vLoc.vehicle_id); }
void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e) { // txtLatitude.Text = e.Position.Location.Latitude.ToString("0.000"); //show the coordinates in the text boxes and format //txtLongitude.Text = e.Position.Location.Longitude.ToString("0.000"); // value to string //map1.Center = new GeoCoordinate(e.Position.Location.Latitude, e.Position.Location.Longitude); // update map to current location map1.SetView(new GeoCoordinate(e.Position.Location.Latitude, e.Position.Location.Longitude), 16); // automatically set map view to gps //map1.SetView(map1.Center, 12, e.Position.Location.Course); // automatically set map view to gps try { cam.CaptureImage(); } catch (Exception ex) { this.Dispatcher.BeginInvoke(delegate() { txtMessage.Text = ex.Message; }); } VehicleTracking vLoc = new VehicleTracking() { vehicle_id = "fleet_1", //add location info,data latitude = e.Position.Location.Latitude, longitude = e.Position.Location.Longitude, time = DateTime.Now //altitude = e.Position.Location.Altitude, //vehicleHeading = e.Position.Location.Course }; vt.Add(vLoc); //add vehicle location to vehicle list if (vt.Count > 5) //every 15 positions update webservice accordingly { vhs.SetArrayOfVehicleTrackingAsync(vt.ToArray()); //convert list to array vhs.SetArrayOfVehicleTrackingAsync(vt.ToArray()); vt.Clear(); //clear items so that resources are refreshed } }