Пример #1
0
    private void BindBBSGridView(UC_GridView grd_BBS, int BoardID)
    {
        string condition = "[Board] = " + BoardID + " AND SendTime BETWEEN DATEADD(Day,-15,GetDate()) AND GETDATE() ORDER by [SendTime] desc";

        grd_BBS.BindGrid(BBS_ForumItemBLL.GetModelList(condition));
        grd_BBS.Attributes["BoardID"] = BoardID.ToString();
    }
Пример #2
0
    public void BindData()
    {
        BBS_ForumItemBLL itembll = new BBS_ForumItemBLL(Convert.ToInt32(ViewState["ItemID"]));
        this.title1 = lblTitle.Text = itembll.Model.Title.ToString();
        lblForumItemName.Text = itembll.Model.Title.ToString();
        lblCatalog.Text = new BBS_CatalogBLL(new BBS_BoardBLL(itembll.Model.Board).Model.Catalog).Model.Name;
        lblBoardName.Text = new BBS_BoardBLL(itembll.Model.Board).Model.Name;
        board = new BBS_BoardBLL(itembll.Model.Board).Model.ID;

        #region 显示发布者信息
        sendman.Text = DisplayFullInfo(itembll.Model.Sender);
        #endregion

        sendtime.Text = itembll.Model.SendTime.ToString();
        browsetime.Text = itembll.Model.HitTimes.ToString();
        replaytimes.Text = itembll.Model.ReplyTimes.ToString();
        browsetime.Text = itembll.Model.HitTimes.ToString();
        replaytimes.Text = itembll.Model.ReplyTimes.ToString();
        itemcontent.InnerHtml = FormatTxt(BBS_ForumItemDAL.txtMessage(itembll.Model.Content.ToString()));

        if (itembll.Model["IsTop"] == "Y")
        {
            cbx_Tpp.Checked = true;
        }

        if (itembll.Model["IsPith"] == "Y")
        {
            cbx_IsPith.Checked = true;
        }

        BindGrid();
    }
Пример #3
0
    public void BindData()
    {
        BBS_ForumItemBLL itembll = new BBS_ForumItemBLL(Convert.ToInt32(ViewState["ItemID"]));

        this.title1           = lblTitle.Text = itembll.Model.Title.ToString();
        lblForumItemName.Text = itembll.Model.Title.ToString();
        lblCatalog.Text       = new BBS_CatalogBLL(new BBS_BoardBLL(itembll.Model.Board).Model.Catalog).Model.Name;
        lblBoardName.Text     = new BBS_BoardBLL(itembll.Model.Board).Model.Name;
        board = new BBS_BoardBLL(itembll.Model.Board).Model.ID;

        #region 显示发布者信息
        sendman.Text = DisplayFullInfo(itembll.Model.Sender);
        #endregion

        sendtime.Text         = itembll.Model.SendTime.ToString();
        browsetime.Text       = itembll.Model.HitTimes.ToString();
        replaytimes.Text      = itembll.Model.ReplyTimes.ToString();
        browsetime.Text       = itembll.Model.HitTimes.ToString();
        replaytimes.Text      = itembll.Model.ReplyTimes.ToString();
        itemcontent.InnerHtml = FormatTxt(BBS_ForumItemDAL.txtMessage(itembll.Model.Content.ToString()));


        if (itembll.Model["IsTop"] == "Y")
        {
            cbx_Tpp.Checked = true;
        }

        if (itembll.Model["IsPith"] == "Y")
        {
            cbx_IsPith.Checked = true;
        }

        BindGrid();
    }
Пример #4
0
 protected void btn_Delete_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < dgrd_Result.Rows.Count; i++)
     {
         CheckBox chb = dgrd_Result.Rows[i].FindControl("chk_ID") as CheckBox;
         if (chb.Checked)
         {
             int id = int.Parse(dgrd_Result.DataKeys[i]["BBS_ForumItem_ID"].ToString());
             BBS_ForumItemBLL forumbll = new BBS_ForumItemBLL(id);
             forumbll.DeleteForumItem(id);
         }
     }
     BindGrid();
 }
Пример #5
0
 protected void btn_Delete_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < dgrd_Result.Rows.Count; i++)
     {
         CheckBox chb = dgrd_Result.Rows[i].FindControl("chk_ID") as CheckBox;
         if (chb.Checked)
         {
             int id = int.Parse(dgrd_Result.DataKeys[i]["BBS_ForumItem_ID"].ToString());
             BBS_ForumItemBLL forumbll = new BBS_ForumItemBLL(id);
             forumbll.DeleteForumItem(id);
         }
     }
     BindGrid();
 }
Пример #6
0
    protected void DelReplay(object sender, System.EventArgs e)
    {
        //删除论坛文章的回复
        BBS_ForumReplyBLL replybll = new BBS_ForumReplyBLL();

        replybll.Model.ID = Int32.Parse(((LinkButton)sender).CommandArgument.ToString());
        replybll.Delete(replybll.Model.ID);

        //修改论坛文章的评论数量
        BBS_ForumItemBLL itembll = new BBS_ForumItemBLL(Convert.ToInt32(ViewState["ItemID"]));

        itembll.UpdateRemoveReplyTimes(Convert.ToInt32(ViewState["ItemID"]));
        BindData();
    }
Пример #7
0
 protected string GetTypeIsPith(int id)
 {
     BBS_ForumItemBLL forumItembll = new BBS_ForumItemBLL(id);
     if (forumItembll.Model.ExtPropertys != null)
     {
         if (forumItembll.Model["IsPith"] == "Y")
             return "<img src='../../../images/pith.jpg'>";
         else
             return "";
     }
     else
     {
         return "";
     }
 }
Пример #8
0
    protected string GetType(int id)
    {
        BBS_ForumItemBLL forumItembll = new BBS_ForumItemBLL(id);
        //if (forumItembll.Model.IsBoardNotice == "Y" || forumItembll.Model.IsPublicNotice == "Y")
        //{
        //    if (forumItembll.Model.IsBoardNotice == "Y")
        //        return "<img src='../../../../images/bulletin.gif'>";
        //    else
        //        return "<img src='../../../../images/sysbulletin.gif'>";
        //}

            if(forumItembll.Model.HitTimes > 5)
                return "<img src='../../../../images/hotfolder.gif'>";
            else
                return "<img src='../../../../images/folder.gif'>";
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     // 在此处放置用户代码以初始化页面
     int itemid = (Request.QueryString["ItemID"] == null) ? 0 : Int32.Parse(Request.QueryString["ItemID"].ToString());
     int boardid = (Request.QueryString["BoardID"] == null) ? 0 : Int32.Parse(Request.QueryString["BoardID"].ToString());
     try
     {
         BBS_ForumItemBLL itembll = new BBS_ForumItemBLL(itemid);
         itembll.DeleteForumItem(itemid);
         MessageBox.ShowAndRedirect(this,"删除成功", "listview.aspx?Board=" + boardid.ToString());
     }
     catch (Exception)
     {
         Server.Transfer("../Mail/Error.aspx");
     }
 }
Пример #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // 在此处放置用户代码以初始化页面
        int itemid  = (Request.QueryString["ItemID"] == null) ? 0 : Int32.Parse(Request.QueryString["ItemID"].ToString());
        int boardid = (Request.QueryString["BoardID"] == null) ? 0 : Int32.Parse(Request.QueryString["BoardID"].ToString());

        try
        {
            BBS_ForumItemBLL itembll = new BBS_ForumItemBLL(itemid);
            itembll.DeleteForumItem(itemid);
            MessageBox.ShowAndRedirect(this, "删除成功", "listview.aspx?Board=" + boardid.ToString());
        }
        catch (Exception)
        {
            Server.Transfer("../Mail/Error.aspx");
        }
    }
Пример #11
0
    protected void cbx_IsPith_Click(object sender, System.EventArgs e)
    {
        BBS_ForumItemBLL itembll = new BBS_ForumItemBLL(Convert.ToInt32(ViewState["ItemID"]));

        if (itembll.Model["IsPith"] == "N")
        {
            itembll.Model["IsPith"] = "Y";
            itembll.Update();
            MessageBox.Show(this.Page, "帖子已经设置为精华贴!");
        }
        else
        {
            itembll.Model["IsPith"] = "N";
            itembll.Update();
            MessageBox.Show(this.Page, "帖已经不是精华贴!");
        }
    }
Пример #12
0
    protected void cmdOK_ServerClick(object sender, System.EventArgs e)
    {
        int BoardID = Int32.Parse(ddlBoardList.SelectedItem.Value);
        BBS_ForumItemBLL itembll = new BBS_ForumItemBLL(Convert.ToInt32(ViewState["itemid"]));
        itembll.Model.Board = BoardID;
        try
        {
            itembll.Update();
            ddlBoardList.Visible = false;
            cmdOK.Visible = false;
            ltMessage.Visible = true;
            ltMessage.Text = "移动成功!";

        }
        catch (Exception)
        {
            Server.Transfer("../Mail/Error.aspx");
        }
    }
Пример #13
0
    protected void cmdOK_ServerClick(object sender, System.EventArgs e)
    {
        int BoardID = Int32.Parse(ddlBoardList.SelectedItem.Value);
        BBS_ForumItemBLL itembll = new BBS_ForumItemBLL(Convert.ToInt32(ViewState["itemid"]));

        itembll.Model.Board = BoardID;
        try
        {
            itembll.Update();
            ddlBoardList.Visible = false;
            cmdOK.Visible        = false;
            ltMessage.Visible    = true;
            ltMessage.Text       = "移动成功!";
        }
        catch (Exception)
        {
            Server.Transfer("../Mail/Error.aspx");
        }
    }
Пример #14
0
    protected string GetTypeIsPith(int id)
    {
        BBS_ForumItemBLL forumItembll = new BBS_ForumItemBLL(id);

        if (forumItembll.Model.ExtPropertys != null)
        {
            if (forumItembll.Model["IsPith"] == "Y")
            {
                return("<img src='../../../../images/pith.jpg'>");
            }
            else
            {
                return("");
            }
        }
        else
        {
            return("");
        }
    }
Пример #15
0
    protected string GetType(int id)
    {
        BBS_ForumItemBLL forumItembll = new BBS_ForumItemBLL(id);

        //if (forumItembll.Model.IsBoardNotice == "Y" || forumItembll.Model.IsPublicNotice == "Y")
        //{
        //    if (forumItembll.Model.IsBoardNotice == "Y")
        //        return "<img src='../../../../images/bulletin.gif'>";
        //    else
        //        return "<img src='../../../../images/sysbulletin.gif'>";
        //}

        if (forumItembll.Model.HitTimes > 5)
        {
            return("<img src='../../../../images/hotfolder.gif'>");
        }
        else
        {
            return("<img src='../../../../images/folder.gif'>");
        }
    }
Пример #16
0
    protected void ModeratorInfo()
    {
        BBS_ForumItemBLL itembll = new BBS_ForumItemBLL(Convert.ToInt32(ViewState["ItemID"]));

        itembll.UpdateHitTimes(Convert.ToInt32(ViewState["ItemID"]));
        author = itembll.Model.Sender.ToString();
        IList <BBS_BoardUserMember> memberList = BBS_BoardUserMemberBLL.GetModelList(" Board=" + (int)ViewState["BoardID"]);
        bool flag = itembll.Model.Sender == Session["UserName"].ToString();

        foreach (BBS_BoardUserMember member in memberList)
        {
            if (member.Role == 1 && member.UserName == (string)ViewState["username"])
            {
                flag = true;
            }
        }
        if (Roles.IsUserInRole("论坛管理员") || flag)
        {
            itemcontent.InnerHtml += "<b>操 作:</b><a href=javascript:window.open('deleteitem.aspx?ItemID=" + Convert.ToInt32(ViewState["ItemID"]) + "&BoardID=" + Convert.ToInt32(ViewState["BoardID"]) + "','_self','');>删除此贴</a>|<a href='MoveItem.aspx?ItemID=" + Convert.ToInt32(ViewState["ItemID"]) + "'>移动帖子</a><br><hr color='#C0C0C0' size='1'>";
            cbx_IsPith.Visible     = true;
            cbx_Tpp.Visible        = true;
            right = true;
        }
    }
Пример #17
0
    protected void btn_OK_Click(object sender, EventArgs e)
    {
        #region 帖子的回复

        #region 添加帖子的回复
        BBS_ForumReplyBLL replybll = new BBS_ForumReplyBLL();
        replybll.Model.ItemID    = Convert.ToInt32(ViewState["ItemID"]);
        replybll.Model.Title     = Title.Value;
        replybll.Model.Content   = ckedit_content.Text;
        replybll.Model.Replyer   = Session["UserName"].ToString();
        replybll.Model.ReplyTime = DateTime.Now;
        replybll.Model.IPAddress = Request.ServerVariables.Get("REMOTE_ADDR").ToString();
        int replyid = replybll.Add();    // 返回已经回复的帖子的ID

        //修改论坛文章的留言量
        BBS_ForumItemBLL itembll = new BBS_ForumItemBLL(Convert.ToInt32(ViewState["ItemID"]));
        itembll.UpdateAddReplyTimes(Convert.ToInt32(ViewState["ItemID"]));
        #endregion

        #region 添加留言的附件
        ArrayList upattlist = (ArrayList)ViewState["UpattList"];
        if (upattlist != null && upattlist.Count > 0)
        {
            foreach (BBS_ForumAttachment att in upattlist)
            {
                string path = att.Path;
                if (path.StartsWith("~"))
                {
                    path = Server.MapPath(path);
                }
                FileStream stream = new FileStream(path, FileMode.Open);
                byte[]     buff   = new byte[stream.Length];
                stream.Read(buff, 0, buff.Length);
                stream.Close();
                att.Path   = "";
                att.ItemID = (int)ViewState["ItemID"];

                #region 自动压缩上传的图片
                if (ATMT_AttachmentBLL.IsImage(att.ExtName))
                {
                    try
                    {
                        MemoryStream         s             = new MemoryStream(buff);
                        System.Drawing.Image originalImage = System.Drawing.Image.FromStream(s);
                        s.Close();

                        int width = originalImage.Width;

                        if (width > 1024 || att.ExtName == "bmp")
                        {
                            if (width > 1024)
                            {
                                width = 1024;
                            }

                            System.Drawing.Image thumbnailimage = ImageProcess.MakeThumbnail(originalImage, width, 0, "W");

                            MemoryStream thumbnailstream = new MemoryStream();
                            thumbnailimage.Save(thumbnailstream, System.Drawing.Imaging.ImageFormat.Jpeg);
                            thumbnailstream.Position = 0;
                            att.FileSize             = (int)(thumbnailstream.Length / 1024);
                            att.ExtName = "jpg";

                            byte[] b = new byte[thumbnailstream.Length];
                            thumbnailstream.Read(b, 0, b.Length);
                            thumbnailstream.Close();
                            buff = b;
                        }
                    }
                    catch { }
                }
                #endregion

                att.Reply = replyid;
                BBS_ForumAttachmentBLL bll = new BBS_ForumAttachmentBLL();
                bll.Model = att;
                bll.Add(buff);

                BBS_ForumAttachment m = bll.Model;
                string uploadcontent  = "";    //插入主表中

                switch (att.ExtName.ToLower())
                {
                case "jpg":
                case "gif":
                case "bmp":
                case "png":
                    uploadcontent = " [IMG]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/IMG]<br/>";
                    break;

                case "mp3":
                    uploadcontent = " [MP=320,70]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/MP]<br/>";
                    break;

                case "avi":
                    uploadcontent = " [MP=320,240]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/MP]<br/>";
                    break;

                case "swf":
                    uploadcontent = " [FLASH]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/FLASH]<br/>";
                    break;

                default:
                    uploadcontent = "<a href=DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + ">" + att.Name + "." + att.ExtName + "</a><br/>";
                    break;
                }
                ViewState["Content"] += uploadcontent + "<br/>";
            }

            if (ViewState["SavePath"] != null)
            {
                try
                {
                    string path = (string)ViewState["SavePath"];
                    path = path.Substring(0, path.LastIndexOf("\\"));
                    Directory.Delete(path, true);
                    ViewState["SavePath"] = null;
                }
                catch { }
            }

            //将附件的路径添加到回复主表中去
            replybll.Model.Content += "<br/><font color=red><b>附件列表:</b></font><br/>" + ViewState["Content"].ToString();
            replybll.Update();

            //清空附件的列表
            for (int i = upattlist.Count - 1; i >= 0; i--)
            {
                this.lbx_AttList.Items.RemoveAt(i);
                upattlist.RemoveAt(i);
            }
            ViewState["UpattList"] = upattlist;
        }
        #endregion

        #endregion

        Response.Redirect("display.aspx?ID=" + ViewState["ItemID"].ToString() + "&BoardID=" + ViewState["BoardID"].ToString());
    }
Пример #18
0
 protected void cbx_Tpp_Click(object sender, System.EventArgs e)
 {
     BBS_ForumItemBLL itembll = new BBS_ForumItemBLL(Convert.ToInt32(ViewState["ItemID"]));
     if (itembll.Model["IsTop"] == "N")
     {
         itembll.Model["IsTop"] = "Y";
         itembll.Update();
         MessageBox.Show(this.Page, "帖子已置顶!");
     }
     else
     {
         itembll.Model["IsTop"] = "N";
         itembll.Update();
         MessageBox.Show(this.Page, "帖子已取消置顶!");
     }
 }
Пример #19
0
    protected void btn_OK_Click(object sender, EventArgs e)
    {
        #region 帖子的回复

        #region 添加帖子的回复
        BBS_ForumReplyBLL replybll = new BBS_ForumReplyBLL();
        replybll.Model.ItemID = Convert.ToInt32(ViewState["ItemID"]);
        replybll.Model.Title = Title.Value;
        replybll.Model.Content =ckedit_content.Text;
        replybll.Model.Replyer = Session["UserName"].ToString();
        replybll.Model.ReplyTime = DateTime.Now;
        replybll.Model.IPAddress = Request.ServerVariables.Get("REMOTE_ADDR").ToString();
        int replyid = replybll.Add();    // 返回已经回复的帖子的ID

        //修改论坛文章的留言量
        BBS_ForumItemBLL itembll = new BBS_ForumItemBLL(Convert.ToInt32(ViewState["ItemID"]));
        itembll.UpdateAddReplyTimes(Convert.ToInt32(ViewState["ItemID"]));
        #endregion

        #region 添加留言的附件
        ArrayList upattlist = (ArrayList)ViewState["UpattList"];
        if (upattlist != null && upattlist.Count > 0)
        {
            foreach (BBS_ForumAttachment att in upattlist)
            {
                string path = att.Path;
                if (path.StartsWith("~")) path = Server.MapPath(path);
                FileStream stream = new FileStream(path, FileMode.Open);
                byte[] buff = new byte[stream.Length];
                stream.Read(buff, 0, buff.Length);
                stream.Close();
                att.Path = "";
                att.ItemID = (int)ViewState["ItemID"];

                #region 自动压缩上传的图片
                if (ATMT_AttachmentBLL.IsImage(att.ExtName))
                {
                    try
                    {
                        MemoryStream s = new MemoryStream(buff);
                        System.Drawing.Image originalImage = System.Drawing.Image.FromStream(s);
                        s.Close();

                        int width = originalImage.Width;

                        if (width > 1024 || att.ExtName == "bmp")
                        {
                            if (width > 1024) width = 1024;

                            System.Drawing.Image thumbnailimage = ImageProcess.MakeThumbnail(originalImage, width, 0, "W");

                            MemoryStream thumbnailstream = new MemoryStream();
                            thumbnailimage.Save(thumbnailstream, System.Drawing.Imaging.ImageFormat.Jpeg);
                            thumbnailstream.Position = 0;
                            att.FileSize = (int)(thumbnailstream.Length / 1024);
                            att.ExtName = "jpg";

                            byte[] b = new byte[thumbnailstream.Length];
                            thumbnailstream.Read(b, 0, b.Length);
                            thumbnailstream.Close();
                            buff = b;
                        }
                    }
                    catch { }
                }
                #endregion

                att.Reply = replyid;
                BBS_ForumAttachmentBLL bll = new BBS_ForumAttachmentBLL();
                bll.Model = att;
                bll.Add(buff);

                BBS_ForumAttachment m = bll.Model;
                string uploadcontent = "";     //插入主表中

                switch (att.ExtName.ToLower())
                {
                    case "jpg":
                    case "gif":
                    case "bmp":
                    case "png":
                        uploadcontent = " [IMG]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/IMG]<br/>";
                        break;
                    case "mp3":
                        uploadcontent = " [MP=320,70]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/MP]<br/>";
                        break;
                    case "avi":
                        uploadcontent = " [MP=320,240]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/MP]<br/>";
                        break;
                    case "swf":
                        uploadcontent = " [FLASH]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/FLASH]<br/>";
                        break;
                    default:
                        uploadcontent = "<a href=DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + ">" + att.Name + "." + att.ExtName + "</a><br/>";
                        break;
                }
                ViewState["Content"] += uploadcontent + "<br/>";

            }

            if (ViewState["SavePath"] != null)
            {
                try
                {
                    string path = (string)ViewState["SavePath"];
                    path = path.Substring(0, path.LastIndexOf("\\"));
                    Directory.Delete(path, true);
                    ViewState["SavePath"] = null;
                }
                catch { }
            }

            //将附件的路径添加到回复主表中去
            replybll.Model.Content += "<br/><font color=red><b>附件列表:</b></font><br/>" + ViewState["Content"].ToString();
            replybll.Update();

            //清空附件的列表
            for (int i = upattlist.Count - 1; i >= 0; i--)
            {
                this.lbx_AttList.Items.RemoveAt(i);
                upattlist.RemoveAt(i);
            }
            ViewState["UpattList"] = upattlist;
        }
        #endregion

        #endregion

        Response.Redirect("display.aspx?ID=" + ViewState["ItemID"].ToString() + "&BoardID=" + ViewState["BoardID"].ToString());
    }
Пример #20
0
 protected void ModeratorInfo()
 {
     BBS_ForumItemBLL itembll = new BBS_ForumItemBLL(Convert.ToInt32(ViewState["ItemID"]));
     itembll.UpdateHitTimes(Convert.ToInt32(ViewState["ItemID"]));
     author = itembll.Model.Sender.ToString();
     IList<BBS_BoardUserMember> memberList = BBS_BoardUserMemberBLL.GetModelList(" Board=" + (int)ViewState["BoardID"]);
     bool flag = itembll.Model.Sender==Session["UserName"].ToString();
     foreach (BBS_BoardUserMember member in memberList)
     {
         if (member.Role == 1 && member.UserName == (string)ViewState["username"])
             flag = true;
     }
     if (Roles.IsUserInRole("论坛管理员") || flag)
     {
         itemcontent.InnerHtml += "<b>操 作:</b><a href=javascript:window.open('deleteitem.aspx?ItemID=" + Convert.ToInt32(ViewState["ItemID"]) + "&BoardID=" + Convert.ToInt32(ViewState["BoardID"]) + "','_self','');>删除此贴</a>|<a href='MoveItem.aspx?ItemID=" + Convert.ToInt32(ViewState["ItemID"]) + "'>移动帖子</a><br><hr color='#C0C0C0' size='1'>";
         cbx_IsPith.Visible = true;
         cbx_Tpp.Visible = true;
         right = true;
     }
 }
Пример #21
0
    protected void DelReplay(object sender, System.EventArgs e)
    {
        //删除论坛文章的回复
        BBS_ForumReplyBLL replybll = new BBS_ForumReplyBLL();
        replybll.Model.ID = Int32.Parse(((LinkButton)sender).CommandArgument.ToString());
        replybll.Delete(replybll.Model.ID);

        //修改论坛文章的评论数量
        BBS_ForumItemBLL itembll = new BBS_ForumItemBLL(Convert.ToInt32(ViewState["ItemID"]));
        itembll.UpdateRemoveReplyTimes(Convert.ToInt32(ViewState["ItemID"]));
        BindData();
    }
Пример #22
0
    protected void cmdOK_ServerClick(object sender, System.EventArgs e)
    {
        #region 添加论文的主题内容
        BBS_ForumItemBLL itembll = new BBS_ForumItemBLL();
        itembll.Model.Board         = Convert.ToInt32(ViewState["BoardID"]);
        itembll.Model.Title         = Title.Value;
        itembll.Model.Content       = ckedit_content.Text;
        itembll.Model.Sender        = Session["UserName"].ToString();
        itembll.Model.SendTime      = DateTime.Now;
        itembll.Model.HitTimes      = 0;                                   //点击次数默认的设置为0
        itembll.Model.ReplyTimes    = 0;                                   //回复次数默认的设置为0
        itembll.Model.LastReplyer   = Session["UserName"].ToString();      //默认的设置为本人
        itembll.Model.LastReplyTime = DateTime.Now;
        itembll.Model.IPAddr        = Request.ServerVariables.Get("REMOTE_ADDR").ToString();

        itembll.Model["IsTop"]  = "N"; //是否置顶
        itembll.Model["IsPith"] = "N"; //是否是精贴

        int itemid = itembll.Add();    // 返回已经发布的论文的ID
        #endregion

        #region 添加论文的附件
        ArrayList upattlist = (ArrayList)ViewState["UpattList"];
        if (upattlist != null && upattlist.Count > 0)
        {
            string _content = "<br/><font color=red><b>附件列表:</b></font><br/>";

            foreach (BBS_ForumAttachment att in upattlist)
            {
                string path = att.Path;
                if (path.StartsWith("~"))
                {
                    path = Server.MapPath(path);
                }
                FileStream stream = new FileStream(path, FileMode.Open);
                byte[]     buff   = new byte[stream.Length];
                stream.Read(buff, 0, buff.Length);
                stream.Close();
                att.Path   = "";
                att.ItemID = itemid;

                #region 自动压缩上传的图片
                if (ATMT_AttachmentBLL.IsImage(att.ExtName))
                {
                    try
                    {
                        MemoryStream         s             = new MemoryStream(buff);
                        System.Drawing.Image originalImage = System.Drawing.Image.FromStream(s);
                        s.Close();

                        int width = originalImage.Width;

                        if (width > 1024 || att.ExtName == "bmp")
                        {
                            if (width > 1024)
                            {
                                width = 1024;
                            }

                            System.Drawing.Image thumbnailimage = ImageProcess.MakeThumbnail(originalImage, width, 0, "W");

                            MemoryStream thumbnailstream = new MemoryStream();
                            thumbnailimage.Save(thumbnailstream, System.Drawing.Imaging.ImageFormat.Jpeg);
                            thumbnailstream.Position = 0;
                            att.FileSize             = (int)(thumbnailstream.Length / 1024);
                            att.ExtName = "jpg";

                            byte[] b = new byte[thumbnailstream.Length];
                            thumbnailstream.Read(b, 0, b.Length);
                            thumbnailstream.Close();
                            buff = b;
                        }
                    }
                    catch { }
                }
                #endregion

                BBS_ForumAttachmentBLL bll = new BBS_ForumAttachmentBLL();
                bll.Model = att;
                bll.Add(buff);

                BBS_ForumAttachment m = bll.Model;
                string _uploadcontent = "";     //插入主表中

                switch (att.ExtName.ToLower())
                {
                case "jpg":
                case "gif":
                case "bmp":
                case "png":
                    _uploadcontent = " [IMG]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/IMG]<br/>";
                    break;

                case "mp3":
                    _uploadcontent = " [MP=320,70]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/MP]<br/>";
                    break;

                case "avi":
                    _uploadcontent = " [MP=320,240]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/MP]<br/>";
                    break;

                case "swf":
                    _uploadcontent = " [FLASH]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/FLASH]<br/>";
                    break;

                default:
                    _uploadcontent = "<a href=DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + ">" + att.Name + "." + att.ExtName + "</a><br/>";
                    break;
                }
                _content += _uploadcontent + "<br/>";
            }

            if (ViewState["SavePath"] != null)
            {
                try
                {
                    string path = (string)ViewState["SavePath"];
                    path = path.Substring(0, path.LastIndexOf("\\"));
                    Directory.Delete(path, true);
                    ViewState["SavePath"] = null;
                }
                catch { }
            }

            //将附件的路径添加到发帖主表中去
            itembll.Model.Content += _content;
            itembll.Update();

            //清空附件的列表
            for (int i = upattlist.Count - 1; i >= 0; i--)
            {
                upattlist.RemoveAt(i);
            }
            ViewState["UpattList"] = upattlist;
        }
        #endregion

        Server.Transfer("listview.aspx?Board=" + ViewState["BoardID"].ToString());
    }
Пример #23
0
    protected void cmdOK_ServerClick(object sender, System.EventArgs e)
    {
        #region 添加论文的主题内容
        BBS_ForumItemBLL itembll = new BBS_ForumItemBLL();
        itembll.Model.Board = Convert.ToInt32(ViewState["BoardID"]);
        itembll.Model.Title = Title.Value;
        itembll.Model.Content = ckedit_content.Text;
        itembll.Model.Sender = Session["UserName"].ToString();
        itembll.Model.SendTime = DateTime.Now;
        itembll.Model.HitTimes = 0;                                        //点击次数默认的设置为0
        itembll.Model.ReplyTimes = 0;                                      //回复次数默认的设置为0
        itembll.Model.LastReplyer = Session["UserName"].ToString();        //默认的设置为本人
        itembll.Model.LastReplyTime = DateTime.Now;
        itembll.Model.IPAddr = Request.ServerVariables.Get("REMOTE_ADDR").ToString();

        itembll.Model["IsTop"] = "N";       //是否置顶
        itembll.Model["IsPith"] = "N";      //是否是精贴

        int itemid = itembll.Add();// 返回已经发布的论文的ID
        #endregion

        #region 添加论文的附件
        ArrayList upattlist = (ArrayList)ViewState["UpattList"];
        if (upattlist != null && upattlist.Count > 0)
        {
            string _content = "<br/><font color=red><b>附件列表:</b></font><br/>";

            foreach (BBS_ForumAttachment att in upattlist)
            {
                string path = att.Path;
                if (path.StartsWith("~")) path = Server.MapPath(path);
                FileStream stream = new FileStream(path, FileMode.Open);
                byte[] buff = new byte[stream.Length];
                stream.Read(buff, 0, buff.Length);
                stream.Close();
                att.Path = "";
                att.ItemID = itemid;

                #region 自动压缩上传的图片
                if (ATMT_AttachmentBLL.IsImage(att.ExtName))
                {
                    try
                    {
                        MemoryStream s = new MemoryStream(buff);
                        System.Drawing.Image originalImage = System.Drawing.Image.FromStream(s);
                        s.Close();

                        int width = originalImage.Width;

                        if (width > 1024 || att.ExtName == "bmp")
                        {
                            if (width > 1024) width = 1024;

                            System.Drawing.Image thumbnailimage = ImageProcess.MakeThumbnail(originalImage, width, 0, "W");

                            MemoryStream thumbnailstream = new MemoryStream();
                            thumbnailimage.Save(thumbnailstream, System.Drawing.Imaging.ImageFormat.Jpeg);
                            thumbnailstream.Position = 0;
                            att.FileSize = (int)(thumbnailstream.Length / 1024);
                            att.ExtName = "jpg";

                            byte[] b = new byte[thumbnailstream.Length];
                            thumbnailstream.Read(b, 0, b.Length);
                            thumbnailstream.Close();
                            buff = b;
                        }
                    }
                    catch { }
                }
                #endregion

                BBS_ForumAttachmentBLL bll = new BBS_ForumAttachmentBLL();
                bll.Model = att;
                bll.Add(buff);

                BBS_ForumAttachment m = bll.Model;
                string _uploadcontent = "";     //插入主表中

                switch (att.ExtName.ToLower())
                {
                    case "jpg":
                    case "gif":
                    case "bmp":
                    case "png":
                        _uploadcontent = " [IMG]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/IMG]<br/>";
                        break;
                    case "mp3":
                        _uploadcontent = " [MP=320,70]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/MP]<br/>";
                        break;
                    case "avi":
                        _uploadcontent = " [MP=320,240]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/MP]<br/>";
                        break;
                    case "swf":
                        _uploadcontent = " [FLASH]DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + "[/FLASH]<br/>";
                        break;
                    default:
                        _uploadcontent = "<a href=DownloadAttachfile.aspx?GUID=" + m.GUID.ToString() + ">" + att.Name + "." + att.ExtName + "</a><br/>";
                        break;
                }
                _content += _uploadcontent + "<br/>";
            }

            if (ViewState["SavePath"] != null)
            {
                try
                {
                    string path = (string)ViewState["SavePath"];
                    path = path.Substring(0, path.LastIndexOf("\\"));
                    Directory.Delete(path, true);
                    ViewState["SavePath"] = null;
                }
                catch { }
            }

            //将附件的路径添加到发帖主表中去
            itembll.Model.Content += _content;
            itembll.Update();

            //清空附件的列表
            for (int i = upattlist.Count - 1; i >= 0; i--)
            {
                upattlist.RemoveAt(i);
            }
            ViewState["UpattList"] = upattlist;
        }
        #endregion

        Server.Transfer("listview.aspx?Board=" + ViewState["BoardID"].ToString());
    }