Exemplo n.º 1
0
        static void CultureTest()
        {
            CultureInfo[] cinfo = CultureInfo.GetCultures(CultureTypes.AllCultures);
            CountryProcessingToDatabase dbProcessor = new CountryProcessingToDatabase();

            foreach (CultureInfo cul in cinfo)
            {
                RegionInfo ri = null;
                try {
                    ri = new RegionInfo(cul.Name);
                    string TwoLetterISORegionName     = ri.TwoLetterISORegionName;
                    string ThreeLetterISORegionName   = ri.ThreeLetterISORegionName;
                    string TwoLetterISOLanguageName   = cul.TwoLetterISOLanguageName;
                    string ThreeLetterISOLanguageName = cul.ThreeLetterISOLanguageName;
                    var    country = dbProcessor.Countries.FirstOrDefault(n => n.Alpha2Code == TwoLetterISORegionName);

                    string RegionName = cul.Name;
                    if (country != null)
                    {
                        if (string.IsNullOrEmpty(country.Culture))
                        {
                            country.Culture = RegionName;
                        }
                        Console.WriteLine("RegionName :" + RegionName + " ;        Country:" + country.CountryName);
                    }
                    else
                    {
                        Console.WriteLine("Country not found for : " + TwoLetterISORegionName);
                    }
                    dbProcessor.SaveChanges();
                } catch {
                    continue;
                }
            }
        }
Exemplo n.º 2
0
        static void ProcessCulture2()
        {
            CountryParser parser = new CountryParser();
            CountryProcessingToDatabase dbProcessor = new CountryProcessingToDatabase();
            var cultures = parser.ParseCultureFromWebsite();

            dbProcessor.InsertCultureforCountries(cultures);
        }
Exemplo n.º 3
0
        static void Intial()
        {
            CountryParser parser = new CountryParser();
            CountryProcessingToDatabase dbProcessor = new CountryProcessingToDatabase();

            parser.InsertAllLanguageThenCountries("allLanguages.json", "countryjson.json");
            ProcessCulture2();
            dbProcessor.InsertPageNumbersInCountryTable();
        }
Exemplo n.º 4
0
        static void ProcessCountries()
        {
            CountryParser parser = new CountryParser();
            CountryProcessingToDatabase dbProcessor = new CountryProcessingToDatabase();

            string fileloc = "Log.txt";

            //-----
            Console.Write("Input Country 2 Digit Alpha Code:");
            var inputCountryCode = Console.ReadLine();
            var countryX         = dbProcessor.Countries.FirstOrDefault(n => n.Alpha2Code == inputCountryCode);
            int countryid        = 0;

            if (countryX != null)
            {
                countryid = countryX.CountryID;
            }
            var countries = dbProcessor.Countries.Where(n => n.CountryID >= countryid).ToList();

            foreach (var country in countries)
            {
                //string url = "http://www.geonames.org/search.html?q=" + country.CountryName;
                //string url = "http://www.geonames.org/advanced-search.html?q=&country=BD&featureClass=A&continentCode=";
                string url = "http://www.geonames.org/advanced-search.html?q=&country=" + country.Alpha2Code + "&featureClass=A";
                File.AppendAllText(fileloc, DateTime.Now + " :: " + url + "\n");
                bool isFeatured = true;
                Console.WriteLine(url);

                int length = 101;//183189;//183189
                length = parser.GetPagesLength(url, isFeatured);

                Console.WriteLine("Length : " + length);
                //length = 1;
                if (length >= 101)
                {
                    length = 101;
                }
                for (int i = 0; i < length; i++)
                {
                    Console.Write("Page : " + (i + 1) + " downloading...");
                    var items = parser.ParseHTML(url, i, 0, -1, true, country);

                    //var items = parser.ParseHTML(url, i, 24, 1);
                    Console.Write(" downloaded... processing...");
                    if (items != null)
                    {
                        foreach (var item in items)
                        {
                            //DisplayCountrytemp.Print(item, -1);
                            dbProcessor.EntryWholeCountryFromCounrtyTemp(item);
                        }
                        Console.Write(" done.\n");
                        File.AppendAllText(fileloc, DateTime.Now + " :: Done Page ::" + (i + 1) + "\n");
                    }
                    else
                    {
                        Console.Write(" none found.\n");
                        File.AppendAllText(fileloc, DateTime.Now + " :: Error not found ::" + url + " ; page no :" + (i + 1) + "\n");
                    }
                }
            }


            dbProcessor.SaveErrorList();
        }