public string CreateXMLFile(XMLMovieProperties data)
        {
            if (data == null)
            {
                return "{ \"Status\" : \"Error\" }";
            }

            try
            {
                //data = HttpContext.Current.Server.UrlDecode(data);
                JavaScriptSerializer json = new JavaScriptSerializer();
                XMLMovieProperties movieProps = data;// json.Deserialize(data, typeof(XMLMovieProperties)) as XMLMovieProperties;

                if (movieProps != null)
                {
                    XMLMovieProperties crawlMovieEntity = new XMLMovieProperties();

                    crawlMovieEntity.MovieName = movieProps.MovieName;
                    crawlMovieEntity.MovieLink = movieProps.MovieLink;
                    crawlMovieEntity.Year = Convert.ToInt32(movieProps.Month.Split(new char[] { ' ' })[1]);
                    crawlMovieEntity.Month = movieProps.Month.Split(new char[] { ' ' })[0];
                    crawlMovieEntity.Reviews = movieProps.Reviews;
                    crawlMovieEntity.SantaPosterLink = string.IsNullOrEmpty(movieProps.SantaPosterLink) ? string.Empty : movieProps.SantaPosterLink;
                    crawlMovieEntity.SaavnSongLink = string.IsNullOrEmpty(movieProps.SaavnSongLink) ? string.Empty : movieProps.SaavnSongLink;
                    crawlMovieEntity.Crawl = string.IsNullOrEmpty(movieProps.Crawl) ? "false" : movieProps.Crawl;
                    string xmlFileContent = new GenerateXMLFile().CreatingFile(crawlMovieEntity);

                    if (!string.IsNullOrEmpty(crawlMovieEntity.Crawl) && crawlMovieEntity.Crawl.ToLower() == "true")
                    {
                        // Crawl the movie
                        CrawlfromXML(xmlFileContent, crawlMovieEntity.MovieName);
                    }
                }
            }
            catch (Exception ex)
            {
                return "{ \"Status\" : \"Error\" }";
            }

            return "{ \"Status\" : \"Ok\" }";
        }
Exemple #2
0
        public List <XMLMovieProperties> GetMovieListFromXMLFiles(bool isFromLatest)
        {
            try
            {
                GenerateXMLFile objGenerateXml = new GenerateXMLFile();

                if (isFromLatest)
                {
                    string fileName = "MovieList-" + DateTime.Now.ToString("MMM-yyyy") + ".xml";

                    return(objGenerateXml.GetMoviesFromXml(new string[] { fileName }));
                }
                else
                {
                    string[] files = new BlobStorageService().GetUploadedFileFromBlob("crawlfiles").ToArray();

                    return(objGenerateXml.GetMoviesFromXml(files));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public List<XMLMovieProperties> GetMovieListFromXMLFiles(bool isFromLatest)
        {
            try
            {
                GenerateXMLFile objGenerateXml = new GenerateXMLFile();

                if (isFromLatest)
                {
                    string fileName = "MovieList-" + DateTime.Now.ToString("MMM-yyyy") + ".xml";

                    return objGenerateXml.GetMoviesFromXml(new string[] { fileName });
                }
                else
                {
                    string[] files = new BlobStorageService().GetUploadedFileFromBlob("crawlfiles").ToArray();

                    return objGenerateXml.GetMoviesFromXml(files);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }