コード例 #1
0
        public ActionResult Post(FormCollection f,HttpPostedFileBase file1)
        {
            int userID = UserID;
            bizBBSMain b = new bizBBSMain();
            bizUsers bu = new bizUsers();
            Users modelUser = bu.Get(userID);
            if ((new bizUserForbid()).GetByUserID(userID) != null)
            {
                TempData["Msg"] = "�����ڽ����ڼ䣬�޷�������";
                return RedirectToAction("Post");
            }

            if (modelUser.Score - modelUser.UsedScore < 0)
            {
                TempData["Msg"] = "��Ļ���Ϊ���֣���ʱ�޷�������";
                return RedirectToAction("Post");
            }

            if (MyText.GetNoSpaceStr(f["txtContent"].ToString()).Trim().Length < 2)
            {
                TempData["Msg"] = "�������ݲ���С��2���ַ���";
                return RedirectToAction("Post");
            }

            if (bbs.GetLevels(modelUser.OnlineTime) < 2)
            {
                TempData["Msg"] = "2���ſ��Է�����������2��ֻ��Ҫ5����Ŷ��";
                return RedirectToAction("Post");
            }

            TempData["Title"] = f["title"].ToString().Trim();
            TempData["Content"] = f["txtContent"].ToString();

            //if (LastPostTime.AddSeconds(20) > DateTime.Now)
            //{
            //    TempData["Msg"] = "�㷢���ٶȹ��죬���Ժ��ٷ���";
            //    return RedirectToAction("Post");
            //}
            //else
            //{
            //    LastPostTime = DateTime.Now;
            //}
            if (MyText.CheckIsLike(b.GetPrevTitle(modelUser.UserID),f["title"].ToString().Trim()))
            {
                TempData["Msg"] = "����ʹ�ú��ϸ������Ƶı��⡣";
                return RedirectToAction("Post");
            }

            string title=f["title"].ToString().Trim();
            string titleColor="";
            string content=f["txtContent"].ToString();
            byte fileType = 1;
            string filePath = "";
            //byte fileType = byte.Parse(f["fileType"]);
            //string filePath=f["filePath"];
            //string face=f["face1"];
            //face = face == "0" ? "" : face + ".gif";
            byte isShowTag = f["isShowTag"] == null || f["isShowTag"].ToString() == "false" ? byte.Parse("0") : byte.Parse("1");
            byte isNiming = 0;
            if (f["NimingCard"] != null && f["NimingCard"] == "on")
                isNiming = 1;
            if (f["BigNimingCard"] != null && f["BigNimingCard"] == "on")
                isNiming = 2;
            byte chenmoType = 0;
            if (f["ChenmoCard"] != null && f["ChenmoCard"] == "on")
                chenmoType = 1;
            byte isVote = 0;
            if (f["chkVote"] != null && f["chkVote"] == "on")
                isVote = 1;
            if (f["NimingCard"] != null && f["NimingCard"] == "on")
                isNiming = 1;
            byte voteType = byte.Parse(f["voteType"]);
            string voteItems = f["txtVoteItem"].Trim().Replace("\r\n","&^^&");
            string username = modelUser.UserName;
            int addUser = modelUser.UserID;
            string addIP = Public.CommonHelper.GetIPAddress();
            string message=b.CheckAdd(addUser, title, content, isNiming, chenmoType);
            if (message != "")
            {
                TempData["Msg"] = message;
                return RedirectToAction("Post");
            }
            if (isVote == 1)
            {
                if (voteItems == "")
                {
                    TempData["Msg"] = "ͶƱ���Ϊ��";
                    return RedirectToAction("Post");
                }
            }
            if (file1 != null)
            {
                string imagePath;
                int typeID;
                bizUserImageType bt = new bizUserImageType();
                UserImageType modelType = bt.GetByDefault(userID);
                typeID = modelType == null ? 0 : modelType.UserImageTypeID;
                TempData["Msg"] = Public.ImageHelper.ImageUpOfBbs(userID, file1, typeID, out imagePath);
                if (TempData["Msg"].ToString() != "")
                {
                    return RedirectToAction("Post");
                }
                content = content + "<br /><img src='"+ imagePath +"' border='0'><br />";
            }
            byte types = b.GetBBSContentType(content);
            int mainID = b.BBSMainAdd(int.Parse(f["typeMain"]),
                f["typeDeID"] == null ? 0 : int.Parse(f["typeDeID"]),
                CommonCache.FilterTextReplace(title), titleColor,2, CommonCache.FilterTextReplace(content), types, "", fileType, CommonCache.FilterTextReplace(filePath),"", isShowTag,
                isNiming, isVote, voteType, voteItems, username, addUser, chenmoType, addIP);

            if (mainID == 0)
            {
                TempData["Msg"] = "�㲻�ܷ���";
                return RedirectToAction("Post");
            }
            return Redirect("/BBS/"+mainID+".html");
        }
コード例 #2
0
        public ActionResult MainUpdate(FormCollection f)
        {
            bizBBSMain b = new bizBBSMain();
            byte types = b.GetBBSContentType(f["txtContent"]);
            string result = b.TopiceUpdate(int.Parse(f["bbsMainID"]), UserID,
                f["typeDeID"] == null ? 0 : int.Parse(f["typeDeID"]),
                CommonCache.FilterTextReplace(f["title"].Trim()), CommonCache.FilterTextReplace(f["txtContent"]), types,
                "",
                f["isShowTag"] == null || f["isShowTag"].ToString() == "false" ? byte.Parse("0") : byte.Parse("1")
                );

            if (result != "")
            {
                TempData["Msg"] = result;
                return RedirectToAction("MainUpdate", new { id = int.Parse(f["bbsMainID"]) });
            }
            else
            {
                return Redirect("/BBS/" + f["bbsMainID"] + ".html");
            }
        }