Exemple #1
0
 /// <summary>
 /// بررسی و مقداردهی مدیر از روی شناسه کاربری
 /// </summary>
 /// <returns></returns>
 private bool InitManager()
 {
     if (manager == null)
     {
         if (Utility.IsEmpty(this.Username))
         {
             this.Username = Security.BUser.CurrentUser.UserName;
         }
         BManager businessManager = new BManager();
         manager = businessManager.GetManagerByUsername(this.Username);
     }
     if (manager.ID == 0)// جانشین
     {
         SubstituteRepository subRep = new SubstituteRepository(false);
         if (subRep.IsSubstitute(Security.BUser.CurrentUser.Person.ID))
         {
             IList <Substitute> sub = subRep.GetSubstitute(Security.BUser.CurrentUser.Person.ID);
             manager = sub.First().Manager;
         }
     }
     if (manager.ID > 0)
     {
         return(true);
     }
     return(false);
 }
Exemple #2
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;
            }
        }