private void FillTracableData(EntityEntry entry) { if (!(entry.Entity is ITrackableEntity)) { return; } ITrackableEntity trackableEntity = entry.Entity as ITrackableEntity; SystemUser currentUser = GlobalConstants.GetCurrentUser(); if (entry.State == EntityState.Added) { trackableEntity.CreateById = currentUser.RecordId; trackableEntity.CreateByCode = currentUser.UserCode; trackableEntity.CreateByName = currentUser.UserName; trackableEntity.CreateTime = DateTime.Now; } else if (entry.State == EntityState.Modified) { trackableEntity.UpdateById = currentUser.RecordId; trackableEntity.UpdateByCode = currentUser.UserCode; trackableEntity.UpdateByName = currentUser.UserName; trackableEntity.UpdateTime = DateTime.Now; } }
public ActionResult <string> GetCurrentLogin() { SystemUser currentUser = (SystemUser)GlobalConstants.GetCurrentUser(); string loginText = null; CommonRepository.UseDbContext(dbContext => { var privilegeList = ( from rp in dbContext.Set <RolePrivilege>() from ur in dbContext.Set <RoleUser>() from r in dbContext.Set <SystemRole>() where rp.RoleId == ur.RoleId && r.RecordId == ur.RoleId && ur.UserId == currentUser.RecordId select r ).Distinct() .SelectMany(x => x.Privileges).ToList(); string privilegeText = GlobalConstants.ToJson(privilegeList); loginText = "{\"company\":\"爱三(佛山)汽车配件有限公司\"," + "\"userName\":\"" + currentUser.UserName + "\"," + "\"userCode\":\"" + currentUser.UserCode + "\"," + "\"privielges\":" + privilegeText + "}"; }); return(loginText); }
public List <SystemProgram> GetUserMenu() { long userId = GlobalConstants.GetCurrentUser().RecordId; List <SystemProgram> programList = new List <SystemProgram>(); CommonRepository.UseDbContext(dbContext => { var allPrograms = (from p in dbContext.Set <SystemProgram>() from rp in dbContext.Set <RolePrivilege>() from r in dbContext.Set <RoleUser>() where p.RecordId == rp.ProgramId && rp.RoleId == r.RoleId && r.UserId == userId && p.ProgramStatus == 0 select p ).Include(x => x.Privielges) .ToList(); programList.AddRange(allPrograms.Where(x => string.IsNullOrEmpty(x.ParentId))); foreach (SystemProgram program in programList) { this.fillMenu(allPrograms, program); } }); return(programList); }
private long GetFilterByWorkshopId() { SystemUser currentUser = GlobalConstants.GetCurrentUser(); using (DbContext dbContext = GlobalConstants.DbContextFactory.GetContext()) { if (dbContext.Set <RoleUser>().Where(x => x.UserId == currentUser.RecordId && x.Role.RoleCode == ROLE_FILTER_BY_WORKSHOP).Count() > 0) { return(dbContext.Set <Operator>().Where(x => x.EmployeeId == currentUser.UserCode).Select(x => x.orgId).FirstOrDefault()); } } return(-1); }
protected override void AfterInsert(RfidCard item, Microsoft.EntityFrameworkCore.DbContext dbContext) { CardIssue issue = new CardIssue(); issue.CardNo = item.RfidNo; issue.CardId = item.RecordId; issue.WorkstationId = -1; issue.WorkstationCode = ""; issue.WorkstationName = ""; SystemUser currentUser = GlobalConstants.GetCurrentUser(); issue.IssueUserId = currentUser.RecordId; issue.IssueUserCode = currentUser.UserCode; issue.IssueUserName = currentUser.UserName; issue.IssueQty = item.IssueQty; dbContext.Add(issue); dbContext.SaveChanges(); }
public string KeepAlive() { GlobalConstants.DefaultLogger.Info("客户端心跳:" + GlobalConstants.GetCurrentUser().UserCode); return("{}"); }