public List <THUMUC_LUUTRU_BO> getListFileByFolder(long ITEM_ID, int LOAITAI_LIEU, long userId,
                                                           string TENDONVI, THUMUC_LUUTRU ThuMuc)
        {
            var result = from tailieu in this.context.TAILIEUDINHKEM
                         join nguoidung in this.context.DM_NGUOIDUNG
                         on tailieu.USER_ID equals nguoidung.ID
                         into group1
                         from g1 in group1.DefaultIfEmpty()
                         where tailieu.ITEM_ID == ITEM_ID && tailieu.LOAI_TAILIEU == LOAITAI_LIEU &&
                         (!tailieu.IS_DELETE.HasValue || !tailieu.IS_DELETE.Value)
                         orderby tailieu.TENTAILIEU
                         select new THUMUC_LUUTRU_BO
            {
                TENTHUMUC       = tailieu.TENTAILIEU,
                SLTHUMUC        = 0,
                ID              = (long)tailieu.TAILIEU_ID,
                NGAYTAO         = tailieu.NGAYTAO,
                IS_THUMUC       = false,
                THUMUCCHA       = tailieu.DINHDANG_FILE,
                TEN_NGUOITAO    = g1.HOTEN,
                TEN_DONVI       = TENDONVI,
                DONVI_ID        = tailieu.IS_PHEDUYET,
                USER_ID         = tailieu.USER_ID,
                ACCESS_MODIFIER = ThuMuc.ACCESS_MODIFIER,
                PERMISSION      = ThuMuc.PERMISSION
            };

            if (userId > 0)
            {
                result = result.Where(x => userId == x.USER_ID);
            }
            return(result.ToList());
        }
Exemplo n.º 2
0
        public JsonResult Delete(long id)
        {
            HSCV_VANBANDENBusiness = Get <HSCV_VANBANDENBusiness>();
            HSCV_VANBANDEN VanBan = HSCV_VANBANDENBusiness.Find(id);

            AssignUserInfo();
            if (VanBan == null || currentUser.ID != VanBan.NGUOITAO)
            {
                return(Json(new { Type = "ERROR", Message = "Không tìm thấy văn bản phát hành cần xóa" }));
            }
            TAILIEUDINHKEMBusiness = Get <TAILIEUDINHKEMBusiness>();
            FileUltilities        file        = new FileUltilities();
            List <TAILIEUDINHKEM> ListTaiLieu = TAILIEUDINHKEMBusiness.GetDataByItemID(id, LOAITAILIEU.VANBANDEN);

            foreach (var item in ListTaiLieu)
            {
                TAILIEUDINHKEMBusiness.repository.Delete(item.TAILIEU_ID);
                file.RemoveFile(URL_FOLDER + item.DUONGDAN_FILE);
                if (!string.IsNullOrEmpty(item.PDF_VERSION))
                {
                    file.RemoveFile(URL_FOLDER + item.PDF_VERSION);
                }
            }
            THUMUC_LUUTRUBusiness = Get <THUMUC_LUUTRUBusiness>();
            THUMUC_LUUTRU ThuMuc = THUMUC_LUUTRUBusiness.GetDataByNam(id.ToString(), ThuMucLuuTruConstant.DefaultVbDen);

            if (ThuMuc != null)
            {
                ThuMuc.IS_DELETE = true;
                THUMUC_LUUTRUBusiness.Save(ThuMuc);
            }
            TAILIEUDINHKEMBusiness.Save();
            HSCV_VANBANDENBusiness.repository.Delete(id);
            HSCV_VANBANDENBusiness.Save();
            #region Xóa đơn vị nhận văn bản
            HSCV_VANBANDEN_DONVINHANBusiness = Get <HSCV_VANBANDEN_DONVINHANBusiness>();
            var ListDonVi = HSCV_VANBANDEN_DONVINHANBusiness.GetData(id);
            if (ListDonVi.Any())
            {
                foreach (var item in ListDonVi)
                {
                    HSCV_VANBANDEN_DONVINHANBusiness.repository.Delete(item.ID);
                }
                HSCV_VANBANDEN_DONVINHANBusiness.Save();
            }
            #endregion
            return(Json(new { Type = "SUCCESS", Message = "Xóa văn bản phát hành thành công" }));
        }
Exemplo n.º 3
0
        public string GetChild(string pid, string sort)
        {
            UserInfoBO user = GetUserInfo();
            List <THUMUC_LUUTRU_BO>  subMenu    = new List <THUMUC_LUUTRU_BO>();
            List <TAILIEUDINHKEM_BO> lstTaiLieu = new List <TAILIEUDINHKEM_BO>();

            TAILIEUDINHKEMBusiness = Get <TAILIEUDINHKEMBusiness>();
            CCTC_THANHPHANBusiness = Get <CCTC_THANHPHANBusiness>();
            int pID = pid.ToIntOrZero();

            THUMUC_LUUTRUBusiness = Get <THUMUC_LUUTRUBusiness>();
            EFILE_CHIASEBusiness  = Get <EFILE_CHIASEBusiness>();
            THUMUC_LUUTRU THUMUC = THUMUC_LUUTRUBusiness.Find(pID);

            if (THUMUC != null)
            {
                if (THUMUC.PERMISSION.HasValue && THUMUC.PERMISSION.Value == FolderPermission.CAN_WRITE)
                {
                    subMenu = new List <THUMUC_LUUTRU_BO>();
                }
                else
                {
                    CCTC_THANHPHAN DONVI = new CCTC_THANHPHAN();
                    if (THUMUC != null)
                    {
                        DONVI = CCTC_THANHPHANBusiness.Find(THUMUC.DONVI_ID);
                    }
                    else
                    {
                        DONVI = CCTC_THANHPHANBusiness.Find(user.DM_PHONGBAN_ID);
                    }
                    List <int> Ids = new List <int>();
                    #region Lấy tài liệu + thư mục con
                    subMenu = TAILIEUDINHKEMBusiness.getListFileByFolder(pID, LOAITAILIEU.TM_UPLOAD, 0, DONVI.NAME, THUMUC);
                    CCTC_THANHPHANBusiness = Get <CCTC_THANHPHANBusiness>();
                    subMenu.AddRange(THUMUC_LUUTRUBusiness.GetThuMucByParent(pID, 0, Ids));
                    #endregion
                }
            }
            return(JsonConvert.SerializeObject(subMenu));
        }
        public JsonResult Delete(long id)
        {
            hscvVanBanDenBusiness = Get <HSCV_VANBANDENBusiness>();
            HSCV_VANBANDEN entityVanBanDen = hscvVanBanDenBusiness.Find(id);

            AssignUserInfo();
            if (entityVanBanDen == null || currentUser.ID != entityVanBanDen.NGUOITAO)
            {
                return(Json(new { Type = "ERROR", Message = "Bạn không có quyền xóa văn bản trình ký này" }));
            }
            attachmentBusiness = Get <TAILIEUDINHKEMBusiness>();
            FileUltilities        file        = new FileUltilities();
            List <TAILIEUDINHKEM> ListTaiLieu = attachmentBusiness.GetDataByItemID(id, LOAITAILIEU.VANBANDEN);

            foreach (var item in ListTaiLieu)
            {
                attachmentBusiness.repository.Delete(item.TAILIEU_ID);
                file.RemoveFile(uploadFolder + item.DUONGDAN_FILE);
                if (!string.IsNullOrEmpty(item.PDF_VERSION))
                {
                    file.RemoveFile(uploadFolder + item.PDF_VERSION);
                }
            }
            storeFolderBusiness = Get <THUMUC_LUUTRUBusiness>();
            THUMUC_LUUTRU ThuMuc = storeFolderBusiness.GetDataByNam(id.ToString(), ThuMucLuuTruConstant.DefaultVanban);

            if (ThuMuc != null)
            {
                ThuMuc.IS_DELETE = true;
                storeFolderBusiness.Save(ThuMuc);
            }
            attachmentBusiness.Save();
            hscvVanBanDenBusiness.repository.Delete(id);
            #region xóa văn bản đến trong elastic

            ElasticSearch.deleteDocument(id.ToString(), ElasticType.VanBanDen);
            #endregion
            return(Json(new { Type = "SUCCESS", Message = "Xóa văn bản đến thành công" }));
        }