public object RolePage(int Roleid, int page, int limit, string showname) { //角色表 var role = roledal.QueryWhere(); //角色权限表 var rolepageres = dal.QueryWhere(d => d.SysRoleID == Roleid); var allrolepageres = dal.QueryWhere(p => p.SysRoleID == Roleid); //权限表 var pageres = pagedal.QueryWhere(); if (showname != null) { var pageid = pagedal.QueryWhere(p => p.ShowName.Contains(showname)).ToList(); if (pageid.Count() > 0) { List <int?> arr = new List <int?>(); foreach (var item in pageid) { arr.Add(item.ID); } rolepageres = rolepageres.Where(r => arr.Contains(r.PageID)); } else { rolepageres = rolepageres.Where(p => p.PageID == 0); } } //角色联表角色权限表 var tt = role.Join(rolepageres.OrderBy(o => o.ID).Skip((page - 1) * limit).Take(limit).Join(pageres, m => m.PageID, n => n.ID, (m, n) => new { m.SysRoleID, n.ShowName, n.ID, n.ParentID }).OrderBy(o => o.ID), r => r.ID, aa => aa.SysRoleID, (r, aa) => new { sysid = aa.SysRoleID, rolename = r.Name, pagename = aa.ShowName, pageid = aa.ID, parentid = aa.ParentID }).ToList(); var count = rolepageres.Count(); var tranres = new { code = 0, msg = "success", data = tt, count = count }; return(tranres); }
public int OperatRecordAdd(int?InstrumentID, string OperateChildType, string VisitUrl, Model.SB_User usermodel, int?AreaID) { try { //GetIpHelper ipmodel = new GetIpHelper(); var ip = GetIpHelper.GetWebClientIp(); var time = DateTime.Now; if (InstrumentID == null && AreaID == null) { var pagecn = pagedal.QueryWhere(p => p.URL.Equals(VisitUrl)).Select(s => s.PageNameCN).FirstOrDefault(); var record = usermodel.Account + "在" + time + "访问" + pagecn + "界面" + VisitUrl; Model.SB_OperateHistory operatmodel = new Model.SB_OperateHistory() { UserId = usermodel.ID, UserName = usermodel.Name, IPAddress = ip, PageURL = VisitUrl, PageNameCN = pagecn, OperateTime = time, OperateChildType = OperateChildType, OperateRecord = record, OperateType = "0", ClientID = usermodel.ClientID, Remark = "等待", Valid = "1", AreaID = 0, FactoryID = 0, InstrumentID = 0, StationID = 0 }; dal.Add(operatmodel); int ress = dal.SaveChanges(); return(ress); } else { var instrures = indal.Find(new object[] { InstrumentID }); var record = ""; Model.SB_OperateHistory operatmodel = new Model.SB_OperateHistory() { UserId = usermodel.ID, UserName = usermodel.Name, IPAddress = ip, OperateTime = time, OperateChildType = OperateChildType, OperateRecord = record, OperateType = "1", ClientID = instrures.ClientID, AreaID = AreaID, StationID = instrures.StationID, FactoryID = instrures.FactoryID, InstrumentID = instrures.ID, Remark = "等待", Valid = "1" }; dal.Add(operatmodel); int ress = dal.SaveChanges(); return(ress); } }catch (Exception e) { throw new Exception("" + e.Data); } }