public void Add(NewsItem value) { _Items.Add(value); }
/// <summary> /// Сваля новините и ги зарежда в tmp таблици /// </summary> private void LoadNewsRSS(SqliteCommand aCmmndNews, SqliteCommand aCmmndEncl, NewsSource aNSource) { // Освобождата tmp таблиците OnLog(LogMessageType.Event, _PNews.WSaitID.ToString() + _Msg1_ExemptionТmpТables); // tmp_news aCmmndNews.CommandText = "DELETE FROM tmp_news;"; aCmmndNews.ExecuteNonQuery(); // tmp_enclosure aCmmndEncl.CommandText = "DELETE FROM tmp_enclosure;"; aCmmndEncl.ExecuteNonQuery(); // Зарежда tmp таблиците // tmp_news aCmmndNews.CommandText = "INSERT INTO tmp_news " + " ( news_site_id, news_id, news_guid, news_title, news_link, news_description, news_body, news_comments, news_pubdate, news_category ) " + " VALUES ( @news_site_id, @news_id, @news_guid, @news_title, @news_link, @news_description, @news_body, @news_comments, @news_pubdate, @news_category ); "; aCmmndNews.Parameters.Clear(); aCmmndNews.Parameters.Add("@news_site_id", DbType.Int32).Value = _PNews.WSaitID; aCmmndNews.Parameters.Add("@news_id", DbType.Int32); aCmmndNews.Parameters.Add("@news_guid", DbType.String); aCmmndNews.Parameters.Add("@news_title", DbType.String); aCmmndNews.Parameters.Add("@news_link", DbType.String); aCmmndNews.Parameters.Add("@news_description", DbType.String); aCmmndNews.Parameters.Add("@news_body", DbType.String); aCmmndNews.Parameters.Add("@news_comments", DbType.String); aCmmndNews.Parameters.Add("@news_pubdate", DbType.DateTime); aCmmndNews.Parameters.Add("@news_category", DbType.String); // tmp_enclosure aCmmndEncl.CommandText = "INSERT INTO tmp_enclosure " + " ( news_id, encl_link, encl_type ) " + " VALUES ( @news_id, @encl_link, @encl_type ); "; aCmmndEncl.Parameters.Clear(); aCmmndEncl.Parameters.Add("@news_id", DbType.Int32); aCmmndEncl.Parameters.Add("@encl_link", DbType.String); aCmmndEncl.Parameters.Add("@encl_type", DbType.String); // OnLog(LogMessageType.Event, _PNews.WSaitID.ToString() + _Msg2_DownloadedAndFilledNews); // create a new xml doc XmlDocument doc = new XmlDocument(); doc.XmlResolver = null; // load the xml doc // doc.Load(aNSource.URL); string rssPage = RSSFeeds.dUtils.DownloadRss(aNSource.URL); int indexEnd = rssPage.IndexOf("</rss>"); if (indexEnd > 0) { indexEnd += 6; int endCount = rssPage.Length - indexEnd; rssPage = rssPage.Remove(indexEnd, endCount); } doc.LoadXml(rssPage); // get an xpath navigator XPathNavigator navigator = doc.CreateNavigator(); NewsItem NData = new NewsItem(); // Get the links from the RSS feed XPathNodeIterator nodesLink = navigator.Select("//rss/channel/item"); int iNewsID = 1; while (nodesLink.MoveNext()) { NData.Clear(); // clean up the link XPathNodeIterator RNode = nodesLink.Current.SelectChildren(XPathNodeType.Element); // bool bRes = true; while (RNode.MoveNext() && bRes) { bRes = _PNews.ParseNews(NData, RNode.Current); } // Ако е успешно заредена новината if (bRes) { // tmp_news aCmmndNews.Parameters["@news_id"].Value = iNewsID; aCmmndNews.Parameters["@news_guid"].Value = NData.Guid; aCmmndNews.Parameters["@news_title"].Value = NData.Title; aCmmndNews.Parameters["@news_link"].Value = NData.Link; aCmmndNews.Parameters["@news_description"].Value = NData.Description; aCmmndNews.Parameters["@news_body"].Value = NData.Body; aCmmndNews.Parameters["@news_comments"].Value = NData.Comments; aCmmndNews.Parameters["@news_pubdate"].Value = NData.pubDate; aCmmndNews.Parameters["@news_category"].Value = (NData.Category.Equals("") ? aNSource.DefCategory : NData.Category).ToLower().Trim(); aCmmndNews.ExecuteNonQuery(); // tmp_enclosure aCmmndEncl.Parameters["@news_id"].Value = iNewsID; foreach (Enclosure encl in NData.Enclosure) { aCmmndEncl.Parameters["@encl_link"].Value = encl.Link; aCmmndEncl.Parameters["@encl_type"].Value = encl.Type; aCmmndEncl.ExecuteNonQuery(); } // iNewsID++; } NData.Clear(); } }
public void Add(NewsItem value) { _Items.Add(value); }