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
        public IList <Substitute> GetSubstitute(decimal personId)
        {
            SubstituteRepository rep  = new SubstituteRepository(false);
            IList <Substitute>   list = rep.GetSubstitute(personId);

            if (list != null && list.Count > 0)
            {
                return(list);
            }
            return(new List <Substitute>());
        }
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;
            }
        }
Exemple #4
0
        /// <summary>
        /// مدیر یک جانشین را برمیگرداند
        ///
        /// اگر جانشین چند نفر باشد فعلا اولی را برمیگرداند
        /// </summary>
        /// <param name="personId"></param>
        /// <returns></returns>
        public decimal GetSubstituteManager(decimal personId)
        {
            SubstituteRepository rep  = new SubstituteRepository(false);
            IList <Substitute>   list = rep.GetSubstitute(personId);

            if (list != null && list.Count > 0)
            {
                list = list.Where(x => x.Active && x.FromDate <= DateTime.Now.Date && x.ToDate >= DateTime.Now.Date).ToList();
                if (list.Count > 0)
                {
                    if (list.First().Manager != null)
                    {
                        return(list.First().Manager.ID);
                    }
                }
            }
            return(0);
        }
Exemple #5
0
        /// <summary>
        /// مدیران یک جانشین را برمیگرداند
        ///
        /// اگر جانشین چند نفر باشد فعلا اولی را برمیگرداند
        /// </summary>
        /// <param name="personId"></param>
        /// <returns></returns>
        public IList <decimal> GetSubstituteManagerList(decimal personId)
        {
            SubstituteRepository rep  = new SubstituteRepository(false);
            IList <Substitute>   list = rep.GetSubstitute(personId);

            if (list != null && list.Count > 0)
            {
                list = list.Where(x => x.Active && x.FromDate <= DateTime.Now.Date && x.ToDate >= DateTime.Now.Date).ToList();
                if (list.Count > 0)
                {
                    var ids = from o in list
                              where o.Active
                              select o.Manager.ID;
                    return(ids.ToList());
                }
            }
            return(new List <decimal>());
        }