public GeneralResponse UpdateAirFlight(AirFlight flight) { string flightsuri = GetBaseURL() + AirFlightUrl; HttpResponseMessage HttpResp = _apimanager.Post <String, AirFlight>(flightsuri, flight); GeneralResponse resp = _apimanager.Unwrap <GeneralResponse>(HttpResp); _apimanager.CloseOrDispose(); return(resp); }
private void AddFlights(string airfile) { string path = airfile; AirFlight af = new AirFlight(); af.Source = "Bengaluru"; af.Destination = "Delhi"; List <FlightPath> flightpath = new List <FlightPath>(); af.AirFlightPath = flightpath; using (TextFieldParser parser = new TextFieldParser(path)) { parser.CommentTokens = new string[] { "#" }; parser.SetDelimiters(new string[] { "," }); parser.HasFieldsEnclosedInQuotes = true; // Skip over header line. parser.ReadLine(); int i = 0; while (!parser.EndOfData) { FlightPath fpath = new FlightPath(); string[] fields = parser.ReadFields(); if (i == 0) { af.FlightId = fields[2]; } fpath.TimeStamp = double.Parse(fields[0]); DateTime fdate = DateTime.Parse(fields[1]); af.FlightDate = fdate.Date; af.FlightDateStr = (fdate.Day - 1).ToString().PadLeft(2, '0') + "-" + fdate.Month.ToString().PadLeft(2, '0') + "-" + fdate.Year.ToString(); fpath.TimeSlice = fdate.Hour.ToString() + ":" + fdate.Minute.ToString() + ":" + fdate.Second.ToString(); string[] pos = fields[3].Split(','); fpath.Latitude = double.Parse(pos[0]); fpath.Longitude = double.Parse(pos[1]); fpath.Altitude = double.Parse(fields[4]); fpath.Speed = double.Parse(fields[5]); fpath.Direction = double.Parse(fields[6]); flightpath.Add(fpath); } } string json = JsonConvert.SerializeObject(af); GeneralResponse resp = new DataManager().AddAirFlighty(af); System.IO.File.AppendAllText(airfile + ".json", json); }