Beispiel #1
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.Forum_Attachment   bll   = new BLL.Forum_Attachment();
            Model.Forum_Attachment model = bll.GetModel(_id);

            //编写编辑操作Begin
            //model.Id = txtId.Text;
            //model.UserId = txtUserId.Text;
            //model.BoardId = txtBoardId.Text;
            //model.TopicId = txtTopicId.Text;
            //model.PostId = txtPostId.Text;
            //model.UploadDatetime = txtUploadDatetime.Text;
            //model.Name = txtName.Text;
            //model.FileName = txtFileName.Text;
            //model.Description = txtDescription.Text;
            //model.FileType = txtFileType.Text;
            //model.FileSize = txtFileSize.Text;
            //model.IsImage = txtIsImage.Text;
            //model.Thumb = txtThumb.Text;
            //model.Download = txtDownload.Text;
            //model.Cost = txtCost.Text;
            //model.CostType = txtCostType.Text;
            //编写编辑操作End

            if (bll.Update(model))
            {
                AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改管理员:" + model.Name); //记录日志
                result = true;
            }

            return(result);
        }
Beispiel #2
0
        private void down(HttpContext context)
        {
            Model.Forum_Attachment model = bll.GetModel(aid);

            if (!BLL.Forum_BoardPermission.CheckPermission(model.BoardId + "|" + modelUser.GroupId, "ViewAttachment"))
            {
                context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                                                                        new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,你还没有下载附件的权限呢!"))));

                return;
            }


            if (model != null)
            {
                //取得文件物理路径
                string fullFileName = Utils.GetMapPath(model.FileName);
                if (!File.Exists(fullFileName))
                {
                    context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                                                                            new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要下载的文件不存在或已经被删除!"))));
                    return;
                }

                model.Download += 1;
                bll.Update(model);

                FileInfo file = new FileInfo(fullFileName);                                                                     //路径
                context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");                                   //解决中文乱码
                context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.Name)); //解决中文文件名乱码
                context.Response.AddHeader("Content-length", file.Length.ToString());
                context.Response.ContentType = "application/zip";
                context.Response.WriteFile(file.FullName);
                context.Response.End();
            }
        }