public ActionResult AddFromTopic(FormCollection f) { try { string title = f["title"]; string content = f["content"]; string username = f["username"]; string fid = f["fid"]; string tid1 = f["tid"]; string picurl = f["picurl"]; string anony = f["anony"]; string uid = f["uid"]; if (title == null) { #region 添加评论/楼数 Miaow.DataSys.sns_Post post = Miaow.DataClass.jz.Querys.IrainDb.sns_Post.CreateObject(); if (anony == "" || anony == null) { post.author = Miaow.function.StringHelper.GetRealIP(); } else { post.author = anony; } //更新回复主表 post.fid = Convert.ToInt32(fid); post.authorico = 0; post.authorid = 0; post.guestname = 0; post.subject = ""; post.dateline = Miaow.function.DateHelper.GetNowToMysqlTime(); post.up = 0; post.wave = 0; post.down = 0; post.postip = Miaow.function.StringHelper.GetRealIP(); post.tid = Convert.ToInt32(tid1); post.replyfloor = (short)(Miaow.DataClass.jz.Querys.GetPostMaxFloorByTid(post.tid) + 1); Miaow.DataClass.jz.Querys.IrainDb.sns_Post.AddObject(post); //更新回复详细表 Miaow.DataSys.sns_PostContent postContent = Miaow.DataClass.jz.Querys.IrainDb.sns_PostContent.CreateObject(); postContent.message = content + "<br/>" + picurl; postContent.picture = ""; postContent.tid = Convert.ToInt32(tid1); Miaow.DataClass.jz.Querys.IrainDb.sns_PostContent.AddObject(postContent); //更新楼数 最后一个回复人id username Miaow.DataSys.sns_topic toppic = Miaow.DataClass.jz.Querys.GetSingleTopPicByTid(post.tid); toppic.replies += 1; toppic.lastauthor = Miaow.function.StringHelper.GetAnonyIP(); toppic.lastauthorid = 0; int res = Miaow.DataClass.jz.Querys.IrainDb.SaveChanges(); //更新新鲜事儿首页会显示这些信息的 Miaow.DataSys.sns_feed_template tmeplate = Miaow.DataClass.jz.Querys.GetSingleFeedTemplateByType("forum_reply"); Miaow.DataSys.sns_feed feed = Miaow.DataClass.jz.Querys.IrainDb.sns_feed.CreateObject(); //这个地方得改改,不过现在,还不晓得怎么改的 feed.appid = "0"; feed.feedtype = 0; feed.fid = 0; feed.type = "forum_reply"; feed.cTime = (int?)post.dateline; feed.uid = 0; feed.username = Miaow.function.StringHelper.GetAnonyIP(); feed.title_data = feed.username + "回复了主题帖:<a href='/topic/" + post.tid + "/x' target='_blank'>" + toppic.subject + "</a>"; feed.body_data = feed.title_data; Webdiyer.WebControls.Mvc.PagedList<Miaow.DataClass.jz.SinglePostDetail> model = null; model = Miaow.DataClass.jz.Querys.GetTopPicPostDetailListById(post.tid, 1, pageSize, "last"); return PartialView("ListTopicPartital", model); #endregion } else { #region 添加新帖子 sns_topic toppic = new sns_topic(); sns_Post post = new sns_Post(); sns_PostContent postContent = new sns_PostContent(); postContent.isHtml = 0; if (picurl == null) { postContent.message = content; } else { postContent.message = content + "<br/>" + picurl; } postContent.picture = ""; if (username == null) { post.author = Miaow.function.StringHelper.GetRealIP(); toppic.author = Miaow.function.StringHelper.GetRealIP(); toppic.lastauthor = Miaow.function.StringHelper.GetRealIP(); } else { post.author = username; toppic.author = username; toppic.lastauthor = username; } post.fid = Convert.ToInt32(fid); post.authorico = 0; post.authorid = 0; post.subject = title; post.dateline = Miaow.function.DateHelper.GetNowToMysqlTime(); post.up = 0; post.wave = 0; post.postip = Miaow.function.StringHelper.GetRealIP(); post.replyfloor = 0; toppic.dateline = Miaow.function.DateHelper.GetNowToMysqlTime(); toppic.lasttime = Miaow.function.DateHelper.GetNowToMysqlTime(); toppic.fid = Convert.ToInt32(fid); toppic.authorico = 0; toppic.authorid = 0; toppic.lastauthorid = 0; toppic.subject = title; Miaow.DataClass.jz.Querys.IrainDb.sns_topic.AddObject(toppic); int res = Miaow.DataClass.jz.Querys.IrainDb.SaveChanges(); if(res > 0 ) { sns_topic topic = Miaow.DataClass.jz.Querys.GetSingleTopPicBySubject(title); int tid = topic.tid; post.tid = tid; postContent.tid = tid; Miaow.DataClass.jz.Querys.IrainDb.sns_Post.AddObject(post); Miaow.DataClass.jz.Querys.IrainDb.sns_PostContent.AddObject(postContent); Miaow.DataClass.jz.Querys.IrainDb.SaveChanges(); } return RedirectToAction("ListTopic", "Forum", new { tid = post.tid, num = "", pageIndex = 1 }); ////获得活动的名称 //string title1 = FroumModels.irainbow.sns_forum.Where(o => o.fid == post.fid).SingleOrDefault().name; //ViewBag.Name = title; //return PartialView("ForumListTopicC", new FroumModels(post.fid, title1, null, 60)); #endregion } } catch (Exception ex) { throw; } }
public ActionResult AddFromTopic(FormCollection f) { try { string title = f["title"]; string content = f["content"]; string username = f["username"]; string fid = f["fid"]; string tid1 = f["tid"]; string picurl = f["picurl"]; string anony = f["anony"]; string uid = f["uid"]; if (title == null) { #region 添加评论/楼数 iPow.DataSys.sns_Post post = iPow.DataClass.jz.Querys.IrainDb.sns_Post.CreateObject(); if (anony == "" || anony == null) { post.author = iPow.function.StringHelper.GetRealIP(); } else { post.author = anony; } //更新回复主表 post.fid = Convert.ToInt32(fid); post.authorico = 0; post.authorid = 0; post.guestname = 0; post.subject = ""; post.dateline = iPow.function.DateHelper.GetNowToMysqlTime(); post.up = 0; post.wave = 0; post.down = 0; post.postip = iPow.function.StringHelper.GetRealIP(); post.tid = Convert.ToInt32(tid1); post.replyfloor = (short)(iPow.DataClass.jz.Querys.GetPostMaxFloorByTid(post.tid) + 1); iPow.DataClass.jz.Querys.IrainDb.sns_Post.AddObject(post); //更新回复详细表 iPow.DataSys.sns_PostContent postContent = iPow.DataClass.jz.Querys.IrainDb.sns_PostContent.CreateObject(); postContent.message = content + "<br/>" + picurl; postContent.picture = ""; postContent.tid = Convert.ToInt32(tid1); iPow.DataClass.jz.Querys.IrainDb.sns_PostContent.AddObject(postContent); //更新楼数 最后一个回复人id username iPow.DataSys.sns_topic toppic = iPow.DataClass.jz.Querys.GetSingleTopPicByTid(post.tid); toppic.replies += 1; toppic.lastauthor = iPow.function.StringHelper.GetAnonyIP(); toppic.lastauthorid = 0; int res = iPow.DataClass.jz.Querys.IrainDb.SaveChanges(); //更新新鲜事儿首页会显示这些信息的 iPow.DataSys.sns_feed_template tmeplate = iPow.DataClass.jz.Querys.GetSingleFeedTemplateByType("forum_reply"); iPow.DataSys.sns_feed feed = iPow.DataClass.jz.Querys.IrainDb.sns_feed.CreateObject(); //这个地方得改改,不过现在,还不晓得怎么改的 feed.appid = "0"; feed.feedtype = 0; feed.fid = 0; feed.type = "forum_reply"; feed.cTime = (int?)post.dateline; feed.uid = 0; feed.username = iPow.function.StringHelper.GetAnonyIP(); feed.title_data = feed.username + "回复了主题帖:<a href='/topic/" + post.tid + "/x' target='_blank'>" + toppic.subject + "</a>"; feed.body_data = feed.title_data; Webdiyer.WebControls.Mvc.PagedList <iPow.DataClass.jz.SinglePostDetail> model = null; model = iPow.DataClass.jz.Querys.GetTopPicPostDetailListById(post.tid, 1, pageSize, "last"); return(PartialView("ListTopicPartital", model)); #endregion } else { #region 添加新帖子 sns_topic toppic = new sns_topic(); sns_Post post = new sns_Post(); sns_PostContent postContent = new sns_PostContent(); postContent.isHtml = 0; if (picurl == null) { postContent.message = content; } else { postContent.message = content + "<br/>" + picurl; } postContent.picture = ""; if (username == null) { post.author = iPow.function.StringHelper.GetRealIP(); toppic.author = iPow.function.StringHelper.GetRealIP(); toppic.lastauthor = iPow.function.StringHelper.GetRealIP(); } else { post.author = username; toppic.author = username; toppic.lastauthor = username; } post.fid = Convert.ToInt32(fid); post.authorico = 0; post.authorid = 0; post.subject = title; post.dateline = iPow.function.DateHelper.GetNowToMysqlTime(); post.up = 0; post.wave = 0; post.postip = iPow.function.StringHelper.GetRealIP(); post.replyfloor = 0; toppic.dateline = iPow.function.DateHelper.GetNowToMysqlTime(); toppic.lasttime = iPow.function.DateHelper.GetNowToMysqlTime(); toppic.fid = Convert.ToInt32(fid); toppic.authorico = 0; toppic.authorid = 0; toppic.lastauthorid = 0; toppic.subject = title; iPow.DataClass.jz.Querys.IrainDb.sns_topic.AddObject(toppic); int res = iPow.DataClass.jz.Querys.IrainDb.SaveChanges(); if (res > 0) { sns_topic topic = iPow.DataClass.jz.Querys.GetSingleTopPicBySubject(title); int tid = topic.tid; post.tid = tid; postContent.tid = tid; iPow.DataClass.jz.Querys.IrainDb.sns_Post.AddObject(post); iPow.DataClass.jz.Querys.IrainDb.sns_PostContent.AddObject(postContent); iPow.DataClass.jz.Querys.IrainDb.SaveChanges(); } return(RedirectToAction("ListTopic", "Forum", new { tid = post.tid, num = "", pageIndex = 1 })); ////获得活动的名称 //string title1 = FroumModels.irainbow.sns_forum.Where(o => o.fid == post.fid).SingleOrDefault().name; //ViewBag.Name = title; //return PartialView("ForumListTopicC", new FroumModels(post.fid, title1, null, 60)); #endregion } } catch (Exception ex) { throw; } }