public string SubmitArticle(ArticleInfo_Add article) { var id = BusinessHelper.GetArticleId(); var manager = new ArticleManager(); var keyWordsList = manager.QuerKeywordOfArticle(); var content = DeepReplaceContent(article.Description, keyWordsList); var tagList = new List <string>(); tagList.Add("script"); content = UsefullHelper.ReplaceHtmlTag(content, tagList); var staticPath = string.Format("/statichtml/zixun/details/{0}/{1}.html", DateTime.Now.ToString("yyyyMMdd"), id); var lastId = string.Empty; var lastTitle = string.Empty; var lastStaticPath = string.Empty; var last = manager.QueryLastArticle(article.Category); if (last != null) { lastId = last.Id; lastTitle = last.Title.Length > 50 ? last.Title.Substring(0, 50) : last.Title; lastStaticPath = last.StaticPath; last.NextId = id; last.NextTitle = article.Title.Length > 50 ? article.Title.Substring(0, 50) : article.Title; last.NextStaticPath = staticPath; manager.UpdateArticle(last); } var entity = new Article { Id = id, GameCode = article.GameCode, Title = article.Title, KeyWords = article.KeyWords, DescContent = article.DescContent, Description = content, IsRedTitle = article.IsRedTitle, Category = article.Category, ShowIndex = 0, ReadCount = 0, CreateTime = DateTime.Now, CreateUserKey = article.CreateUserKey, CreateUserDisplayName = article.CreateUserDisplayName, UpdateTime = DateTime.Now, UpdateUserKey = article.CreateUserKey, UpdateUserDisplayName = article.CreateUserDisplayName, PreId = lastId, PreTitle = lastTitle, PreStaticPath = lastStaticPath, StaticPath = "", }; manager.AddArticle(entity); return(id); }
public async Task <StatusCodeResult> PostArticle([FromBody] Article p) { if (await PostAsyncArticleCheck(p)) { return(await PostAsyncPartTwoArticle(p)); } else { am.AddArticle(p); return(new StatusCodeResult(201)); //created } }
public ActionResult AddArticle(Post post) { post.PostNo = new Random().Next(100000); post.CreateTime = DateTime.UtcNow; //格林威治时间 post.Author = "admin"; try { articleManager.AddArticle(post); return(RedirectToAction("Success")); } catch (Exception exception) { throw; } }
protected void imgPublish_Click(object sender, ImageClickEventArgs e) { Article article = new Article(); article.Title = this.txtTitle.Text.ToString(); article.Contents = this.ftbContent.Text.ToString(); article.Author = user; article.Clicks = 0; article.PubDate = DateTime.Now; if (ArticleManager.AddArticle(article) != null) { Response.Redirect("~/refresh.aspx?msg=" + "发表文章成功!"); } else { this.lblMsg.Text = "很遗憾,发表失败,请重新尝试!"; } }
protected void btnPost_Click(object sender, EventArgs e) { if (isEdit) { int id = int.Parse(Request.QueryString["ID"]); Article article = ArticleManager.GetArticle(id); article.Title = txtTitle.Text.Trim(); article.SubTitle = txtSubTitle.Text.Trim(); article.Abstract = txtAbstract.Text; article.Content = txtContent.Text; article.CopyFrom = txtCopyFrom.Text.Trim(); article.Author = txtAuthor.Text.Trim(); article.Keywords = GlobalSettings.FormatKeywords(txtKeywords.Text); article.DisplayOrder = int.Parse(txtDisplayOrder.Text); article.ArticleMemo = txtMemo.Text; article.Status = csArticle.SelectedValue; if (!string.IsNullOrEmpty(ddlArticleImages.SelectedValue)) { article.Image = int.Parse(ddlArticleImages.SelectedValue); } if (string.IsNullOrEmpty(txtDate.Text.Trim())) { article.Date = DateTime.Now; } else { article.Date = DateTime.Parse(txtDate.Text.Trim()); } article.UpdateTime = DateTime.Now; article.UpdateUser = Profile.AccountInfo.UserID; DataActionStatus status = ArticleManager.UpdateArticle(article); if (status == DataActionStatus.DuplicateName) { //mbMsg.ShowMsg("新增资讯失败,存在同名资讯!"); } else if (status == DataActionStatus.UnknownFailure) { throw new HHException(ExceptionType.Failed, "更新资讯信息失败,请联系管理员!"); } else if (status == DataActionStatus.Success) { throw new HHException(ExceptionType.Success, "操作成功,已成功更新资讯!"); } } else { Article article = new Article(); //int parentID = int.Parse(Request.QueryString["catid"]); int parentID = ascCategory.SelectedCategoryID; article.Category = parentID; article.Title = txtTitle.Text.Trim(); article.SubTitle = txtSubTitle.Text.Trim(); article.Abstract = txtAbstract.Text; article.Content = txtContent.Text; article.CopyFrom = txtCopyFrom.Text.Trim(); article.Author = txtAuthor.Text.Trim(); article.Keywords = GlobalSettings.FormatKeywords(txtKeywords.Text); article.DisplayOrder = int.Parse(txtDisplayOrder.Text); article.ArticleMemo = txtMemo.Text; article.Status = csArticle.SelectedValue; if (!string.IsNullOrEmpty(ddlArticleImages.SelectedValue)) { article.Image = int.Parse(ddlArticleImages.SelectedValue); } if (string.IsNullOrEmpty(txtDate.Text.Trim())) { article.Date = DateTime.Now; } else { article.Date = DateTime.Parse(txtDate.Text.Trim()); } article.CreateTime = DateTime.Now; article.CreateUser = Profile.AccountInfo.UserID; article.UpdateTime = DateTime.Now; article.UpdateUser = Profile.AccountInfo.UserID; DataActionStatus status; ArticleManager.AddArticle(article, out status); if (status == DataActionStatus.DuplicateName) { throw new HHException(ExceptionType.Failed, "新增资讯失败,存在同名资讯!"); } else if (status == DataActionStatus.UnknownFailure) { throw new HHException(ExceptionType.Failed, "新增资讯失败,请联系管理员!"); } else if (status == DataActionStatus.Success) { throw new HHException(ExceptionType.Success, "操作成功,已成功增加一个新的资讯!"); } } }