Example #1
0
 public ActionResult addFavorite(int docid,string returnURL)
 {
     string employeeNumber = User.Identity.Name;
     UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(Convert.ToInt32(employeeNumber));
     //这里要先判断是否已经收藏过
     if (new BLLFavorite().isFavorite(Convert.ToInt32(employeeNumber),docid))
     {
         TempData["errorMsg"] = "您已经收藏过此文档了。";
         return RedirectToAction(returnURL, "User");
     }
     BLLDocument bllDocument = new BLLDocument();
     DocumentModel docModel = bllDocument.getDocumentById(docid);
     if (employeeNumber == "" || docModel == null )
     {
         TempData["errorMsg"] = "您无权进行添加收藏操作,请重新登录。";
         return RedirectToAction(returnURL, "User");
     }
     if (docModel.PublisherNumber == Convert.ToInt32(employeeNumber))
     {
         TempData["errorMsg"] = "您不能收藏自己发布的文档。";
         return RedirectToAction(returnURL, "User");
     }
     BLLFavorite bllFavorite = new BLLFavorite();
     if (bllFavorite.addToMyFavorite(Convert.ToInt32(employeeNumber), docid))
     {
         TempData["successMsg"] = "添加成功。";
     }
     else
     {
         TempData["errorMsg"] = "添加失败。";
     }
     return RedirectToAction(returnURL, "User");
 }
Example #2
0
 public ActionResult Detail(int docid)
 {
     BLLDocument bllDocument = new BLLDocument();
     DocumentModel docModel = bllDocument.getDocumentById(docid);
     ViewData["docModel"] = docModel;
     List<DocumentModel> viewdocList = bllDocument.getTopTenDocumentByViewNumber();
     ViewData["viewTop10Doc"] = viewdocList;
     List<DocumentModel> dldocList = bllDocument.getTopTenDocumentByDownloadNumber();
     ViewData["dlTop10Doc"] = dldocList;
     ViewData["canIDownload"] = new BLLAuth().ifEmpCanDownlaodThisDoc(Convert.ToInt32(User.Identity.Name), docid);
     bllDocument.ViewNumberIncrement(docid);
     return View();
 }
Example #3
0
 public ActionResult Delete(int docid, string returnURL)
 {
     //先要判断当前用户是否有权限删除这篇文档
     string employeeNumber = User.Identity.Name;
     BLLDocument bllDocument = new BLLDocument();
     DocumentModel docModel = bllDocument.getDocumentById(docid);
     UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(Convert.ToInt32(employeeNumber));
     //如果是审核者,则直接删除
     if (empModel != null && empModel.IsChecker.Equals(true) && docModel.CheckerNumber.Equals(Convert.ToInt32(employeeNumber)))
     {
         if (bllDocument.deleteDocumentById(docid))
         {
             TempData["successMsg"] = "删除成功。";
         }
         else
         {
             TempData["errorMsg"] = "删除失败。";
         }
         return RedirectToAction(returnURL, "User");
     }
     //如果不是审核者,也不是这篇文档的发布者,删除失败
     if (employeeNumber == "" || docModel == null || docModel.PublisherNumber != Convert.ToInt32(employeeNumber))
     {
         TempData["errorMsg"] = "您无权删除此文件,请重新登录。";
         return RedirectToAction(returnURL, "User");
     }
     //如果不是审核者,也是这篇文档的发布者,则删除
     if (bllDocument.deleteDocumentById(docid))
     {
         TempData["successMsg"] = "删除成功。";
     }
     else
     {
         TempData["errorMsg"] = "删除失败。";
     }
     return RedirectToAction(returnURL, "User");
 }
Example #4
0
        public void getFilePath(string FileDownloadName)
        {
            BLLDocument bllDocument = new BLLDocument();
            int docid = bllDocument.getDocumentByFileDiskName(FileDownloadName).Id;
            string folderPath = new BLLFolder().GetFolderById(bllDocument.getDocumentById(docid).FolderId).PhysicalPath;
            string fileType = FileDownloadName.Split('.')[1];
            string filePath = "";
            HttpContext.Response.AddHeader("content-disposition",
                "attachment; filename=" + FileDownloadName);

            if (fileType.Equals("flv"))
            {
                filePath = REPO_ROOT + folderPath + "\\" + FileDownloadName;
            }
            else {
                //filePath = "C:\\Users\\Margaret\\Documents\\Visual Studio 2010\\Projects\\GeekInsideKMS\\Index\\swf\\" + FileDownloadName.Split('.')[0] + ".swf";
                filePath = REPO_ROOT + "swf\\" + FileDownloadName.Split('.')[0] + ".swf";
            }

            HttpContext.Response.TransmitFile(filePath);
        }
Example #5
0
 public ActionResult doCheck(int docid, string returnURL)
 {
     //先要判断当前用户是否有权设置这篇文档
     string employeeNumber = User.Identity.Name;
     BLLDocument bllDocument = new BLLDocument();
     DocumentModel docModel = bllDocument.getDocumentById(docid);
     UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(Convert.ToInt32(employeeNumber));
     //如果不是审核者,则返回错误
     if (empModel == null || empModel.IsChecker.Equals(false))
     {
         TempData["errorMsg"] = "您无权操作此文件,请重新登录。";
         return RedirectToAction(returnURL, "User");
     }
     //如果是审核者,可以操作
     if (bllDocument.setDocCheckedById(docid, Convert.ToInt32(employeeNumber)))
     {
         TempData["successMsg"] = "操作成功。";
     }
     else
     {
         TempData["errorMsg"] = "操作失败。";
     }
     return RedirectToAction(returnURL, "User");
 }
Example #6
0
        public void getFile(int docid)
        {
            BLLDocument bllDocument = new BLLDocument();
            bllDocument.DownloadNumberIncrement(docid);
            string FileDownloadName = bllDocument.getDocumentById(docid).FileDiskName;
            string FileFolderPath = new BLLFolder().GetFolderById(bllDocument.getDocumentById(docid).FolderId).PhysicalPath;
            HttpContext.Response.AddHeader("content-disposition",
                "attachment; filename=" + FileDownloadName);

            string filePath = REPO_ROOT + FileFolderPath + "\\" + FileDownloadName;
            HttpContext.Response.TransmitFile(filePath);
        }
Example #7
0
 public ActionResult DeleteFavorite(int docid)
 {
     string employeeNumber = User.Identity.Name;
     UserEmployeeModel empModel = new BLLUserAccount().GetUserByEmpNumber(Convert.ToInt32(employeeNumber));
     ViewData["empModel"] = empModel;
     BLLDocument bllDocument = new BLLDocument();
     DocumentModel docModel = bllDocument.getDocumentById(docid);
     if (employeeNumber == "" || docModel == null || docModel.PublisherNumber != Convert.ToInt32(employeeNumber))
     {
         TempData["errorMsg"] = "您无权进行删除操作,请重新登录。";
         return RedirectToAction("MyFavorite", "User");
     }
     BLLFavorite bllFavorite = new BLLFavorite();
     if (bllFavorite.deleteMyFavorite(Convert.ToInt32(employeeNumber),docid))
     {
         TempData["successMsg"] = "删除成功。";
     }
     else
     {
         TempData["errorMsg"] = "删除失败。";
     }
     return RedirectToAction("MyFavorite", "User");
 }