Пример #1
0
        /// <summary>
        /// آیا کاربر فعلی اپراتور است
        /// </summary>
        /// <returns></returns>
        private bool IsOperator()
        {
            BOperator        op     = new BOperator();
            IList <Operator> opList = op.GetOperator(curentUserPersonId);

            return(opList.Count > 0 ? true : false);
        }
Пример #2
0
        /// <summary>
        /// لیست بخش های تحت مدیریت یک اپراتور را برمیگرداند
        /// </summary>
        /// <param name="mangerId"></param>
        /// <returns></returns>
        public IList <Department> GetUnderManagmentDepartmentByOperator(decimal operatorPersonId)
        {
            if (operatorPersonId > 0)
            {
                BOperator          bus                = new BOperator();
                IList <Operator>   opList             = bus.GetOperator(operatorPersonId);
                IList <Department> depList            = new List <Department>();
                List <decimal>     nodeParentChildsId = new List <decimal>();

                var flows = from n in opList
                            select n.Flow;
                IList <Flow> flowList = flows.ToList();
                foreach (Flow flow in flowList)
                {
                    foreach (UnderManagment underManagment in flow.UnderManagmentList)
                    {
                        if (underManagment.Department != null && underManagment.Department.ID > 0)
                        {
                            nodeParentChildsId.Add(underManagment.Department.ID);
                            nodeParentChildsId.AddRange(underManagment.Department.ParentPathList);
                            if (underManagment.ContainInnerChilds)
                            {
                                nodeParentChildsId = GetDepartmentChildsIdList(underManagment.Department);
                            }
                        }
                        else
                        {
                            throw new InvalidDatabaseStateException(UIFatalExceptionIdentifiers.UnderManagmentDepartmentNull, "بخش مربوط به افراد تحت مدیریت در هیچ صورتی نباید تهی باشد", ExceptionSrc);
                        }
                    }
                }
                nodeParentChildsId = nodeParentChildsId.GroupBy(x => x).Select(x => x.First()).ToList();
                foreach (decimal id in nodeParentChildsId)
                {
                    depList.Add(new Department()
                    {
                        ID = id
                    });
                }
                return(depList);
            }
            else
            {
                throw new IllegalServiceAccess(String.Format("این سرویس تنها توسط مدیران قابل استفاده میباشد. شناسه کاربری {0} میباشد", this.workingUsername), ExceptionSrc);
            }
        }