public void setPost(string _title, string _content, string _comment, string _category, string _tag, DateTime _publishDate, string _ping) { _blogPost = default(postInfo); _blogPost.title = _title; _blogPost.description = _content; _blogPost.mt_allow_comments = _comment; //According to received string, comments are allowed or not. _blogPost.categories = _category.Split(','); //Categories must be split with "," also if category does not exist, it will not create. _blogPost.mt_keywords = _tag; //Tags are split with "," but it xml-rpc do this for us. _blogPost.dateCreated = _publishDate; _blogPost.mt_allow_pings = _ping; //According to received string, ping is allowed or not. }
public ActionResult changeForum(postInfo info) { try { if (toolsHelpers.updateToolsController.updatePostInfo(u => u.postId == info.postId, info) == true) { Response.Redirect("/backStage/forumManagement/forumInvitationIndex"); return(Content("success")); } return(Content("修改论坛帖子失败!")); } catch { return(Content("修改论坛帖子出错!")); } }
/// <summary> /// 论坛表增加数据 /// </summary> /// <param name="info"></param> /// <returns></returns> public static Boolean insertPostInfo(postInfo info) { try { using (LazyfitnessEntities db = new LazyfitnessEntities()) { db.postInfo.Add(info); db.SaveChanges(); return(true); } } catch { return(false); } }
/// <summary> /// 查找论坛信息表中的数据 /// </summary> /// <typeparam name="TKey"></typeparam> /// <param name="whereLambda"></param> /// <param name="orderBy"></param> /// <returns></returns> public static postInfo[] selectPostInfo <TKey>(Expression <Func <postInfo, bool> > whereLambda, Expression <Func <postInfo, TKey> > orderBy) { try { using (LazyfitnessEntities db = new LazyfitnessEntities()) { DbQuery <postInfo> dataObject = db.postInfo.Where(whereLambda).OrderBy(orderBy) as DbQuery <postInfo>; postInfo[] infoList = dataObject.ToArray(); return(infoList); } } catch { postInfo[] nullInfo = new postInfo[0]; return(nullInfo); } }
/// <summary> /// 将所保存的记录保存在数据库并清除现有记录 /// </summary> /// <returns></returns> public bool SaveToDB() { rwl.EnterWriteLock(); using (LazyfitnessEntities db = new LazyfitnessEntities()) { foreach (PageViewRecord record in records) { switch (record.RegionId) { case 0: resourceInfo rinfo = db.resourceInfo.Where(article => article.resourceId == record.Id).FirstOrDefault(); if (rinfo == null) { break; } rinfo.pageView += record.PageView; break; case 1: quesAnswInfo qinfo = db.quesAnswInfo.Where(ques => ques.quesAnswId == record.Id).FirstOrDefault(); if (qinfo == null) { break; } qinfo.pageView += record.PageView; break; case 2: postInfo pinfo = db.postInfo.Where(post => post.postId == record.Id).FirstOrDefault(); if (pinfo == null) { break; } pinfo.pageView += record.PageView; break; default: break; } } db.SaveChanges(); records.Clear(); rwl.ExitWriteLock(); } return(true); }
public void forumSubmit(int areaId, int userId, string title, string editor) { postInfo pInfo = new postInfo { areaId = areaId, postTitle = title, userId = userId, postTime = DateTime.Now, pageView = 0, isPost = 0, postStatus = 1, postContent = editor }; using (LazyfitnessEntities db = new LazyfitnessEntities()) { db.postInfo.Add(pInfo); db.SaveChanges(); Response.Redirect(Url.Action("forumPart", "Home", new { partId = areaId })); } }
public string forumInvitationAdd(postInfo info) { try { if (toolsHelpers.selectToolsController.selectUserInfo(u => u.userId == info.userId, u => u.userId).Length == 0) { return("没有此用户,不能增加论坛帖子"); } info.postTime = DateTime.Now; info.pageView = 0; if (toolsHelpers.insertToolsController.insertPostInfo(info) == true) { Response.Redirect("/backStage/forumManagement/forumInvitationIndex"); return("success"); } return("false"); } catch { return("论坛帖子增加出错!"); } }
public ActionResult sureForum(int postId) { try { //有此帖子时候返回帖子所属分区名,帖子的作者,帖子的信息 //先返回帖子信息 postInfo[] infoList = toolsHelpers.selectToolsController.selectPostInfo(u => u.postId == postId, u => u.postId); //查看有无此贴 if (infoList == null || infoList.Length == 0) { return(Content("没有这篇帖子")); } //得到分区名 int areaId = infoList[0].areaId; postArea[] areaList = toolsHelpers.selectToolsController.selectPostArea(u => u.areaId == areaId, u => u.areaId); //得到帖子作者 int userId = infoList[0].userId.Value; userInfo[] userList = toolsHelpers.selectToolsController.selectUserInfo(u => u.userId == userId, u => u.userId); if (areaList == null || userList == null || areaList.Length == 0 || userList.Length == 0) { return(Content("此片论坛帖子存在错误信息不可读,请及时删除此论坛帖子")); } postInfo forumInfo = infoList[0]; string areaName = areaList[0].areaName; string ownerName = userList[0].userName; ViewBag.areaName = areaName; ViewBag.ownerName = ownerName; ViewBag.forumInfo = forumInfo; return(View()); } catch { return(Content("获取论坛帖子信息出错!")); } }
/// <summary> /// 修改论坛帖子表中的数据 /// </summary> /// <param name="whereLambda"></param> /// <param name="info"></param> /// <returns></returns> public static Boolean updatePostInfo(Expression <Func <postInfo, bool> > whereLambda, postInfo info) { try { using (LazyfitnessEntities db = new LazyfitnessEntities()) { DbQuery <postInfo> dataObject = db.postInfo.Where(whereLambda) as DbQuery <postInfo>; postInfo oldInfo = dataObject.FirstOrDefault(); oldInfo.areaId = info.areaId; oldInfo.postTitle = info.postTitle; oldInfo.pageView = info.pageView; oldInfo.isPost = info.isPost; oldInfo.amount = info.amount; oldInfo.postStatus = info.postStatus; oldInfo.postContent = info.postContent; db.SaveChanges(); return(true); } } catch { return(false); } }
public AppLoginModel GetLoginInfo(RoutePostAppLoginInfo request, AppMobileLogin model, IDbConnection db) { //using (var db = DbFactory.Open()) //{ //村级的时候需要将岗位信息返回出去 //村长有转发的权利可以显示转发按钮 var villageModel = db.Single <VillageWorkingGroup>(x => x.HandPhone == request.userName); var infoList = db.SqlList <VillagePerson>( "EXEC AppVillageUserPostInfo @handphone", new { handphone = request.userName }); // 需要转移的人员总数 var totalnum = db.Select <VillageTransferPerson>(w => w.adcd == model.adcd) .Sum(w => w.HouseholderNum); List <postInfo> postList = new List <postInfo>(); postInfo postModel = null; //村级的职位信息 var vgroup = ConfigurationManager.AppSettings["村级工作组"].Split(','); var village = ConfigurationManager.AppSettings["村级网格"].Split(','); infoList.ForEach( w => { postModel = new postInfo { postCode = w.Post }; if (vgroup.Contains(w.Post)) { postModel.postTypecode = "村级工作组"; } if (village.Contains(w.Post)) { postModel.postTypecode = "村级网格"; } if (postList.Count(x => x.postCode == postModel.postCode && x.postTypecode == postModel.postTypecode) == 0) { postModel.transferNum = postModel.postCode == "人员转移组" ? totalnum : 0; postList.Add(postModel); } }); if (villageModel != null && villageModel.Post == "村级主要负责人") { return(new AppLoginModel { ActionName = "村级", StatusCode = 1, IsSend = true, Message = "返回登录信息成功", Token = request.token, Adcd = model.adcd, ExistUser = true, Postion = postList }); } else { return(new AppLoginModel { ActionName = "村级", StatusCode = 1, IsSend = false, Message = "返回登录信息成功", Token = request.token, Adcd = model.adcd, ExistUser = true, Postion = postList }); } // } }