コード例 #1
0
ファイル: BUser.cs プロジェクト: ImanRezaeipour/GTS
        /// <summary>
        /// بخشهایی که اجازه دسترسی به آنها دارد به همراه پدران و بچه ها را برمیگرداند
        /// </summary>
        /// <returns></returns>
        IList <decimal> IDataAccess.GetAccessibleDeparments()
        {
            BApplicationSettings.CheckGTSLicense();

            if (userRepository.HasAllDepartmentAccess(this.CurrentUserId))
            {
                IList <Department> list = new DepartmentRepository(false).GetAll();
                var ids = from obj in list
                          select obj.ID;
                return(ids.ToList <decimal>());
            }
            else
            {
                BDepartment    bDepartment         = new BDepartment();
                List <decimal> depList             = new List <decimal>();
                List <decimal> childAndParentsList = new List <decimal>();
                depList.AddRange(userRepository.GetUserDepartmentList(this.CurrentUserId));
                foreach (decimal depId in depList)//اضافه کردن بچه ها و والد ها
                {
                    IList <Department> childs = new List <Department>();
                    childs = bDepartment.GetDepartmentChildsByParentPath(depId);
                    childAndParentsList.AddRange(bDepartment.GetByID(depId).ParentPathList);
                    var ids = from child in childs
                              select child.ID;
                    childAndParentsList.AddRange(ids.ToList <decimal>());
                }
                depList.AddRange(childAndParentsList);
                return(depList);
            }
        }
コード例 #2
0
 public void GetDepartmentChildByParentPath_Test()
 {
     try
     {
         IList <Department> list = busDep.GetDepartmentChildsByParentPath(ADORoot.ID);
         Assert.IsTrue(list.Where(x => x.ID == ADODepartment1.ID).Count() > 0);
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
コード例 #3
0
        /// <summary>
        /// شناسه گرهای بچه را استخراج میکند
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private List <decimal> GetDepartmentChildsIdList(Department node)
        {
            BDepartment          bDepartment = new BDepartment();
            IList <Department>   departmentchilds;
            List <decimal>       childIds = new List <decimal>();
            DepartmentRepository depRep   = new DepartmentRepository(false);

            departmentchilds = bDepartment.GetDepartmentChildsByParentPath(node.ID);
            if (departmentchilds == null || departmentchilds.Count == 0)
            {
                return(new List <decimal>());
            }
            else
            {
                var ids = from n in departmentchilds select n.ID;
                childIds.AddRange(ids.ToList <decimal>());
                return(childIds);
            }
        }
コード例 #4
0
        /// <summary>
        /// همه بچهای یک گره را بصورت بازگشتی برمیگرداند
        /// </summary>
        /// <param name="childs"></param>
        /// <param name="node"></param>
        private List <Department> GetDepartmentChildList(Department node)
        {
            try
            {
                BDepartment          bDepartment = new BDepartment();
                IList <Department>   departmentchilds;
                DepartmentRepository depRep = new DepartmentRepository(false);
                departmentchilds = bDepartment.GetDepartmentChildsByParentPath(node.ID);
                if (departmentchilds == null || departmentchilds.Count == 0)
                {
                    return(new List <Department>());
                }
                else
                {
                    return(departmentchilds.ToList());
                }
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex, "BUnderManagment", "GetDepartmentChildList");

                throw ex;
            }
        }