protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
private static List <CardSlotInfo> GetCardSlotInfo(TcpClientService tcp, DeviceOverview deviceView) { List <CardSlotInfo> cardSlotInfo = new List <CardSlotInfo>(); var context = new GlsunViewEntities(); foreach (var e in deviceView.Slots) { CardSlotInfo slotInfo = new CardSlotInfo { Slot = e.SlotNumber, Status = e.IsInsert ? "在位" : "N/A", CardType = e.CardType }; //其他信息 switch (e.CardType) { case "EDFA": EDFACommService srvEDFA = new EDFACommService(tcp, e.SlotNumber); EDFAInfo edfaInfo = new EDFAInfo(); edfaInfo.RefreshData(srvEDFA); switch (edfaInfo.Work_Mode) { case 0: slotInfo.WorkMode = "其他"; break; case 1: slotInfo.WorkMode = "ACC模式"; break; case 2: slotInfo.WorkMode = "APC模式"; break; case 3: slotInfo.WorkMode = "AGC模式"; break; default: slotInfo.WorkMode = ""; break; } slotInfo.HardwareVersion = edfaInfo.Hardware_Version; slotInfo.SoftwareVersion = edfaInfo.Software_Version; var alarm = context.AlarmInformation .Where(a => a.DAddress == deviceView.IP && a.AISlot == slotInfo.Slot) .OrderByDescending(a => a.AITime).FirstOrDefault(); if (alarm != null) { slotInfo.CurrentAlarm = alarm.AIContent; } else { slotInfo.CurrentAlarm = ""; } break; case "OEO": OEOCommService srvOEO = new OEOCommService(tcp, e.SlotNumber); OEOInfo oeoInfo = new OEOInfo(); oeoInfo.RefreshData(srvOEO); slotInfo.HardwareVersion = oeoInfo.Hardware_Version; slotInfo.SoftwareVersion = oeoInfo.Software_Version; //SFP模块是否有转发 bool bTranspond = false; //SFP模块是否有环回 bool bLoopback = false; foreach (var spf in oeoInfo.SFPSet) { if (spf.Work_Mode == 1) { bTranspond = true; } if (spf.Work_Mode == 3) { bLoopback = true; } } if (bTranspond && bLoopback) { slotInfo.WorkMode = "转发+环回"; } else if (bTranspond) { slotInfo.WorkMode = "转发"; } else if (bLoopback) { slotInfo.WorkMode = "环回"; } else { slotInfo.WorkMode = "N/A"; } var alarmOEO = context.AlarmInformation .Where(a => a.DAddress == deviceView.IP && a.AISlot == slotInfo.Slot) .OrderByDescending(a => a.AITime).FirstOrDefault(); if (alarmOEO != null) { slotInfo.CurrentAlarm = alarmOEO.AIContent; } else { slotInfo.CurrentAlarm = ""; } break; case "OLP": OLPCommService srvOLP = new OLPCommService(tcp, e.SlotNumber); OLPInfo olpInfo = new OLPInfo(); olpInfo.RefreshData(srvOLP); slotInfo.HardwareVersion = olpInfo.Hardware_Version; slotInfo.SoftwareVersion = olpInfo.Software_Version; switch (olpInfo.Work_Mode) { case 0: slotInfo.WorkMode = "手动"; break; case 1: slotInfo.WorkMode = "自动"; break; default: break; } var alarmOLP = context.AlarmInformation .Where(a => a.DAddress == deviceView.IP && a.AISlot == slotInfo.Slot) .OrderByDescending(a => a.AITime).FirstOrDefault(); if (alarmOLP != null) { slotInfo.CurrentAlarm = alarmOLP.AIContent; } else { slotInfo.CurrentAlarm = ""; } break; default: slotInfo.CardType = "N/A"; slotInfo.HardwareVersion = "N/A"; slotInfo.SoftwareVersion = "N/A"; slotInfo.WorkMode = "N/A"; slotInfo.CurrentAlarm = "N/A"; break; } cardSlotInfo.Add(slotInfo); } context.Dispose(); return(cardSlotInfo); }