public async Task <ActionResult> AddComment(Models.ArticleViewModels.CreateCommentViewModel model) { var userid = Guid.Parse(Session["userid"].ToString()); BlogSystem.IBLL.IArticleManager articleManager = new ArticleManager(); await articleManager.CreateComment(userid, model.Id, model.Content); return(Json(new { result = "ok" })); }
protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "removeTag") { ArticleManager.GetInstance().RemoveTagByTagName(e.CommandArgument.ToString()); } bind(); }
protected void localDataBind() { DataTable tempDt; tempDt = ArticleManager.GetArticleInfoByArticleState(9); //绑定数据 gvArticleList.DataSource = tempDt; gvArticleList.DataBind(); }
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 ResourceFileService(ArticleManager article) { if (_firstLoad) { var initializer = SiteManager.Kernel.Get <ResourceCatalogInit>(); _firstLoad = false; } _article = article; }
private void bind() { int count = BlogManager.GetInstance().BlogBaseModel.BlogModel.RecentArticleListCount; listModel = ArticleManager.GetInstance().GetRecentArticleList(count); dlRecentArtcle.DataSource = listModel; dlRecentArtcle.DataBind(); }
public static List <Article> getArticleListOfOthersForNoLogin(int userId, GroupNode gn) { if (gn != null) { // 1、如果第二个参数不为null: PrimaryGroups pg = PrimaryGroupMananger.selectRecord(new PrimaryGroups(gn.PrimaryGroupId, "")); if (pg == null) { return(null); } List <Article> al = ArticleManager.getArticleListByPrimaryGroup(pg); if (al == null) { return(null); } List <Tag> tagList = TagManager.getAllTagsByCertainGroupId(pg.GroupId); if (tagList != null) { int tagListLength = tagList.Count; for (int i = 0; i < tagListLength; i++) { Tag t = tagList[i]; if (t.TagName != "其他") { List <Article> articleListInTag = ArticleManager.getArticleListByDynamicSearch(t); if (articleListInTag != null) { int articleListInTagLength = articleListInTag.Count; for (int k = 0; k < articleListInTagLength; k++) { Article a = articleListInTag[k]; int alLength = al.Count; for (int p = 0; p < alLength; p++) { if (al[p].ArticleId == a.ArticleId) { al.RemoveAt(p); alLength -= 1; } } } } } } } return(al); } else { // 2、如果第二个参数为null,只需返回所有文章中没有被分到任何主分类的文章的列表即可 PrimaryGroups pg = new PrimaryGroups(); pg.GroupId = 0; // 其它主分类的 id 为 0 return(ArticleManager.getArticleListByPrimaryGroup(pg)); } }
public override IResponseMessage OnTextRequest(RequestMessageText requestMessage) { var content = requestMessage.Content.Trim().ToLower(); if (content == "help") { using (var manager = new ArticleManager()) { return(manager.GetHelp()); } } if (content == "about") { using (var manager = new ArticleManager()) { return(manager.GetAbout()); } } if (content == "top") { using (var manager = new ArticleManager()) { return(manager.GetTop()); } } if (content == "next") { return(new ResponseMessageText("此命令功能尚未开发完成,请稍后再试")); } if (content == "tags") { using (var manager = new ArticleManager()) { return(manager.GetAllTags()); } } if (content.Length == 8) { long publishDate; if (long.TryParse(content, out publishDate)) { using (var manager = new ArticleManager()) { return(manager.GetByPublishDate(content)); } } } IResponseMessage responseForTag; using (var manager = new ArticleManager()) { responseForTag = manager.GetByTag(content); } return(responseForTag ?? new ResponseMessageText("无此命令或关键字,请发送 help 来获得帮助")); }
public async Task <ActionResult> EditCategory(Guid categoryId, string newCategoryName) { //未登陆、系统内置、重名、信息为空、当前用户不是分类的拥有者不可编辑 if (categoryId == null || newCategoryName == null || categoryId == Guid.Empty || newCategoryName.Trim() == "") { return(Json(new { status = "fail", result = "提交的数据不完整,请重试!" }, JsonRequestBehavior.AllowGet)); } //获取当前登陆的id,cookie的id需要解密 string userCookieId = ""; string message; if (Request.Cookies["userId"] != null) { if (!JwtHelper.GetJwtDecode(Request.Cookies["userId"].Value, out userCookieId, out message)) { return(Json(new { status = "fail", result = message }, JsonRequestBehavior.AllowGet)); } } string userId = Session["userId"] == null ? userCookieId : Session["userId"].ToString(); if (userId.Trim() == "") { return(Json(new { status = "fail", result = "还未登陆无法编辑" }, JsonRequestBehavior.AllowGet)); } IArticleManager articleManager = new ArticleManager(); if (!await articleManager.ExistsCategory(categoryId))//分类id不存在 { return(Json(new { status = "fail", result = "未能找到对应ID的分类,请稍后再试" }, JsonRequestBehavior.AllowGet)); } var data = await articleManager.GetOneCategoryById(categoryId); //要经过上面的判断否则会出错 if (data.UserId != Guid.Parse(userId)) //分类作者才可编辑分类 { if (data.UserId == Guid.Parse("00000000-0000-0000-0000-000000000001")) { return(Json(new { status = "fail", result = "系统内置分类不可进行编辑" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { status = "fail", result = "非本人分类不可进行编辑" }, JsonRequestBehavior.AllowGet)); } } //循环自己所有的分类,对比是否有重名 List <BlogCategoryDto> categories = await articleManager.GetAllCategories(Guid.Parse(userId)); foreach (BlogCategoryDto category in categories) { if (category.BlogCategoryName == newCategoryName)//修改后的名字和现有的重复,则提示失败 { return(Json(new { status = "fail", result = "该名字已存在,请修改后重试!" }, JsonRequestBehavior.AllowGet)); } } await articleManager.EditCategory(categoryId, newCategoryName); return(Json(new { status = "ok", result = "编辑成功!" }, JsonRequestBehavior.AllowGet)); }
protected void lnkRemoveArticle_Click(object sender, EventArgs e) { ArticleManager.GetInstance().RemoveArticleByNo(articleNo); string script = string.Format("alert('{0}'); location.href='{1}';", UmcConfiguration.Message[ArticleConst.MESSAGE_ARTICLE_REMOVE], ListQueryString); Utility.JsCall(sender, script); }
public ArticleInfo_QueryCollection QueryNoStaticPathArticleList(int pageIndex, int pageSize) { var result = new ArticleInfo_QueryCollection(); var manager = new ArticleManager(); int totalCount = 0; result.ArticleList = manager.QueryNoStaticPathArticleList(pageIndex, pageSize, out totalCount); result.TotalCount = totalCount; return(result); }
public static void Update() { var model = ArticleManager.GetInstance().GetModel(1); model.readcount += 1; model.title = "Good"; model.updatetime = DateTime.Now; ArticleManager.GetInstance().Update(model); ArticleManager.GetInstance().Save(); }
public WeatherForecastController( ILogger <WeatherForecastController> logger, ArticleManager articleManager, IWebHostEnvironment environment ) { _logger = logger; this._articleManager = articleManager; this._environment = environment; }
public ActionResult GetArticleTypeTableInline(int pk, string value, string name) { var art = new ArticleManager(); art.EditItemTypeField(pk, name, value); return(Json(new { result = true })); }
/************************************************************************************************************************************************************ * * 【关于本类用法的重要说明】 * 当前台用户点击导航树上的某一个节点时,需要调用本类中的getArticleList方法族获取文章列表。这个类的难点就在于理解获取文章列表的三个方法的差异。 * 获取文章列表有三个不同方法,分别对应以下三种情况: * 1、用户点击了非“其他”的主分类之后,需要显示指定主分类下所有文章的列表,此时调用getArticleListOfCertainPrimaryGroup(GroupNode gn); * 2、用户点击了非“其他”的主分类下的非“其他”的子分类或兴趣标签,需要通过动态搜索显示指定子分类或兴趣标签下所有文章的列表,此时调用getArticleListByDynamicSearch(GroupNode gn); * 3、用户点击了“其他”主分类,需要显示所有没有被分到任何主分类的文章列表,此时调用getArticleListOfOthers( int userId , GroupNode gn ),并将第二个参数gn置为null; * 4、用户点击了非“其他”的主分类下的“其他”子分类,需要显示该主分类下所有未在任何一个该用户关注了的子分类和兴趣标签下的文章的列表, * 此时调用getArticleListOfOthers( int userId , GroupNode gn ),并将第二个参数设置为被点击的“其他”子分类对应的GroupNode实例。 * * 注:关于三个函数的具体功能请参看相应函数前的注释 * ************************************************************************************************************************************************************/ /* * 输入:一个GroupNode的model实例(仅使用其中的id字段,将这个字段作为groupId解析) * 输出:Article的列表 * 功能:读取传入参数中的id,获取数据库中该主分类的全部文章的Article的model对象列表并返回 * 用途说明:当用户点击某个主分类查看该分类下所有文章时,此函数返回该主分类所有文章的列表 */ public static List <Article> getArticleListOfCertainPrimaryGroup(GroupNode gn) { PrimaryGroups pg = PrimaryGroupMananger.selectRecord(new PrimaryGroups(gn.Id, "")); if (pg != null) { return(ArticleManager.getArticleListByPrimaryGroup(pg)); } return(null); }
private void BindxxArticle() { DataTable dt = ArticleManager.SelectxxTop8(); if (dt != null && dt.Rows.Count != 0) { RPxxArticle.DataSource = dt; RPxxArticle.DataBind(); } }
public ActionResult CreateCategory(CreateCategory model) { if (ModelState.IsValid) { BlogSystem.IBLL.IArticleManager articleManager = new ArticleManager(); articleManager.CreateCategory(model.CategoryName, Guid.Parse(Session["userId"].ToString())); return(RedirectToAction("CategoryList")); } ModelState.AddModelError(key: "", errorMessage: "您的信息有误!"); return(View(model)); }
public async Task <ActionResult> ArticleList(int pageIndex = 1, int pageSize = 2) { //总页码,当前页码,可显示页码数 var articleManager = new ArticleManager(); var userId = Guid.Parse(Session["userId"].ToString()); //获取用户id var articles = await articleManager.GetAllArticles(userId, pageIndex - 1, pageSize); //获取分页数据 var dataCount = await articleManager.GetDataCount(userId); //获取数据条数 return(View(new PagedList <ArticleDto>(articles, pageIndex, pageSize, dataCount))); //返回分页list }
/* * 输入:新文章的标题和内容 * 输出:成功返回得到的articleId,失败返回-1 * 功能:本函数需要依次实现以下功能: * 1、新建一个article的model实例,将title填进去 * 2、截取content的前100~150字作为abstract,填进article实例中去 * 3、将article实例的time字段设为当前时间,wordCount字段设为-1,heat字段设为0 * 4、调用dal层函数在数据库Article表中新增一条记录,得到返回的articleId * 5、以articleId为文件名、title + content为文件内容将文章以txt格式存储于本地文件系统中(放到App_Data\Articles目录下面) * 6、将文章存储的路径填写到数据库article表的fileURL字段中 * 7、调用parseArticle函数,将该文章进行解析和自动分类 * 8、返回得到的articleId。 * 用途说明:管理员使用该函数向数据库中新增文章 */ public static int addArticle(string title, string content) { Article a = new Article(); if (title.Contains("\"")) { title = title.Replace("\"", "\\\""); } if (title.Contains("'")) { title = title.Replace("'", "\\'"); } a.Title = title; if (content.Length > 300) { a.Abstrct = content.Substring(4, 300); } else { a.Abstrct = content.Substring(4, content.Length - 4); } a.FileURL = ""; // 这里 FileURF 先随便设一个,下面如果插入成功的话,再重新update a.Time = DateTime.Now; a.WordCount = 0; a.Heat = 0; int aid = ArticleManager.addRecord(a); if (aid > -1) { string dirPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "App_Data\\Articles"; if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); // 如果文件夹 Article不存在则新建 } a.ArticleId = aid; a.FileURL = "\\" + aid + ".txt"; ArticleManager.updateFileURL(a); // 重新设置 FileURL parseArticle(a, content); // 这里面要从新设置一下 wordCount ArticleManager.updateWordCount(a); FileStream fs = new FileStream(dirPath + a.FileURL, FileMode.Create); StreamWriter sw = new StreamWriter(fs); //开始写入 sw.Write(content); //清空缓冲区 sw.Flush(); //关闭流 sw.Close(); fs.Close(); } return(aid); }
public async Task <ActionResult> EditArticle(EditArticleViewModel model) { if (!ModelState.IsValid) { return(View(model)); } IArticleManager articleManager = new ArticleManager(); await articleManager.EditArticle(model.Id, model.Title, model.Content, model.CategoryIds); return(RedirectToAction("ArticleList")); }
internal static void Delete(IDataStore dataStore, Article article) { ArticleManager manager = new ArticleManager(dataStore); BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Delete(article); Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status); Assert.IsNull(manager.GetArticle(article.ArticleId)); Trace.WriteLine("Successfully deleted article " + article.Subject); }
public async Task <ActionResult> ArticleList_two(int pageIndex = 1, int pageSize = 2) { var articleMgr = new ArticleManager(); var userid = Guid.Parse(Session["userid"].ToString()); //当前用户第n页数据 var articles = await articleMgr.GetAllArticlesByUserId(userid, pageIndex - 1, pageSize); var dataCount = await articleMgr.GetDataCount(userid); return(View(new PagedList <Dto.ArticleDto>(articles, pageIndex, pageSize, dataCount))); }
protected void dlAttachFile_ItemCommand(object source, DataListCommandEventArgs e) { //첨부파일을 삭제한다. if (e.CommandName == "removeAttach") { int fileNo = int.Parse(e.CommandArgument.ToString()); ArticleManager.GetInstance().RemoveAttachFileByFileNo(fileNo); init(); } }
public void BindArtID() { int id = Convert.ToInt32(Request.QueryString["id"]); DataTable dt = ArticleManager.SelectArticle(id); if (dt != null && dt.Rows.Count > 0) { ArtContentRepeater.DataSource = dt; ArtContentRepeater.DataBind(); } }
public ActionResult CreateCategory(CreateCategoryViewModel model) { if (ModelState.IsValid) { IBLL.IArticleManager articleManager = new ArticleManager(); articleManager.CreateCategory(model.CategoryName, Guid.Parse(Session["userid"].ToString())); return(RedirectToAction("CategoryList")); } ModelState.AddModelError("", "您录入的信息有误"); return(View(model)); }
/// <summary> /// 删除相应函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void OnDelArticle(object sender, EventArgs e) { LinkButton lbBtn = sender as LinkButton; int ArticleID = Convert.ToInt32(lbBtn.CommandArgument); if (ArticleManager.DeleteArticleByID(ArticleID) == 0) { ClientScript.RegisterStartupScript(GetType(), "", "alert('删除过程出错!')", true); } PageDataBind(); }
public async Task <ActionResult> ArticleList(int currentIndex = 1, int pageSize = 4) { var articleManager = new ArticleManager(); var userId = Guid.Parse(Session["userId"].ToString()); var articles = await articleManager.GetAllArticleGroupPage(userId, currentIndex - 1, pageSize); var count = await articleManager.GetPageCount(userId); //ViewBag.PageCount = count % pageSize == 0 ? count / pageSize : count / pageSize + 1; //ViewBag.CurrentIndex = currentIndex; return(View(new PagedList <Dto.ArticleDto>(articles, currentIndex, pageSize, count))); }
public async Task <ActionResult> ArticleDetails(Guid?id) { ArticleManager articleManager = new ArticleManager(); if (id == null || !await articleManager.ExistsArticle(id.Value)) { return(RedirectToAction(nameof(ArticleList))); } ViewBag.Comments = await articleManager.GetCommentByArticleId(id.Value); return(View(await articleManager.GetOneArticleById(id.Value))); }
public async Task <ActionResult> CreateCategory(CategoryViewModels category) { if (ModelState.IsValid) { IArticleManager articleManager = new ArticleManager(); await articleManager.CreateCategory(category.CategoryName, Guid.Parse(Session["userId"].ToString())); return(RedirectToAction("categoryList", "Article")); } ModelState.AddModelError("categoryError", "您的输入有误,请重新输入"); return(View(category)); }
private void DataBinds() { PagedDataSource pdsList = new PagedDataSource(); //对PagedDataSource 对象的相关属性赋值 pdsList.DataSource = ArticleManager.GetAllArticles(); pdsList.AllowPaging = true; pdsList.PageSize = anpPager.PageSize; pdsList.CurrentPageIndex = anpPager.CurrentPageIndex - 1; rpArticle.DataSource = pdsList; rpArticle.DataBind(); }
public void InsertTest() { ArticleManager manager = new ArticleManager(); MySpider.DAL.Model.ArticleDBModel item = manager.ConvertToDalModel(new MySpider.BLL.Model.ArticleModel { Title = "tt", Summary = "test 1", Created = DateTime.Now }); DBContext.Save(item); }
public ArticleController(ArticleManager articleManager) { this._articleManager = articleManager; }
public FavoritesController(ArticleManager articleManager, UsersManager usersManager) { this._articleManager = articleManager; this._usersManager = usersManager; }
public BrowseController(ArticleManager articleManager, CategoryManager categoryManager, SearchesManager searchesManager) { this._articleManager = articleManager; this._categoryManager = categoryManager; this._searchesManager = searchesManager; }
public SolutionFinderController(SolutionFinderManager _solFinderManager, ArticleManager articleManager, UsersManager usersManager) { this._solFinderManager = _solFinderManager; this._articleManager = articleManager; this._usersManager = usersManager; }