public Worker GetWorkerByRfid(string rfid) { var w = _workerCache.GetList().Find(x => !string.IsNullOrEmpty(x.Rfid) && x.Rfid == rfid); if (w != null) { return(_workerCache[w.Id]); } return(null); }
public Worker GetWorkerByCn(string cn) { var worker = _workerCache.GetList().Find(x => x.Cn == cn); if (worker != null) { return(_workerCache[worker.Id]); } return(null); }
public List <ComboboxItemDto> GetWorkerItemsByWorkRole(int workRoleId) { var list = new List <ComboboxItemDto>(); int depotId = _workerCache[GetCurrentUserWorkerIdAsync().Result].DepotId; var lst = _workerCache.GetList().FindAll(x => x.DepotId == depotId && x.IsActive == true); lst.Sort((a, b) => a.Cn.CompareTo(b.Cn)); var role = _workRoleCache[workRoleId]; foreach (var w in lst) { var post = _postCache[w.PostId]; if (string.IsNullOrEmpty(w.WorkRoleNames)) { if (!string.IsNullOrEmpty(post.DefaultWorkRoleName) && post.DefaultWorkRoleName == role.Name) { list.Add(new ComboboxItemDto { Value = w.Id.ToString(), DisplayText = w.CnNamePost }); } } else { var roles = w.WorkRoleNames.Split(',', '|'); if (roles.Contains(role.Name)) { list.Add(new ComboboxItemDto { Value = w.Id.ToString(), DisplayText = w.CnNamePost }); } } } return(list); }
public async Task AddWorkerUsers() { var users = await Repository.GetAllListAsync(); foreach (WorkerCacheItem worker in _workerCache.GetList()) { if (!string.IsNullOrWhiteSpace(_workerCache[worker.Id].LoginRoleNames)) { string[] roles = _workerCache[worker.Id].LoginRoleNames.Split(',', '|'); // User string userName = "******" + worker.Cn; var user = users.FirstOrDefault(x => x.UserName == userName); if (user == null) { // Add WorkerUser var newUser = User.CreateUser(AbpSession.TenantId ?? 0, userName, User.WorkerUserDefaultPassword); newUser.WorkerId = worker.Id; CheckErrors(await _userManager.CreateAsync(newUser)); CheckErrors(await _userManager.SetRoles(newUser, roles)); } } } }