public string To_Call(string s) { s = s.Replace("\"", String.Empty).ToUpper().Trim(); // check length if (s.Length < 4) { return(null); } if (s.Contains('-')) { return(null); } // check for numeric flight number string icao = s.Substring(0, 3); try { // try to find the string in aircraft registration database AirlineDesignator airline = AirlineDirectory.FindByICAO(icao); if (airline != null) { return(s); } } catch (Exception ex) { Console.WriteLine("[" + System.Reflection.MethodBase.GetCurrentMethod().Name + "]" + ex.Message + ": " + s); } return(null); }
public string To_Flight(string s) { s = s.Replace("\"", String.Empty).ToUpper().Trim(); if (s.Length < 3) { return(null); } string iata = s.Substring(0, 2); string flightnumber = s.Substring(2); if (!IsInt(flightnumber)) { return(null); } try { // try to find the string in IATA airline database AirlineDesignator airline = AirlineDirectory.FindByIATA(iata); if (airline != null) { return(s); } } catch (Exception ex) { Console.WriteLine("[" + System.Reflection.MethodBase.GetCurrentMethod().Name + "]" + ex.Message + ": " + s); } return(null); }