Exemple #1
0
        /// <summary>
        /// 检查用户对于一批目录是否具有指定权限,返回具有权限的目录Id列表
        /// </summary>
        /// <param name="handle"></param>
        /// <param name="permission"></param>
        /// <param name="toFilterDirIdList"></param>
        /// <returns></returns>
        public List <string> FilterDirIds(LibHandle handle, DMFuncPermissionEnum permission, List <string> toFilterDirIdList)
        {
            if (handle == LibHandleCache.Default.GetSystemHandle() || string.IsNullOrEmpty(handle.UserId) || handle.UserId == "admin")
            {
                return(toFilterDirIdList);//系统用户则直接原样返回
            }
            string           personId       = handle.PersonId;
            DMUserPermission userPermission = DMUserPermissionCache.Default.GetCacheItem(personId);

            if (userPermission.IsUnlimited)
            {
                return(toFilterDirIdList);//用户权限不受限制则直接原样返回
            }
            Dictionary <string, List <string> > dicDirId_DirIds = DirLinkAddress.GetDirIdsForDirs(toFilterDirIdList);

            if (dicDirId_DirIds == null)
            {
                return(new List <string>());
            }

            List <string> resultList = new List <string>();

            try
            {
                //使用每个目录的目录标识列表(含自身和所有父级目录)检查是否可用权限
                resultList = (from item in toFilterDirIdList
                              where dicDirId_DirIds.ContainsKey(item) && userPermission.CheckCan(dicDirId_DirIds[item], string.Empty, permission)
                              select item).ToList();
            }
            catch (Exception exp)
            {
                DMCommonMethod.WriteLog("FilterDocIds", exp.Message);
            }
            return(resultList);
        }
Exemple #2
0
        /// <summary>
        /// 全文索引创建结果的处理
        /// </summary>
        /// <param name="docId"></param>
        /// <param name="modifyVerId">修订版标识号</param>
        /// <param name="isSuccess"></param>
        public static void DealFullIndexResult(string docId, int modifyVerId, bool isSuccess)
        {
            try
            {
                LibDataAccess    dataAccess = new LibDataAccess();
                LibDBTransaction trans      = dataAccess.BeginTransaction();
                try
                {
                    string sql = "";
                    if (dataAccess.DatabaseType == LibDatabaseType.SqlServer)
                    {
                        sql = string.Format(
                            " update a                        " +
                            " set a.ISFULLINDEX = {2}         " +
                            " from DMDOCUMENT a               " +
                            " where a.DOCID = '{0}' and (select max(DOCMODIFYID) from DMDOCMODIFYHISTORY where DOCID = '{0}') = {1}",//修订号与最新修订号相同才设置索引结果
                            docId, modifyVerId, isSuccess ? 1 : 0);
                    }
                    else
                    {
                        //Oracle To do
                    }

                    if (string.IsNullOrEmpty(sql) == false)
                    {
                        dataAccess.ExecuteNonQuery(sql);
                    }
                    trans.Commit();
                }
                catch
                {
                    trans.Rollback();
                    throw;
                }
            }
            catch (Exception exp)
            {
                //发生异常时记录日志
                DMCommonMethod.WriteLog("DealFullIndexResult", string.Format("DocId:{0}\r\nIsSuccess{1}\r\nnError:{2}",
                                                                             docId, isSuccess, exp.ToString()));
            }
        }
Exemple #3
0
        /// <summary>
        /// 触发需要删除文档的全文索引事件
        /// </summary>
        /// <param name="docId"></param>
        /// <param name="modifyVerId">默认为删除所有修订版索引。如果修订版号码小于等于0则表示删除所有修订版的索引,否则为删除指定修订版索引</param>
        public static void RaiseNeedDeleteDocFullIndex(string docId, int modifyVerId = -1)
        {
            try
            {
                if (NeedDeleteDocFullIndex != null)
                {
                    //异步调用事件
                    NeedDeleteDocFullIndex.BeginInvoke(docId, modifyVerId, null, null);
                    //Delegate[] delegAry = NeedDeleteDocFullIndex.GetInvocationList();
                    ////遍历委托列表
                    //foreach (DeleteDocFullIndexCall deleg in delegAry)
                    //{
                    //    //异步调用委托
                    //    deleg.BeginInvoke(docId, modifyVerId, null, null);
                    //}
                }
            }
            catch (Exception exp)
            {
                //发生异常时记录日志
                DMCommonMethod.WriteLog("RaiseNeedDeleteDocFullIndex", string.Format("DocId:{0}\r\nModifyVerId:{1}\r\nError:{2}",
                                                                                     docId, modifyVerId, exp.ToString()));
            }

            //if (NeedDeleteDocFullIndex != null)
            //{
            //    //异步调用事件
            //    ThreadPool.QueueUserWorkItem(delegate {
            //        try
            //        {
            //            NeedDeleteDocFullIndex(docId, modifyVerId);
            //        }
            //        catch (Exception exp)
            //        {
            //            //发生异常时记录日志
            //            DMCommonMethod.WriteLog("RaiseNeedDeleteDocFullIndex", string.Format("DocId:{0}\r\nModifyVerId:{1}\r\nError:{2}",
            //                    docId, modifyVerId, exp.ToString()));
            //        }
            //    });
            //}
        }
Exemple #4
0
 /// <summary>
 /// 触发文档创建全文索引事件
 /// </summary>
 /// <param name="docId">文档编号</param>
 /// <param name="docType">文档类型,文档的扩展名,含.号</param>
 /// <param name="modifyVerId">修订版标识号</param>
 /// <param name="isFullNew">是否为全新的文档。新增和替换的认为是全新的,编辑的认为不是全新的</param>
 /// <param name="fullPath">文档在文件系统上的绝对路径</param>
 public static void RaiseNewDocArrivedToFullIndex(string docId, string docType, int modifyVerId, bool isFullNew, string fullPath)
 {
     try
     {
         if (NewDocArrivedToFullIndex != null)
         {
             //异步调用事件
             NewDocArrivedToFullIndex.BeginInvoke(docId, docType, modifyVerId, isFullNew, fullPath, null, null);
             //Delegate[] delegAry = NewDocArrivedToFullIndex.GetInvocationList();
             ////遍历委托列表
             //foreach (NewDocArrivedToFullIndexCall deleg in delegAry)
             //{
             //    //异步调用委托
             //    deleg.BeginInvoke(docId, docType, modifyVerId, isFullNew, fullPath, null, null);
             //}
         }
     }
     catch (Exception exp)
     {
         //发生异常时记录日志
         DMCommonMethod.WriteLog("RaiseNewDocArrivedToFullIndex", string.Format("DocId:{0}\r\nDocType:{1}\r\nModifyVerId:{2}\r\nIsFullNew:{3}\r\nFullPath:{4}\r\nError:{5}",
                                                                                docId, docType, modifyVerId, isFullNew, fullPath, exp.ToString()));
     }
     //if (NewDocArrivedToFullIndex != null)
     //{
     //    ThreadPool.QueueUserWorkItem(delegate {
     //        try
     //        {
     //            NewDocArrivedToFullIndex(docId, docType, modifyVerId, isFullNew, fullPath);
     //        }
     //        catch (Exception exp)
     //        {
     //            //发生异常时记录日志
     //            DMCommonMethod.WriteLog("RaiseNewDocArrivedToFullIndex", string.Format("DocId:{0}\r\nDocType:{1}\r\nModifyVerId:{2}\r\nIsFullNew:{3}\r\nFullPath:{4}\r\nError:{5}",
     //                    docId, docType, modifyVerId, isFullNew, fullPath, exp.ToString()));
     //        }
     //    });
     //}
 }
Exemple #5
0
        /// <summary>
        /// 检查用户对于一批文档是否具有指定权限,返回具有权限的文档Id列表
        /// </summary>
        /// <param name="handle"></param>
        /// <param name="permission"></param>
        /// <param name="toFilterDocIdList"></param>
        /// <returns></returns>
        public List <string> FilterDocIds(LibHandle handle, DMFuncPermissionEnum permission, List <string> toFilterDocIdList)
        {
            if (handle == LibHandleCache.Default.GetSystemHandle() || string.IsNullOrEmpty(handle.UserId) || handle.UserId == "admin")
            {
                return(toFilterDocIdList);//系统用户则直接原样返回
            }
            string           personId       = handle.PersonId;
            DMUserPermission userPermission = DMUserPermissionCache.Default.GetCacheItem(personId);

            if (userPermission.IsUnlimited)
            {
                return(toFilterDocIdList);//用户权限不受限制则直接原样返回
            }
            Dictionary <string, List <DocInfo> > dicDocId_DirIds = DirLinkAddress.GetParentDirIdsForDocs(toFilterDocIdList);

            if (dicDocId_DirIds == null)
            {
                return(null);
            }

            List <string> resultList = new List <string>();
            Dictionary <string, List <string> > tempDic = new Dictionary <string, List <string> >();

            foreach (KeyValuePair <string, List <DocInfo> > item in dicDocId_DirIds)
            {
                foreach (DocInfo temp in item.Value)
                {
                    if (temp.DirType == DirTypeEnum.Private && temp.CreatorId == personId)
                    {
                        if (!resultList.Contains(item.Key))
                        {
                            resultList.Add(item.Key);
                            break;
                        }
                    }
                    else
                    {
                        if (tempDic.ContainsKey(item.Key))
                        {
                            tempDic[item.Key].Add(temp.DirId);
                        }
                        else
                        {
                            tempDic.Add(item.Key, new List <string>()
                            {
                                temp.DirId
                            });
                        }
                    }
                }
            }
            try {
                //使用每个文档的标识和父目录标识列表检查是否可用权限
                resultList.AddRange((from item in toFilterDocIdList
                                     where tempDic.ContainsKey(item) && userPermission.CheckCan(tempDic[item], item, permission)
                                     select item).ToList());
            }
            catch (Exception exp)
            {
                DMCommonMethod.WriteLog("FilterDocIds", exp.Message);
            }
            return(resultList);
        }
Exemple #6
0
        /// <summary>
        /// 检查是否可以浏览指定目录
        /// 如果目录自身有管理或浏览权限、或者目录下的某个目录(无论是子目录还是孙目录等)有管理或者浏览权限、或者下面的某个文档有浏览或管理权限,则可以浏览
        /// </summary>
        /// <param name="dirId"></param>
        /// <returns></returns>
        public bool CheckDirCanBrowse(string dirId, DirLinkAddress dirLink = null)
        {
            try
            {
                if (string.IsNullOrEmpty(dirId))
                {
                    return(false);
                }
                if (dirLink == null)
                {
                    dirLink = new DirLinkAddress(dirId, new LibDataAccess());
                }

                //合并权限
                int           mergePermission = 0;
                List <string> dirIdList       = dirLink.SubDirIdList;
                dirIdList.Add(dirId);

                dirLink.GetDocIds();//文档编号列表需要单独获取
                List <string> docIdList = dirLink.DocIdList;

                lock (this._LockObjOfDicDirAndDoc)
                {
                    foreach (string itemId in dirIdList)
                    {
                        if (this._DicDirectoryPowers.ContainsKey(itemId))
                        {
                            mergePermission |= this._DicDirectoryPowers[itemId];  //按位或
                            if ((mergePermission & (int)DMFuncPermissionEnum.Manage) == (int)DMFuncPermissionEnum.Manage)
                            {
                                return(true);
                            }
                            if ((mergePermission & (int)DMFuncPermissionEnum.Browse) == (int)DMFuncPermissionEnum.Browse)
                            {
                                return(true);
                            }
                        }
                    }
                    foreach (string itemId in docIdList)
                    {
                        if (this._DicDocumentPowers.ContainsKey(itemId))
                        {
                            mergePermission |= this._DicDocumentPowers[itemId];  //按位或
                            if ((mergePermission & (int)DMFuncPermissionEnum.Manage) == (int)DMFuncPermissionEnum.Manage)
                            {
                                return(true);
                            }
                            if ((mergePermission & (int)DMFuncPermissionEnum.Browse) == (int)DMFuncPermissionEnum.Browse)
                            {
                                return(true);
                            }
                        }
                    }
                }
                return(false);
            }
            catch (Exception exp)
            {
                DMCommonMethod.WriteLog("DMUserPermission.CheckDirCanBrowse", string.Format("DirId:{0}\r\nError:{1}", dirId, exp.ToString()));
                return(false);
            }
        }