void btnSave_Click(object sender, EventArgs e) { int _selectCategoryId = Convert.ToInt32(this.ddlcategoryList.SelectedValue); if (_selectCategoryId == 0) { this.ltErrorMsg.Text = "请选择所属分类"; return; } articleInfo = new ArticleInfo(); articleInfo.ArticleId = articleId; articleInfo.CategoryId = _selectCategoryId; articleInfo.Title = txtTitle.Text; articleInfo.Content = txtContent.Text; articleInfo.GUID = Guid.NewGuid().ToString(); articleInfo.PublishDate = Convert.ToDateTime(string.Format("{0} {1}", this.PublishDate.SelectedDate.ToString("yyyy-MM-dd"), DateTime.Now.ToString("hh:mm:ss"))); articleInfo.LinkUrl = this.txtLinkUrl.Text; articleInfo.Url = string.Format("{1}news/html/{0}.aspx", articleInfo.GUID, ResolveUrl("~")); articleInfo.ImageUrl = this.txtImageUrl.Text; articleInfo.Introduction = this.txtIntroduction.Text; if (!string.IsNullOrEmpty(articleInfo.LinkUrl)) { articleInfo.Url = this.articleInfo.LinkUrl; } ArticleManage.Update(articleInfo); string js = string.Format("alert('保存成功!');window.location.href='articlelist.aspx?categoryId={0}';", _selectCategoryId); Page.ClientScript.RegisterStartupScript(this.GetType(), "SaveSuccess", js, true); }
/// <summary> /// 根据GUID获得文章详细信息 /// </summary> /// <param name="guid">GUID</param> /// <param name="language">语言,主要生成URL用</param> /// <returns></returns> public static ArticleInfo GetByGUID(string guid, WebLanguage language = WebLanguage.zh_cn) { var model = ArticleManage.GetByGUID(guid); LoadExtensionInfo(model, language); return(model); }
/// <summary> /// 根据文章ID,获得文章详细信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public static ArticleInfo Get(int id, WebLanguage language = WebLanguage.zh_cn) { var model = ArticleManage.Get(id); LoadExtensionInfo(model, language); return(model); }
public ActionResult Login(LoginViewModel loginViewModel) { var _articleNum = new ArticleManage().NoAuditNum(); if (ModelState.IsValid) { //加密密码 string _password = Security.Sha256(loginViewModel.Password); var _res = adminManage.Verity(loginViewModel.Accounts, _password); if (_res.Code == 2) { var _admin = adminManage.Find(loginViewModel.Accounts); Session.Add("AdminID", _admin.AdministratorID); Session.Add("Accounts", _admin.Accounts); Session.Add("NoAuditNum", _articleNum); _admin.LoginIP = Request.UserHostAddress; _admin.LoginTime = DateTime.Now; adminManage.Update(_admin); return(RedirectToAction("Index", "Home")); } else if (_res.Code == 1) { ModelState.AddModelError("Password", _res.Message); } else if (_res.Code == 3) { ModelState.AddModelError("Accounts", _res.Message); } else { ModelState.AddModelError("", _res.Message); } } return(View(loginViewModel)); }
/// <summary> /// 根据文章URl,获得文章详细信息 /// </summary> /// <param name="url"></param> /// <returns></returns> public static ArticleInfo GetByUrl(string url, WebLanguage language = WebLanguage.zh_cn) { var model = ArticleManage.GetByUrl(url); LoadExtensionInfo(model, language); return(model); }
public async Task <ActionResult> BedCount(Guid id) { IArticleManage articleManage = new ArticleManage(); await articleManage.BedCountAdd(id); return(Json(data: new { result = "ok" })); }
/// <summary> /// 根据GUID获得文章详细信息 /// </summary> /// <param name="guid">GUID</param> /// <param name="language">语言,主要生成URL用</param> /// <returns></returns> public static ArticleInfo GetByFullTimespan(string guid) { var model = ArticleManage.GetByFullTimespan(guid); LoadExtensionInfo(model); return(model); }
public async Task <ActionResult> AddComment(CreateCommentViewModel model) { var userid = Guid.Parse(Session["userId"].ToString()); IArticleManage articleManage = new ArticleManage(); await articleManage.CreateComment(userid, model.Id, model.Content); return(Json(data: new { result = "ok" })); }
public static IPageOfList <ArticleInfo> List(SearchSetting setting, WebLanguage language = WebLanguage.zh_cn) { var list = ArticleManage.List(setting); foreach (var item in list) { LoadExtensionInfo(item, language); } return(list); }
/// <summary> /// 根据文章ID,获得相关文章 /// </summary> /// <param name="siteId">所属站点</param> /// <param name="article">所属文章</param> /// <param name="topCount"></param> /// <returns></returns> public static IList <ArticleInfo> GetRelatedByArticleId(int siteId, int articleId, int topCount, WebLanguage language = WebLanguage.zh_cn) { var list = ArticleManage.GetRelatedByArticleId(siteId, articleId, topCount); foreach (var item in list) { LoadExtensionInfo(item, language); } return(list); }
/// <summary> /// 查询,带分页 /// </summary> /// <param name="setting"></param> /// <returns></returns> public static IPageOfList <ArticleInfo> List(ArticleSearchSetting setting) { var list = ArticleManage.List(setting); foreach (var item in list) { LoadExtensionInfo(item); } return(list); }
/// <summary> /// 根据类别ID获取TOP几条,没有分页 /// </summary> /// <param name="siteId"></param> /// <param name="categoryId"></param> /// <param name="topCount"></param> /// <returns></returns> public static IList <ArticleInfo> ListWithoutPage(int siteId, int categoryId, int topCount, bool topOneImage, WebLanguage language) { var list = ArticleManage.ListWithoutPage(siteId, categoryId, topCount, topOneImage); foreach (var item in list) { LoadExtensionInfo(item, language); } return(list); }
/// <summary> /// 获得文章列表 /// </summary> /// <param name="siteId"></param> /// <param name="categoryId"></param> /// <param name="topCount">默认10条</param> /// <returns></returns> public static List <ArticleInfo> ListWithoutPage(int categoryId, int topCount, bool isTopOneImg = false) { var list = ArticleManage.ListWithoutPage(categoryId, topCount, isTopOneImg); foreach (var item in list) { LoadExtensionInfo(item); } return(list); }
/// <summary> /// 查询页面所调用方法 /// 获取所有的数据 /// </summary> /// <param name="siteId"></param> /// <param name="key"></param> /// <returns></returns> public static List <ArticleInfo> Seek(int siteId, string key) { var list = ArticleManage.Seek(siteId, key); foreach (var item in list) { LoadExtensionInfo(item); } return(list); }
public ActionResult CreateCategory(CreateCategoryViewModel model) { if (ModelState.IsValid) { IArticleManage articleManage = new ArticleManage(); articleManage.CreateCategory(model.CategoryName, userid: Guid.Parse(Session["userId"].ToString())); return(RedirectToAction("CategoryList")); } ModelState.AddModelError(key: "", errorMessage: "类型创建失败"); return(View(model)); }
public async Task <ActionResult> ArticleDetails(Guid?id) { var ArticleManage = new ArticleManage(); if (id == null || !await new ArticleManage().ExistsArticle(id.Value)) { return(RedirectToAction(nameof(ArticleList))); } ViewBag.Comments = await new ArticleManage().GetCommentsByArticleId(id.Value); return(View(await ArticleManage.GetOneArticleById(id.Value))); }
/// <summary> /// 添加或编辑 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int Create(ArticleInfo model) { if (model.Id > 0) { //Update ArticleManage.Update(model); } else { int i = ArticleManage.Insert(model); model.Id = i; } return(model.Id); }
protected void Page_Load(object sender, EventArgs e) { string url = Goodspeed.Web.UrlHelper.Current.FileName; string guid = url.Substring(0, url.LastIndexOf('.')); articleInfo = ArticleManage.GetArticleInfoByGUID(guid); if (articleInfo == null) { Response.Write("参数错误!"); Response.End(); } this.Page.Title = string.Format("{0} - {1}", articleInfo.Title, System.Configuration.ConfigurationManager.AppSettings["WebSiteTitlePostfix"]); }
public async Task <ActionResult> EditArticle(Guid id) { var articleManage = new ArticleManage(); var data = await articleManage.GetOneArticleById(id); var userid = Guid.Parse(Session["userId"].ToString()); ViewBag.CategoryIds = await new ArticleManage().GetAllCagetory(userid); return(View(new EditArticleViewModel() { Id = data.Id, Title = data.Title, Content = data.Content, CategoryIds = data.CategoryIds })); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (articleId != 0) { articleInfo = ArticleManage.GetArticleInfoByArticleId(articleId); this.txtContent.Text = articleInfo.Content; this.txtTitle.Text = articleInfo.Title; this.PublishDate.SelectedDate = articleInfo.PublishDate; this.txtLinkUrl.Text = articleInfo.LinkUrl; this.txtImageUrl.Text = articleInfo.ImageUrl; this.txtIntroduction.Text = articleInfo.Introduction; } } }
public static ArticleInfo Create(ArticleInfo model) { if (model.Id == 0) { //Insert int id = ArticleManage.Insert(model); model.Id = id; } else { ArticleManage.Update(model); } //插入ArticleTags表 ArticleManage.InsertArticleTagData(model.Id, model.Tags); return(model); }
public async Task <ActionResult> EditArticle(EditArticleViewModel model) { if (ModelState.IsValid) { var articleManage = new ArticleManage(); await articleManage.EditArticle(model.Id, model.Title, model.Content, model.CategoryIds); return(RedirectToAction("ArticleList")); } else { var userid = Guid.Parse(Session["userId"].ToString()); ViewBag.CategoryIds = await new ArticleManage().GetAllCagetory(userid); return(View(model)); } }
void InitInfo() { articleId = CECRequest.GetQueryInt("articleid", 0); action = CECRequest.GetQueryString("action"); categoryId = CECRequest.GetQueryInt("categoryid", 0); if (action.ToLower() == "del") { ArticleManage.Delete(articleId); Response.Redirect("articlelist.aspx"); return; } this.PublishDate.SelectedDate = DateTime.Now; this.ddlcategoryList.BuildTree(ArticleCategoryManage.GetArticleCategoryTable(), "CategoryName", "CategoryId"); this.ddlcategoryList.SelectedValue = categoryId.ToString(); }
/// <summary> /// 添加或编辑 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int Create(ArticleInfo model) { //处理一下关键词 if (!string.IsNullOrEmpty(model.Keywords)) { model.Keywords = Regex.Replace(model.Keywords, @"(\s+|,)", ","); } if (model.Id > 0) { //Update ArticleManage.Update(model); } else { int i = ArticleManage.Insert(model); model.Id = i; } return(model.Id); }
private const int CACHETIMEOUT = 0;//缓存30分钟 #region == Edit OR Add == /// <summary> /// 添加或编辑 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int Create(ArticleInfo model) { if (model.Id > 0) { //Update ArticleManage.Update(model); } else { int i = ArticleManage.Insert(model); model.Id = i; } //Insert ArticleTag string[] tags = model.Tags.Split(new char[] { ',' }); if (tags.Length > 0) { ArticleManage.InsertTags(model.Id, tags); } return(model.Id); }
// GET: AdminPerson/Home public ActionResult Index() { ArticleManage _article = new ArticleManage(); ViewBag.CommentNum = new CommentManage().Count(); ViewBag.UserNum = new UserManage().Count(); ViewBag.MovieNum = new MovieManage().Count(); ViewBag.ArticleNum = _article.Count(); List <DateTime> SevenDay = new List <DateTime>(); List <int> Counts = new List <int>(); for (var i = -6; i < 1; i++) { SevenDay.Add(DateTime.Now.Date.AddDays(i)); } foreach (var item in SevenDay) { Counts.Add(_article.Count(p => p.Releasetime == item.Date)); } ViewBag.labels = SevenDay.ToArray(); ViewBag.data = Counts.ToArray(); return(View()); }
public IActionResult Create(dynamic model) { var response = ResponseModelFactory.CreateInstance; if (model.schoolUuid == null && AuthContextService.CurrentUser.SchoolGuid == null) { response.SetFailed("请登录学校账号"); return(Ok(response)); } using (_dbContext) { var entity = new ArticleManage(); entity.ArticleUuid = Guid.NewGuid(); entity.SchoolUuid = AuthContextService.CurrentUser.SchoolGuid.Value; entity.IsDelete = 0; entity.Title = model.title; entity.Content = model.content; entity.AddTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); _dbContext.ArticleManage.Add(entity); _dbContext.SaveChanges(); response.SetSuccess(); return(Ok(response)); } }
public static ArticleInfo GetByTimespan(string timespan) { return(ArticleManage.GetByTimespan(timespan)); }
/// 获得相关文章 /// </summary> /// <param name="topCount"></param> /// <param name="articleId"></param> /// <returns></returns> public static List <ArticleInfo> GetRelatedArticleList(int topCount, int articleId, string tags) { return(ArticleManage.GetRelatedArticleList(topCount, articleId, tags)); }
/// <summary> /// 根据自定义条件获得文章列表 /// </summary> /// <param name="condition"></param> /// <returns></returns> public static List <ArticleInfo> ListWithoutPageByCondition(string condition) { return(ArticleManage.ListWithoutPageByCondition(condition)); }