public void InsertTopics() { string[] sep = new string[] { "," }; IList <Topic> topics = new List <Topic>(); Ward.Provider provider = new Ward.Provider(); var zones = provider.RetrieveZones(); if (zones != null && zones.Count() > 0) { foreach (var zone in zones.Split(sep, StringSplitOptions.RemoveEmptyEntries)) { var wards = provider.RetrieveWards(zone); if (wards != null && wards.Count() > 0) { foreach (var ward in wards.Split(sep, StringSplitOptions.RemoveEmptyEntries)) { Topic topic = new Topic { Id = Guid.NewGuid(), Name = zone.Replace('"', ' ').Trim() + "-" + ward.Replace('"', ' ').Trim() }; topics.Add(topic); } } } } context.Topics.InsertAllOnSubmit(topics.AsEnumerable()); SubmitData(); }
/// <summary> /// RetrieveWardDataforLocality /// </summary> private static void RetrieveWardDataforLocality() { Console.WriteLine("Input Locality Name"); string localityName = Console.ReadLine(); WardData.Provider provider = new WardData.Provider(); string wardName = provider.RetrieveWard(localityName); Console.WriteLine("The ward name you belong is " + wardName); }
/// <summary> /// GetWard based on latitude and longitude /// </summary> /// <param name="latitude"></param> /// <param name="longitude"></param> /// <returns></returns> public string GetWard(string key1, string key2) { WardData.Provider rdr = new WardData.Provider(); string ward = rdr.RetrieveWard(key1.Replace('_', '.'), key2.Replace('_', '.')); if (string.IsNullOrEmpty(ward)) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(ward); }
/// <summary> /// GetWard based on latitude and longitude /// </summary> /// <param name="latitude"></param> /// <param name="longitude"></param> /// <returns></returns> public string GetWard(string key1, string key2) { WardData.Provider rdr = new WardData.Provider(); string ward = rdr.RetrieveWard(key1.Replace('_', '.'), key2.Replace('_', '.')); if (string.IsNullOrEmpty(ward)) { throw new HttpResponseException(HttpStatusCode.NotFound); } return ward; }
/// <summary> /// Retrieve Localities /// </summary> private static void RetrieveLocalities() { Console.WriteLine("Input Locality Name"); string localityName = Console.ReadLine(); WardData.Provider provider = new WardData.Provider(); var localities = provider.RetrieveLocalities(localityName); foreach (var locality in localities) { Console.WriteLine(locality.Name); } }
/// <summary> /// RetrieveData /// </summary> private static void RetrieveWardDataforCordinates() { Console.WriteLine("Input Latitude"); string latitude = Console.ReadLine(); Console.WriteLine("Input Longitude"); string longitude = Console.ReadLine(); WardData.Provider provider = new WardData.Provider(); string wardName = provider.RetrieveWard(latitude, longitude); Console.WriteLine("The ward name you belong is " + wardName); }
/// <summary> /// ProcessLocalityDataforWards /// </summary> private static void ProcessLocalityDataforWards() { string[] files = Directory.GetFiles(@"C:\Users\nairs6\Downloads"); foreach (var file in files) { if (file.Contains(".csv")) { string path = file; WardData.Provider provider = new WardData.Provider(); provider.InsertWard(path); } } }
/// <summary> /// PostSpotImageProcess /// </summary> public void PostSpotImageProcess() { var spotImages = context.SpotImages.Where(@w => @w.WardId == null && @w.UserAddress == null); WardData.Provider provider = new WardData.Provider(); foreach (var spotImage in spotImages) { var ward = provider.RetrieveWard(spotImage.Latitude, spotImage.Longitude); spotImage.WardId = context.Wards.Where(@w => @w.Name == ward).First().Id; string url = string.Format("http://maps.googleapis.com/maps/api/geocode/xml?latlng={0},{1}&sensor=false", spotImage.Latitude, spotImage.Longitude); XElement xml = XElement.Load(url); if (xml.Element("status").Value == "OK") { spotImage.UserAddress = xml.Element("result").Element("formatted_address").Value; } } SubmitData(); }
/// <summary> /// InsertWard Information from CSV /// </summary> private static void ProcessCordinateDataforWards() { string[] directories = Directory.GetDirectories(@"C:\Users\nairs6\Downloads"); //Retrieve the Zone Details WardData.Provider provider = new WardData.Provider(); foreach (var directory in directories) { if (!directory.Contains("Processed")) { string zoneNumber = directory.Substring(directory.LastIndexOf('\\')).Split('-')[0].Replace("\\", ""); string zoneName = directory.Substring(directory.LastIndexOf('\\')).Split('-')[1].Replace(".txt", ""); provider.InsertZone(Convert.ToInt32(zoneNumber), zoneName); Zone zone = provider.RetrieveZone(Convert.ToInt32(zoneNumber)); if (zone == null) { Environment.Exit(0); } Console.WriteLine("The zone selected is " + zone.Name); string[] files = Directory.GetFiles(@"C:\Users\nairs6\Downloads\" + zoneNumber + "-" + zoneName); foreach (var file in files) { if (file.Contains(".txt")) { string wardNumber = file.Substring(file.LastIndexOf('\\')).Split('-')[0].Replace("\\", ""); string wardName = file.Substring(file.LastIndexOf('\\')).Split('-')[1].Replace(".txt", ""); string path = file; provider.InsertWard(zone.Id, Convert.ToInt32(wardNumber), wardName, path); } } } } }
/// <summary> /// RetrieveData /// </summary> private static void RetrieveWardDataforCordinates() { Console.WriteLine("Input Latitude"); string latitude = Console.ReadLine(); Console.WriteLine("Input Longitude"); string longitude = Console.ReadLine(); WardData.Provider provider = new WardData.Provider(); string wardName = provider.RetrieveWard(latitude, longitude); Console.WriteLine("The ward name you belong is " + wardName); }
/// <summary> /// InsertWard Information from CSV /// </summary> private static void ProcessCordinateDataforWards() { string[] directories = Directory.GetDirectories(@"C:\Users\nairs6\Downloads"); //Retrieve the Zone Details WardData.Provider provider = new WardData.Provider(); foreach (var directory in directories) { if (!directory.Contains("Processed")) { string zoneNumber = directory.Substring(directory.LastIndexOf('\\')).Split('-')[0].Replace("\\", ""); string zoneName = directory.Substring(directory.LastIndexOf('\\')).Split('-')[1].Replace(".txt", ""); provider.InsertZone(Convert.ToInt32(zoneNumber), zoneName); Zone zone = provider.RetrieveZone(Convert.ToInt32(zoneNumber)); if (zone == null) { Environment.Exit(0); } Console.WriteLine("The zone selected is " + zone.Name); string[] files = Directory.GetFiles(@"C:\Users\nairs6\Downloads\" + zoneNumber + "-" + zoneName); foreach (var file in files) { if (file.Contains(".txt")) { string wardNumber = file.Substring(file.LastIndexOf('\\')).Split('-')[0].Replace("\\", ""); string wardName = file.Substring(file.LastIndexOf('\\')).Split('-')[1].Replace(".txt", ""); string path = file; provider.InsertWard(zone.Id, Convert.ToInt32(wardNumber), wardName, path); } } } } }
/// <summary> /// ProcessLocalityDataforWards /// </summary> private static void ProcessLocalityDataforWards() { string[] files = Directory.GetFiles(@"C:\Users\nairs6\Downloads"); foreach (var file in files) { if (file.Contains(".csv")) { string path = file; WardData.Provider provider = new WardData.Provider(); provider.InsertWard(path); } } }
/// <summary> /// RetrieveWardDataforLocality /// </summary> private static void RetrieveWardDataforLocality() { Console.WriteLine("Input Locality Name"); string localityName = Console.ReadLine(); WardData.Provider provider = new WardData.Provider(); string wardName = provider.RetrieveWard(localityName); Console.WriteLine("The ward name you belong is " + wardName); }
/// <summary> /// Retrieve Localities /// </summary> private static void RetrieveLocalities() { Console.WriteLine("Input Locality Name"); string localityName = Console.ReadLine(); WardData.Provider provider = new WardData.Provider(); var localities = provider.RetrieveLocalities(localityName); foreach (var locality in localities) { Console.WriteLine(locality.Name); } }
/// <summary> /// GetWard based on locality /// </summary> /// <param name="key"></param> /// <returns></returns> public string GetWard(string key) { var values = key.Split('|'); if (values.Length > 0) { WardData.Provider rdr = new WardData.Provider(); string method = values[0].ToLower(); if (method == "zones") { string zones = rdr.RetrieveZones(); if (string.IsNullOrEmpty(zones)) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(zones); } else if (method == "wards") { string data = values[1]; string wards = rdr.RetrieveWards(data); if (string.IsNullOrEmpty(wards)) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(wards); } else if (method == "ward") { string data = values[1]; string ward = rdr.RetrieveWard(data); if (string.IsNullOrEmpty(ward)) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(ward); } else if (method == "locality") { string data = values[1]; var localities = rdr.RetrieveLocalities(data); StringBuilder localityList = new StringBuilder(); foreach (var locality in localities) { localityList.Append(locality.Name + ","); } if (localities == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(localityList.ToString()); } } return("100"); }
/// <summary> /// GetWard based on locality /// </summary> /// <param name="key"></param> /// <returns></returns> public string GetWard(string key) { var values = key.Split('|'); if (values.Length > 0) { WardData.Provider rdr = new WardData.Provider(); string method = values[0].ToLower(); if (method == "zones") { string zones = rdr.RetrieveZones(); if (string.IsNullOrEmpty(zones)) { throw new HttpResponseException(HttpStatusCode.NotFound); } return zones; } else if (method == "wards") { string data = values[1]; string wards = rdr.RetrieveWards(data); if (string.IsNullOrEmpty(wards)) { throw new HttpResponseException(HttpStatusCode.NotFound); } return wards; } else if (method == "ward") { string data = values[1]; string ward = rdr.RetrieveWard(data); if (string.IsNullOrEmpty(ward)) { throw new HttpResponseException(HttpStatusCode.NotFound); } return ward; } else if(method == "locality") { string data = values[1]; var localities = rdr.RetrieveLocalities(data); StringBuilder localityList = new StringBuilder(); foreach (var locality in localities) { localityList.Append(locality.Name + ","); } if (localities == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return localityList.ToString(); } } return "100"; }
public void InsertTopics() { string[] sep = new string[] { "," }; IList<Topic> topics = new List<Topic>(); Ward.Provider provider = new Ward.Provider(); var zones = provider.RetrieveZones(); if (zones != null && zones.Count() > 0) { foreach (var zone in zones.Split(sep, StringSplitOptions.RemoveEmptyEntries)) { var wards = provider.RetrieveWards(zone); if (wards != null && wards.Count() > 0) { foreach (var ward in wards.Split(sep, StringSplitOptions.RemoveEmptyEntries)) { Topic topic = new Topic { Id = Guid.NewGuid(), Name = zone.Replace('"', ' ').Trim() + "-" + ward.Replace('"', ' ').Trim() }; topics.Add(topic); } } } } context.Topics.InsertAllOnSubmit(topics.AsEnumerable()); SubmitData(); }