示例#1
0
        public static string LocalizeCountryAndSubdiv(string locale, string location)
        {
            string[] s = location.Split(';');
            string   country = s[0], subdivision = s[1];

            if (subdivision != "*" && !(locale == "ENUS" && country == "US"))
            {
                subdivision = SubdivisionData.QuerySubdiv(locale, country + ";" + subdivision).Name;
            }
            country = CountryData.QueryCountry(locale, country).Name;

            return(string.Join(";", new string[] { country, subdivision, s[2] }));
        }
        // TODO: Pay attention to T100FF data
        public static string QueryAirportYearAvailability(string airportCode, string codeType, string dataSrc, string locale)
        {
            NpgsqlConnection conn = null;

            try {
                conn = new NpgsqlConnection(ASTDatabase.connStr2);
                conn.Open();
                string sql = string.Format(@"SELECT ""AVAILABILITY"" FROM ""AirportAvailability"" WHERE ""CODE"" = '{0}' AND ""DATA_SOURCE"" ='{1}'",
                                           airportCode, dataSrc);

                NpgsqlCommand    command = new NpgsqlCommand(sql, conn);
                NpgsqlDataReader dr      = command.ExecuteReader();

                Airport airport = AirportData.Query(airportCode, locale);
                if (airport == null)
                {
                    return("");
                }

                while (dr.Read())
                {
                    Dictionary <string, object> res = new Dictionary <string, object>()
                    {
                        { "iata", airport.Iata },
                        { "icao", airport.Icao },
                        { "country", airport.Country },
                        { "city", airport.ServeCity[0] },
                        { "countryL", CountryData.QueryCountry(locale, airport.Country).Name },
                        { "serveCityL", City.LocalizeCountryAndSubdiv(locale, airport.ServeCity[0]) },
                        { "name", airport.FullName },
                        { "note", airport.Note },
                        { "nameEn", airport.FullName },       // TODO
                        { "cityEn", airport.ServeCity[0] },   // TODO
                        { "yearAvailability", dr["AVAILABILITY"].ToString() }
                    };
                    return(new JavaScriptSerializer().Serialize(res));
                }
            } finally {
                conn.Close();
            }
            return("");
        }
示例#3
0
 public string QueryAllCountry(string locale)
 {
     return(CountryData.QueryAllCountry(locale));
 }