Beispiel #1
0
        private static IList GetCurrentDestinationType(string input)
        {
            //make first letter upper
            input = input.First().ToString().ToUpper() + input.Substring(1);

            List <City> filteredCities = FireBaseDatabase.SelectCitytBy("name", input);

            if (filteredCities != null && filteredCities.Count > 0)
            {
                return(filteredCities);
            }

            List <Country> filteredCountries = FireBaseDatabase.SelectCountryBy("name", input);

            if (filteredCountries != null && filteredCountries.Count > 0)
            {
                return(filteredCountries);
            }

            List <State> filteredStates = FireBaseDatabase.SelectStateBy("name", input);

            if (filteredStates != null && filteredStates.Count > 0)
            {
                return(filteredStates);
            }

            List <Continent> filteredContinents = FireBaseDatabase.SelectContinentBy("name", input);

            if (filteredContinents != null && filteredContinents.Count > 0)
            {
                return(filteredContinents);
            }

            return(null);
        }
Beispiel #2
0
        public static List <string> FilterDestinationsByBlogs(List <string> destinations, List <string> tags)
        {
            List <Blog>   allBlogs             = FireBaseDatabase.SelectAllBlogs();
            List <string> filteredDestinations = new List <string>();

            foreach (string destination in destinations)
            {
                List <Blog> blogs = allBlogs.Where(x => x.LocationName.ToLower().Equals(destination.ToLower())).ToList();
                blogs = FilterBlogsBy(tags, blogs);
                if (blogs.Count() > 0)
                {
                    filteredDestinations.Add(destination);
                }
            }

            return(filteredDestinations);
        }
Beispiel #3
0
        public static void UpdateBlogsTags(List <Blog> blogs)
        {
            string text;

            foreach (Blog blog in blogs)
            {
                text = Crawler.ReadTextFrom(blog.BlogLink);
                text = TextProcessor.Preprocess(text);

                List <string> tagsList = new List <string>();
                tagsList = GetTags(text);

                tagsList = tagsList.Where(tag => tag.Length > 2).ToList();


                tagsList.AddRange(blog.Tags);
                tagsList = tagsList.Distinct <string>().ToList();

                FireBaseDatabase.UpdateBlog(blog.Id, "tags", tagsList);
            }
        }
Beispiel #4
0
        private static void CreateBlogs(Object instance, Type t)
        {
            List <string> tagsList;

            Blog   blog;
            string text;
            string date;

            FieldInfo blogsField = t.GetField("blogs", BindingFlags.Instance
                                              | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy);

            Dictionary <string, List <string> > blogs = (Dictionary <string, List <string> >)blogsField.GetValue(instance);

            object[] parametersArray;

            foreach (string key in blogs.Keys)
            {
                foreach (string link in blogs[key])
                {
                    text = "";
                    date = "";

                    tagsList          = new List <string>();
                    blog              = new Blog();
                    blog.LocationName = key;
                    blog.BlogLink     = link;

                    parametersArray = new object[] { link };
                    text            = Crawler.ReadTextFrom(link);

                    tagsList  = GetTags(text);
                    blog.Tags = tagsList;

                    date      = Crawler.ReadDateFrom(link);
                    blog.Date = date;

                    FireBaseDatabase.Insert(blog);
                }
            }
        }