Exemple #1
0
        private DataSetActionResult DeleteBulletin(BulletinBoardModel model)
        {
            DataSetActionResult result = new DataSetActionResult();

            try
            {
                bool bResult = bulletinBoardService.DeleteBulletin(model);
                if (bResult)
                {
                    result.Result      = bResult;
                    result.DataSetData = null;
                }
                else
                {
                    result.Result = !bResult;
                }
            }
            catch (Exception ex)
            {
                result.Result        = false;
                result.ReturnMessage = ex.Message;
            }

            return(result);
        }
Exemple #2
0
        private DataSetActionResult GetAllBulletinsExceptBodyHistory(BulletinBoardModel model)
        {
            DataSetActionResult result = new DataSetActionResult();

            try
            {
                DataSet dataSet = bulletinBoardService.GetAllBulletinsExceptBodyHistory(model);
                if (dataSet.Tables[0].Rows.Count > 0)
                {
                    result.Result      = true;
                    result.DataSetData = dataSet;
                }
                else
                {
                    result.Result = false;
                }
            }
            catch (Exception ex)
            {
                result.Result        = false;
                result.ReturnMessage = ex.Message;
            }

            return(result);
        }
Exemple #3
0
 public bool UpdateBulletin(BulletinBoardModel model)
 {
     try
     {
         return(bulletinBoardDAO.UpdateBulletin(model));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #4
0
 public DataSet GetAllBulletinsExceptBodyHistory(BulletinBoardModel model)
 {
     try
     {
         return(bulletinBoardDAO.GetAllBulletinsExceptBodyHistory(model));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        public HttpResponseMessage AddBulletinBoard()
        {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            HttpRequestBase    request = ((HttpContextWrapper)this.Request.Properties["MS_HttpContext"]).Request;
            BulletinBoardModel model   = new BulletinBoardModel();
            //获取附件
            HttpPostedFileBase upfile = request.Files["fileNewName"];

            if (upfile != null && upfile.ContentLength > 0)
            {
                DateTime tfile = DateTime.Now;
                //创建绝对路径
                string tempPath   = tfile.Year + @"\" + tfile.ToString("yyyyMMdd");
                string serverPath = Path.Combine(ConfigManageClass.BulletinBoardPath, tempPath);
                //判断绝对路径是否存在,如果没有,则创建
                if (!Directory.Exists(serverPath))
                {
                    Directory.CreateDirectory(serverPath);
                }
                //获取客户端上传的文件名字
                string newfile = upfile.FileName;
                //获取文件的后缀名
                string filetype = Path.GetExtension(newfile);
                //获取路径中文件的名字(不带文件的扩展名)
                string filename    = Path.GetFileNameWithoutExtension(newfile).Replace('(', 'a').Replace(')', 'a');
                string newfilename = filename + filetype;
                string filepath    = Path.Combine(serverPath, newfilename);
                request.Files["fileNewName"].SaveAs(filepath);
                model.filename = newfilename;
                model.filepath = filepath;
                model.filesize = upfile.ContentLength;
            }

            if (!string.IsNullOrEmpty(request.Form["userid"]))
            {
                model.createuserid = Convert.ToInt32(request.Form["userid"]);
            }

            model.author     = request.Form["author"];
            model.content    = request.Form["hidcontent"];
            model.createtime = Convert.ToDateTime(request.Form["createtime"]);
            model.seq        = Convert.ToInt32(request.Form["seq"]);
            model.title      = request.Form["title"];

            int success = bll.AddBulletinBoard(model);

            if (success > 0)
            {
                response.Content = new StringContent("{\"success\":true}", Encoding.GetEncoding("UTF-8"), "text/html");
            }
            return(response);
        }
Exemple #6
0
 /// <summary>
 /// 新增公告
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int AddBulletinBoard(BulletinBoardModel model)
 {
     using (Entities db = new Entities())
     {
         base_articles article = new base_articles();
         article.author       = model.author;
         article.content      = model.content;
         article.createtime   = model.createtime;
         article.createuserid = model.createuserid;
         article.seq          = model.seq;
         article.title        = model.title;
         article.status       = 0;   //0:未删除 1:删除
         article.filename     = model.filename;
         article.filepath     = model.filepath;
         article.filesize     = model.filesize;
         db.base_articles.Add(article);
         return(db.SaveChanges());
     }
 }
Exemple #7
0
 /// <summary>
 /// 编辑公告
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int EditBulletinBoard(BulletinBoardModel model)
 {
     using (Entities db = new Entities())
     {
         base_articles article = db.base_articles.Find(model.id);
         if (article != null)
         {
             article.author     = model.author;
             article.content    = model.content;
             article.seq        = model.seq;
             article.title      = model.title;
             article.createtime = DateTime.Now;
             if (model.filename != null && model.filepath != null)
             {
                 //删除替换之前的附件
                 if (System.IO.File.Exists(article.filepath))
                 {
                     System.IO.File.Delete(article.filepath);
                 }
                 article.filename = model.filename;
                 article.filepath = model.filepath;
                 article.filesize = model.filesize;
             }
             if (model.filename == null && model.filepath == null && article.filename != null && article.filepath != null)
             {
                 //删除附件
                 if (System.IO.File.Exists(article.filepath))
                 {
                     System.IO.File.Delete(article.filepath);
                 }
                 article.filepath = null;
                 article.filename = null;
                 article.filesize = null;
             }
             return(db.SaveChanges());
         }
         else
         {
             return(0);
         }
     }
 }
Exemple #8
0
        /// <summary>
        /// 查看公告详细信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public BulletinBoardModel ViewBulletinBoard(int id)
        {
            BulletinBoardModel model = new BulletinBoardModel();

            using (Entities db = new Entities())
            {
                base_articles article = db.base_articles.FirstOrDefault(t => t.id == id);
                if (article != null)
                {
                    model.id           = article.id;
                    model.author       = article.author;
                    model.content      = article.content;
                    model.createtime   = article.createtime;
                    model.createuserid = article.createuserid;
                    model.filename     = article.filename;
                    model.filepath     = article.filepath;
                    model.filesize     = article.filesize;
                    model.seq          = article.seq;
                    model.status       = article.status;
                    model.title        = article.title;
                }
                return(model);
            }
        }
Exemple #9
0
 /// <summary>
 /// 编辑公告
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int EditBulletinBoard(BulletinBoardModel model)
 {
     return(dal.EditBulletinBoard(model));
 }
Exemple #10
0
 /// <summary>
 /// 新增一条公告
 /// </summary>
 /// <param name="model"></param>
 /// <param name="fileList"></param>
 /// <returns></returns>
 public int AddBulletinBoard(BulletinBoardModel model)
 {
     return(dal.AddBulletinBoard(model));
 }