public static void ProccesPlanepolyMovie(HttpRequest Request, HttpResponse Response) { WebClient client = new WebClient(); string url = "https://www.planepoly.com:8181/PlanepolyCoreWeb/OSConcierge?lat=6.210506&long=-75.57096&idTipos=201&consulta=eventos&bypass=626262"; Stream data = client.OpenRead(url); StreamReader reader = new StreamReader(data); string s = reader.ReadToEnd(); data.Close(); reader.Close(); Response.AddHeader("Access-Control-Allow-Origin", "*"); var movieList = JsonConvert.DeserializeObject <Movie>(s); var movieServiceList = movieList.servicios; foreach (var it in movieServiceList) { it.nombre = it.nombre.Trim(); } var movieListOrdered = movieServiceList.OrderByDescending(x => x.estr).OrderBy(x => x.nombre).ToList(); movieList.servicios = movieListOrdered; List <string> theaterNameList = new List <string>(); movieList.servicios.ForEach(x => x.ptos.Select(y => y.nombre).ToList().ForEach(z => theaterNameList.Add(z))); var theatersList = theaterNameList.Distinct().OrderBy(y => y).ToList(); var genresList = (from service in movieServiceList orderby service.genero select service.genero).Distinct().ToList <String>(); var allMovieNameList = (from service in movieServiceList orderby service.nombre select service.nombre).Distinct().ToList <string>(); MovieCatalog movieCatalog = new MovieCatalog(); movieCatalog.theaters = theatersList; movieCatalog.genres = genresList; movieCatalog.movies = allMovieNameList; Dictionary <string, List <string> > theaterMoviesList = new Dictionary <string, List <string> >(); foreach (var item in movieCatalog.theaters) { List <string> movieNameList = new List <string>(); theaterMoviesList.Add(item, movieNameList); } List <MovieLookup> movieLookupList = new List <MovieLookup>(); foreach (var service in movieList.servicios) { MovieLookup movieLookup = new MovieLookup(); movieLookup.name = service.nombre; movieLookup.img = service.img; movieLookup.url = service.url; movieLookup.premiere = service.estr; movieLookup.genre = service.genero; movieLookup.locations = new List <MovieLookupLocation>(); foreach (var location in service.ptos) { if (theaterMoviesList.ContainsKey(location.nombre)) { var tempList = theaterMoviesList[location.nombre]; tempList.Add(service.nombre); } MovieLookupLocation mlLocation = new MovieLookupLocation(); mlLocation.name = location.nombre; mlLocation.address = location.direccion; List <MovieLookupShow> mlShowList = new List <MovieLookupShow>(); Dictionary <int, string> shows = new Dictionary <int, string>(); shows.Add(0, ""); shows.Add(1, ""); shows.Add(2, ""); shows.Add(3, ""); shows.Add(4, ""); shows.Add(5, ""); shows.Add(6, ""); shows.Add(7, ""); foreach (var show in location.funcs) { if (shows.ContainsKey(show.dia)) { var valDay = shows[show.dia]; valDay += show.hora + " "; shows[show.dia] = valDay; } } foreach (var it in shows) { if (it.Value.Trim() != "") { MovieLookupShow mls = new MovieLookupShow(); mls.frequency = it.Key; mls.hours = it.Value.Trim(); switch (mls.frequency) { case 0: mls.name = "Diario"; break; case 1: mls.name = "Lunes"; break; case 2: mls.name = "Martes"; break; case 3: mls.name = "Miércoles"; break; case 4: mls.name = "Jueves"; break; case 5: mls.name = "Viernes"; break; case 6: mls.name = "Sábado"; break; case 7: mls.name = "Domingo"; break; default: break; } mlShowList.Add(mls); } } mlLocation.schedule = mlShowList; movieLookup.locations.Add(mlLocation); } movieLookupList.Add(movieLookup); } foreach (var it in theaterMoviesList) { it.Value.Sort(); } movieCatalog.theaterMovies = theaterMoviesList; var movieLookupListOrdered = (from item in movieLookupList orderby item.premiere descending, item.name select item).ToList(); string movieCatalogJSON = JsonConvert.SerializeObject(movieCatalog); string movieLookupJSON = JsonConvert.SerializeObject(movieLookupListOrdered); Response.Write(JsonConvert.SerializeObject(movieLookupListOrdered)); // Now that we have just gathered all the information, create static JSON versions // Now there are two files to consume the feed // Full movie catalog (mapped from origin). string fileName = @"D:\SitiosWeb\Sitio\EC100A_Servicios\EC100A_PlanepolyWidget\planepoly-movies.json"; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(movieLookupJSON); } fileName = @"D:\SitiosWeb\Sitio\EC100A_Servicios\EC100A_PlanepolyWidget\planepoly-movies-catalog.json"; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(movieCatalogJSON); } }
public static void ProccesPlanepolyEvent(HttpRequest Request, HttpResponse Response) { List <EventService> eventPlanepolyServiceList = new List <EventService>(); string[] urls = { "https://www.planepoly.com:8181/PlanepolyCoreWeb/OSConcierge?lat=6.210506&long=-75.57096&idTipos=202&consulta=eventos&bypass=626262" /* Refers to 'Obras de Teatro' at Planepoly.com */, "https://www.planepoly.com:8181/PlanepolyCoreWeb/OSConcierge?lat=6.210506&long=-75.57096&idTipos=203&consulta=eventos&bypass=626262" /* Refers to 'Conciertos' at Planepoly.com */, "https://www.planepoly.com:8181/PlanepolyCoreWeb/OSConcierge?lat=6.210506&long=-75.57096&idTipos=209&consulta=eventos&bypass=626262" /* Refers to 'Culturales' at Planepoly.com */ }; //string[] urls = { "https://www.planepoly.com:8181/PlanepolyCoreWeb/OSConcierge?lat=6.210506&long=-75.57096&idTipos=203&consulta=eventos&bypass=626262" /* Refers to 'Obras de Teatro' at Planepoly.com */}; string s = ""; try { for (int i = 0; i < urls.Length; i++) { s = ReadHtmlPageContent(urls[i]); Event o = JsonConvert.DeserializeObject <Event>(s); foreach (var item in o.servicios) { eventPlanepolyServiceList.Add(item); } } } catch (Exception e) { Response.Write("{0} Exception caught." + e.ToString()); } Response.AddHeader("Access-Control-Allow-Origin", "*"); // Get data to be stored in file List <EventLookup> eventLookupList = TransformEventServiceToEventLookup(eventPlanepolyServiceList); List <string> theaterNameList = new List <string>(); eventPlanepolyServiceList.ForEach(x => x.ptos.Select(y => y.nombre).ToList().ForEach(z => theaterNameList.Add(z))); var theatersList = theaterNameList.Distinct().OrderBy(y => y).ToList(); var genresList = (from service in eventPlanepolyServiceList orderby service.genero select service.genero).Distinct().ToList <String>(); var allMovieNameList = (from service in eventPlanepolyServiceList orderby service.nombre select service.nombre).Distinct().ToList <string>(); MovieCatalog eventCatalog = new MovieCatalog(); eventCatalog.theaters = theatersList; eventCatalog.genres = genresList; eventCatalog.movies = allMovieNameList; Dictionary <string, List <string> > theaterMoviesList = new Dictionary <string, List <string> >(); foreach (var item in eventCatalog.theaters) { List <string> movieNameList = new List <string>(); theaterMoviesList.Add(item, movieNameList); } eventCatalog.theaterMovies = theaterMoviesList; foreach (var service in eventPlanepolyServiceList) { EventLookup eventLookup = new EventLookup(); eventLookup.name = service.nombre; eventLookup.img = service.img; eventLookup.url = service.url; eventLookup.premiere = service.estr; eventLookup.genre = service.genero; eventLookup.locations = new List <EventLookupLocation>(); foreach (var location in service.ptos) { if (theaterMoviesList.ContainsKey(location.nombre)) { var tempList = theaterMoviesList[location.nombre]; tempList.Add(service.nombre); } } } eventLookupList = (from item in eventLookupList orderby item.premiere descending, item.typeName, item.name select item).Distinct().ToList(); string eventLookupJSON = JsonConvert.SerializeObject(eventLookupList); string eventCatalogJSON = JsonConvert.SerializeObject(eventCatalog); // Full movie (mapped from origin) string fileName = @"D:\SitiosWeb\Sitio\EC100A_Servicios\EC100A_PlanepolyWidget\planepoly-events.json"; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(eventLookupJSON); } fileName = @"D:\SitiosWeb\Sitio\EC100A_Servicios\EC100A_PlanepolyWidget\planepoly-events-catalog.json"; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(eventCatalogJSON); } // This is the page result. //Response.Write(eventLookupJSON); Response.Write(eventCatalogJSON); }
public static void ProccesPlanepolyMovie(HttpRequest Request, HttpResponse Response) { WebClient client = new WebClient(); string url = "https://www.planepoly.com:8181/PlanepolyCoreWeb/OSConcierge?lat=6.210506&long=-75.57096&idTipos=201&consulta=eventos&bypass=626262"; Stream data = client.OpenRead(url); StreamReader reader = new StreamReader(data); string s = reader.ReadToEnd(); data.Close(); reader.Close(); Response.AddHeader("Access-Control-Allow-Origin", "*"); var movieList = JsonConvert.DeserializeObject<Movie>(s); var movieServiceList = movieList.servicios; foreach (var it in movieServiceList) { it.nombre = it.nombre.Trim(); } var movieListOrdered = movieServiceList.OrderByDescending(x => x.estr).OrderBy(x => x.nombre).ToList(); movieList.servicios = movieListOrdered; List<string> theaterNameList = new List<string>(); movieList.servicios.ForEach(x => x.ptos.Select(y => y.nombre).ToList().ForEach(z => theaterNameList.Add(z))); var theatersList = theaterNameList.Distinct().OrderBy(y => y).ToList(); var genresList = (from service in movieServiceList orderby service.genero select service.genero).Distinct().ToList<String>(); var allMovieNameList = (from service in movieServiceList orderby service.nombre select service.nombre).Distinct().ToList<string>(); MovieCatalog movieCatalog = new MovieCatalog(); movieCatalog.theaters = theatersList; movieCatalog.genres = genresList; movieCatalog.movies = allMovieNameList; Dictionary<string, List<string>> theaterMoviesList = new Dictionary<string, List<string>>(); foreach (var item in movieCatalog.theaters) { List<string> movieNameList = new List<string>(); theaterMoviesList.Add(item, movieNameList); } List<MovieLookup> movieLookupList = new List<MovieLookup>(); foreach (var service in movieList.servicios) { MovieLookup movieLookup = new MovieLookup(); movieLookup.name = service.nombre; movieLookup.img = service.img; movieLookup.url = service.url; movieLookup.premiere = service.estr; movieLookup.genre = service.genero; movieLookup.locations = new List<MovieLookupLocation>(); foreach (var location in service.ptos) { if (theaterMoviesList.ContainsKey(location.nombre)) { var tempList = theaterMoviesList[location.nombre]; tempList.Add(service.nombre); } MovieLookupLocation mlLocation = new MovieLookupLocation(); mlLocation.name = location.nombre; mlLocation.address = location.direccion; List<MovieLookupShow> mlShowList = new List<MovieLookupShow>(); Dictionary<int, string> shows = new Dictionary<int, string>(); shows.Add(0, ""); shows.Add(1, ""); shows.Add(2, ""); shows.Add(3, ""); shows.Add(4, ""); shows.Add(5, ""); shows.Add(6, ""); shows.Add(7, ""); foreach (var show in location.funcs) { if (shows.ContainsKey(show.dia)) { var valDay = shows[show.dia]; valDay += show.hora + " "; shows[show.dia] = valDay; } } foreach (var it in shows) { if (it.Value.Trim() != "") { MovieLookupShow mls = new MovieLookupShow(); mls.frequency = it.Key; mls.hours = it.Value.Trim(); switch (mls.frequency) { case 0: mls.name = "Diario"; break; case 1: mls.name = "Lunes"; break; case 2: mls.name = "Martes"; break; case 3: mls.name = "Miércoles"; break; case 4: mls.name = "Jueves"; break; case 5: mls.name = "Viernes"; break; case 6: mls.name = "Sábado"; break; case 7: mls.name = "Domingo"; break; default: break; } mlShowList.Add(mls); } } mlLocation.schedule = mlShowList; movieLookup.locations.Add(mlLocation); } movieLookupList.Add(movieLookup); } foreach (var it in theaterMoviesList) { it.Value.Sort(); } movieCatalog.theaterMovies = theaterMoviesList; var movieLookupListOrdered = (from item in movieLookupList orderby item.premiere descending, item.name select item).ToList(); string movieCatalogJSON = JsonConvert.SerializeObject(movieCatalog); string movieLookupJSON = JsonConvert.SerializeObject(movieLookupListOrdered); Response.Write(JsonConvert.SerializeObject(movieLookupListOrdered)); // Now that we have just gathered all the information, create static JSON versions // Now there are two files to consume the feed // Full movie catalog (mapped from origin). string fileName = @"D:\SitiosWeb\Sitio\EC100A_Servicios\EC100A_PlanepolyWidget\planepoly-movies.json"; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(movieLookupJSON); } fileName = @"D:\SitiosWeb\Sitio\EC100A_Servicios\EC100A_PlanepolyWidget\planepoly-movies-catalog.json"; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(movieCatalogJSON); } }
public static void ProccesPlanepolyEvent(HttpRequest Request, HttpResponse Response) { List<EventService> eventPlanepolyServiceList = new List<EventService>(); string[] urls = {"https://www.planepoly.com:8181/PlanepolyCoreWeb/OSConcierge?lat=6.210506&long=-75.57096&idTipos=202&consulta=eventos&bypass=626262" /* Refers to 'Obras de Teatro' at Planepoly.com */, "https://www.planepoly.com:8181/PlanepolyCoreWeb/OSConcierge?lat=6.210506&long=-75.57096&idTipos=203&consulta=eventos&bypass=626262" /* Refers to 'Conciertos' at Planepoly.com */, "https://www.planepoly.com:8181/PlanepolyCoreWeb/OSConcierge?lat=6.210506&long=-75.57096&idTipos=209&consulta=eventos&bypass=626262" /* Refers to 'Culturales' at Planepoly.com */ }; //string[] urls = { "https://www.planepoly.com:8181/PlanepolyCoreWeb/OSConcierge?lat=6.210506&long=-75.57096&idTipos=203&consulta=eventos&bypass=626262" /* Refers to 'Obras de Teatro' at Planepoly.com */}; string s = ""; try { for (int i = 0; i < urls.Length; i++) { s = ReadHtmlPageContent(urls[i]); Event o = JsonConvert.DeserializeObject<Event>(s); foreach (var item in o.servicios) { eventPlanepolyServiceList.Add(item); } } } catch (Exception e) { Response.Write("{0} Exception caught." + e.ToString()); } Response.AddHeader("Access-Control-Allow-Origin", "*"); // Get data to be stored in file List<EventLookup> eventLookupList = TransformEventServiceToEventLookup(eventPlanepolyServiceList); List<string> theaterNameList = new List<string>(); eventPlanepolyServiceList.ForEach(x => x.ptos.Select(y => y.nombre).ToList().ForEach(z => theaterNameList.Add(z))); var theatersList = theaterNameList.Distinct().OrderBy(y => y).ToList(); var genresList = (from service in eventPlanepolyServiceList orderby service.genero select service.genero).Distinct().ToList<String>(); var allMovieNameList = (from service in eventPlanepolyServiceList orderby service.nombre select service.nombre).Distinct().ToList<string>(); MovieCatalog eventCatalog = new MovieCatalog(); eventCatalog.theaters = theatersList; eventCatalog.genres = genresList; eventCatalog.movies = allMovieNameList; Dictionary<string, List<string>> theaterMoviesList = new Dictionary<string, List<string>>(); foreach (var item in eventCatalog.theaters) { List<string> movieNameList = new List<string>(); theaterMoviesList.Add(item, movieNameList); } eventCatalog.theaterMovies = theaterMoviesList; foreach (var service in eventPlanepolyServiceList) { EventLookup eventLookup = new EventLookup(); eventLookup.name = service.nombre; eventLookup.img = service.img; eventLookup.url = service.url; eventLookup.premiere = service.estr; eventLookup.genre = service.genero; eventLookup.locations = new List<EventLookupLocation>(); foreach (var location in service.ptos) { if (theaterMoviesList.ContainsKey(location.nombre)) { var tempList = theaterMoviesList[location.nombre]; tempList.Add(service.nombre); } } } eventLookupList = (from item in eventLookupList orderby item.premiere descending, item.typeName, item.name select item).Distinct().ToList(); string eventLookupJSON = JsonConvert.SerializeObject(eventLookupList); string eventCatalogJSON = JsonConvert.SerializeObject(eventCatalog); // Full movie (mapped from origin) string fileName = @"D:\SitiosWeb\Sitio\EC100A_Servicios\EC100A_PlanepolyWidget\planepoly-events.json"; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(eventLookupJSON); } fileName = @"D:\SitiosWeb\Sitio\EC100A_Servicios\EC100A_PlanepolyWidget\planepoly-events-catalog.json"; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(eventCatalogJSON); } // This is the page result. //Response.Write(eventLookupJSON); Response.Write(eventCatalogJSON); }