// GET: MachineShelf/Details/5 public ActionResult Details(int id) { MachineShelf shelf = null; StringBuilder sbRooms = new StringBuilder(); sbRooms.Append("["); using (var ctx = new GlsunViewEntities()) { shelf = ctx.MachineShelf.Find(id); int count = 0; foreach (var room in ctx.MachineRoom) { sbRooms.AppendFormat("{{id: {0}, text: '{1}'}}", room.ID, room.MRName); count++; if (count != ctx.MachineRoom.Count()) { sbRooms.Append(","); } } } sbRooms.Append("]"); ViewBag.RoomData = sbRooms.ToString(); ViewBag.Action = "Details"; return(View("Create", shelf)); }
public ActionResult Create(RouteGroup group, HttpPostedFileBase iconFile) { var json = new JsonResult(); User loginUser = null; try { string iconFileName = ""; if (iconFile != null) { iconFileName = SaveIcon(iconFile); } using (var ctx = new GlsunViewEntities()) { loginUser = (from u in ctx.User where u.ULoginName == HttpContext.User.Identity.Name select u).FirstOrDefault(); group.CreatorID = loginUser.ID; group.CreationTime = DateTime.Now; //图标没值 if (string.IsNullOrWhiteSpace(group.RGIcon)) { group.RGIcon = iconFileName; } ctx.RouteGroup.Add(group); ctx.SaveChanges(); } json.Data = new { Code = "", Data = "", Message = "保存成功" }; } catch (Exception ex) { json.Data = new { Code = "Exception", Data = "", Message = ex.Message }; } return(json); }
public ActionResult DeviceIndex(int id) { Device d = null; using (var ctx = new GlsunViewEntities()) { d = ctx.Device.Find(id); } int mfID = 0; if (d != null) { mfID = d.MFID; } DeviceOverview deviceView; DeviceInfo info; List <CardSlotInfo> cardSlotInfo; GetDeviceOverView(mfID, out deviceView, out info, out cardSlotInfo); JavaScriptSerializer serializer = new JavaScriptSerializer(); ViewBag.DeviceView = serializer.Serialize(deviceView); ViewBag.CardSlotInfo = serializer.Serialize(cardSlotInfo); return(View("Index", info)); }
public ActionResult Edit(MachineRoom room) { var json = new JsonResult(); try { using (var ctx = new GlsunViewEntities()) { var loginUser = (from u in ctx.User where u.ULoginName == HttpContext.User.Identity.Name select u).FirstOrDefault(); var roomModify = (from r in ctx.MachineRoom where r.ID == room.ID select r).FirstOrDefault(); roomModify.MRName = room.MRName; roomModify.MRAddress = room.MRAddress; roomModify.MRDescription = room.MRDescription; roomModify.MRIcon = room.MRIcon; roomModify.Remark = room.Remark; roomModify.EditorID = loginUser.ID; roomModify.EditingTime = DateTime.Now; ctx.SaveChanges(); } json.Data = new { Code = "", Data = "", Message = "保存成功" }; } catch (Exception ex) { json.Data = new { Code = "Exception", Data = "", Message = ex.Message }; } return(json); }
public ActionResult Create(MachineShelf shelf) { var json = new JsonResult(); try { using (var ctx = new GlsunViewEntities()) { var loginUser = (from u in ctx.User where u.ULoginName == HttpContext.User.Identity.Name select u).FirstOrDefault(); if (loginUser != null) { shelf.CreatorID = loginUser.ID; shelf.CreationTime = DateTime.Now; } ctx.MachineShelf.Add(shelf); ctx.SaveChanges(); } json.Data = new { Code = "", Data = "", Message = "保存成功" }; } catch (Exception ex) { json.Data = new { Code = "Exception", Data = "", Message = ex.Message }; } return(json); }
public ActionResult Edit(MachineShelf shelf) { var json = new JsonResult(); try { using (var ctx = new GlsunViewEntities()) { var loginUser = (from u in ctx.User where u.ULoginName == HttpContext.User.Identity.Name select u).FirstOrDefault(); var shelfModify = (from r in ctx.MachineShelf where r.ID == shelf.ID select r).FirstOrDefault(); shelfModify.MSName = shelf.MSName; shelfModify.MSNumber = shelf.MSNumber; shelfModify.MSLayers = shelf.MSLayers; shelfModify.MSIcon = shelf.MSIcon; shelfModify.MRID = shelf.MRID; shelfModify.Remark = shelf.Remark; shelfModify.EditorID = loginUser.ID; shelfModify.EditingTime = DateTime.Now; ctx.SaveChanges(); } json.Data = new { Code = "", Data = "", Message = "保存成功" }; } catch (Exception ex) { json.Data = new { Code = "Exception", Data = "", Message = ex.Message }; } return(json); }
public JsonResult Delete(int id, FormCollection collection) { var json = new JsonResult(); try { using (var ctx = new GlsunViewEntities()) { var module = (from m in ctx.Module where m.ID == id select m).First(); DeleteChildModule(module.ID); var moduleAuthority = from ma in ctx.ModuleAuthority where ma.MID == id select ma; ctx.ModuleAuthority.RemoveRange(moduleAuthority); ctx.Module.Remove(module); ctx.SaveChanges(); } json.Data = new { Code = "", Data = id, Message = "删除成功" }; } catch (Exception ex) { json.Data = new { Code = "Exception", Data = id, Message = ex.Message }; } return(json); }
public PartialViewResult Menu() { List <Module> modules = null; using (var context = new GlsunViewEntities()) { var loginUser = (from u in context.User where u.ULoginName == HttpContext.User.Identity.Name select u).FirstOrDefault(); //管理员 if (loginUser.UUserType == 0) { modules = (from m in context.Module where m.IsEnabled == true && m.MType == "menu" && m.MName != "拓扑操作" select m).ToList(); } else { var subSet = (from um in context.v_UserModule where um.UID == loginUser.ID select um.MID).ToList().Distinct(); modules = context.Module.Where(m => subSet.Contains(m.ID) && m.MType == "menu" && m.MName != "拓扑操作").ToList(); } var topoModule = modules.Where(m => m.MName == "拓扑管理").FirstOrDefault(); if (topoModule != null) { var netId = 100000; var deviceId = 200000; foreach (var net in context.Subnet.OrderBy(s => s.ID)) { var m = new Module { ID = netId + net.ID, MParentID = topoModule.ID, MLevel = 1, MIconType = "image", MIcon = "image/topo/" + net.SIcon, MName = net.SName, MUrl = string.Format("Subnet/Index/{0}", net.ID) }; modules.Add(m); foreach (var device in context.Device.Where(d => d.SID == net.ID).OrderBy(d => d.ID)) { var md = new Module { ID = deviceId + device.ID, MParentID = m.ID, MLevel = 2, MIconType = "image", MIcon = "image/topo/" + device.DIcon, MName = device.DName, MUrl = string.Format("DeviceView/Index/{0}", device.ID) }; modules.Add(md); } } } } return(PartialView(modules)); }
// GET: NMUCard /// <summary> /// /// </summary> /// <param name="id">设备ID</param> /// <returns></returns> public ActionResult Index(int id) { Device d = null; using (var ctx = new GlsunViewEntities()) { d = ctx.Device.Find(id); } //IP地址->连接服务->实例化一个状态类->填充状态 TcpClientService tcp = new TcpClientService(d.DAddress, d.DPort.Value); NMUCommService service = new NMUCommService(tcp); NMUInfo nmuInfo = new NMUInfo(); try { tcp.Connect(); nmuInfo.RefreshStatus(service); } catch (Exception ex) { } tcp.Dispose(); //JavaScriptSerializer serializer = new JavaScriptSerializer(); //ViewBag.DeviceInfo = serializer.Serialize(deviceView); ViewBag.DID = d.ID; return(View(nmuInfo)); }
public ActionResult Create(Route route) { var json = new JsonResult(); User loginUser = null; try { using (var ctx = new GlsunViewEntities()) { loginUser = (from u in ctx.User where u.ULoginName == HttpContext.User.Identity.Name select u).FirstOrDefault(); var frameA = ctx.MachineFrame.Find(route.RAMFID); var frameB = ctx.MachineFrame.Find(route.RBMFID); route.RAIP = frameA.MFIP; route.RBIP = frameB.MFIP; route.CreationTime = DateTime.Now; route.CreatorID = loginUser.ID; ctx.Route.Add(route); ctx.SaveChanges(); } json.Data = new { Code = "", Data = "", Message = "保存成功" }; } catch (Exception ex) { json.Data = new { Code = "Exception", Data = "", Message = ex.Message }; } return(json); }
public ActionResult Edit(DeviceLine line) { var json = new JsonResult(); User loginUser = null; try { using (var ctx = new GlsunViewEntities()) { loginUser = (from u in ctx.User where u.ULoginName == HttpContext.User.Identity.Name select u).FirstOrDefault(); var route = ctx.Route.Find(line.RID); var modifyLine = ctx.DeviceLine.Find(line.ID); modifyLine.DLName = route.RName; modifyLine.RID = line.RID; modifyLine.EditorID = loginUser.ID; modifyLine.EditingTime = DateTime.Now; ctx.SaveChanges(); } json.Data = new { Code = "", Data = "", Message = "保存成功" }; } catch (Exception ex) { json.Data = new { Code = "Exception", Data = "", Message = ex.Message }; } return(json); }
public ActionResult ConfirmFast(string confirmIds) { JsonResult json = new JsonResult(); var arrIds = confirmIds.Split(','); List <int> Ids = new List <int>(); if (arrIds.Length > 0) { Ids = (from id in arrIds select int.Parse(id)).ToList(); using (var ctx = new GlsunViewEntities()) { var loginUser = (from u in ctx.User where u.ULoginName == HttpContext.User.Identity.Name select u).FirstOrDefault(); var alarmInfos = ctx.AlarmInformation.Where(a => Ids.Contains(a.ID)); foreach (var info in alarmInfos) { info.AIConfirm = true; info.AIConfirmTime = DateTime.Now; info.UID = loginUser.ID; info.ULoginName = loginUser.ULoginName; info.UName = loginUser.UName; } ctx.SaveChanges(); } } json.Data = Ids; return(json); }
public string Delete(int id) { object result = null; User loginUser = null; string details = ""; DeviceLine line = null; try { using (var ctx = new GlsunViewEntities()) { loginUser = (from u in ctx.User where u.ULoginName == HttpContext.User.Identity.Name select u).FirstOrDefault(); var deviceLineDel = ctx.DeviceLine.Find(id); line = deviceLineDel.CopyProperty(); ctx.DeviceLine.Remove(deviceLineDel); ctx.SaveChanges(); var dA = ctx.Device.Find(line.DIDA); var dB = ctx.Device.Find(line.DIDB); details = string.Format("{0}-{1}", dA.DName, dB.DName); } result = new { Code = "", Data = id, Message = "删除成功" }; //日志记录 _topoLogger.Record(loginUser, "删除设备连线", details, "成功", "", line.ID, line.DLName, "设备连线"); } catch (Exception ex) { result = new { Code = "Exception", Data = id, Message = ex.Message }; //日志记录 _topoLogger.Record(loginUser, "删除设备连线", details, "失败", string.Format("发生异常:{0}", ex.Message), line.ID, line.DLName, "设备连线"); } return(new JavaScriptSerializer().Serialize(result)); }
public ActionResult Edit(Device device, HttpPostedFileBase iconFile) { var json = new JsonResult(); User loginUser = null; try { string iconFileName = ""; if (iconFile != null) { iconFileName = SaveIcon(iconFile); } using (var ctx = new GlsunViewEntities()) { loginUser = (from u in ctx.User where u.ULoginName == HttpContext.User.Identity.Name select u).FirstOrDefault(); var deviceModify = ctx.Device.Find(device.ID); deviceModify.DName = device.DName; deviceModify.DAddress = device.DAddress; deviceModify.DPort = device.DPort; deviceModify.DType = device.DType; deviceModify.DIcon = device.DIcon; deviceModify.DProtocal = device.DProtocal; deviceModify.CoordinateX = device.CoordinateX; deviceModify.CoordinateY = device.CoordinateY; deviceModify.Remark = device.Remark; deviceModify.EditorID = loginUser.ID; deviceModify.EditingTime = DateTime.Now; deviceModify.MFID = device.MFID; if (!string.IsNullOrWhiteSpace(iconFileName)) { deviceModify.DIcon = iconFileName; device.DIcon = iconFileName; } ctx.SaveChanges(); } var data = new TopologyNode { ID = device.ID, Name = device.DName, Address = device.DAddress, Icon = device.DIcon, X = device.CoordinateX.Value, Y = device.CoordinateY.Value }; json.Data = new { Code = "", Data = data, Message = "保存成功" }; //日志记录 _topoLogger.Record(loginUser, "修改设备", "", "成功", "", device.ID, device.DName, "设备"); } catch (Exception ex) { json.Data = new { Code = "Exception", Data = device, Message = ex.Message }; //日志记录 _topoLogger.Record(loginUser, "修改设备", "", "失败", string.Format("发生异常:{0}"), device.ID, device.DName, "设备"); } return(json); }
/// <summary> /// 设置用户操作权限的数据 /// </summary> public virtual void SetAuthorityData() { IEnumerable <v_UserModuleAuthority> userModuleAuth = null; string controllerName = (string)ControllerContext.RouteData.Values["controller"]; string actionName = (string)ControllerContext.RouteData.Values["action"]; string moduleUrl = controllerName + "/" + actionName; ViewBag.Controller = controllerName; ViewBag.Action = actionName; //拓扑管理用子级操作权限controllerName if (moduleUrl.ToLower() == "topology/index") { moduleUrl = "Subnet/Index"; } using (var ctx = new GlsunViewEntities()) { var loginUser = (from u in ctx.User where u.ULoginName == HttpContext.User.Identity.Name select u).FirstOrDefault(); if (loginUser.UUserType == 0) { var module = ctx.Module.Where(m => m.MUrl == moduleUrl).FirstOrDefault(); if (module != null) { var subSet = (from m in ctx.Module join ma in ctx.ModuleAuthority on m.ID equals ma.MID join a in ctx.Authority on ma.AID equals a.ID where m.ID == module.ID select new { AName = a.AName, AIcon = a.AIcon, ACode = a.ACode, AClassName = a.AClassName, AShowNumber = a.AShowNumber }).ToList(); userModuleAuth = from n in subSet orderby n.AShowNumber select new v_UserModuleAuthority { AName = n.AName, AIcon = n.AIcon, ACode = n.ACode, AClassName = n.AClassName }; } } else { userModuleAuth = ctx.v_UserModuleAuthority .Where(uma => uma.UID == loginUser.ID && uma.MUrl == moduleUrl) .OrderBy(uma => uma.AShowNumber) .ToList() .Distinct(new UserModuleAuthorityComparer()); } } ViewBag.UserModuleAuth = userModuleAuth; }
/// <summary> /// 获取子网状态 /// </summary> /// <returns></returns> public ActionResult GetSubnetStatus() { var result = new JsonResult(); try { var nodeStatus = MemoryCacheHelper.GetCacheItem<List<TopoNodeStatus>>("subnet_status", () => { IEnumerable<Subnet> nets = null; using (var ctx = new GlsunViewEntities()) { nets = ctx.Subnet.ToList(); } List<TopoNodeStatus> status = new List<TopoNodeStatus>(); foreach (var n in nets) { status.Add(DeviceStatusGetter.GetSubnetStatus(n)); } return status; }, null, DateTime.Now.AddSeconds(10)); result.Data = new { Code = "", Data = nodeStatus }; } catch (Exception ex) { result.Data = new { Code = "Exception", Data = ex.Message }; } return result; }
public ActionResult RealTimeStatus(int did) { var ret = new JsonResult(); ret.JsonRequestBehavior = JsonRequestBehavior.AllowGet; try { Device d = new Device(); using (var ctx = new GlsunViewEntities()) { d = ctx.Device.Find(did); } //IP地址->连接服务->实例化一个状态类->填充状态 TcpClientService tcp = new TcpClientService(d.DAddress, d.DPort.Value); NMUCommService service = new NMUCommService(tcp); NMUInfo nmuInfo = new NMUInfo(); tcp.Connect(); nmuInfo.RefreshStatus(service); tcp.Dispose(); ret.Data = new { Code = "", Data = nmuInfo }; } catch (Exception ex) { ret.Data = new { Code = "Exception", Data = "" }; } return(ret); }
public ActionResult Rename(int id, string name) { var json = new JsonResult(); User loginUser = null; Subnet net = null; try { using (var ctx = new GlsunViewEntities()) { loginUser = (from u in ctx.User where u.ULoginName == HttpContext.User.Identity.Name select u).FirstOrDefault(); var subnetModify = (from s in ctx.Subnet where s.ID == id select s).FirstOrDefault(); subnetModify.SName = name; subnetModify.EditorID = loginUser.ID; subnetModify.EditingTime = DateTime.Now; net = subnetModify.CopyProperty(); net.Device = null; ctx.SaveChanges(); } json.Data = new { Code = "", Data = net, Message = "重命名成功" }; //日志记录 _topoLogger.Record(loginUser, "修改子网", "重命名", "成功", "", net.ID, net.SName, "子网"); } catch (Exception ex) { json.Data = new { Code = "Exception", Data = net, Message = ex.Message }; //日志记录 _topoLogger.Record(loginUser, "修改子网", "重命名", "失败", string.Format("发生异常:{0}", ex.Message), net.ID, net.SName, "子网"); } return json; }
public void RecordConfig(User user, MachineFrame frame, List <DeviceOperationLog> logs) { using (var ctx = new GlsunViewEntities()) { ctx.DeviceOperationLog.AddRange(logs); } }
public string GetRouteOption(int id) { //路由组数据 StringBuilder sbRoute = new StringBuilder(); sbRoute.Append("["); using (var ctx = new GlsunViewEntities()) { int count = 0; var routes = ctx.Route.ToList(); if (id > 0) { routes = routes.Where(r => r.RGID == id).ToList(); } foreach (var r in routes) { sbRoute.AppendFormat("{{id: {0}, text: '{1}'}}", r.ID, r.RName); count++; if (count != routes.Count()) { sbRoute.Append(","); } } } sbRoute.Append("]"); return(sbRoute.ToString()); }
public ActionResult Delete(int id, FormCollection collection) { var json = new JsonResult(); try { using (var ctx = new GlsunViewEntities()) { using (var tran = new TransactionScope()) { var authDelete = ctx.Authority.Find(id); var moduleAuth = ctx.ModuleAuthority.Where(m => m.AID == id); //删除外键引用记录 foreach (var ma in moduleAuth) { var roleAuth = ctx.RoleAuthority.Where(r => r.MAID == ma.ID); ctx.RoleAuthority.RemoveRange(roleAuth); ctx.ModuleAuthority.Remove(ma); } ctx.Authority.Remove(authDelete); ctx.SaveChanges(); tran.Complete(); } } json.Data = new { Code = "", Data = id, Message = "删除成功" }; } catch (Exception ex) { json.Data = new { Code = "Exception", Data = id, Message = ex.Message }; } return(json); }
public ActionResult Authority(int id) { ModuleAuth module = new ModuleAuth(); module.ModuleID = id; using (var ctx = new GlsunViewEntities()) { var theModule = ctx.Module.Find(id); if (theModule != null && (theModule.MParentID != 0 || theModule.MName == "拓扑管理")) { module.Authorities = ctx.Authority.ToList(); module.OwnAuthorityID = (from m in ctx.Module join ma in ctx.ModuleAuthority on m.ID equals ma.MID join a in ctx.Authority on ma.AID equals a.ID where m.ID == id select a.ID).ToList(); } else { module.Authorities = new List <Authority>(); module.OwnAuthorityID = new List <int>(); } } return(View(module)); }
public ActionResult GetSubnetDeviceStatus(int sId) { var result = new JsonResult(); try { string key = string.Format("subnet_device_status_{0}", sId); var nodeStatus = MemoryCacheHelper.GetCacheItem<List<TopoNodeStatus>>(key, () => { IEnumerable<Device> devices = null; using (var ctx = new GlsunViewEntities()) { devices = ctx.Device.Where(d => d.SID == sId).ToList(); } List<TopoNodeStatus> status = new List<TopoNodeStatus>(); foreach (var d in devices) { status.Add(DeviceStatusGetter.GetDeviceStatus(d)); } return status; }, null, DateTime.Now.AddSeconds(5)); result.Data = new { Code = "", Data = nodeStatus }; } catch (Exception ex) { result.Data = new { Code = "Exception", Data = ex.Message }; } return result; }
public ActionResult Edit(Role role) { var json = new JsonResult(); try { using (var ctx = new GlsunViewEntities()) { var loginUser = (from u in ctx.User where u.ULoginName == HttpContext.User.Identity.Name select u).FirstOrDefault(); var roleModify = (from r in ctx.Role where r.ID == role.ID select r).FirstOrDefault(); roleModify.RName = role.RName; roleModify.RCode = role.RCode; roleModify.EditorID = loginUser.ID; roleModify.EditingTime = DateTime.Now; ctx.SaveChanges(); } json.Data = new { Code = "", Data = role, Message = "保存成功" }; } catch (Exception ex) { json.Data = new { Code = "Exception", Data = role, Message = ex.Message }; } return(json); }
public JsonResult Delete(int id, FormCollection collection) { var json = new JsonResult(); try { using (var ctx = new GlsunViewEntities()) { var userDel = (from u in ctx.User where u.ID == id select u).FirstOrDefault(); var userRoleDel = from ur in ctx.UserRole where ur.UID == id select ur; ctx.User.Remove(userDel); ctx.UserRole.RemoveRange(userRoleDel); ctx.SaveChanges(); } json.Data = new { Code = "", Data = id, Message = "删除成功" }; } catch (Exception ex) { json.Data = new { Code = "Exception", Data = id, Message = ex.Message }; } return(json); }
public ActionResult List(int page = 1, int pageSize = 10) { IEnumerable <v_User> users = null; int itemCount = 0; using (var ctx = new GlsunViewEntities()) { itemCount = ctx.User.Count(); users = ctx.v_User.OrderBy(u => u.ID) .Skip((page - 1) * pageSize) .Take(pageSize) .ToList(); } PagingInfo pagingInfo = new PagingInfo { TotalItems = itemCount, CurrentPage = page, ItemsPerPage = pageSize, ShowPageCount = 5 }; ViewBag.PagingInfo = pagingInfo; SetAuthorityData(); return(View(users)); }
public ActionResult GetRealTimeAlarmCount() { JsonResult json = new JsonResult(); json.JsonRequestBehavior = JsonRequestBehavior.AllowGet; /*int criticalCount = 0; * int majorCount = 0; * int minorCount = 0; * int warnCount = 0; * int normalCount = 0; * //统计未确认告警 * using(var ctx = new GlsunViewEntities()) * { * criticalCount = ctx.AlarmInformation.Where(a => a.AIConfirm == false && a.AILevel == "CRITICAL").Count(); * majorCount = ctx.AlarmInformation.Where(a => a.AIConfirm == false && a.AILevel == "MAJOR").Count(); * minorCount = ctx.AlarmInformation.Where(a => a.AIConfirm == false && a.AILevel == "MINOR").Count(); * warnCount = ctx.AlarmInformation.Where(a => a.AIConfirm == false && a.AILevel == "WARN").Count(); * normalCount = ctx.AlarmInformation.Where(a => a.AIConfirm == false && a.AILevel == "NORMAL").Count(); * } * json.Data = new * { * critical = criticalCount, * major = majorCount, * minor = minorCount, * warn = warnCount, * normal = normalCount * };*/ var data = MemoryCacheHelper.GetCacheItem <object>("alarm_statistics", () => { int criticalCount = 0; int majorCount = 0; int minorCount = 0; int warnCount = 0; int normalCount = 0; //统计未确认告警 using (var ctx = new GlsunViewEntities()) { criticalCount = ctx.AlarmInformation.Where(a => a.AIConfirm == false && a.AILevel == "CRITICAL").Count(); majorCount = ctx.AlarmInformation.Where(a => a.AIConfirm == false && a.AILevel == "MAJOR").Count(); minorCount = ctx.AlarmInformation.Where(a => a.AIConfirm == false && a.AILevel == "MINOR").Count(); warnCount = ctx.AlarmInformation.Where(a => a.AIConfirm == false && a.AILevel == "WARN").Count(); normalCount = ctx.AlarmInformation.Where(a => a.AIConfirm == false && a.AILevel == "NORMAL").Count(); } return(new { critical = criticalCount, major = majorCount, minor = minorCount, warn = warnCount, normal = normalCount }); }, null, DateTime.Now.AddSeconds(5)); json.Data = data; return(json); }
private void SetMachineData() { //机房数据 StringBuilder sbRooms = new StringBuilder(); //机房对应机架数据 StringBuilder sbRoomShelfs = new StringBuilder(); //机架层数数据 StringBuilder sbShelfLayers = new StringBuilder(); sbRooms.Append("["); sbRoomShelfs.Append("{"); sbShelfLayers.Append("{"); using (var ctx = new GlsunViewEntities()) { int count = 0; foreach (var room in ctx.MachineRoom) { sbRooms.AppendFormat("{{id: {0}, text: '{1}'}}", room.ID, room.MRName); count++; sbRoomShelfs.AppendFormat("{0}:[", room.ID); var shelfs = ctx.MachineShelf.Where(s => s.MRID == room.ID); int cnt = 0; foreach (var shelf in shelfs) { sbRoomShelfs.AppendFormat("{{id: {0}, text: '{1}'}}", shelf.ID, shelf.MSName); cnt++; if (cnt != shelfs.Count()) { sbRoomShelfs.Append(","); } } sbRoomShelfs.Append("]"); if (count != ctx.MachineRoom.Count()) { sbRooms.Append(","); sbRoomShelfs.Append(","); } } count = 0; foreach (var shelf in ctx.MachineShelf) { sbShelfLayers.AppendFormat("{0}:{1}", shelf.ID, shelf.MSLayers); count++; if (count != ctx.MachineShelf.Count()) { sbShelfLayers.Append(","); } } } sbRooms.Append("]"); sbRoomShelfs.Append("}"); sbShelfLayers.Append("}"); ViewBag.RoomData = sbRooms.ToString(); ViewBag.RoomShelfData = sbRoomShelfs.ToString(); ViewBag.ShelfLayerData = sbShelfLayers.ToString(); }
// GET: UserLog public ActionResult List(int page = 1, int pageSize = 10) { LogSearchConditions conditions = null; IEnumerable <UserLog> logs = null; PagingInfo pagingInfo = null; using (var ctx = new GlsunViewEntities()) { //logs = ctx.UserLog.OrderBy(r => r.ID) // .Skip((page - 1) * pageSize) // .Take(pageSize) // .ToList(); logs = ctx.UserLog.ToList(); } conditions = (LogSearchConditions)Session["UserLogSearchConditions"]; if (conditions == null) { conditions = new LogSearchConditions { Operator = "", OperationType = "不限", OperationResult = "不限", OperationDateBeg = DateTime.Now.AddMonths(-3), OperationDateEnd = DateTime.Now }; } if (!string.IsNullOrWhiteSpace(conditions.Operator)) { logs = logs.Where(u => u.ULOperator.Contains(conditions.Operator)); } if (conditions.OperationType != "不限") { logs = logs.Where(u => u.ULOperationType == conditions.OperationType); } if (conditions.OperationResult != "不限") { logs = logs.Where(u => u.ULOperationResult == conditions.OperationResult); } logs = logs.Where(u => u.ULOperationTime >= conditions.OperationDateBeg); logs = logs.Where(u => u.ULOperationTime < conditions.OperationDateEnd.AddDays(1)); var totalLogs = logs.Count(); logs = logs.OrderByDescending(l => l.ULOperationTime) .Skip((page - 1) * pageSize) .Take(pageSize) .ToList(); pagingInfo = new PagingInfo { TotalItems = totalLogs, CurrentPage = page, ItemsPerPage = pageSize, ShowPageCount = 5 }; ViewBag.Conditions = conditions; ViewBag.PagingInfo = pagingInfo; SetAuthorityData(); return(View(logs)); }
// GET: RouteGroup public ActionResult Index(int id) { List <Route> routes = null; using (var ctx = new GlsunViewEntities()) { routes = ctx.Route.Where(r => r.RGID == id).ToList(); } return(View(routes)); }