private async void LoadArticles() { Rss.RSS_adress = "https://wpworld.pl/feed/"; //ArticlesListProgressRing.IsActive = true; List <Article> articles; try { articles = await Rss.loadArticles(); } catch (Exception ex) { MessageDialog md = new MessageDialog("Błąd ładowania artykułów"); await md.ShowAsync(); articles = new List <Article>(); } GlobalProgressRing.IsActive = false; //ArticlesListProgressRing.IsActive = false; Articles = new ObservableCollection <Article>(articles); ArticlesListView.ItemsSource = Articles; DateTime dateTime = Articles[0].publishDate; string date = Articles[0].ParsedDateTime; if (!MainVisualStateGroup.CurrentState.Name.Equals("NarrowState")) { SelectedArticle = Articles[0]; loadArticle(); } }
public async Task <IActionResult> GetNews() { try { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("https://www.boursenews.ir/"); // List all Names. HttpResponseMessage response = client.GetAsync("fa/rss/14").Result; // Blocking call! if (response.IsSuccessStatusCode) { string xmlString = await response.Content.ReadAsStringAsync(); XmlSerializer serializer = new XmlSerializer(typeof(Rss), new XmlRootAttribute("rss")); StringReader stringReader = new StringReader(xmlString); Rss rss = (Rss)serializer.Deserialize(stringReader); return(Ok(GetRequestResult(rss))); } else { throw new StockAssistanceProviderGlobalException(RssServiceErrors.ConnectionError); } } catch (Exception ex) { throw new StockAssistanceProviderGlobalException(RssServiceErrors.ConnectionError, ex); } }
public void CreateRssFromUriHttp() { string inputUri = @"http://adventuresinsidethemessagebox.wordpress.com/feed/"; Rss rss = new Rss(inputUri); Assert.IsTrue(rss != null); }
public bool LerRetorno() { bool resultado = false; string mensagem = ""; string msgUF = ""; this.result = (Rss)serializer.Deserialize(fileStream); mensagem += String.Format("Consultas efetuadas: {0} de {1}", this.result.channel.ApiConsultas, this.result.channel.ApiLimite) + "\n"; foreach (Item CrmUf in this.result.channel.Items) { if (CrmUf.Uf == "SP") { msgUF = String.Format("{0}: {1} da UF: {2} \nNome: {3}\nSituação: {4}\n", CrmUf.Tipo, CrmUf.Numero, CrmUf.Uf, CrmUf.Nome, CrmUf.Situacao); if (!String.IsNullOrEmpty(CrmUf.Profissao)) { msgUF += "Especialidade: " + CrmUf.Profissao; } } mensagem += String.Format("Status do CRM: {0} na UF: {1} é: {2} ", CrmUf.Numero, CrmUf.Uf, CrmUf.Situacao) + "\n"; } MessageBox.Show(mensagem); MessageBox.Show(msgUF); return(resultado); }
/// <inheritdoc /> public void StoreDecision(DecisionModel decision) { this.RemoveAllOccurences(decision); string titre = decision.EstSupprimée ? RemovedIndicator + decision.Titre : decision.Titre; var item = new RssItem { title = titre, pubDate = decision.Date.ToString("ddd, dd MMM yyyy HH:mm:ss"), description = decision.Description, link = decision.Lien?.ToString(), guid = new Guid { isPermaLink = false, Value = decision.GetHashCode().ToString() } }; foreach (Domaine decisionDomaine in decision.Domaines) { RssChannel channel = this.OpenOrCreateChannelForDomaine(decisionDomaine); channel.Add(item); var rss = new Rss { channel = new [] { channel } }; var serializer = new XmlSerializer(typeof(Rss)); IFile file = this._feedsStorageDirectory.CreateOrReturn(FileNameForDomaine(decisionDomaine)); using (StreamWriter writer = file.CreateWriter()) serializer.Serialize(writer, rss); } }
/// <summary> /// 保存,保存后关闭 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { try { Rss rss = new Rss(); rss.CreateDate = DateTime.Now.ToString(); rss.DateType = ddlDateType.SelectedItem.Text; rss.SendDay = ddlDate.SelectedIndex + 1; rss.SendTime += ddlTime.SelectedIndex.ToString().PadLeft(2, '0') + ":00:00"; rss.SendTo = txtCC.Text; rss.TemplateID = hideTempID.Value; rss.UserID = Request.QueryString["userid"]; rss.SendType = ddlSendType.SelectedItem.Text; if (!String.IsNullOrEmpty(rss.TemplateID)) { SubscribeDB.DeleteSubScribe(rss); } SubscribeDB.InsertSubScribe(rss); lblError.Text = "成功"; string userID = Request.QueryString["userid"]; if (!string.IsNullOrEmpty(userID)) { BindSubscribeList(userID); } } catch (Exception ex) { lblError.Text = ex.Message; lblError.Visible = true; } }
public void GenerateRSS(Rss rss) { rss.Channel.LastBuildDate = DateTimeOffset.Now.ToString("r"); XmlSerializer xs = new XmlSerializer(typeof(Rss)); using (Stream s = File.Create(@"rss2.xml")) xs.Serialize(s, rss); //XmlWriterSettings settings = new XmlWriterSettings(); //settings.Indent = true; //settings.IndentChars = "\t"; //using (XmlWriter writer = XmlWriter.Create("rss.xml", settings)) //{ // writer.WriteStartDocument(); // writer.WriteStartElement("rss"); // writer.WriteAttributeString("version", "2.0"); // writer.WriteAttributeString("xmlns", "atom", null, "http://www.w3.org/2005/Atom"); // writer.WriteStartElement("channel"); // writer.WriteElementString("title", rss.Channel.Title); // writer.WriteElementString("link", rss.Channel.Link); // writer.WriteElementString("description", rss.Channel.Description); // WriteAttributeStringIfPresent(writer, "copyright", rss.Channel.Copyright); // WriteAttributeStringIfPresent(writer, "language", rss.Channel.Language); // WriteAttributeStringIfPresent(writer, "managingEditor", rss.Channel.ManagingEditor); // WriteAttributeStringIfPresent(writer, "webMaster", rss.Channel.WebMaster); // WriteAttributeStringIfPresent(writer, "category", rss.Channel.Category); // WriteAttributeStringIfPresent(writer, "generator", rss.Channel.Generator); // WriteAttributeStringIfPresent(writer, "docs", rss.Channel.Docs); // WriteAttributeStringIfPresent(writer, "cloud", rss.Channel.Cloud); // WriteAttributeStringIfPresent(writer, "ttl", rss.Channel.Ttl); // //WriteAttributeStringIfPresent(writer, "image", channel.Image); // WriteAttributeStringIfPresent(writer, "lastBuildDate", DateTime.Now.ToString("r")); // WriteAttributeStringIfPresent(writer, "skipDays", rss.Channel.SkipDays); // WriteAttributeStringIfPresent(writer, "skipHours", rss.Channel.SkipHours); // //WriteAttributeStringIfPresent(writer, "pubDate", c.PubDate.ToString("r")); // foreach (Item i in rss.Channel.Items) // { // writer.WriteStartElement("item"); // writer.WriteElementString("title", i.Title); // writer.WriteElementString("link", i.Link); // writer.WriteElementString("description", i.Description); // WriteAttributeStringIfPresent(writer, "author", i.Author); // WriteAttributeStringIfPresent(writer, "category", i.Category); // WriteAttributeStringIfPresent(writer, "comments", i.Comments); // WriteAttributeStringIfPresent(writer, "source", i.Source); // //WriteAttributeStringIfPresent(writer, "enclosure", i.Enclosure); // writer.WriteElementString("guid", i.Link); // writer.WriteEndElement(); // } // writer.WriteEndElement(); // writer.WriteEndElement(); // writer.WriteEndDocument(); // writer.Flush(); // writer.Close(); }
private void FeedUpdated(Rss feed) { ItemsView.Items.Clear(); ListViewItem top_item = new ListViewItem(Title); //view_item.Text = Title; top_item.IndentCount = 0; //view_item.ToolTipText = Title; //view_item.ImageIndex = ; ItemsView.Items.Add(top_item); int items_num = 0; foreach (Rss.Channel channel in Feed.Channels) { foreach (Rss.Channel.Item item in channel.Items) { ListViewItem view_item = new ListViewItem(item.Title); //view_item.Text = item.Title; view_item.Tag = item; view_item.ToolTipText = item.Description; view_item.ImageIndex = 1; ItemsView.Items.Add(view_item); items_num++; if (items_num >= max_items) return; } } //columnHeader1.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); columnHeader1.Width = -2; }
/// <summary> /// Read all RSS feed from a valid link and display it in HTML view. /// </summary> /// <param name="link">link to RSS feed</param> /// <returns>HTML view of RSS feed from the link</returns> // GET: ReadRSS public ActionResult Index(string link) { //List of RSS var rssList = new List <Rss>(); if (!String.IsNullOrEmpty(link)) { try { var reader = XmlReader.Create(link); var feed = SyndicationFeed.Load(reader); ViewBag.FeedTitle = feed.Title.Text; ViewBag.Link = link; foreach (var item in feed.Items) { var rss = new Rss(); rss.Title = item.Title.Text; rss.Link = item.Links[0].Uri.ToString(); rss.PublishDate = item.PublishDate.DateTime; rss.Description = item.Summary.Text; rss.RssTitle = feed.Title.Text; rssList.Add(rss); } } catch { TempData["EXCEPTION"] = "You provided invalid link for RSS feed "; return(RedirectToAction("Index")); } } return(View(rssList)); }
static async Task Main(string[] args) { foreach (var rssUrl in rssUrls) { // analyze var content = await _httpClient.GetStringAsync(rssUrl); Rss newRss = null; try { newRss = XmlConvertExtension.DeserializeObject <Rss>(content); } catch { Console.WriteLine($"{rssUrl} RSS订阅发生异常,请查看RSS源是否能正常访问!"); } // find exsited rss var existRss = await FindRssAsync(Path.Combine(root, "edi.wang.xml")); // compare rss if (newRss.Channel.Items.Count == existRss.Channel.Items.Count) { Console.WriteLine($"{rssUrl} 暂无更新!"); } else { Console.WriteLine($"请注意! {rssUrl} 有更新:" + newRss.Channel.Items[0].Title + " 发布时间:" + newRss.Channel.Items[0].PubDateString); } } Console.ReadLine(); }
public void CreateRssFromUriFileSystem() { string inputUri = @"..\..\..\SolutionArtefacts\jc_blog_rss.xml"; Rss rss = new Rss(inputUri); Assert.IsTrue(rss != null); }
public void RssTestJson() { SimplTypesScope simplTypesScope = SimplTypesScope.Get("rss", typeof(Rss), typeof(Channel), typeof(Item)); List <String> categorySet = new List <String> { "cate\\dgory1", "category2" }; Item item1 = new Item("testItem1", "testItem1Description", new ParsedUri("http://www.google.com"), "asdf", "nabeel", categorySet); Item item2 = new Item("testItem2", "testItem2Description", new ParsedUri("http://www.google.com"), "asdf", "nabeel", categorySet); Channel c = new Channel("testTile", "testDesc", new ParsedUri("http://www.google.com"), new List <Item> { item1, item2 }); Rss rss = new Rss(1.4f, c); TestMethods.TestSimplObject(rss, simplTypesScope, Format.Json); }
private void AjouterRSS() { Console.Clear(); Console.WriteLine("Entrez l'url du flux rss :"); string url = Console.ReadLine(); IRssParser parser = new RssParserWithLinQ(); try { Rss rss = parser.ParserRSS(url); if (User.AjouterRSS(rss)) { DetailRss(rss); Console.WriteLine("Ajout du flux avec succès !"); } else { Console.WriteLine("L'ajout du flux est un échec"); } Console.WriteLine(PHRASE_CONTINUER); Console.ReadKey(); Console.Clear(); } catch (Exception e) { Debug.WriteLine(e.Message); Console.WriteLine("Problème lors de l'ajout du flux"); Console.WriteLine(PHRASE_CONTINUER); Console.ReadKey(); } }
public RssListViewModel ToRssListViewModel(Rss rss, List <RssViewModel> rssFeed, int page) { return(new RssListViewModel { Theme = rss.Theme, Site = rss.Name, RssReaders = rssFeed.AsEnumerable() .Skip((page - 1) * PageSize) .Take(PageSize), PagingView = new ListView { CurrentPage = page, PostsPerPage = PageSize, TotalPosts = rssFeed.Count() }, HeaderViewModel = new HeaderViewModel { Title = rss.Name, FirstTagWord = "", SecondTagWord = "", ThirdTagWord = "" } }); }
public void CreateRssFromWebUriStephenson() { string inputUri = @"http://geekswithblogs.net/michaelstephenson/Rss.aspx"; Rss rss = new Rss(inputUri); Assert.IsTrue(rss != null); Assert.IsTrue(rss.feed.feed_uri == null); // Not provided in the file, hence cannot be assigned. }
public static void SaveDisqus(Rss comments) { using (var fileStream = File.Open(CONTENTBASEFOLDER + "\\disqus.xml", FileMode.Create)) { XmlSerializer serializer = new XmlSerializer(typeof(Rss)); serializer.Serialize(fileStream, comments); } }
public ActionResult DeleteConfirmed(int id) { Rss rss = db.Rsses.Find(id); db.Rsses.Remove(rss); db.SaveChanges(); return(RedirectToAction("Index")); }
public void CreateRssFromUriFileSystemStephenson() { string inputUri = @"..\..\..\SolutionArtefacts\stephenson_blog_rss.xml"; Rss rss = new Rss(inputUri); Assert.IsTrue(rss != null); Assert.IsTrue(rss.feed.feed_uri == null); // Not provided in the file, hence cannot be assigned. }
public static Rss NewRss() { var comments = new Rss(); comments.Channel = new Channel(); comments.Channel.Items = new List <Item>(); return(comments); }
private IEnumerable <PostModel> Convert(Rss feed) { return(feed.Channel.Item.Select(x => new PostModel() { Description = x.Description, Text = x.Encoded, Title = x.Title })); }
private async void LoadFeed(Uri url) { var feed = await Rss.Load(url); FeedTitle.Text = feed.Title; foreach (var item in feed.Feeditems) { AddRssItem(item); } }
protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] native_parms) { try { rss = ion.portal.DownloadRssOrThrowAsync().Result; } catch (Exception e) { Log.E(this, "Failed to download the rss feed.", e); } return(null); }
private void WriteFile(RssChannel channel) { var rss = new Rss { channel = new[] { channel } }; using (StreamWriter writer = this._file.CreateWriter()) Serializer.Serialize(writer, rss); }
public IActionResult Create([FromBody] Rss item) { if (item == null || !ModelState.IsValid) { return(BadRequest()); } Repo.Add(item); return(CreatedAtRoute("GetAllRssFeeds", null, null)); }
public void WriteRssFile(Rss rssData, string rssFileName) { XmlSerializer xs = new XmlSerializer(typeof(Rss)); using (StreamWriter sw = new StreamWriter(rssFileName)) { xs.Serialize(sw, rssData); sw.Close(); } }
public static void WriteRSS(Rss value, Stream destination) { XmlSerializerNamespaces xsn = new XmlSerializerNamespaces(); xsn.Add("atom", "http://www.w3.org/2005/Atom"); xsn.Add("dc", "http://purl.org/dc/elements/1.1/"); xsn.Add("content", "http://purl.org/rss/1.0/modules/content/"); XmlSerializer ser = new XmlSerializer(value.GetType()); ser.Serialize(destination, value, xsn); }
public ActionResult Edit([Bind(Include = "ID,Title,Link,Description,Comments,PublishDate")] Rss rss) { if (ModelState.IsValid) { db.Entry(rss).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rss)); }
public RssCrawler(CrawlDataDelegate onCrawlDataDelegate, IMongoDatabase mongoDb, Rss rss) { if (mongoDb != null) { MongoDbFeedData = new MongoDbUtil <FeedData>(mongoDb); } OnCrawlDataDelegate = onCrawlDataDelegate; Rss = rss; }
public void ProcessRequest(HttpContext context) { CategoryContext categoryContext = new CategoryContext(); String userName = context.Request.QueryString["uname"].ToString(); String url = context.Request.QueryString["url"].ToString(); String type = context.Request.QueryString["type"].ToString(); if (type.Equals("rss")) { String ctyname = context.Request.QueryString["ctyname"].ToString(); Category category = categoryContext.Categories.Where(c => c.Name.ToString().Equals(ctyname)).FirstOrDefault(); var reader = XmlReader.Create(url); var feed = SyndicationFeed.Load(reader); String title = feed.Title.Text.ToString(); Rss rss = new Rss { Name = title, UserName = userName, Url = url }; category.Rsses.Add(rss); categoryContext.SaveChanges(); } else if (type.Equals("essay")) { String fvtname = context.Request.QueryString["fvtname"].ToString(); Favourite favourite = categoryContext.Favourites.Where(f => (f.UserName.ToString().Equals(userName) && f.Name.ToString().Equals(fvtname))).FirstOrDefault(); List <String> tad = getWebTitleAndDescription(url); String title = tad[0]; String description = tad[1]; Essay essay = new Essay { Url = url, Title = title, Description = description }; favourite.Essays.Add(essay); categoryContext.SaveChanges(); } //context.Response.ContentType = "text/plain"; //context.Response.Write(""); }
public ActionResult Create([Bind(Include = "ID,Title,Link,Description,Comments,PublishDate")] Rss rss) { if (ModelState.IsValid) { db.Rsses.Add(rss); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rss)); }
private void DetailRss(Rss rss) { Console.Clear(); Console.WriteLine("Voici les détails du flux que vous avez ajouté :"); AfficheurRss.AfficherRss(rss); Console.WriteLine("Entrez le nom de la catégorie du flux rss"); Categorie categorie = new Categorie(Console.ReadLine()); User.AjouterCategorieRss(rss, categorie); User.AjouterCategorieUtilisateur(categorie); }
public void CreateAndDeleteRssFromUriFileSystem() { // Create and delete Rss in succession. Any db locking issues? string inputUri = @"..\..\..\SolutionArtefacts\jc_blog_rss.xml"; Rss rss = new Rss(inputUri); Assert.IsTrue(rss != null); using (jarwinEntities context = new jarwinEntities()) { context.feeds.Add(rss.feed); try { context.SaveChanges(); } catch (Exception ex) { Assert.Fail("Error - failed to insert Feed record: " + ex.Message); } int feedID = (int)rss.feed.feed_id; // Value provided by SQL Server identity column. int feedItemID = 0; foreach (var feedItem in rss.feedItems) { feedItem.feed_id = feedID; feedItem.feed_item_id = feedItemID; context.feed_item.Add(feedItem); feedItemID += 1; } try { context.SaveChanges(); } catch (Exception ex) { Assert.Fail("Error - failed to insert FeedItem record: " + ex.Message); } try { rss.Delete((int)rss.feed.feed_id); } catch (Exception ex) { Assert.Fail("Error - failed to delete Feed or FeedItem record: " + ex.Message); } } }
public void GetRSS_AllData_ValidRssXml() { MemoryStream ms = new MemoryStream(); Rss rss = GetFullRSS(); RSSHelper.WriteRSS(rss, ms); var result = Encoding.UTF8.GetString(ms.GetBuffer()).Trim('\0'); Assert.AreEqual(GetFullRSSText(), result); }
public void WriteRead_LargeObject_Ok() { MemoryStream ms = new MemoryStream(); Rss rss = GetFullRSS(); RSSHelper.WriteRSS(rss, ms); ms.Position = 0; Rss newRss = RSSHelper.ReadRSS(ms); Assert.AreEqual(rss.Channel.Description, newRss.Channel.Description); }
protected void Page_Load(object sender, EventArgs e) { Response.ContentType = "application/xml"; // 输出并按xml格式显示 MemoryStream ms = new MemoryStream(); Rss rss = GetFullRSS(); RSSHelper.WriteRSS(rss, ms); ms = RSSHelper.RemoveEmptyElement(ms); var result = Encoding.UTF8.GetString(ms.GetBuffer()).Trim('\0'); Response.Write(result); }
public static void WriteRSS(Rss value, Stream destination) { XmlSerializerNamespaces xsn = new XmlSerializerNamespaces(); xsn.Add("atom", "http://www.w3.org/2005/Atom"); xsn.Add("dc", "http://purl.org/dc/elements/1.1/"); xsn.Add("content", "http://purl.org/rss/1.0/modules/content/"); XmlSerializer ser = new XmlSerializer(value.GetType()); ser.Serialize(destination, value, xsn); }
public static Rss FetchRss(string url) { string content = Convert.ToString(FetchRssContent(url)); var rss = new Rss { Url = url, Content = content }; return(rss); }
public RSSPost(Rss.RssItem rssitem) { Title = rssitem.Title; Content = rssitem.Description; User = rssitem.Author; Date = rssitem.PubDate; if (rssitem.Comments != null & rssitem.Comments.Length > 0) { Comments = new List<string>(rssitem.Comments.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries)); } else { Comments = new List<string>(); } }
public RSSPost(Rss.RssItem rssitem) { if (rssitem.Enclosure != null) { MediaItemUrl = rssitem.Enclosure.Url.ToString(); MediaType = rssitem.Enclosure.Type; MediaLenght = rssitem.Enclosure.Length; } Title = rssitem.Title; Content = rssitem.Description; User = rssitem.Author; Date = rssitem.PubDate; if (rssitem.Comments != null & rssitem.Comments.Length > 0) { Comments = new List<string>(rssitem.Comments.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries)); } else { Comments = new List<string>(); } }
public static bool GetRss(string rssUrl, ref Rss rssinfo ) { bool flag = false; #region ��ȡRss��Ϣ try { System.Net.WebRequest myRequest = System.Net.WebRequest.Create(rssUrl); System.Net.WebResponse myResponse = myRequest.GetResponse(); System.IO.Stream rssStream = myResponse.GetResponseStream(); System.Xml.XmlDocument rssDoc = new System.Xml.XmlDocument(); rssDoc.Load(rssStream); System.Xml.XmlNode link = rssDoc.SelectSingleNode("rss/channel/link"); rssinfo.Link = link.InnerText; System.Xml.XmlNode rssdescription = rssDoc.SelectSingleNode("rss/channel/description"); rssinfo.Description = rssdescription.InnerText; System.Xml.XmlNode rsspubdate = rssDoc.SelectSingleNode("rss/channel/pubDate"); if (rsspubdate != null) { rssinfo.UpdateDate = rsspubdate.InnerText; } System.Xml.XmlNode iconpath = rssDoc.SelectSingleNode("rss/channel/image/url"); if (iconpath != null) { rssinfo.IconPath = iconpath.InnerText; } flag = true; } catch { // throw new Exception("Error"); //��������쳣�������ٴθ��� } #endregion return flag; }
public ArrayList GetAllRssByTopicId(int topicid) { ArrayList rsslist = new ArrayList(); string sql = "SELECT * FROM Channel WHERE top_id=" + topicid.ToString(); using (DbTransaction transaction = connection.BeginTransaction()) { try { using (SQLiteDataReader reader = dataop.ExecuteReader(sql, null)) { if (reader.HasRows) { while (reader.Read()) { Rss newrss = new Rss(); newrss.RssId = reader.GetInt32(0); newrss.RssTitle = reader.GetString(1); newrss.Link = reader.GetString(2); newrss.RssLink = reader.GetString(3); newrss.Description = reader.GetString(4); newrss.BuildDate = reader.GetDateTime(5); newrss.UpdateDate = reader.GetString(6); newrss.IconPath = reader.GetString(7); newrss.UnreadCount = reader.GetInt32(8); newrss.TopicId = reader.GetInt32(9); rsslist.Add(newrss); } } } transaction.Commit(); } catch { transaction.Rollback(); throw; } } return rsslist; }
public async void CreateAndUpdateRssFromUriFileSystem() { // Create and then update. string inputUri = @"..\..\..\SolutionArtefacts\jc_blog_rss.xml"; Rss rss = new Rss(inputUri); Assert.IsTrue(rss != null); using (jarwinEntities context = new jarwinEntities()) { context.feeds.Add(rss.feed); try { context.SaveChanges(); } catch (Exception ex) { Assert.Fail("Error - failed to insert Feed record: " + ex.Message); } int feedID = (int)rss.feed.feed_id; // Value provided by identity column. int feedItemID = 0; foreach (var feedItem in rss.feedItems) { feedItem.feed_id = feedID; feedItem.feed_item_id = feedItemID; context.feed_item.Add(feedItem); feedItemID += 1; } try { context.SaveChanges(); } catch (Exception ex) { Assert.Fail("Error - failed to insert FeedItem record: " + ex.Message); } //try //{ // bool success = await rss.Update((int)rss.feed.feed_id); // Assert.IsTrue(success); //} //catch (Exception ex) //{ // Assert.Fail("Error - failed to update Feed or FeedItem record: " + ex.Message); //} } }
public int InsertNewRss(Rss newrss) { int flag = 0; if (RssIsExistByUrl(newrss.RssLink)) return flag; string sql = "INSERT INTO Channel(cha_name,cha_link,cha_url,cha_desc,cha_createtime,cha_updatetime,cha_iconpath,cha_unreadcount,top_id)" + "values(@rssname,@link,@rssurl,@description,@createtime,@updatetime,@iconpath,@unreadcount,@topicid)"; using (DbTransaction transaction = connection.BeginTransaction()) { try { SQLiteParameter[] parameters = new SQLiteParameter[]{ new SQLiteParameter("@rssname", newrss.RssTitle), new SQLiteParameter("@link", newrss.Link), new SQLiteParameter("@rssurl", newrss.RssLink), new SQLiteParameter("@description",newrss.Description), new SQLiteParameter("@createtime", newrss.BuildDate), new SQLiteParameter("@updatetime", newrss.UpdateDate), new SQLiteParameter("@iconpath", newrss.IconPath), new SQLiteParameter("@unreadcount", newrss.UnreadCount), new SQLiteParameter("@topicid", newrss.TopicId) }; dataop.ExecuteNonQuery(sql, parameters); transaction.Commit(); flag = 1; } catch { flag = -1; transaction.Rollback(); throw; } } return flag; }
private void UpdateRssFeed(Rss.Structure.RssFeed rss, RssFeed rssFeed) { var miniRss = new RssFeed(rss); rssFeed.Stories.Clear(); foreach (RssStory story in miniRss.Stories){ rssFeed.Stories.Add(story); } _applicationSettings.Remove(rssFeed.RssTitle); rssFeed.RssTitle = miniRss.RssTitle.ToLower(); NotifyPropertyChanged("StorySources"); NotifyPropertyChanged("Stories"); rssFeed.LastUpdated = DateTime.Now; _applicationSettings[RssFeedsKey] = new Collection<RssFeed> (StorySources); _applicationSettings.Save(); }
public void HandleRss(IRCMessage sIRCMessage) { var sSendMessage = sIrcBase.Networks[sIRCMessage.ServerName].sSendMessage; if(IsWarningAdmin(sIRCMessage.Nick, sIRCMessage.Host, AdminFlag.Operator)) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("WarningAdmin", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(!IsAdmin(sIRCMessage.Nick, sIRCMessage.Host, AdminFlag.Operator)) return; if(sIRCMessage.Info.Length < 5) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoValue", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(sIRCMessage.Info[4].ToLower() == "info") { var text = sLManager.GetCommandTexts("rss/info", sIRCMessage.Channel, sIRCMessage.ServerName); if(text.Length < 2) { sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); return; } var db = SchumixBase.DManager.Query("SELECT Name, Channel FROM rssinfo WHERE ServerName = '{0}'", sIRCMessage.ServerName); if(!db.IsNull()) { if(db.Rows.Count == 0) { sSendMessage.SendChatMessage(sIRCMessage, text[1], sLConsole.Other("Nothing", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); return; } foreach(DataRow row in db.Rows) { bool started = false; string name = row["Name"].ToString(); string[] channel = row["Channel"].ToString().Split(SchumixBase.Comma); foreach(var list in RssList) { if(name.ToLower() == list.Name.ToLower()) { if(list.Started) started = true; break; } } if(channel.SplitToString(SchumixBase.Space).IsNullOrEmpty()) sSendMessage.SendChatMessage(sIRCMessage, text[0], started ? sLConsole.Other("Started", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)) : sLConsole.Other("Stopped", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)), name, sLConsole.Other("Nothing", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); else sSendMessage.SendChatMessage(sIRCMessage, text[0], started ? sLConsole.Other("Started", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)) : sLConsole.Other("Stopped", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName)), name, channel.SplitToString(SchumixBase.Space)); } } else sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FaultyQuery", sIRCMessage.Channel, sIRCMessage.ServerName)); } else if(sIRCMessage.Info[4].ToLower() == "list") { var db = SchumixBase.DManager.Query("SELECT Name FROM rssinfo WHERE ServerName = '{0}'", sIRCMessage.ServerName); if(!db.IsNull()) { if(db.Rows.Count == 0) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("rss/list", sIRCMessage.Channel, sIRCMessage.ServerName), sLConsole.Other("Nothing", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); return; } foreach(DataRow row in db.Rows) sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("rss/list", sIRCMessage.Channel, sIRCMessage.ServerName), row["Name"].ToString()); } else sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FaultyQuery", sIRCMessage.Channel, sIRCMessage.ServerName)); } else if(sIRCMessage.Info[4].ToLower() == "start") { var text = sLManager.GetCommandTexts("rss/start", sIRCMessage.Channel, sIRCMessage.ServerName); if(text.Length < 3) { sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); return; } if(sIRCMessage.Info.Length < 6) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } foreach(var list in RssList) { if(sIRCMessage.Info[5].ToLower() == list.Name.ToLower()) { if(list.Started) { sSendMessage.SendChatMessage(sIRCMessage, text[0], list.Name); return; } list.Start(); sSendMessage.SendChatMessage(sIRCMessage, text[1], list.Name); return; } } sSendMessage.SendChatMessage(sIRCMessage, text[2], sIRCMessage.Info[5]); } else if(sIRCMessage.Info[4].ToLower() == "stop") { var text = sLManager.GetCommandTexts("rss/stop", sIRCMessage.Channel, sIRCMessage.ServerName); if(text.Length < 3) { sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); return; } if(sIRCMessage.Info.Length < 6) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } foreach(var list in RssList) { if(sIRCMessage.Info[5].ToLower() == list.Name.ToLower()) { if(!list.Started) { sSendMessage.SendChatMessage(sIRCMessage, text[0], list.Name); return; } list.Stop(); sSendMessage.SendChatMessage(sIRCMessage, text[1], list.Name); return; } } sSendMessage.SendChatMessage(sIRCMessage, text[2], sIRCMessage.Info[5]); } else if(sIRCMessage.Info[4].ToLower() == "reload") { if(sIRCMessage.Info.Length < 6) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("No1Value", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(sIRCMessage.Info[5].ToLower() == "all") { foreach(var list in RssList) list.Reload(); sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetCommandText("rss/reload/all", sIRCMessage.Channel, sIRCMessage.ServerName)); } else { var text = sLManager.GetCommandTexts("rss/reload", sIRCMessage.Channel, sIRCMessage.ServerName); if(text.Length < 2) { sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); return; } if(sIRCMessage.Info.Length < 6) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } foreach(var list in RssList) { if(sIRCMessage.Info[5].ToLower() == list.Name.ToLower()) { list.Reload(); sSendMessage.SendChatMessage(sIRCMessage, text[0], list.Name); return; } } sSendMessage.SendChatMessage(sIRCMessage, text[1], sIRCMessage.Info[5]); } } else if(sIRCMessage.Info[4].ToLower() == "channel") { if(sIRCMessage.Info.Length < 6) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoCommand", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(sIRCMessage.Info[5].ToLower() == "add") { var text = sLManager.GetCommandTexts("rss/channel/add", sIRCMessage.Channel, sIRCMessage.ServerName); if(text.Length < 3) { sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); return; } if(sIRCMessage.Info.Length < 7) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(sIRCMessage.Info.Length < 8) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoChannelName", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(!Rfc2812Util.IsValidChannelName(sIRCMessage.Info[7])) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NotaChannelHasBeenSet", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } var db = SchumixBase.DManager.QueryFirstRow("SELECT Channel FROM rssinfo WHERE LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName); if(!db.IsNull()) { string[] channel = db["Channel"].ToString().Split(SchumixBase.Comma); string data = channel.SplitToString(SchumixBase.Comma); if(channel.ToList().Contains(sIRCMessage.Info[7].ToLower())) { sSendMessage.SendChatMessage(sIRCMessage, text[2]); return; } if(channel.Length == 1 && data.IsNullOrEmpty()) data += sIRCMessage.Info[7].ToLower(); else data += SchumixBase.Comma + sIRCMessage.Info[7].ToLower(); SchumixBase.DManager.Update("rssinfo", string.Format("Channel = '{0}'", data), string.Format("LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName)); sSendMessage.SendChatMessage(sIRCMessage, text[0]); } else sSendMessage.SendChatMessage(sIRCMessage, text[1]); } else if(sIRCMessage.Info[5].ToLower() == "remove") { var text = sLManager.GetCommandTexts("rss/channel/remove", sIRCMessage.Channel, sIRCMessage.ServerName); if(text.Length < 3) { sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); return; } if(sIRCMessage.Info.Length < 7) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(sIRCMessage.Info.Length < 8) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoChannelName", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(!Rfc2812Util.IsValidChannelName(sIRCMessage.Info[7])) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NotaChannelHasBeenSet", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } var db = SchumixBase.DManager.QueryFirstRow("SELECT Channel FROM rssinfo WHERE LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName); if(!db.IsNull()) { string[] channel = db["Channel"].ToString().Split(SchumixBase.Comma); string data = string.Empty; if(!channel.ToList().Contains(sIRCMessage.Info[7].ToLower())) { sSendMessage.SendChatMessage(sIRCMessage, text[2]); return; } for(int x = 0; x < channel.Length; x++) { if(channel[x] == sIRCMessage.Info[7].ToLower()) continue; data += SchumixBase.Comma + channel[x]; } SchumixBase.DManager.Update("rssinfo", string.Format("Channel = '{0}'", data.Remove(0, 1, SchumixBase.Comma)), string.Format("LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName)); sSendMessage.SendChatMessage(sIRCMessage, text[0]); } else sSendMessage.SendChatMessage(sIRCMessage, text[1]); } } else if(sIRCMessage.Info[4].ToLower() == "add") { var text = sLManager.GetCommandTexts("rss/add", sIRCMessage.Channel, sIRCMessage.ServerName); if(text.Length < 2) { sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); return; } if(sIRCMessage.Info.Length < 6) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(sIRCMessage.Info.Length < 7) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("UrlMissing", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(sIRCMessage.Info.Length < 8) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("WebsiteNameMissing", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } var db = SchumixBase.DManager.QueryFirstRow("SELECT 1 FROM rssinfo WHERE LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[5].ToLower()), sIRCMessage.ServerName); if(db.IsNull()) { bool started = false; foreach(var list in RssList) { if(sIRCMessage.Info[5].ToLower() == list.Name.ToLower()) { if(list.Started) { started = true; continue; } list.Start(); started = true; } } if(!started) { var rss = new Rss(sIRCMessage.ServerName, sUtilities.SqlEscape(sIRCMessage.Info[5]), sUtilities.SqlEscape(sIRCMessage.Info[6]), sUtilities.SqlEscape(sIRCMessage.Info[7].ToLower())); RssList.Add(rss); rss.Start(); } SchumixBase.DManager.Insert("`rssinfo`(ServerId, ServerName, Name, Link, Website)", sIRCMessage.ServerId, sIRCMessage.ServerName, sUtilities.SqlEscape(sIRCMessage.Info[5]), sUtilities.SqlEscape(sIRCMessage.Info[6]), sUtilities.SqlEscape(sIRCMessage.Info[7].ToLower())); sSendMessage.SendChatMessage(sIRCMessage, text[0]); } else sSendMessage.SendChatMessage(sIRCMessage, text[1]); } else if(sIRCMessage.Info[4].ToLower() == "remove") { var text = sLManager.GetCommandTexts("rss/remove", sIRCMessage.Channel, sIRCMessage.ServerName); if(text.Length < 2) { sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); return; } if(sIRCMessage.Info.Length < 6) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } var db = SchumixBase.DManager.QueryFirstRow("SELECT 1 FROM rssinfo WHERE LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[5].ToLower()), sIRCMessage.ServerName); if(!db.IsNull()) { Rss gitr = null; bool isstop = false; foreach(var list in RssList) { if(sIRCMessage.Info[5].ToLower() == list.Name.ToLower()) { if(!list.Started) { isstop = true; continue; } list.Stop(); gitr = list; isstop = true; } } if(isstop && !gitr.IsNull()) RssList.Remove(gitr); SchumixBase.DManager.Delete("rssinfo", string.Format("Name = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[5]), sIRCMessage.ServerName)); sSendMessage.SendChatMessage(sIRCMessage, text[0]); } else sSendMessage.SendChatMessage(sIRCMessage, text[1]); } else if(sIRCMessage.Info[4].ToLower() == "change") { if(sIRCMessage.Info.Length < 6) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoCommand", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(sIRCMessage.Info[5].ToLower() == "colors") { var text = sLManager.GetCommandTexts("rss/change/colors", sIRCMessage.Channel, sIRCMessage.ServerName); if(text.Length < 2) { sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); return; } if(sIRCMessage.Info.Length < 7) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(sIRCMessage.Info.Length < 8) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("StatusIsMissing", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(!sIRCMessage.Info[7].IsBoolean()) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("ValueIsNotTrueOrFalse", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } var db = SchumixBase.DManager.QueryFirstRow("SELECT Colors FROM rssinfo WHERE LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName); if(!db.IsNull()) { bool enabled = db["Colors"].ToBoolean(); if(sIRCMessage.Info[7].ToBoolean() == enabled) { if(enabled) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FunctionAlreadyTurnedOn", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } else { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FunctionAlreadyTurnedOff", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } } SchumixBase.DManager.Update("rssinfo", string.Format("Colors = '{0}'", sIRCMessage.Info[7].ToLower()), string.Format("LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName)); sSendMessage.SendChatMessage(sIRCMessage, text[0]); } else sSendMessage.SendChatMessage(sIRCMessage, text[1]); } else if(sIRCMessage.Info[5].ToLower() == "shorturl") { var text = sLManager.GetCommandTexts("rss/change/shorturl", sIRCMessage.Channel, sIRCMessage.ServerName); if(text.Length < 2) { sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); return; } if(sIRCMessage.Info.Length < 7) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(sIRCMessage.Info.Length < 8) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("StatusIsMissing", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(!sIRCMessage.Info[7].IsBoolean()) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("ValueIsNotTrueOrFalse", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } var db = SchumixBase.DManager.QueryFirstRow("SELECT ShortUrl FROM rssinfo WHERE LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName); if(!db.IsNull()) { bool enabled = db["ShortUrl"].ToBoolean(); if(sIRCMessage.Info[7].ToBoolean() == enabled) { if(enabled) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FunctionAlreadyTurnedOn", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } else { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("FunctionAlreadyTurnedOff", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } } SchumixBase.DManager.Update("rssinfo", string.Format("ShortUrl = '{0}'", sIRCMessage.Info[7].ToLower()), string.Format("LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName)); sSendMessage.SendChatMessage(sIRCMessage, text[0]); } else sSendMessage.SendChatMessage(sIRCMessage, text[1]); } else if(sIRCMessage.Info[5].ToLower() == "url") { var text = sLManager.GetCommandTexts("rss/change/url", sIRCMessage.Channel, sIRCMessage.ServerName); if(text.Length < 2) { sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); return; } if(sIRCMessage.Info.Length < 7) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(sIRCMessage.Info.Length < 8) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("UrlMissing", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } var db = SchumixBase.DManager.QueryFirstRow("SELECT 1 FROM rssinfo WHERE LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName); if(db.IsNull()) { sSendMessage.SendChatMessage(sIRCMessage, text[0]); return; } var db0 = SchumixBase.DManager.QueryFirstRow("SELECT Link FROM rssinfo WHERE LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName); if(!db0.IsNull()) { if(sUtilities.SqlEscape(sIRCMessage.Info[7]) == db0["Link"].ToString()) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("TheGivenUrlIsntDifferent", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } } SchumixBase.DManager.Update("rssinfo", string.Format("Link = '{0}'", sUtilities.SqlEscape(sIRCMessage.Info[7])), string.Format("LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName)); Rss gitr = null; bool isstop = false; foreach(var list in RssList) { if(sIRCMessage.Info[6].ToLower() == list.Name.ToLower()) { if(!list.Started) { isstop = true; continue; } list.Stop(); gitr = list; isstop = true; } } if(isstop && !gitr.IsNull()) RssList.Remove(gitr); var db1 = SchumixBase.DManager.QueryFirstRow("SELECT Link, Website FROM rssinfo WHERE LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName); if(!db1.IsNull()) { var rss = new Rss(sIRCMessage.ServerName, sUtilities.SqlEscape(sIRCMessage.Info[6]), db1["Link"].ToString(), db1["Website"].ToString()); RssList.Add(rss); rss.Start(); } sSendMessage.SendChatMessage(sIRCMessage, text[1]); } else if(sIRCMessage.Info[5].ToLower() == "website") { var text = sLManager.GetCommandTexts("rss/change/website", sIRCMessage.Channel, sIRCMessage.ServerName); if(text.Length < 2) { sSendMessage.SendChatMessage(sIRCMessage, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(sIRCMessage.Channel, sIRCMessage.ServerName))); return; } if(sIRCMessage.Info.Length < 7) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("NoName", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } if(sIRCMessage.Info.Length < 8) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("WebsiteNameMissing", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } var db = SchumixBase.DManager.QueryFirstRow("SELECT 1 FROM rssinfo WHERE LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName); if(db.IsNull()) { sSendMessage.SendChatMessage(sIRCMessage, text[0]); return; } var db0 = SchumixBase.DManager.QueryFirstRow("SELECT Website FROM rssinfo WHERE LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName); if(!db0.IsNull()) { if(sUtilities.SqlEscape(sIRCMessage.Info[7].ToLower()) == db0["Website"].ToString()) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("TheGivenWebsiteIsntDifferent", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } } bool rsslb = false; foreach(var rsslist in Enum.GetNames(typeof(RssWebsiteList))) { if(sUtilities.SqlEscape(sIRCMessage.Info[7].ToLower()) == rsslist.ToLower()) { rsslb = true; break; } } if(!rsslb) { sSendMessage.SendChatMessage(sIRCMessage, sLManager.GetWarningText("ThisIsntInTheWebsiteList", sIRCMessage.Channel, sIRCMessage.ServerName)); return; } SchumixBase.DManager.Update("rssinfo", string.Format("Website = '{0}'", sUtilities.SqlEscape(sIRCMessage.Info[7].ToLower())), string.Format("LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName)); Rss gitr = null; bool isstop = false; foreach(var list in RssList) { if(sIRCMessage.Info[6].ToLower() == list.Name.ToLower()) { if(!list.Started) { isstop = true; continue; } list.Stop(); gitr = list; isstop = true; } } if(isstop && !gitr.IsNull()) RssList.Remove(gitr); var db1 = SchumixBase.DManager.QueryFirstRow("SELECT Link, Website FROM rssinfo WHERE LOWER(Name) = '{0}' And ServerName = '{1}'", sUtilities.SqlEscape(sIRCMessage.Info[6].ToLower()), sIRCMessage.ServerName); if(!db1.IsNull()) { var rss = new Rss(sIRCMessage.ServerName, sUtilities.SqlEscape(sIRCMessage.Info[6]), db1["Link"].ToString(), db1["Website"].ToString()); RssList.Add(rss); rss.Start(); } sSendMessage.SendChatMessage(sIRCMessage, text[1]); } } }
//���RSS public static void AddRss(Rss rss) { _RssList.Add(rss); }
//����ָ����RSS public static void ModifyRss(Rss rss) { for (int i = 0; i < _RssList.Count; i++) { if (((Rss)_RssList[i]).RssId == rss.RssId) { _RssList.RemoveAt(i); _RssList.Add(rss); return; } } }