public void processLocationColumn(Column col)
        {
            int rowCount = col.Data.Count;

            string[] jsonResponse = new string[rowCount];

            for (int i = 0; i < rowCount; i++)
            {
                string address = col.Data[i];
                string url     = "https://maps.googleapis.com/maps/api/geocode/json?address=" + address + "&key=AIzaSyBe7bmv5rusSTJ__tPpPoNkCUt0rxjR7jo";
                var    request = (HttpWebRequest)WebRequest.Create(url);

                var response = (HttpWebResponse)request.GetResponse();

                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                jsonResponse[i] = responseString;
            }

            int    arrayEntryCount   = 0;
            var    locationHeirarchy = new Dictionary <int, string>();
            string countryList       = "";

            foreach (var val in jsonResponse)
            {
                dynamic jsonResult = JsonConvert.DeserializeObject(val);

                string resultStatus = jsonResult.status;

                // check if identified as a location
                if (resultStatus == "OK")
                {
                    AddressComponents[] address = jsonResult.results[0].address_components.ToObject <AddressComponents[]>();
                    countryList += address[address.Length - 1].long_name;
                    countryList += ",";
                    if (address[0].long_name.ToLower() != col.Data[arrayEntryCount].ToLower())
                    {
                        errorRows.Add(arrayEntryCount);           // if it not a location then add to error
                    }
                }
                else
                {
                    errorRows.Add(arrayEntryCount);           // if it not a location then add to error
                }

                arrayEntryCount++;
            }

            var regionParameter     = new ObjectParameter("region", typeof(string));
            var resolutionParameter = new ObjectParameter("resolution", typeof(string));

            // get
            db.getRegionCodeAndResolution(countryList, regionParameter, resolutionParameter);
            col.Region     = regionParameter.Value.ToString();
            col.Resolution = resolutionParameter.Value.ToString();
        }
        public String CheckCountry()
        {
            Column col  = new Column();
            string loc1 = "rathgama";
            string loc2 = "London";
            string loc6 = "Dublin";
            string loc3 = "Paris";
            string loc4 = "NY";
            string loc5 = "Rathnapura";

            col.Data = new List <string>();
            col.Data.Add(loc6);
            col.Data.Add(loc2);
            col.Data.Add(loc1);


            int rowCount = col.Data.Count;

            string[] jsonResponse = new string[rowCount];

            /*
             * for (int i = 0; i < rowCount; i++)
             * {
             *  string address = col.Data[i];
             *  string url = "https://maps.googleapis.com/maps/api/geocode/json?address=" + address + "&key=AIzaSyBe7bmv5rusSTJ__tPpPoNkCUt0rxjR7jo";
             *  var request = (HttpWebRequest)WebRequest.Create(url);
             *
             *  var response = (HttpWebResponse)request.GetResponse();
             *
             *  var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
             *  jsonResponse[i] = responseString;
             * }
             */
            //jsonResponse[0]="{ \"results" : [{\"address_components\" : [{\"long_name\" : \"Rathgama\",\"short_name\" : \"Rathgama\", \"types\" : [ \"locality\", \"political\" ]},{\"long_name\" : \"Galle\",  \"short_name\" : \"Galle\", \"types\" : [ \"administrative_area_level_2\", \"political\" ]},  { \"long_name\" : \"Southern Province\", \"short_name\" : \"SP\", \"types\" : [ \"administrative_area_level_1\", \"political\" ]}, { \"long_name\" : \"Sri Lanka\", \"short_name\" : \"LK\", \"types\" : [ \"country\", "political" ] } ], "formatted_address" : "Rathgama, Sri Lanka", "geometry" : { "bounds" : { "northeast" : {  "lat" : 6.0994063, "lng" : 80.15857869999999 }, "southwest" : { "lat" : 6.085765599999999, "lng" : 80.1325178} }, "location" : { "lat" : 6.0936187, "lng" : 80.14305419999999},"location_type" : "APPROXIMATE", "viewport" : {"northeast" : { "lat" : 6.0994063, "lng" : 80.15857869999999 },"southwest" : { "lat" : 6.085765599999999, "lng" : 80.1325178 } } }, "place_id" : "ChIJc73LoPd24ToRpNTaC290rk0", "types" : [ "locality", "political" ] } ], "status" : "OK"}"

            int    arrayEntryCount   = 0;
            var    locationHeirarchy = new Dictionary <int, string>();
            string countryList       = "";

            foreach (var val in jsonResponse)
            {
                arrayEntryCount++;
                dynamic jsonResult = JsonConvert.DeserializeObject(val);

                string resultStatus = jsonResult.status;

                if (resultStatus == "OK")
                {
                    //LocationCount++;
                    AddressComponents[] address = jsonResult.results[0].address_components.ToObject <AddressComponents[]>();
                    countryList += address[address.Length - 1].long_name;
                    countryList += ",";
                }
            }

            FYPEntities entity = new FYPEntities();

            var regionParameter     = new ObjectParameter("region", typeof(string));
            var resolutionParameter = new ObjectParameter("resolution", typeof(string));

            entity.getRegionCodeAndResolution(countryList, regionParameter, resolutionParameter);


            return(regionParameter.Value.ToString() + " " + resolutionParameter.Value.ToString());
        }