コード例 #1
0
        public bool storePoi(string requestType, Feed feed, long urlId)
        {
            setPoi(feed);

            DAL.poiSingleton pois = DAL.poiSingleton.Instance;
            int poiId             = pois.storePoi(Title, Comments, Date, Url, Descritpion, Content, requestType, urlId);

            if (poiId == 0)
            {
                return(false);
            }

            bool result = pois.storeCategory(feed.Category, poiId);

            return(true);
        }
コード例 #2
0
ファイル: FeedsSingleton.cs プロジェクト: heununes/poiEngine
        public Feed[] getRssFeeds()
        {
            DAL.poiSingleton pois = DAL.poiSingleton.Instance;

            DAL.enderecosUrlSingleton             enderecos = DAL.enderecosUrlSingleton.Instance;
            DAL.poiDatabase.enderecosURLDataTable rows      = enderecos.getUrlsByType(requestType);

            DAL.categorySingleton categoriesSingleton          = DAL.categorySingleton.Instance;
            DAL.poiDatabase.categoriesDataTable categoriesRows = categoriesSingleton.getCategories();

            string[] categoriesArray = categoriesSingleton.getCategoriesToArray(true);



            var tempRssData = new List <Feed>();

            foreach (DAL.poiDatabase.enderecosURLRow row in rows)
            {
                XmlReader       reader      = XmlReader.Create(row.url);
                SyndicationFeed feedsObject = SyndicationFeed.Load(reader);
                reader.Close();
                Feed feed = new Feed();

                Poi.Poi poi = new Poi.Poi();


                foreach (SyndicationItem item in feedsObject.Items)
                {
                    string title = "";
                    try
                    {
                        title = item.Title.Text;
                    }
                    catch (NullReferenceException ex)
                    {
                        title = "";
                    }
                    if (this.verifyEligibilaty(categoriesArray, title.Trim().ToLower()))
                    {
                        int i = 0;
                        // verificar se o titulo contém alguma key word
                        feed.Title = title;
                        if (item.Links[0].Uri.IsAbsoluteUri)
                        {
                            feed.Link = item.Links[0].Uri.AbsoluteUri;
                        }

                        feed.Content = item.Summary.Text;
                        if (item.Categories.LongCount() > 0)
                        {
                            string[] categories = new string[item.Categories.LongCount()];
                            foreach (SyndicationCategory category in item.Categories)
                            {
                                categories[i] = category.Name;
                                i++;
                            }
                            feed.Category = categories;
                        }
                        else
                        {
                            string[] categories = new string[1];
                            categories[0] = "Generic";
                            feed.Category = categories;
                        }

                        //feed.Date = item.PublishDate.Date;
                        Boolean result = false;
                        if (pois.alreadyExists(title) == false)
                        {
                            result = poi.storePoi(requestType, feed, row.id_enderecosURL);
                        }

                        if (result == true)
                        {
                            tempRssData.Add(feed);
                        }
                    }
                }
            }

            // TODO store poi's in database with threads ??
            //Poi.ThreadPoi poi = new Poi.ThreadPoi(tempRssData.ToArray<Feed>());

            return(tempRssData.ToArray <Feed>());
        }