public virtual string Expand(IList<string> parms, IList<string> vals, ArticleDto activeArticle, IList<ArticleDto> allArticles) { IDictionary<string, string> vars = prepareVariables(parms, vals, activeArticle); Regex replaceRegex = new Regex(@"%([^\)%]+)%"); string expandedText = macroText; MatchCollection matches = replaceRegex.Matches(expandedText); Match[] matchArr = new Match[matches.Count]; matches.CopyTo(matchArr, 0); IEnumerable<Match> sortedMatches = (IEnumerable<Match>)matchArr.OrderByDescending(x => x.Index); foreach (Match match in sortedMatches) { string preText = expandedText.Substring(0, match.Index); string postText = expandedText.Substring(match.Index + match.Length); string parmName = match.Groups[1].Value; string value = ""; if (vars.ContainsKey(parmName)) value = vars[parmName]; expandedText = preText + value + postText; } return expandedText; }
public ArticleDto ParseArticleRawText(string sourceText, string relativePath) { ArticleDto article = new ArticleDto(relativePath, this); article.Content = sourceText; article.OutputPath = relativePath; article.Template = null; //No template return article; }
/// <summary> /// Processes article text to produce data structures for further processing. /// </summary> /// <param name="sourceText">The text to </param> /// <param name="relativePath">Used for error reporting and creation of indexes later on.</param> /// <returns></returns> public ArticleDto ParseArticleRawText(string sourceText, string relativePath) { ArticleDto article = new ArticleDto(relativePath, this); IDictionary<string, IList<string>> attributes; article.Content = WinSSC.Util.MarkdownUtil.ParseMarkdown(sourceText, relativePath, attrs, out attributes); article.Attributes = attributes; article.SourceFileRelativePath = relativePath; return article; }
public void WrapArticle(ArticleDto article) { int startPos = article.TemplateContent.IndexOf(CONTENT_MARKER); if (startPos >= 0) { string preTemplate = article.TemplateContent.Substring(0, startPos); string postTemplate = article.TemplateContent.Substring(startPos + CONTENT_MARKER.Length); article.Content = preTemplate + article.Content + postTemplate; } else { Logger.LogError("Content marker (" + CONTENT_MARKER + " ) could not be found in " + article.Template.Name + " template"); } }
public bool AddArticle(ArticleDto article, WriterDto writer) { Utils.SendObject(Constants.AddArticleCommand, _stream); var response = Utils.ReadObject <string>(_stream); var articleUpdateDto = new ArticleUpdateDto { ArticleDto = article, WriterDto = writer }; Utils.SendObject(articleUpdateDto, _stream); var finalResponse = Utils.ReadObject <string>(_stream); return(finalResponse == Constants.Success); }
public async Task <IActionResult> OnGetAsync(int id) { try { Article = await articleService.GetArticleAsync(id); Article.ViewCount += 1; await articleService.UpdateArticleAsync(Article); } catch (EntityNotFoundException e) { return(new NotFoundResult()); } return(Page()); }
/// <summary> /// 保存 /// </summary> /// <param name="theData">保存的数据</param> public ActionResult SaveData(ArticleDto theData) { if (!string.IsNullOrEmpty(theData.Cover)) { theData.Cover = theData.Cover.Substring(theData.Cover.IndexOf("/Upload")); } Article article = _mapper.Map <ArticleDto, Article>(theData);//进行Dto对象与模型之间的映射 if (theData.Id == 0) { article.CreateTime = DateTime.Now; _articleBusiness.Insert(article); } else { _articleBusiness.Update(article); _attachmentBusiness.Delete(m => m.TargetId == article.Id); } List <string> attachments = new List <string>(); if (!string.IsNullOrEmpty(theData.Attachments)) { attachments = theData.Attachments.Split(',').CastToList <string>(); } List <Attachment> attachmentList = new List <Attachment>(); attachments.ForEach(m => { var data = m.Split('&'); Attachment attach = new Attachment(); attach.Directory = data[0]; attach.SavePath = data[1].Substring(data[1].IndexOf("/Upload")); attach.Thumb = data[2].Substring(data[1].IndexOf("/Upload")); attach.FileExt = Path.GetExtension(data[1]); attach.Name = data[3]; attach.Type = 1; attach.TargetId = article.Id; attach.CreateTime = DateTime.Now; attach.Store = 0; attachmentList.Add(attach); }); if (attachmentList.Count > 0) { _attachmentBusiness.BulkInsert(attachmentList); } return(Success()); }
public async Task <IHttpActionResult> GetOneByAuthorIdCodeWithSn(string authorIdCode, int sequenceNumberForAuthor) { var userId = User.Identity.GetUserId(); var articleEntry = await _dbContext.Articles.Where(a => a.Principal.User.IdCode == authorIdCode && a.SequenceNumberForAuthor == sequenceNumberForAuthor) .Select(a => new { article = a, likeCount = a.Likes.Count, liked = a.Likes.Any(l => l.OperatorId == userId), type = a.Type, attachedPoints = a.AttachedPoints, voteForPoint = a.VoteForPoint }) .SingleOrDefaultAsync(); if (articleEntry == null) { return(NotFound()); } if (articleEntry.article.Archived != ArchivedState.None && userId != articleEntry.article.PrincipalId && !User.IsInRole(KeylolRoles.Operator)) { return(Unauthorized()); } var articleDto = new ArticleDto(articleEntry.article, true, includeProsCons: true, includeSummary: true) { AttachedPoints = articleEntry.attachedPoints.Select(point => new NormalPointDto(point, true)).ToList(), TypeName = articleEntry.type.ToString(), LikeCount = articleEntry.likeCount, Liked = articleEntry.liked, Archived = articleEntry.article.Archived, Rejected = articleEntry.article.Rejected, Spotlight = articleEntry.article.SpotlightTime != null, Warned = articleEntry.article.Warned }; if (articleEntry.voteForPoint != null) { articleDto.VoteForPoint = new NormalPointDto(articleEntry.voteForPoint, true); } return(Ok(articleDto)); }
public ArticleDto GetArticleDetails(string name, bool isDiary) { var documentName = generalHelper.AddSpecialCharsForString(name); var details = new ArticleDto(); if (isDiary) { var article = db.Diary.First(x => x.Name == documentName); details.Id = article.Id; details.CodedName = generalHelper.RemoveSpecialCharsFromString(article.Name); details.Name = "# " + article.Name; details.Body = article.Body; details.Date = article.DateCreated.ToLongDateString(); details.UserName = userHelper.GetUserById(article.UserId).UserName; details.ImageUrl = articleHelper.GetImageRelativePathByArticleId(article.Id); details.AlbumYear = article.AlbumYear.ToString(); details.ReleaseYear = article.ReleaseYear.ToString(); details.Label = article.Label; details.CatalogueNumber = article.CatalogueNumber; details.Genre = article.Genre; details.Series = "Z pamiętnika płytoholika"; details.IsDiary = true; return(details); } var articleModel = db.Articles.First(x => x.Name == documentName); details.Id = articleModel.Id; details.CodedName = generalHelper.RemoveSpecialCharsFromString(articleModel.Name); details.Name = articleModel.Name; details.Body = articleModel.Body; details.Date = articleModel.DateCreated.ToLongDateString(); details.UserName = userHelper.GetUserById(articleModel.UserId).UserName; details.ImageUrl = articleHelper.GetImageRelativePathByArticleId(articleModel.Id); details.Category = articleHelper.GetCategoryById(articleModel.CategoryId).Name; details.Subcategory = articleHelper.GetSubCategoryById(articleModel.SubCategoryId).Name; details.Prelude = articleModel.Prelude; details.IndexDescription = articleModel.IndexDescription; details.Series = articleHelper.GetSeriesById(articleModel.Series).Name != "Default" ? articleHelper.GetSeriesById(articleModel.Series).Name : null; details.IsDiary = false; return(details); }
public List <ArticleDto> GetSearchResult(string searchString) { var results = new List <ArticleDto>(); var articlesSearch = db.Articles.Where( x => x.IsPublished && (x.Name.Contains(searchString) || x.Body.Contains(searchString) || x.Prelude.Contains(searchString))).ToList(); foreach (var item in articlesSearch) { var element = new ArticleDto { Id = item.Id, Name = item.Name, CodedName = generalHelper.RemoveSpecialCharsFromString(item.Name), ImageUrl = articleHelper.GetImageRelativePathByArticleId(item.Id), Category = articleHelper.GetCategoryById(item.CategoryId).Name, Subcategory = articleHelper.GetSubCategoryById(item.SubCategoryId).Name, Date = item.DateCreated.ToLongDateString(), SortCode = item.Name.ToLowerInvariant().Contains(searchString.ToLowerInvariant()) ? 1 : 2 }; results.Add(element); } var diariesSearch = db.Diary.Where( x => x.IsPublished && (x.Name.Contains(searchString) || x.Body.Contains(searchString) || x.Label.Contains(searchString))) .ToList(); foreach (var diary in diariesSearch) { var diaryElement = new ArticleDto { Id = diary.Id, Name = diary.Name, CodedName = generalHelper.RemoveSpecialCharsFromString(diary.Name) + "?isDiary=true", ImageUrl = articleHelper.GetImageRelativePathByArticleId(diary.Id), Category = "Pamiętnik", Subcategory = "Pamiętnik", Date = diary.DateCreated.ToLongDateString(), SortCode = diary.Name.ToLowerInvariant().Contains(searchString.ToLowerInvariant()) ? 1 : 2 }; results.Add(diaryElement); } return(results.OrderBy(x => x.SortCode).ThenBy(x => x.Name).ToList()); }
public PagedResultDto <ArticleDto> QueryArticles([FromQuery] ArticleSearchDto searchDto) { DateTime monthDays = DateTime.Now.AddDays(-30); DateTime weeklyDays = DateTime.Now.AddDays(-7); DateTime threeDays = DateTime.Now.AddDays(-3); long?userId = _currentUser.Id; ISelect <Article> articleSelect = _articleRepository .Select .Include(r => r.Classify) .Include(r => r.UserInfo) .IncludeMany(r => r.Tags, r => r.Where(u => u.Status == true)) .IncludeMany(r => r.UserLikes, r => r.Where(u => u.CreateUserId == userId)) .Where(r => r.IsAudit == true) .WhereCascade(r => r.IsDeleted == false) .WhereIf(searchDto.UserId != null, r => r.CreateUserId == searchDto.UserId) .WhereIf(searchDto.TagId.HasValue, r => r.Tags.AsSelect().Any(u => u.Id == searchDto.TagId)) .WhereIf(searchDto.ClassifyId.HasValue, r => r.ClassifyId == searchDto.ClassifyId) .WhereIf(searchDto.Title.IsNotNullOrEmpty(), r => r.Title.Contains(searchDto.Title)) .WhereIf(searchDto.Sort == "THREE_DAYS_HOTTEST", r => r.CreateTime > threeDays) .WhereIf(searchDto.Sort == "WEEKLY_HOTTEST", r => r.CreateTime > weeklyDays) .WhereIf(searchDto.Sort == "MONTHLY_HOTTEST", r => r.CreateTime > monthDays) .OrderByDescending( searchDto.Sort == "THREE_DAYS_HOTTEST" || searchDto.Sort == "WEEKLY_HOTTEST" || searchDto.Sort == "MONTHLY_HOTTEST" || searchDto.Sort == "HOTTEST", r => (r.ViewHits + r.LikesQuantity * 20 + r.CommentQuantity * 30)) .OrderByDescending(r => r.CreateTime); List <ArticleDto> articleDtos = articleSelect .ToPagerList(searchDto, out long totalCount) .Select(a => { ArticleDto articleDto = _mapper.Map <ArticleDto>(a); articleDto.Tags = a.Tags.Select(r => new TagDto() { TagName = r.TagName, Id = r.Id, }).ToList(); articleDto.IsLiked = userId != null && a.UserLikes.Any(); articleDto.ThumbnailDisplay = _currentUser.GetFileUrl(articleDto.Thumbnail); return(articleDto); }) .ToList(); return(new PagedResultDto <ArticleDto>(articleDtos, totalCount)); }
public ActionResult Create(ArticleDto article, HttpPostedFileBase image) { if (ModelState.IsValid) { // Insert article in database using (var database = new BlogEntities()) { var authorId = database.AspNetUsers.Where(u => u.UserName == this.User.Identity.Name).First().Id; // Set articlea author article.AuthorId = authorId; article.DatePost = DateTime.Now; // Upload image. Check allowed types. if (image != null) { var allowedContentTypes = new[] { "image/jpeg", "image/jpg", "image/png", "image/gif", "image/tif" }; if (allowedContentTypes.Contains(image.ContentType)) { var imagesPath = "/Content/Images/"; var filename = Guid.NewGuid().ToString() + image.FileName; var uploadPath = imagesPath + filename; var physicalPath = Server.MapPath(uploadPath); image.SaveAs(physicalPath); article.ImagePath = uploadPath; } } OpArticleInsert op = new OpArticleInsert(); op.Article = article; OperationResult result = OperationManager.Singleton.ExecuteOperation(op); if (result.Status) { TempData["Success"] = "Added Successfully!"; return(RedirectToAction("Index")); } else { return(RedirectToAction("Create")); } } } return(View(article)); }
public async Task AddArticleAsync(ArticleDto article) { using (var context = new PressfordContext()) { context.Users.Attach(article.Author); context.Articles.Add(new Article { Author = article.Author, Title = article.Title, Body = article.Body, PublishDate = DateTime.Now } ); await context.SaveChangesAsync(); } }
private static ArticleDto Map(IArticle article) { var articleDto = new ArticleDto { Id = article.Id, Calories = article.Calories, Name = article.Name, NutrientIntakes = article.NutrientIntakes }; if (article.Name != null) { articleDto.Name = article.Name; } return(articleDto); }
public ActionResult Create( [Bind(Include = "Id,Name,Description,Price,TotalInShelf,TotalInVault,StoreId")] ArticleDto article) { if (ModelState.IsValid) { _articleAppService.CreateArticle(article); return(RedirectToAction("Index")); } var storesOutput = _storeAppService.GetAllStores(); ViewBag.StoreId = new SelectList(storesOutput.Stores, "Id", "Name", article.StoreId); return(View(article)); }
/// <summary> /// 更新文章 /// </summary> /// <param name="input"></param> /// <returns></returns> public async ValueTask <bool> UpdateArticleAsync(int id, ArticleDto input) { var article = await _articleRepository.GetAsync(id); if (article == null) { return(false); } article.CategoryId = input.CategoryId; article.Content = input.Content; article.Mdcontent = input.Mdcontent; article.LastDate = DateTime.Now; article = await _articleRepository.UpdateAsync(article); return(true); }
public Result UpdateArticle(ArticleDto article) { var articleResult = _mapper.Map <Article>(article); try { articleResult.DateChanged = DateTime.Now; _repository.Article.Update(articleResult); _repository.Save(); } catch (Exception e) { return(new Result(false, 500, "დაფიქსირდა შეცდომა")); } return(Result.SuccessInstance()); }
public async Task UpdateAsync_AlreadyExists() { var service = new ArticleService(_unitOfWorkMock.Object); var article = new ArticleDto { ID = 2, Barcode = "AAA" }; var result = await service.UpdateAsync(article, 1); Assert.IsNotNull(result); Assert.AreEqual(result.Status, ServiceResponseStatus.AlreadyExists); Assert.AreEqual(result.Result, null); }
private static bool Filter(this ArticleDto article, string term) { if (string.IsNullOrWhiteSpace(term)) { return(true); } return(article.Name.ToLower().Contains(term) || !string.IsNullOrWhiteSpace(article.Description) && article.Description.ToLower().Contains(term) || !string.IsNullOrWhiteSpace(article.Code) && article.Code.ToLower().Contains(term) || !string.IsNullOrWhiteSpace(article.Barcode) && article.Barcode.ToLower().Contains(term) || article.Recommendations.Any(r => r.Comment.ToLower().Contains(term))); }
public async Task <Article> AddArticle(ArticleDto articleDto) { var tags = await UpsertTags(articleDto.Tags); var newArticle = await _context.Articles.AddAsync(new Article { Title = articleDto.Title, Body = articleDto.Body, Date = DateTime.UtcNow, Tags = tags.ToArray() }); await _context.SaveChangesAsync(true); return(newArticle.Entity); }
public ActionResult DeleteConfirm(int id) { string url = "articledata/findarticle/" + id; HttpResponseMessage response = client.GetAsync(url).Result; if (response.IsSuccessStatusCode) { //Put data into article data transfer object ArticleDto SelectedArticle = response.Content.ReadAsAsync <ArticleDto>().Result; return(View(SelectedArticle)); } else { return(RedirectToAction("Error")); } }
public SqlParameter[] JsonStringToSqlParameter(string jsonString) { SqlParameter[] arParames = new SqlParameter[13]; ArticleDto articleDto = JsonHelper.JsonDeserializeBySingleData <ArticleDto>(jsonString); arParames[0] = new SqlParameter("@ArticleId", SqlDbType.Int); arParames[0].Value = articleDto.ArticleId; arParames[1] = new SqlParameter("@ArticleTitle ", SqlDbType.VarChar, 500); arParames[1].Value = articleDto.ArticleTitle; arParames[2] = new SqlParameter("@ArticleDescription ", SqlDbType.VarChar, 5000); arParames[2].Value = articleDto.ArticleDescription; arParames[3] = new SqlParameter("@ArticleKeywords ", SqlDbType.VarChar, 500); arParames[3].Value = articleDto.ArticleKeywords; arParames[4] = new SqlParameter("@ArticleContent ", SqlDbType.Text); arParames[4].Value = articleDto.ArticleContent; arParames[5] = new SqlParameter("@ArticleAuthor ", SqlDbType.VarChar, 50); arParames[5].Value = articleDto.ArticleAuthor; arParames[6] = new SqlParameter("@ArticleEditor ", SqlDbType.VarChar, 50); arParames[6].Value = articleDto.ArticleEditor; arParames[7] = new SqlParameter("@ArticleTime ", SqlDbType.DateTime); arParames[7].Value = articleDto.ArticleTime; arParames[8] = new SqlParameter("@ArticleTop ", SqlDbType.Bit); arParames[8].Value = articleDto.ArticleTop; arParames[9] = new SqlParameter("@ArticleHot ", SqlDbType.Bit); arParames[9].Value = articleDto.ArticleHot; arParames[10] = new SqlParameter("@ArticleClassic ", SqlDbType.Bit); arParames[10].Value = articleDto.ArticleClassic; arParames[11] = new SqlParameter("@ArticleCategory ", SqlDbType.Int); arParames[11].Value = articleDto.ArticleCategory; arParames[12] = new SqlParameter("@ArticleImg ", SqlDbType.VarChar, 500); arParames[12].Value = articleDto.ArticleImg; return(arParames); }
public IActionResult AddArticle(ArticleDto model) { if (string.IsNullOrEmpty(model.Content) || string.IsNullOrEmpty(model.Header)) { return(Json(new { isNull = true, message = "Lütfen gerekli alanlarý doldurunuz." })); } var user = HttpContext.Session.GetObject <AuthorDto>("LoginUser"); if (user == null || user.Id < 0) { return(Json(new { isNull = true, message = "Giriþ yapmadan yazý ekleyemezsiniz :(" })); } model.CreatedBy = user.Id; return(Ok(_articleService.AddArticle(model))); }
public JsonResult Articles([FromBody] PageModel msg) { ReplyModel reply = new ReplyModel(); PageData <ArticleDto> articles = ArticleDto.GetList(_articleQuery, msg); if (articles.Data.Any()) { reply.Status = "002"; reply.Msg = "获取数据成功"; reply.Data = articles; } else { reply.Msg = "没有数据了"; } return(Json(reply)); }
public bool UpdateArticle(ArticleDto updated, ArticleDto original, WriterDto writer) { Utils.SendObject(Constants.UpdateArticleCommand, _stream); var response = Utils.ReadObject <string>(_stream); updated.Id = original.Id; var articleUpdateDto = new ArticleUpdateDto { ArticleDto = updated, WriterDto = writer }; Utils.SendObject(articleUpdateDto, _stream); var finalResponse = Utils.ReadObject <string>(_stream); return(finalResponse == Constants.Success); }
public void AddArticleTest() { var article = new ArticleDto() { Id = 42, Header = "Head", Content = "Content" }; blog.AddArticle(article); Mock.Get(articleRepository) .Verify(repo => repo.Add(It.IsAny <Article>()), Times.Once); Mock.Get(articleRepository).VerifyNoOtherCalls(); uowMock.Verify(x => x.Commit(), Times.Once); }
public async Task ShouldUpdateImages() { // this part already tested upper var article = new ArticleDto { Title = "Here is the title", DatePublished = DateTime.UtcNow }; article.Content = File.ReadAllText("TestData/Content_With_New_Images.html"); var service = GetService <IArticleService>(); article = await service.Create(article); // updating images throw new NotImplementedException(); }
public IActionResult Register([FromBody] ArticleDto articleDto) { Article article = mapper.Map <Article>(articleDto); try { articleService.Create(article); return(Ok(article)); } catch (ApplicationException ex) { return(BadRequest(new { message = ex.Message })); } }
// GET: Admin/Text/Delete/5 public ActionResult Delete(int id) { OpArticleSelect op = new OpArticleSelect(); OperationResult result = OperationManager.Singleton.ExecuteOperation(op); var article = result.Items.Cast <ArticleDto>().Where(u => u.Id == id).FirstOrDefault(); var model = new ArticleDto(); model.Id = article.Id; model.Title = article.Title; model.Content = article.Content; model.ImagePath = article.ImagePath; model.DatePost = article.DatePost; return(View(model)); }
public async Task ShouldAddImages() { var article = new ArticleDto { Title = "Here is the title", DatePublished = DateTime.UtcNow }; article.Content = File.ReadAllText("TestData/Content_With_New_Images.html"); var service = GetService <IArticleService>(); article = await service.Create(article); ForIt <Image>().ShouldContains(x => x.ArticleId == article.Id) .CountShouldBe(2); }
public ResponseViewModel Add(ArticleDto articleDto) { var response = new ResponseViewModel(); var article = ArticleModelMapping(articleDto); _articleDal.Add(article); var saving = _articleDal.SaveChanges(); if (!saving) { response.IsSuccess = false; response.Message = "db error while add article"; } return(response); }
/// <summary> /// Parses the Tech Today message. /// </summary> /// <param name="subject">The subject of message.</param> /// <param name="body">The body of message.</param> /// <returns>Article dto.</returns> public ArticleDto Parse(string subject, string body) { ArticleDto articleDto = new ArticleDto(); var document = new HtmlDocument(); document.LoadHtml(body); var message = document.DocumentNode.SelectSingleNode("//td[table[@class='column50']]"); articleDto.Title = message.SelectSingleNode("//td[@class='h1m']/a").InnerHtml.ToString(); articleDto.Link = message.SelectSingleNode("//td[@class='h1m']/a").Attributes["href"].Value; articleDto.Body = body; return(articleDto); }
private ArticleDto CreateArticleDto( Article a, ArticleType at, User u, int commentCount) { var articleDto = new ArticleDto() { Content = HttpUtility.HtmlDecode(a.Content), CreateDate = a.CreateDate, Id = a.Id, IsShow = a.IsShow, LastUpdate = (DateTime)a.LastDateTime, ReadCount = a.ReadCount, Title = HttpUtility.HtmlDecode(a.Title), UrlQuoteUrl = a.UrlQuoteUrl, RealName = u.RealName, UserName = u.UserName, UserHeadImg = u.SmallImgHead, Domain = u.Domain, CommentCount = commentCount, ContentDesc = HttpUtility.HtmlDecode(a.ContentDesc) }; if (at != null) { articleDto.ArticleTypeId = at.Id; articleDto.ArticleTypeName = at.TypeName; } var articleTag = a.ArticleTags.ToList(); var atList = articleTag.Select(x => new { @id = x.Id, @tagName = x.TagName }); atList.Each(x => articleDto.ArticleTags.Add( x.id, x.tagName)); return(articleDto); }
public List <ArticleDto> GetSliderDetails() { var articleList = db.Articles.Where(x => x.IsPublished).OrderByDescending(x => x.DateCreated).Take(4).ToList(); var diaryList = db.Diary.Where(x => x.IsPublished).OrderByDescending(x => x.DateCreated).Take(4).ToList(); // Fixed number of articles for slider IT NEEDS TO BE REWRITED var postList = new List <ArticleDto>(); foreach (var item in articleList) { var article = new ArticleDto { Name = item.Name, CodedName = generalHelper.RemoveSpecialCharsFromString(item.Name), ImageUrl = articleHelper.GetImageRelativePathByArticleId(item.Id), UserName = userHelper.GetUserById(item.UserId).UserName, Date = item.DateCreated.ToLongDateString(), DateHelper = item.DateCreated, Category = articleHelper.GetCategoryById(item.CategoryId).Name, Subcategory = articleHelper.GetSubCategoryById(item.SubCategoryId).Name, Series = articleHelper.GetSeriesById(item.Series).Name != "Default" ? articleHelper.GetSeriesById(item.Series).Name : null, IsDiary = false }; postList.Add(article); } foreach (var item in diaryList) { var article = new ArticleDto { Name = item.Name, CodedName = generalHelper.RemoveSpecialCharsFromString(item.Name) + "?isDiary=true", ImageUrl = articleHelper.GetImageRelativePathByArticleId(item.Id), UserName = userHelper.GetUserById(item.UserId).UserName, Date = item.DateCreated.ToLongDateString(), DateHelper = item.DateCreated, Series = "Z pamiętnika płytoholika", IsDiary = true }; postList.Add(article); } return(postList.OrderByDescending(x => x.DateHelper).Take(4).ToList()); }
public virtual string Expand(IList<string> parms, IList<string> vals, ArticleDto activeArticle, IList<ArticleDto> allArticles) { if (transform == null) return ""; StringBuilder sb = new StringBuilder(); StringWriter writer = new StringWriter(sb); try { XmlDocument articleTree = BuildArticleTree(allArticles, groupingCriteria.ToArray(), activeArticle); if(parms.Count > 0 || vals.Count > 0) { //Add a parms node to the XML document as a L2 element. XmlNode parmsNode = articleTree.CreateElement("MacroParms"); articleTree.FirstChild.AppendChild(parmsNode); for(int i = 0; i < parms.Count; i++) { XmlNode pNode = articleTree.CreateElement("p" + (i + 1)); parmsNode.AppendChild(pNode); pNode.InnerText = parms[i]; } for (int i = 0; i < vals.Count; i++) { XmlNode pNode = articleTree.CreateElement("v" + (i + 1)); parmsNode.AppendChild(pNode); pNode.InnerText = vals[i]; } } transform.Transform(articleTree, new XsltArgumentList(), writer); if(Logger.DebugOn) { Logger.LogDebug("Data for macro " + Name + ":\r\n" + articleTree.Serialize()); } } catch(System.Xml.Xsl.XsltException ex) { Logger.LogError("Could not apply transformation on XSL macro " + Name + ":\r\n" + ex.Message); } return sb.ToString(); }
public IList<MacroInvocation> LocateMacrosInContent(ArticleDto article) { //Nothing to do return new List<MacroInvocation>(); }
private IDictionary<string, string> prepareVariables(IList<string> parms, IList<string> vals, ArticleDto activeArticle) { for (int i = 0; i < parms.Count; i++) { parms[i] = parms[i]; } Dictionary<string, string> vars = new Dictionary<string, string>(); for (int i = 0; i < parms.Count; i++) { string key = "p" + (i + 1); if (vars.ContainsKey(key)) { vars[key] = parms[i]; } else { vars.Add(key, parms[i]); } } for (int i = 0; i < vals.Count; i++) { string key = "v" + (i + 1); if (vars.ContainsKey(key)) { vars[key] = vals[i]; } else { vars.Add(key, vals[i]); } } for (int i = 0; i < vals.Count; i++) { string key = (i + 1).ToString(); if (vars.ContainsKey(key)) { vars[key] = vals[i]; } else { vars.Add(key, vals[i]); } } foreach (var kvp in activeArticle.Attributes) { if (kvp.Value.Count > 0) { if (vars.ContainsKey(kvp.Key)) { vars[kvp.Key] = kvp.Value[0]; } else { vars.Add(kvp.Key, kvp.Value[0]); } } for (int i = 0; i < kvp.Value.Count; i++) { string key = kvp.Key + (i + 1); if (vars.ContainsKey(key)) { vars[key] = kvp.Value[0]; } else { vars.Add(key, kvp.Value[0]); } } } return vars; }
public override string Expand(IList<string> parms, IList<string> vals, ArticleDto activeArticle, IList<ArticleDto> allArticles) { Markdown md = new Markdown(); string html = md.Transform(base.Expand(parms, vals, activeArticle, allArticles)); return html; }
public void FinaliseArticleHtml(ArticleDto article) { Markdown md = new Markdown(); article.Content = MarkdownUtil.ReplaceEscapedMacros(article.Content); article.Content = md.Transform(article.Content); }
public IList<MacroInvocation> LocateMacrosInArticleTemplateContent(ArticleDto article) { return WinSSC.Util.MarkdownUtil.LocateMarkdownMacros(article.TemplateContent); }
public void FinaliseArticleHtml(ArticleDto article) { //Nothing to do }