コード例 #1
0
        public override ActionResult List()
        {
            var documentInfoId = GetQueryString("DocumentInfoID");

            ViewBag.HighestAuthority = DocumentCabinetsFO.GetHighestAuthorityString(documentInfoId);
            var entity = entities.Set <S_F_DocumentInfo>().FirstOrDefault(i => i.ID == documentInfoId);

            if (entity != null)
            {
                ViewBag.IsValid = entity.IsValid;
            }
            return(base.List());
        }
コード例 #2
0
        public JsonResult DoInherit(string documentInfoId)
        {
            var entity = entities.Set <S_F_DocumentInfo>().FirstOrDefault(i => i.ID == documentInfoId);

            if (entity != null)
            {
                var authList = entities.Set <S_F_DocumentFileAuthority>().Where(i => i.DocumentInfoID == documentInfoId).ToList();
                //删除原有继承的权限设置
                entities.Set <S_F_DocumentFileAuthority>().Delete(i => i.DocumentInfoID == documentInfoId && i.IsParentAuth == 1);
                authList.RemoveWhere(a => a.IsParentAuth == 1);
                //entities.SaveChanges();

                //设置继承的权限
                entities.Set <S_F_DocumentInfo>().Where(i => i.ID == documentInfoId && i.IsInherit == 0).Update(i => i.IsInherit = 1);
                var parentAuthList = entities.Set <S_F_DocumentFileAuthority>().Where(i => i.DocumentInfoID == entity.ParentID);
                foreach (S_F_DocumentFileAuthority authority in parentAuthList)
                {
                    var auth = authList.FirstOrDefault(a => a.RoleType == authority.RoleType && a.RoleCode == authority.RoleCode);
                    if (auth == null)
                    {
                        auth                = new S_F_DocumentFileAuthority();
                        auth.ID             = FormulaHelper.CreateGuid();
                        auth.DocumentInfoID = entity.ID;
                        auth.AuthType       = authority.AuthType;
                        auth.RoleType       = authority.RoleType;
                        auth.RoleCode       = authority.RoleCode;
                        auth.IsParentAuth   = 1;
                        entities.Set <S_F_DocumentFileAuthority>().Add(auth);
                    }
                    else
                    {
                        auth.AuthType     = authority.AuthType;
                        auth.IsParentAuth = 1;
                    }
                }
                entities.SaveChanges();

                //强制权限继承
                var forceInherit = ConfigurationManager.AppSettings["ForceInherit"];
                if (forceInherit != null && forceInherit.ToLower() == "true")
                {
                    DocumentCabinetsFO.InheritAuthority(documentInfoId);
                }
            }

            return(Json(""));
        }
コード例 #3
0
        public override JsonResult GetTree()
        {
            //只显示没有作废且没有删除的节点
            var documentInfoList = entities.Set <S_F_DocumentInfo>().Where(a => a.IsDeleted == 0 && a.IsValid == "T").ToList();
            var list             = documentInfoList.Select(documentInfo => new
            {
                documentInfo.ID,
                documentInfo.ParentID,
                documentInfo.FullPathID,
                documentInfo.Name,
                documentInfo.Code,
                documentInfo.SortIndex,
                documentInfo.Level,
                documentInfo.IsInherit,
                documentInfo.IsValid,
                IconType  = "mini-tree-folder",
                Authority = DocumentCabinetsFO.GetHighestAuthorityString(documentInfo.ID)
            }).ToList();

            var result = list.Where(a => string.IsNullOrEmpty(a.ParentID)).ToList();

            foreach (var item in list)
            {
                if (item.Authority == DocumentCabinetsAuthType.CanWrite.ToString() ||
                    item.Authority == DocumentCabinetsAuthType.FullControl.ToString())
                {
                    var acestors = list.Where(a => item.FullPathID.Contains(a.ID)).ToList();
                    foreach (var acestor in acestors)
                    {
                        if (!result.Contains(acestor))
                        {
                            result.Add(acestor);
                        }
                    }
                }
            }

            return(Json(result));
        }
コード例 #4
0
        /// <summary>
        /// 获取节点的最高权限
        /// </summary>
        /// <param name="documentInfoId">节点ID</param>
        /// <returns>最高权限</returns>
        public JsonResult GetHighestAuthority(string documentInfoId)
        {
            var highestAuth = DocumentCabinetsFO.GetHighestAuthorityString(documentInfoId);

            return(Json(new { HighestAuthority = highestAuth }, JsonRequestBehavior.AllowGet));
        }