/// <summary> /// 查询所有的职员 /// </summary> /// <returns></returns> public async Task <List <StaffSimpleInfoDto> > QueryAllStaff() { using (var staffInfoService = new StaffInfoService()) { List <StaffSimpleInfoDto> staffDtoList = new List <StaffSimpleInfoDto>(); var staffList = await staffInfoService.GetAllOrder().ToListAsync(); using (var sectionService = new SectionService()) { foreach (var staff in staffList) { string sectionName = sectionService.GetAll().Where(p => p.Id == staff.SectionId).FirstOrDefault().Name; staffDtoList.Add(new StaffSimpleInfoDto() { Id = staff.Id, Name = staff.Name, Tel = staff.Tel, Position = staff.Position, Status = staff.Status, Email = staff.Email, SectionName = sectionName }); } } return(staffDtoList); } }
/// <summary> /// 得到职员的详细信息 /// </summary> /// <returns></returns> public async Task <List <StaffSimpleInfoDto> > GetAllStaffDetial() { var staffDetailList = new List <StaffSimpleInfoDto>(); using (StaffInfoService staffInfoService = new StaffInfoService()) { var staffList = await staffInfoService.GetAll().ToListAsync(); using (SectionService sectionService = new SectionService()) { foreach (var item in staffList) { var sn = (await sectionService.GetOneById(item.SectionId)).Name; staffDetailList.Add(new StaffSimpleInfoDto() { Id = item.Id, Name = item.Name, Tel = item.Tel, Email = item.Email, SectionName = sn, Position = item.Position, Status = item.Status, CreateTime = item.CreatTime, Address = item.Address, Photo = item.ImagePath, IdCard = item.IdCard }); } } } return(staffDetailList); }
/// <summary> /// 增加多个职员 /// </summary> /// <param name="staffInfos">职员信息</param> /// <param name="operatorId">操作员id</param> /// <param name="key">秘钥</param> /// <param name="originalRoleName">角色名</param> /// <returns></returns> public async Task AddGroupStaff(List <StaffBsicInfoDto> staffInfos, Guid operatorId, string key, string originalRoleName) { List <Guid> modifyIds = new List <Guid>(); using (IStaffInfoService staffInfoService = new StaffInfoService()) { foreach (var staffInfo in staffInfos) { var staff = new Model.StaffInfo() { Name = staffInfo.Name, Tel = staffInfo.Tel, Password = StringEncryptAndDecrypt.AESEncrypt(staffInfo.Tel, key), Email = staffInfo.Email, Address = staffInfo.Address, IdCard = staffInfo.IdCard, ImagePath = staffInfo.ImagePath, SectionId = staffInfo.SectionId, Position = staffInfo.Position }; await staffInfoService.CreateAsync(staff, false); modifyIds.Add(staff.Id); } await staffInfoService.Save(); } using (IAccountOperateLogService accountOperateLogService = new AccountOperateLogService()) { using (IStaffPowerInfoService staffPowerInfoService = new StaffPowerInfoService()) { using (IRoleInfoService roleInfoService = new RoleInfoService()) { foreach (var modifyId in modifyIds) { await accountOperateLogService.CreateAsync(new Model.AccountOperateLog() { OperatorId = operatorId, ModifiedId = modifyId, OPerateType = ('1').ToString() }, false); //初始权限 await staffPowerInfoService.CreateAsync(new Model.StaffPowerInfo() { StaffId = modifyId, RoleId = (await roleInfoService.GetAll().Where(p => p.Name == originalRoleName).FirstAsync()).Id //得到对应权限的Id }, false); } //一起更新 await accountOperateLogService.Save(); await staffPowerInfoService.Save(); } } } }
/// <summary> /// 修改密码 /// </summary> /// <param name="tel">账号(电话)</param> /// <param name="password">新密码</param> /// <param name="key">秘钥(用于加解密)</param> /// <returns></returns> public async Task ChangePwd(string tel, string password, string key) { using (IStaffInfoService staffInfoService = new StaffInfoService()) { var staff = await staffInfoService.GetAll().Where(p => p.Tel == tel).FirstAsync(); staff.Password = StringEncryptAndDecrypt.AESEncrypt(password, key); await staffInfoService.EditAsync(staff); } }
public string GetStaffInfoDatas() { StaffInfoService service = new StaffInfoService(); DataTable dt = service.GetStaffInfo(); string[] column = { "ID", "Name", "Sex", "PhoneNumber" }; string result = DataGridJsonParser.DataTableToJson(dt, column); return(result); }
public static string DeleteStaffInfo(string myStaffInfoItemId) { if (mPageOpPermission.ToArray()[3] == '1') { return(StaffInfoService.DeleteStaffInfo(myStaffInfoItemId)); } else { return("该用户没有修改权限!"); } }
/// <summary> /// 冻结账号 /// </summary> /// <param name="tel">账号(电话)</param> /// <returns></returns> public async Task LockAccount(string tel) { using (IStaffInfoService staffInfoService = new StaffInfoService()) { var staff = staffInfoService.GetAll().Where(p => p.Tel == tel).FirstOrDefault(); if (staff != null) { staff.Status = false; await staffInfoService.EditAsync(staff); } } }
public List <string> GetInitalInfo(string tel) { using (StaffInfoService staffInfoService = new StaffInfoService()) { var staff = staffInfoService.GetAll().Where(p => p.Tel == tel).FirstOrDefault(); return(new List <string>() { staff.Name, staff.Position, staff.ImagePath }); } }
/// <summary> /// 增加一个职员 /// </summary> /// <param name="staffInfo">职员信息</param> /// <param name="operatorId">操作员id</param> /// <param name="key">秘钥</param> /// <param name="originalRoleName">角色名</param> /// <returns></returns> public async Task AddOneStaff(StaffBsicInfoDto staffInfo, Guid operatorId, string key, string originalRoleName) { using (IStaffInfoService staffInfoService = new StaffInfoService()) { var staff = new Model.StaffInfo() { Name = staffInfo.Name, Tel = staffInfo.Tel, Password = StringEncryptAndDecrypt.AESEncrypt(staffInfo.Tel, key), Email = staffInfo.Email, Address = staffInfo.Address, IdCard = staffInfo.IdCard, ImagePath = staffInfo.ImagePath, SectionId = staffInfo.SectionId, Position = staffInfo.Position }; await staffInfoService.CreateAsync(staff); using (IAccountOperateLogService accountOperateLogService = new AccountOperateLogService()) { await accountOperateLogService.CreateAsync(new Model.AccountOperateLog() { OperatorId = operatorId, ModifiedId = staff.Id, OPerateType = "1" }); } //初始权限 using (IStaffPowerInfoService staffPowerInfoService = new StaffPowerInfoService()) { using (IRoleInfoService roleInfoService = new RoleInfoService()) { await staffPowerInfoService.CreateAsync(new Model.StaffPowerInfo() { StaffId = staff.Id, RoleId = (await roleInfoService.GetAll().Where(p => p.Name == "一级权限").FirstAsync()).Id }); } } } }
/// <summary> /// 移除职员状态 /// </summary> /// <param name="staffId"></param> /// <param name="operatorId"></param> /// <returns></returns> public async Task ChangeStaffStatusById(Guid staffId, Guid operatorId) { using (var staffInfoService = new StaffInfoService()) { var staff = await staffInfoService.GetOneById(staffId); staff.Status = !staff.Status; await staffInfoService.EditAsync(staff); using (var accountOperateLogService = new AccountOperateLogService()) { await accountOperateLogService.CreateAsync(new Model.AccountOperateLog() { OperatorId = operatorId, ModifiedId = staffId, OPerateType = "2" }); } } }
/// <summary> /// 职员登陆 /// </summary> /// <param name="account">账号(电话)</param> /// <param name="password">密码</param> /// <param name="key">秘钥(用于加解密)</param> /// <param name="userId">职员id(用于返回)</param> /// <returns></returns> public bool Login(string account, string password, string key, out Guid userId) { var pwd = StringEncryptAndDecrypt.AESEncrypt(password, key); using (IStaffInfoService staffInfoService = new StaffInfoService()) { var user = staffInfoService.GetAll().FirstOrDefaultAsync(p => p.Tel == account && p.Password == pwd); //user在此是一个异步方法 user.Wait(); //等待user执行结束 var data = user.Result; //拿到user执行的结果 if (data != null) { userId = data.Id; return(true); } else { userId = new Guid(); return(false); } } }
/// <summary> /// 解封职员账号(管理员操作) /// </summary> /// <param name="tel">账号(电话)</param> /// <param name="_operatorId">操作员的ID</param> /// <returns></returns> public async Task UnlockAccount(string tel, Guid _operatorId) { using (IStaffInfoService staffInfoService = new StaffInfoService()) { var staff = staffInfoService.GetAll().FirstOrDefault(p => p.Tel == tel); if (staff != null && !staff.Status) { staff.Status = true; await staffInfoService.CreateAsync(staff); using (IAccountOperateLogService accountOperateLogService = new AccountOperateLogService()) { await accountOperateLogService.CreateAsync(new AccountOperateLog() { OperatorId = _operatorId, ModifiedId = staff.Id, OPerateType = "2" //代表update操作 }); } } } }
/// <summary> /// 根据账号得到职员基础信息 /// </summary> /// <param name="tel">账号(电话)</param> /// <returns></returns> public StaffSimpleInfoDto GetSTaffInfoByTel(string tel) { using (IStaffInfoService staffInfoService = new StaffInfoService()) { var staff = staffInfoService.GetAll().FirstOrDefault(p => p.Tel == tel); if (staff != null) { return(new StaffSimpleInfoDto() { Id = staff.Id, Name = staff.Name, Tel = staff.Tel, Email = staff.Email, Status = staff.Status, SectionName = GetSectionNameById(staff.SectionId) }); } else { return(null); } } }
public static string UpdateStaffInfo(string organizationId, string staffInfoItemId, string staffId, string name, bool sex, string workingTeam, string phoneNumber, bool enabled) { if (mPageOpPermission.ToArray()[2] == '1') { if (string.IsNullOrWhiteSpace(organizationId)) { return("保存失败,请刷新后重试。"); } if (string.IsNullOrWhiteSpace(staffId)) { return("职工ID不可为空。"); } if (string.IsNullOrWhiteSpace(name)) { return("请输入姓名"); } return(StaffInfoService.UpdateStaffInfo(organizationId, staffInfoItemId, staffId, workingTeam, name, sex, phoneNumber, enabled)); } else { return("该用户没有修改权限!"); } }
public static string GetStaffInfoWithDataGridFormat(string organizationId, string searchName, string searchId, string searchTeamName) { DataTable dt = StaffInfoService.GetStaffInfo(organizationId, searchName, searchId, searchTeamName); return(DataGridJsonParser.DataTableToJson(dt)); }