Пример #1
0
        public ActionResult Create(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();
                    if (loginUser != null)
                    {
                        room.CreatorID    = loginUser.ID;
                        room.CreationTime = DateTime.Now;
                    }

                    ctx.MachineRoom.Add(room);
                    ctx.SaveChanges();
                }
                json.Data = new { Code = "", Data = "", Message = "保存成功" };
            }
            catch (Exception ex)
            {
                json.Data = new { Code = "Exception", Data = "", Message = ex.Message };
            }
            return(json);
        }
Пример #2
0
        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);
        }
Пример #3
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(int id)
        {
            MachineRoom room = null;

            using (var ctx = new GlsunViewEntities())
            {
                room = ctx.MachineRoom.Find(id);
            }
            ViewBag.Action = "Edit";
            return(View("Create", room));
        }
Пример #4
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <returns></returns>
        public ActionResult Create()
        {
            MachineRoom room = new MachineRoom();

            return(View(room));
        }
Пример #5
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>();
            }
        }