Exemple #1
0
        /// <summary>
        /// درخت بخشهای تحت مدیریت یک مدیر را برمیگرداند
        /// </summary>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public IList <Department> GetManagerDepartmentTree(decimal managerId, decimal parentId)
        {
            try
            {
                GTS.Clock.Business.RequestFlow.BManager bmanager = new GTS.Clock.Business.RequestFlow.BManager();
                GTS.Clock.Model.RequestFlow.Manager     mng      = bmanager.GetByID(managerId);

                List <decimal> nodeParentChildsId = new List <decimal>();
                var            flows = from n in mng.ManagerFlowList
                                       where n.Active && n.Flow.ActiveFlow
                                       select n.Flow;
                Department root = this.GetByID(parentId);
                IList <GTS.Clock.Model.RequestFlow.Flow> flowList = flows.ToList();
                foreach (GTS.Clock.Model.RequestFlow.Flow flow in flowList)
                {
                    SetVisibility(root, flow, new GTS.Clock.Business.RequestFlow.BFlow().GetDepartmentChilds(root.ID, flow.ID));
                }
                this.RemoveNotVisibleChilds(root);
                return(root.ChildList);
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw ex;
            }
        }
Exemple #2
0
        /// <summary>
        /// درخت بخش های تحت مدیریت یک مدیر را برمیگرداند
        /// سازمان بر میگردد
        /// جانشینی لحاظ نمیگردد
        /// فقط جریان اصلی لحاظ میگردد
        /// </summary>
        /// <param name="managerId">کلید اصلی مدیر</param>
        /// <returns>بخش</returns>
        public Department GetManagerDepartmentTree_JustOrgan(decimal managerId)
        {
            try
            {
                GTS.Clock.Business.RequestFlow.BManager bmanager = new GTS.Clock.Business.RequestFlow.BManager();
                GTS.Clock.Model.RequestFlow.Manager     mng      = bmanager.GetByID(managerId);

                List <decimal> nodeParentChildsId = new List <decimal>();
                var            flows = new List <GTS.Clock.Model.RequestFlow.Flow>();
                flows.AddRange(from n in mng.ManagerFlowList
                               where !n.Flow.IsDeleted && n.Active && n.Flow.ActiveFlow && n.Flow.MainFlow
                               select n.Flow);

                Department root = this.GetDepartmentsTree();
                IList <GTS.Clock.Model.RequestFlow.Flow> flowList = flows.ToList();
                if (flowList.Count() > 0)
                {
                    IList <Department> departmentsList = new BDepartment().GetAllWithoutDataAccess();
                    root = departmentsList.Where(x =>
                                                 x.DepartmentType == DepartmentType.Organization &&
                                                 flowList.First().UnderManagmentList.Any(y => y.Department.ID == x.ID || y.Department.ParentPath.Contains("," + x.ID.ToString() + ","))
                                                 )
                           .FirstOrDefault();                 //ریشه سازمان
                    if (root == null)
                    {
                        root = new Department();
                    }
                    departmentsList = departmentsList.Where(x => x.DepartmentType == DepartmentType.Organization || x.DepartmentType == DepartmentType.Assistance || x.DepartmentType == DepartmentType.Management || x.DepartmentType == DepartmentType.Unit).ToList();
                    root.Visible    = true;
                    var bFlow = new GTS.Clock.Business.RequestFlow.BFlow();
                    foreach (GTS.Clock.Model.RequestFlow.Flow flow in flowList.Distinct())
                    {
                        SetVisibility(bFlow, root, flow, bFlow.GetDepartmentChilds(root.ID, flow.ID, departmentsList), departmentsList);
                    }
                    this.RemoveNotVisibleChilds(root);
                    return(root);
                }
                else
                {
                    return(new Department());
                }
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw ex;
            }
        }
Exemple #3
0
        /// <summary>
        /// درخت بخش های تحت مدیریت یک مدیر را برمیگرداند
        /// </summary>
        /// <param name="managerId">کلید اصلی مدیر</param>
        /// <returns>بخش</returns>
        public Department GetManagerDepartmentTree(decimal managerId)
        {
            try
            {
                GTS.Clock.Business.RequestFlow.BManager bmanager = new GTS.Clock.Business.RequestFlow.BManager();
                GTS.Clock.Model.RequestFlow.Manager     mng      = bmanager.GetByID(managerId);

                List <decimal> nodeParentChildsId = new List <decimal>();
                var            flows = new List <GTS.Clock.Model.RequestFlow.Flow>();
                flows.AddRange(from n in mng.ManagerFlowList
                               where !n.Flow.IsDeleted && n.Active && n.Flow.ActiveFlow
                               select n.Flow);

                #region اگر این شخص جانشین هم باشد
                SubstituteRepository subRep = new SubstituteRepository(false);
                if (subRep.IsSubstitute(Security.BUser.CurrentUser.Person.ID))
                {
                    IList <GTS.Clock.Model.RequestFlow.Substitute> subList = subRep.GetSubstitute(Security.BUser.CurrentUser.Person.ID);
                    foreach (GTS.Clock.Model.RequestFlow.Substitute sub in subList)
                    {
                        flows.AddRange(from n in sub.Manager.ManagerFlowList
                                       where n.Active && !n.Flow.IsDeleted && n.Flow.ActiveFlow
                                       select n.Flow);
                    }
                }
                #endregion

                Department root = this.GetDepartmentsTree();
                IList <GTS.Clock.Model.RequestFlow.Flow> flowList = flows.ToList();
                IList <Department> departmentsList = new BDepartment().GetAllWithoutDataAccess();
                root.Visible = true;

                var bFlow = new GTS.Clock.Business.RequestFlow.BFlow();
                foreach (GTS.Clock.Model.RequestFlow.Flow flow in flowList.Distinct())
                {
                    SetVisibility(bFlow, root, flow, this.GetDepartmentChilds(flow, root.ID, departmentsList), departmentsList);
                }
                this.RemoveNotVisibleChilds(root);
                return(root);
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw ex;
            }
        }