Ejemplo n.º 1
0
        /// <summary>
        /// 取得後端作業選項身分授權的巢狀清單
        /// </summary>
        public List <OperationWithRoleAuth> GetOperationWithRoleAuthNestedList(string roleName)
        {
            List <OperationWithRoleAuth> entities = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                List <Operations> topOps = empAuthDao.GetList <Operations>(op => op.ParentId == null && !op.IsHideSelf)
                                           .OrderBy(op => op.SortNo).ToList();
                List <Operations> subOps = empAuthDao.GetList <Operations>(op => op.ParentId != null && !op.IsHideSelf)
                                           .OrderBy(op => op.SortNo).ToList();
                List <EmployeeRoleOperationsDesc> roleAuthItems = empAuthDao.GetList <EmployeeRoleOperationsDesc>(ro => ro.RoleName == roleName)
                                                                  .ToList();

                if (topOps != null && subOps != null && roleAuthItems != null)
                {
                    entities = topOps.ConvertAll <OperationWithRoleAuth>(op =>
                    {
                        // top item
                        OperationWithRoleAuth opAuth = new OperationWithRoleAuth();
                        opAuth.ImportDataFrom(op);

                        EmployeeRoleOperationsDesc roleAuthItem = roleAuthItems.Find(ro => ro.OpId == op.OpId);

                        if (roleAuthItem != null)
                        {
                            opAuth.ImportDataFrom(roleAuthItem);
                        }

                        // sub item
                        opAuth.SubItems = subOps.Where(subOp => subOp.ParentId == op.OpId)
                                          .Select(subOp =>
                        {
                            OperationWithRoleAuth subOpAuth = new OperationWithRoleAuth();
                            subOpAuth.ImportDataFrom(subOp);

                            EmployeeRoleOperationsDesc subRoleAuthItem = roleAuthItems.Find(ro => ro.OpId == subOp.OpId);

                            if (subRoleAuthItem != null)
                            {
                                subOpAuth.ImportDataFrom(subRoleAuthItem);
                            }

                            return(subOpAuth);
                        }).ToList();

                        return(opAuth);
                    });
                }

                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entities);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 取得選擇用部門清單
        /// </summary>
        public List <Department> GetDepartmentListToSelect()
        {
            List <Department> entities = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                entities = empAuthDao.GetList <Department>()
                           .OrderBy(dept => dept.SortNo).ToList();
                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entities);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 取得選擇用員工身分清單
        /// </summary>
        public List <EmployeeRoleToSelect> GetEmployeeRoleListToSelect()
        {
            List <EmployeeRoleToSelect> entities = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                entities = empAuthDao.GetList <EmployeeRole>()
                           .OrderBy(r => r.SortNo)
                           .AsEnumerable()
                           .Select(r => new EmployeeRoleToSelect()
                {
                    RoleId          = r.RoleId,
                    RoleName        = r.RoleName,
                    RoleDisplayName = r.RoleDisplayName,
                    DisplayText     = string.Format("{0} ({1})", r.RoleDisplayName, r.RoleName)
                }).ToList();

                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entities);
        }