public List<SearchItem> GetAirports()
        {
            var airportsList = new List<SearchItem>();
            try
            {
                var db = new MySqlDatabase(DbConfiguration.DatabaseRead);
                DataSet dataSet = db.ExecuteQuery(CommandBuilder.BuildGetAirportsCommand(db.Connection));

                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    var item = new SearchItem
                                   {
                                       Name = row["AirportName"] as string,
                                       Code = row["AirportCode"] as string,
                                       CityName = row["CityName"] as string,
                                       CountryCode = row["CountryCode"] as string
                                   };
                    airportsList.Add(item);
                }
            }
            catch (Exception ex)
            {
                DBExceptionLogger.LogException(ex, Source, "GetAirports", Severity.Critical);
            }
            return airportsList;
        }
Esempio n. 2
0
        private static Document IndexDocument(SearchItem item)
        {
            var doc = new Document();
            doc.Add(new Field("SearchKey", (item.FullTextColumn ?? item.Code), Field.Store.NO, Field.Index.ANALYZED));
            doc.Add(new Field("Type", "Airport", Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("Name", item.Name, Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("Code", item.Code ?? string.Empty, Field.Store.YES, Field.Index.NOT_ANALYZED));

            doc.Add(new Field("CityName", item.CityName ?? string.Empty, Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("CountryCode", item.CountryCode ?? string.Empty, Field.Store.YES, Field.Index.NOT_ANALYZED));

            return doc;
        }