Exemplo n.º 1
0
 /// <summary>
 /// 构造函数。
 /// </summary>
 /// <param name="dataPoxy"></param>
 /// <param name="syncName"></param>
 public SyncStudentsData(IDataSync dataPoxy,string syncName)
     : base(dataPoxy, syncName)
 {
     this.studentsEntity = new SFITStudentsEntity();
     this.classStudentEntity = new SFITClassStudentsEntity();
     this.roleEmployeeEntity = new SecurityRoleEmployeeEntity();
     this.studentUserRoleID = ModuleConfiguration.ModuleConfig.StudentUserRoleID;
 }
        /// <summary>
        /// 根据角色ID获取用户信息。
        /// </summary>
        /// <param name="roleID">角色ID。</param>
        /// <returns></returns>
        public OrgEmployeeCollection GetAllEmployeeByRole(string roleID)
        {
            lock (this)
            {
                OrgEmployeeCollection collection = new OrgEmployeeCollection();
                IOrgFactory factory = ModuleConfiguration.ModuleConfig.OrgFactory;
                if (factory != null)
                {
                    //角色下用户。
                    List<GUIDEx> listEmployeeID = new SecurityRoleEmployeeEntity().GetAllEmployee(roleID);
                    //角色下岗位级别。
                    List<GUIDEx> listRankID = new SecurityRoleRankEntity().GetAllRank(roleID);
                    //角色下岗位。
                    List<GUIDEx> listPostID = new SecurityRolePostEntity().GetAllPost(roleID);
                    //角色下部门。
                    List<GUIDEx> listDepartmentID = new SecurityRoleDepartmentEntity().GetAllDeprtment(roleID);

                    #region 角色下用户。
                    if (listEmployeeID != null && listEmployeeID.Count > 0)
                    {
                        foreach (GUIDEx eid in listEmployeeID)
                        {
                            OrgEmployeeCollection employeeCollection = factory.GetAllEmployee(eid);
                            if (employeeCollection != null && employeeCollection.Count == 1)
                            {
                                collection.Add(employeeCollection[0]);
                            }
                        }
                    }
                    #endregion

                    #region 岗位级别。
                    if (listRankID != null && listRankID.Count > 0)
                    {
                        OrgPostCollection postCollection = factory.GetAllPost(null);
                        if (postCollection != null && postCollection.Count > 0)
                        {
                            if (listPostID == null)
                                listPostID = new List<GUIDEx>();
                            foreach (GUIDEx rankID in listRankID)
                            {
                                OrgPostCollection posts = postCollection.FindByRank(rankID);
                                if (posts != null && posts.Count > 0)
                                {
                                    foreach (OrgPost p in posts)
                                    {
                                        if (!listPostID.Contains(p.PostID))
                                            listPostID.Add(p.PostID);
                                    }
                                }
                            }
                        }
                    }
                    #endregion

                    OrgEmployeeCollection allEmployeeCollection = null;

                    #region 岗位下用户。
                    if (listPostID != null && listPostID.Count > 0)
                    {
                        if (allEmployeeCollection == null)
                            allEmployeeCollection = factory.GetAllEmployee(null);

                        foreach (GUIDEx postID in listPostID)
                        {
                            OrgEmployeeCollection employees = allEmployeeCollection.FindByPost(postID);
                            if (employees != null && employees.Count > 0)
                            {
                                collection.Add(employees);
                            }
                        }
                    }
                    #endregion

                    #region 部门下用户。
                    if (listDepartmentID != null && listDepartmentID.Count > 0)
                    {
                        if (allEmployeeCollection == null)
                            allEmployeeCollection = factory.GetAllEmployee(null);

                        foreach (GUIDEx deptID in listDepartmentID)
                        {
                            OrgEmployeeCollection employees = allEmployeeCollection.FindByDepartment(deptID);
                            if (employees != null && employees.Count > 0)
                            {
                                collection.Add(employees);
                            }
                        }
                    }
                    #endregion
                }
                return collection;
            }
        }