Пример #1
0
        /// <summary>
        /// بچه های یک بخش را برمیگرداند
        /// </summary>
        /// <param name="nodeID"></param>
        /// <returns></returns>
        public IList <Department> GetDepartmentChilds(decimal nodeID, decimal flowId)
        {
            try
            {
                DepartmentRepository             depRep = new DepartmentRepository(false);
                GTS.Clock.Model.RequestFlow.Flow flow   = new GTS.Clock.Business.RequestFlow.BFlow().GetByID(flowId);
                List <Department>  underManagmentTree   = new List <Department>();
                IList <Department> containsNode         = new GTS.Clock.Business.RequestFlow.BUnderManagment().GetUnderManagmentDepartmentByFlow(flow, true);
                foreach (Department dep in containsNode)
                {
                    underManagmentTree.Add(dep);
                }
                IList <Department> childs = this.GetDepartmentChildsWithoutDA(nodeID);
                IList <Department> result = new List <Department>();
                foreach (Department child in childs)
                {
                    if (underManagmentTree.Contains(child))
                    {
                        result.Add(child);
                    }
                }

                return(result);
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw ex;
            }
        }
Пример #2
0
        /// <summary>
        /// درخت بخشهای تحت مدیریت یک مدیر را برمیگرداند
        /// </summary>
        /// <param name="managerId">کلید اصلی مدیر</param>
        /// <returns>لیست بخش ها</returns>
        public IList <Department> GetOperatorDepartmentTree(decimal operatorPersonId, decimal parentId)
        {
            try
            {
                GTS.Clock.Business.RequestFlow.BOperator     boperator = new GTS.Clock.Business.RequestFlow.BOperator();
                IList <GTS.Clock.Model.RequestFlow.Operator> opList    = boperator.GetOperator(operatorPersonId);

                List <decimal> nodeParentChildsId = new List <decimal>();
                var            flows = from n in opList
                                       where n.Active && !n.Flow.IsDeleted && n.Flow.ActiveFlow
                                       select n.Flow;
                Department root = this.GetByID(parentId);
                IList <GTS.Clock.Model.RequestFlow.Flow> flowList = flows.ToList();
                IList <Department> departmentsList = new BDepartment().GetAll();

                var bFlow = new GTS.Clock.Business.RequestFlow.BFlow();
                foreach (GTS.Clock.Model.RequestFlow.Flow flow in flowList)
                {
                    SetVisibility(bFlow, root, flow, bFlow.GetDepartmentChilds(root.ID, flow.ID, departmentsList), departmentsList);
                }
                this.RemoveNotVisibleChilds(root);
                return(root.ChildList);
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw ex;
            }
        }
Пример #3
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;
            }
        }
Пример #4
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;
            }
        }
Пример #5
0
        /// <summary>
        /// بصورت بازگشتی درحت را پیمایش و شرط نمایش را بررسی میکند
        ///  اگر تشخیص داده شد که گره ای نباید نشان داده شود نیازی به پیمایش گره های فرزند نیست
        ///  زیرا این تشخیص شامل آنها نیز میشود
        /// </summary>
        /// <param name="department"></param>
        /// <param name="visibleIds"></param>
        //private void SetVisibility(Department department, GTS.Clock.Model.RequestFlow.Flow flow, IList<Department> containsChildList)
        //{
        //    GTS.Clock.Business.RequestFlow.BFlow bFlow = new GTS.Clock.Business.RequestFlow.BFlow();
        //    if (department.ChildList != null)
        //    {
        //        foreach (Department child in department.ChildList)
        //        {
        //            if (!containsChildList.Contains(child))
        //            {
        //                child.Visible = child.Visible || false;//ممکن است در جریانهای قبلی مقدار یک گرفته باشد
        //            }
        //            else
        //            {
        //                child.Visible = true;
        //                this.SetVisibility(child, flow, bFlow.GetDepartmentChilds(child.ID, flow.ID));
        //            }
        //        }
        //    }
        //}

        /// <summary>
        /// بررسی امکان رویت بخش ها
        /// بصورت بازگشتی درحت را پیمایش و شرط نمایش را بررسی میکند
        ///  اگر تشخیص داده شد که بخش ای نباید نشان داده شود نیازی به پیمایش زیر بخش های فرزند نیست
        ///  زیرا این تشخیص شامل آنها نیز میشود
        /// </summary>
        /// <param name="department">بخش</param>
        /// <param name="flow">جریان کاری</param>
        /// <param name="containsChildList">لیست زیر بخش ها</param>
        /// <param name="departmentsList">لیست بخش های که روی آن باید پیمایش شود</param>
        private void SetVisibility(GTS.Clock.Business.RequestFlow.BFlow bFlow, Department department, GTS.Clock.Model.RequestFlow.Flow flow, IList <Department> containsChildList, IList <Department> departmentsList)
        {
            if (departmentsList.Where(x => x.ParentID == department.ID).Any())
            {
                foreach (Department child in departmentsList.Where(x => x.ParentID == department.ID).ToList <Department>())
                {
                    if (!containsChildList.Contains(child))
                    {
                        child.Visible = child.Visible || false;//ممکن است در جریانهای قبلی مقدار یک گرفته باشد
                    }
                    else
                    {
                        child.Visible = true;
                        this.SetVisibility(bFlow, child, flow, bFlow.GetDepartmentChilds(child.ID, flow.ID, departmentsList), departmentsList);
                    }
                }
            }
        }
Пример #6
0
 /// <summary>
 /// بصورت بازگشتی درحت را پیمایش و شرط نمایش را بررسی میکند
 ///  اگر تشخیص داده شد که گره ای نباید نشان داده شود نیازی به پیمایش گره های فرزند نیست
 ///  زیرا این تشخیص شامل آنها نیز میشود
 /// </summary>
 /// <param name="department"></param>
 /// <param name="visibleIds"></param>
 private void SetVisibility(Department department, GTS.Clock.Model.RequestFlow.Flow flow, IList <Department> containsChildList)
 {
     GTS.Clock.Business.RequestFlow.BFlow bFlow = new GTS.Clock.Business.RequestFlow.BFlow();
     if (department.ChildList != null)
     {
         foreach (Department child in department.ChildList)
         {
             if (!containsChildList.Contains(child))
             {
                 child.Visible = child.Visible || false;//ممکن است در جریانهای قبلی مقدار یک گرفته باشد
             }
             else
             {
                 child.Visible = true;
                 this.SetVisibility(child, flow, bFlow.GetDepartmentChilds(child.ID, flow.ID));
             }
         }
     }
 }