/** * syncAll gets the flights from remote servers as well. */ public FlightPlan GetRemoteFlightPlan(string flightId) { FlightPlan flightPlan; RemoteFlightIdToPlan.TryGetValue(flightId, out flightPlan); if (flightPlan != null) { return(flightPlan); } RemoteFlightIdToServer.TryGetValue(flightId, out Server server); if (server == null) { return(FlightPlan.NULL); } try { StringBuilder url = new StringBuilder(server.ServerUrl); url.Append("/api/FlightPlan/"); url.Append(flightId); Task <string> queryResult = ExecuteAsyncGet(url.ToString()); flightPlan = JsonConvert.DeserializeObject <FlightPlan>(queryResult.Result); RemoteFlightIdToPlan.TryAdd(flightId, flightPlan); return(flightPlan); } catch (Exception) { return(FlightPlan.NULL); } }
/* Query remote server and add its flights to total flights */ private void QueryAndGetFlights(string url, Server server, List <Flight> totalFlights) { Task <string> queryResult = ExecuteAsyncGet(url); List <Flight> flights = JsonConvert.DeserializeObject <List <Flight> >(queryResult.Result); foreach (Flight remoteFlight in flights) { remoteFlight.Is_External = true; totalFlights.Add(remoteFlight); RemoteFlightIdToServer.TryAdd(remoteFlight.Flight_Id, server); } }