protected void GenerateLinkData(DeviceBase dev) { foreach (Link lnk in dev.GetLinkList()) { // 两种设备都是思科交换机时,无需添加iou2net的信息 if (lnk.SrcDevice.DP.Type == lnk.DstDevice.DP.Type) continue; string str = ""; // 配置语句 int srcType = (int)lnk.SrcDevice.DP.Type; // 本端设备类型 int srcIndex = (int)lnk.SrcDevice.DP.Index; // 本端设备序号 int dstType = (int)lnk.DstDevice.DP.Type; // 远端设备类型 int dstIndex = (int)lnk.DstDevice.DP.Type; // 远端设备序号 int srcPort = 0; // 本端设备端口 int dstPort = 0; // 远端设备端口 srcPort = Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"]) + (int)lnk.SrcDevice.DP.Type * 1000 + (int)lnk.SrcDevice.DP.Index * 100 + lnk.SrcCard.Number * 10 + lnk.SrcSocket.Number; dstPort = Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"]) + (int)lnk.DstDevice.DP.Type * 1000 + (int)lnk.DstDevice.DP.Index * 100 + lnk.DstCard.Number * 10 + lnk.DstSocket.Number; string serverip = ConfigurationManager.AppSettings["NormalServerIP"]; // 本地端口 str = "../public/iou2net.pl -u "; if (lnk.SrcDevice == dev) { if (lnk.DstCard.Card_Prefix.Contains("FXP")) dstPort += (Int32.Parse(ConfigurationManager.AppSettings["SerialPortBase"]) - Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"])); str += srcPort + ":" + serverip + ":" + dstPort; str += " -p " + lnk.GUID + " & " + "\\n"; } else { if (lnk.SrcCard.Card_Prefix.Contains("FXP")) srcPort += (Int32.Parse(ConfigurationManager.AppSettings["SerialPortBase"]) - Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"])); str += dstPort + ":" + serverip + ":" + srcPort; str += " -p " + lnk.GUID + " & " + "\\n"; } fileContent += str + "\\nsleep 2\\n"; startTimeOut += 4; } }
/// <summary> /// 添加连接,之所以使用偏移而不使用起始点,是因为在保存文件时,double会导致精度问题,从而点跑出框外 /// </summary> /// <param name="pt1">起点偏移</param> /// <param name="pt2">终点偏移</param> public void AddLink(Point pt1, Point pt2, DeviceCard srcCard, DeviceCard dstCard, DeviceSocket srcSocket, DeviceSocket dstSocket, DeviceBase dest) { Link lnk = new Link(); lnk.PTSrcOffset = pt1; lnk.PTDstOffset = pt2; lnk.PTSRC = new Point( pt1.X + (double)ImageBorder.GetValue(Canvas.LeftProperty), pt1.Y + (double)ImageBorder.GetValue(Canvas.TopProperty)); lnk.PTDST = new Point( pt2.X + (double)dest.ImageBorder.GetValue(Canvas.LeftProperty), pt2.Y + (double)dest.ImageBorder.GetValue(Canvas.TopProperty)); lnk.PaintBoard = paintBoard; lnk.SrcDevice = this; lnk.SrcCard = srcCard; lnk.SrcSocket = srcSocket; lnk.DstDevice = dest; lnk.DstCard = dstCard; lnk.DstSocket = dstSocket; lnk.TextSrc.Text = srcCard.toString(); if (srcCard.ShowSocket) lnk.TextSrc.Text += "/" + srcSocket.toString(); lnk.TextDst.Text = dstCard.toString(); if (dstCard.ShowSocket) lnk.TextDst.Text += "/" + dstSocket.toString(); try { if (SetDeviceSocketUsed(srcCard, srcSocket, this) && SetDeviceSocketUsed(dstCard, dstSocket, dest)) { linkList.Add(lnk); dest.GetLinkList().Add(lnk); paintBoard.Children.Add(lnk); AdjustLinkPosition(lnk); destination = null; } } catch (System.Exception ex) { MessageBox.Show(ex.ToString()); } }
protected void GenerateLinkData(DeviceBase dev) { foreach (Link lnk in dev.GetLinkList()) { // 两种设备都是思科路由器时,无需添加iou2net的信息 if (lnk.SrcDevice.DP.Type == lnk.DstDevice.DP.Type) continue; string str = ""; // 配置语句 int srcType = (int)lnk.SrcDevice.DP.Type; // 本端设备类型 int srcIndex = (int)lnk.SrcDevice.DP.Index; // 本端设备序号 int dstType = (int)lnk.DstDevice.DP.Type; // 远端设备类型 int dstIndex = (int)lnk.DstDevice.DP.Type; // 远端设备序号 int srcPort = 0; // 本端设备端口 int dstPort = 0; // 远端设备端口 int srcportbase = Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"]); int dstportbase = Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"]); if (lnk.SrcCard.Card_Type == DeviceCardType.DEVICE_CARD_TYPE_SERIAL) { srcportbase = Int32.Parse(ConfigurationManager.AppSettings["SerialPortBase"]); dstportbase = Int32.Parse(ConfigurationManager.AppSettings["SerialPortBase"]); } srcPort = srcportbase + (int)lnk.SrcDevice.DP.Type * 1000 + (int)lnk.SrcDevice.DP.Index * 100 + lnk.SrcCard.Number * 10 + lnk.SrcSocket.Number; dstPort = dstportbase + (int)lnk.DstDevice.DP.Type * 1000 + (int)lnk.DstDevice.DP.Index * 100 + lnk.DstCard.Number * 10 + lnk.DstSocket.Number; string serverip = ConfigurationManager.AppSettings["LocalServerIP"]; // 本地端口 str = "/home/lab_admin/public/CiscoIOU/iou2net.pl -u "; if (lnk.SrcDevice == dev) { if (lnk.DstCard.Card_Prefix.Contains("FXP")) dstPort += (Int32.Parse(ConfigurationManager.AppSettings["SerialPortBase"]) - Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"])); if (lnk.DstDevice.DP.Type == DeviceType.DEVICE_TYPE_CISCOSWITCHER) serverip = ConfigurationManager.AppSettings["SwitchServerIP"]; str += srcPort + ":" + serverip + ":" + dstPort; str += " -p " + lnk.GUID + " & " + "\\n"; } else { if (lnk.SrcCard.Card_Prefix.Contains("FXP")) srcPort += (Int32.Parse(ConfigurationManager.AppSettings["SerialPortBase"]) - Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"])); if (lnk.SrcDevice.DP.Type == DeviceType.DEVICE_TYPE_CISCOSWITCHER) serverip = ConfigurationManager.AppSettings["SwitchServerIP"]; str += dstPort + ":" + serverip + ":" + srcPort; str += " -p " + lnk.GUID + " & " + "\\n"; } fileContent += str + "\\nsleep 2\\n"; startTimeOut += 4; } }