public async Task <ActionResult <IEnumerable <GetEmployeeDto> > > Get([FromQuery] EmployeeQueryParameter parameter) { var abc = await service.GetAllAsync(parameter); var xyz = TypeAdapter.Adapt <List <GetEmployeeDto> >(abc); return(Ok(xyz)); }
private EmployeeQueryParameter getCondition() { var condition = new EmployeeQueryParameter(); condition.Name = this.txtName.Text.Trim(); condition.Login = this.txtUserName.Text.Trim(); condition.Owner = CurrentCompany.CompanyId; condition.IpLimitation = this.txtIp.Text.Trim(); return(condition); }
public Object Get([FromUri] EmployeeQueryParameter param) { if (param.ExcludeOwner) { param.LoginName = RequestContext.Principal.Identity.Name; } IEmployeeService employeeService = new EmployeeService(); return(new { totalCount = employeeService.CountEmployee(param), data = employeeService.SearchEmployee(param) }); }
public IEnumerable <EmployeeListView> QueryEmployeeInfo(EmployeeQueryParameter condition, Pagination pagination) { var result = new List <EmployeeListView>(); using (var dbOperator = new DbOperator(Provider, ConnectionString)) { if (!string.IsNullOrEmpty(condition.Name)) { dbOperator.AddParameter("@iName", condition.Name); } if (!string.IsNullOrEmpty(condition.Login)) { dbOperator.AddParameter("@iUserName", condition.Login); } if (condition.Enabled.HasValue) { dbOperator.AddParameter("@iEnabled", condition.Enabled.Value); } if (!string.IsNullOrWhiteSpace(condition.IpLimitation)) { dbOperator.AddParameter("@iIpLimitation", condition.IpLimitation); } dbOperator.AddParameter("@iOwner", condition.Owner); dbOperator.AddParameter("@iPageSize", pagination.PageSize); dbOperator.AddParameter("@iPageIndex", pagination.PageIndex); System.Data.Common.DbParameter totalCount = dbOperator.AddParameter("@oTotalCount"); totalCount.DbType = System.Data.DbType.Int32; totalCount.Direction = System.Data.ParameterDirection.Output; using (var reader = dbOperator.ExecuteReader("[dbo].[P_QueryEmployees]", System.Data.CommandType.StoredProcedure)) { while (reader.Read()) { var info = new EmployeeListView(); info.Name = reader.GetString(0); info.Gender = (Common.Enums.Gender)reader.GetByte(1); info.UserName = reader.GetString(2); info.RoleName = reader.GetString(3); info.Email = reader.GetString(4); info.Cellphone = reader.GetString(5); info.Enabled = reader.GetBoolean(6); info.IsAdministrator = reader.GetBoolean(7); info.Id = reader.GetGuid(8); info.Remark = reader.IsDBNull(9) ? string.Empty : reader.GetString(9); info.IpLimitation = reader.IsDBNull(10) ? string.Empty : reader.GetString(10); result.Add(info); } } if (pagination.GetRowCount) { pagination.RowCount = (int)totalCount.Value; } } return(result); }
/// <summary> /// 获取指定公司的所有员工 /// </summary> /// <param name="ownerId">所属公司Id</param> public static IEnumerable <EmployeeListView> QueryEmployees(Guid ownerId) { var condition = new EmployeeQueryParameter { Owner = ownerId }; var pagination = new Pagination { GetRowCount = false, PageIndex = 1, PageSize = int.MaxValue }; return(QueryEmployees(condition, pagination)); }
private EmployeeQueryParameter getCondition() { var condition = new EmployeeQueryParameter(); condition.Name = this.txtName.Text.Trim(); condition.Login = this.txtUserName.Text.Trim(); condition.Owner = CurrentCompany.CompanyId; if (!string.IsNullOrWhiteSpace(this.ddlEnabled.SelectedValue)) { condition.Enabled = this.ddlEnabled.SelectedValue == "1"; } return(condition); }
public async Task <IPaged <Employee> > PagedAsync(EmployeeQueryParameter param, int pageIndex, int pageSize) { Expression <Func <Employee, bool> > query = null; if (param != null && !string.IsNullOrWhiteSpace(param.Key)) { query = e => e.Username.Contains(param.Key) || e.RealName.Contains(param.Key); } else { query = e => true; } var result = await base.PagedAsync(query, pageIndex, pageSize); return(result); }
public async Task <List <Employee> > RetrieveAsync(EmployeeQueryParameter param) { Expression <Func <Employee, bool> > query = null; if (param != null && !string.IsNullOrWhiteSpace(param.Key)) { query = e => e.Username.Contains(param.Key) || e.RealName.Contains(param.Key); } else { query = e => true; } var list = (await base.SelectAsync(query)).ToList(); return(list); }
private void queryEmployeeList(Pagination pagination) { string companyId = Request.QueryString["CompanyId"]; if (!string.IsNullOrWhiteSpace(companyId)) { var condition = new EmployeeQueryParameter(); condition.Owner = Guid.Parse(companyId); var staffInfos = EmployeeService.QueryEmployees(condition, pagination); rptEmployees.DataSource = staffInfos.Select(p => new { p.Name, p.UserName, Gender = p.Gender.GetDescription(), UserRoles = p.RoleName, p.Email, p.Cellphone, p.Enabled, p.Remark, p.Id, p.IsAdministrator }); rptEmployees.DataBind(); if (staffInfos.Any()) { empoyeePager.Visible = true; if (pagination.GetRowCount) { empoyeePager.RowCount = pagination.RowCount; } } else { empoyeePager.Visible = false; } } }
/// <summary> /// 员工列表查询 /// </summary> /// <param name="condition">查询条件</param> /// <param name="pagination">分页条件</param> public static IEnumerable <EmployeeListView> QueryEmployees(EmployeeQueryParameter condition, Pagination pagination) { var repository = Factory.CreateEmployeeRepository(); return(repository.QueryEmployeeInfo(condition, pagination)); }
public IEnumerable <EmployeeDto> SearchEmployee(EmployeeQueryParameter param) { try { string sql = ""; Object value = "%" + param.query + "%"; if (String.IsNullOrWhiteSpace(param.query)) { value = DBNull.Value; } sql = @"SELECT Id, loginName, employeeNo, fullName, position, email, ext, phone, reportTo, groupName, subDeptId, subDept, deptName, devision, hod, empType FROM ( SELECT [ID] Id, [LOGIN_NAME] loginName, [EMP_NO] employeeNo, [DISPLAY_NAME] fullName , [POSITION] position, [EMAIL] email, [TELEPHONE] ext, [MOBILE_PHONE] phone, [MANAGER] reportTo, [GROUP_NAME] groupName, [TEAM_ID] subDeptId, [TEAM_NAME] subDept, [DEPT_NAME] deptName, [DEPT_TYPE] devision, [HOD] hod, [EMP_TYPE] empType, ROW_NUMBER() OVER (ORDER BY [DISPLAY_NAME]) ROW_NO FROM @VIEW_NAME@ WHERE (@value IS NULL OR EMP_NO LIKE @value OR (LOGIN_NAME LIKE @value ) OR DISPLAY_NAME LIKE @value OR EMAIL LIKE @value) AND (@EmpType = '' OR EMP_TYPE = @EmpType) AND (@LoginName = '' OR LOWER(LOGIN_NAME) <> @LoginName) AND (EMP_TYPE IN @EMPLOYEE_TYPE@) AND (@EmpId = 0 OR ID = @EmpId) ) AS query WHERE query.ROW_NO > @start AND query.ROW_NO <= (@start + @limit)"; return(_employeeRepository.SqlQuery <EmployeeDto>( sql.Replace("@EMPLOYEE_TYPE@", (param.IncludeGenericAcct ? "('INTEGRATED', 'NONE_AD', 'GENERIC')" : "('INTEGRATED', 'NONE_AD')")) .Replace("@VIEW_NAME@", (param.IncludeInactive? "[HR].[VIEW_EMPLOYEE_ALL]" : "[HR].[VIEW_EMPLOYEE_LIST]")), new object[] { new SqlParameter("@value", value), new SqlParameter("@start", param.start), new SqlParameter("@limit", param.limit), new SqlParameter("@EmpType", param.Integrated == true ? "INTEGRATED": ""), new SqlParameter("@LoginName", !string.IsNullOrEmpty(param.LoginName) ? param.LoginName: ""), new SqlParameter("@EmpId", param.EmpId) })); } catch (SmartException e) { throw e; } }