Example #1
0
        // 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));
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        private static void GetDeviceOverView(int id, out DeviceOverview deviceView, out DeviceInfo info, out List <CardSlotInfo> cardSlotInfo)
        {
            MachineFrame frame = null;
            MachineShelf shelf = null;
            MachineRoom  room  = null;

            using (var ctx = new GlsunViewEntities())
            {
                frame = ctx.MachineFrame.Find(id);
                shelf = ctx.MachineShelf.Find(frame.MSID);
                room  = ctx.MachineRoom.Find(shelf.MRID);
            }
            var tcp = TcpClientServicePool.GetService(frame.MFIP, frame.MFPort.Value);
            //设备整体状态信息
            NMUCommService nmu = new NMUCommService(tcp);

            deviceView         = new DeviceOverview();
            deviceView.IP      = frame.MFIP;
            deviceView.Port    = frame.MFPort.Value;
            deviceView.MCUType = frame.MFMCUType;
            //主控卡信息
            NMUInfo nmuInfo = new NMUInfo();

            //设备信息
            info = new DeviceInfo();
            //卡槽信息
            cardSlotInfo = new List <CardSlotInfo>();
            if (tcp != null)
            {
                try
                {
                    deviceView.RefreshStatus(nmu);
                    nmuInfo.RefreshStatus(nmu);
                    info = new DeviceInfo
                    {
                        Type         = string.Format("{0}-{1}U-{2}", frame.MFName, deviceView.Unit, deviceView.Type),
                        Shelf        = string.Format("{0}-{1},第{2}层", shelf.MSName, shelf.MSNumber, frame.MSLayer),
                        Room         = room.MRName,
                        Address      = room.MRAddress,
                        Description  = room.MRDescription,
                        SerialNumber = nmuInfo.Serial_Number,
                        IP           = frame.MFIP,
                        Mask         = nmuInfo.Subnet_Mask,
                        MACAddr      = deviceView.MACAddr
                    };
                    cardSlotInfo = GetCardSlotInfo(tcp, deviceView);
                }
                catch (Exception ex)
                {
                    deviceView.Type = "NoResponse";
                    deviceView.Unit = 4;
                }
                finally
                {
                    TcpClientServicePool.FreeService(tcp);
                }
            }
            else
            {
                throw new TimeoutException("设备连接超时");
            }

            if (deviceView.Slots == null)
            {
                deviceView.Slots = new List <Slot>();
            }
        }