Esempio n. 1
0
 /// <summary>
 /// 获取指定文档信息详情
 /// </summary>
 /// <param name="strDocId">文档编号</param>
 /// <returns></returns>
 public static Model.HelpDoc GetModel(string strDocId)
 {
     Model.HelpDoc doc = Repository.HelpDoc.GetModel(strDocId);
     if (doc != null)
     {
         doc.IsDefaultRole = DocUsrRole.QueryExist(strDocId, "4b5df8d4-e422-48b4-8138-7fd6806dd214");
         doc.docFullText   = null;
         doc.viewRoleList  = DocUsrRole.GetListByDocId(strDocId);
         doc.editRoleList  = DocRoleCtrl.GetEditRoleList(strDocId);
     }
     return(doc);
 }
Esempio n. 2
0
        /// <summary>
        /// 根据文档类型ID获取所有文档清单(分页)
        /// </summary>
        /// <returns></returns>
        public static IList <Model.HelpDoc> GetListByDocTypeId(int pageIndex, int rowCount, string strDocTypeId, bool isRecursion, out int totalCount, out int pageCount, ClaimsPrincipal user)
        {
            IList <Model.HelpDoc> helpDocListTemp =
                user.Identity.IsAuthenticated
                ? Repository.HelpDoc.GetListByDocTypeId(1, int.MaxValue, strDocTypeId, out totalCount, out pageCount, isRecursion)
                : Repository.HelpDoc.GetVisitorListByDocTypeId(1, int.MaxValue, strDocTypeId, out totalCount, out pageCount, isRecursion);

            var helpDocList = new List <Model.HelpDoc>();

            //2018.12.17 17:52:00 针对文档的编辑权限加的代码
            if (user.Identity.IsAuthenticated)
            {
                string strUsrId = user.Identities.First(u => u.IsAuthenticated).FindFirst("UsrId").Value;
                var    roleList = Repository.UsrRole.GetModel(strUsrId).ToList();
                if (helpDocListTemp != null && helpDocListTemp.Count > 0)
                {
                    foreach (var doc in helpDocListTemp)
                    {
                        var displayflag = false;
                        foreach (var role in roleList)
                        {
                            if (Repository.DocRoleCtrl.Get(doc.docId, role.roleId).Count > 0)
                            {
                                doc.editRole = true;
                                break;
                            }
                        }
                        //用户无编辑权限时判断是否有可读的权限,如果没有,则过滤改文档
                        if (!doc.editRole)
                        {
                            doc.viewRoleList = DocUsrRole.GetListByDocId(doc.docId);
                            foreach (var view in doc.viewRoleList)
                            {
                                foreach (var userrole in roleList)
                                {
                                    if (view == userrole.roleId)
                                    {
                                        displayflag = true;
                                        break;
                                    }
                                }
                                if (displayflag)
                                {
                                    break;
                                }
                            }
                        }
                        if (displayflag || doc.editRole)
                        {
                            helpDocList.Add(doc);
                        }
                    }
                }
                totalCount  = helpDocList.Count;
                pageCount   = totalCount / rowCount;
                helpDocList = helpDocList.Skip((pageIndex - 1) * rowCount).Take(rowCount).ToList();
            }
            else
            {
                helpDocList = helpDocListTemp.ToList();
                helpDocList = helpDocList.Skip((pageIndex - 1) * rowCount).Take(rowCount).ToList();
            }

            return(helpDocList);
        }