public static void UpDateTile(Array articleArray) { var xmlDocument = new XmlDocument(); xmlDocument.LoadXml(File.ReadAllText("tile.xml", Encoding.UTF8)); TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); string pattern = "(\\d+)/(\\d+)/(\\d+) "; //正则匹配 var regex = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline); XmlNodeList texts = xmlDocument.GetElementsByTagName("text"); int newArticlNum = (articleArray.Length < 5) ? articleArray.Length : 5; for (int j = 0; j < newArticlNum; j++) { Models.ArticleModel article = (Models.ArticleModel)articleArray.GetValue(j); for (int i = 0; i < texts.Length - 2; i += 2) { texts[i].InnerText = article.Title.Substring(0, article.Title.Length > 50 ? 50 : article.Title.Length); var matchStrings = regex.Matches(article.PubDate.ToString()); texts[i + 1].InnerText = matchStrings[0].Value; } texts[6].InnerText = article.Summary.Substring(0, 200); var notification = new TileNotification(xmlDocument); TileUpdateManager.CreateTileUpdaterForApplication().Update(notification); } }
public ActionResult Searchresult(string SearchText) { var data = _coll.GetAllArticles(); if (!string.IsNullOrEmpty(SearchText)) { string text = SearchText.ToUpper(); var result = data.Where(a => a.Title.Contains(text)); foreach (var unconvertedArticle in result) { Models.ArticleModel viewModel = new Models.ArticleModel() { Id = unconvertedArticle.Id, Author = unconvertedArticle.Author, Title = unconvertedArticle.Title, Content = ArticleTextManager.DecodeArticleText(unconvertedArticle.ArticleText), TagID = unconvertedArticle.TagID, CreatedAt = unconvertedArticle.DateCreated, LastEdited = unconvertedArticle.LastEdited, Thumbnail = unconvertedArticle.Images }; _articles.Add(viewModel); } ViewData["Articles"] = _articles; return(View()); } else { foreach (var unconvertedArticle in data) { Models.ArticleModel viewModel = new Models.ArticleModel() { Id = unconvertedArticle.Id, Author = unconvertedArticle.Author, Title = unconvertedArticle.Title, Content = ArticleTextManager.DecodeArticleText(unconvertedArticle.ArticleText), TagID = unconvertedArticle.TagID, CreatedAt = unconvertedArticle.DateCreated, LastEdited = unconvertedArticle.LastEdited, Thumbnail = unconvertedArticle.Images }; _articles.Add(viewModel); } ViewData["Articles"] = _articles; return(View()); } }
public IActionResult LoadArticlesByTag(int tagId) { var data = _coll.GetArticlesByTag(tagId); UserCollection userColl = new UserCollection(); foreach (var unconvertedArticle in data) { var author = userColl.GetByID(unconvertedArticle.AuthorId); Models.ArticleModel viewModel = new Models.ArticleModel() { Id = unconvertedArticle.Id, Author = author.FirstName + " " + author.LastName, Title = unconvertedArticle.Title, Content = ArticleTextManager.DecodeArticleText(unconvertedArticle.ArticleText), TagID = unconvertedArticle.TagID, CreatedAt = unconvertedArticle.DateCreated, LastEdited = unconvertedArticle.LastEdited, Thumbnail = unconvertedArticle.Images }; _articles.Add(viewModel); } _articles.Reverse(); return(View("../Home/Articles", _articles)); }
public IActionResult ArticlePage(int id) { if (id != 0) { var article = _articleColl.GetArticleById(id); UserCollection userColl = new UserCollection(); var author = userColl.GetByID(article.AuthorId); Models.ArticleModel articleModel = new Models.ArticleModel() { Title = article.Title, Content = ArticleTextManager.DecodeArticleText(article.ArticleText), Thumbnail = article.Images, Author = author.FirstName + " " + author.LastName }; return(View(articleModel)); } else { return(Content("<script>console.log('It can not be null!');</script>")); } }
public ActionResult Display(long articleId) { Dbo.Article article = BusinessManagement.Article.GetArticleDbo(articleId); Models.ArticleModel model = new Models.ArticleModel() { ArticleId = article.Id, BlogId = article.BlogId, Caption = article.Caption, MediaType = article.MediaTypeId.Value, MediaUrl = article.MediaUrl, Tags = article.Tags, Comments = article.Comments }; //ViewData.Model = new ArticleModel(); string articleUrl = BASE_URL + "/ArticleDisplay/Display?id=" + articleId; ViewBag.urlFB = HttpUtility.UrlEncode(articleUrl); ViewBag.urlTw = articleUrl; return View(model); }
public ActionResult Display(long articleId) { Dbo.Article article = BusinessManagement.Article.GetArticleDbo(articleId); Models.ArticleModel model = new Models.ArticleModel() { ArticleId = article.Id, BlogId = article.BlogId, Caption = article.Caption, MediaType = article.MediaTypeId.Value, MediaUrl = article.MediaUrl, Tags = article.Tags, Comments = article.Comments }; //ViewData.Model = new ArticleModel(); string articleUrl = BASE_URL + "/ArticleDisplay/Display?id=" + articleId; ViewBag.urlFB = HttpUtility.UrlEncode(articleUrl); ViewBag.urlTw = articleUrl; return(View(model)); }