/// <summary> /// Constructor para inicializar la plantilla con el ID de un proyecto específico /// </summary> /// <param name="idProyecto"></param> public EnlaceViewModel(int idEnlace, int idProyecto) { this.idEnlace = idEnlace; this.idProyecto = idProyecto; //this.proyectoActual = new Proyecto(idProyecto); this.enlaceActual = new Enlace(idEnlace, idProyecto); this.listaNodos = new List<SelectListItem>(); Data.dsTopologiaTableAdapters.EnlacesTableAdapter Adapter = new Data.dsTopologiaTableAdapters.EnlacesTableAdapter(); Data.dsTopologia.EnlacesDataTable dt = Adapter.SelectEnlace(idProyecto, idEnlace); if (dt.Rows.Count > 0) { Data.dsTopologia.EnlacesRow dr = dt[0]; this.idEnlace = idEnlace; this.idProyecto = idProyecto; if (!dr.IscNombreNull()) this.cNombre = dr.cNombre; if (!dr.IsnBandwidthNull()) this.nBandwidth = dr.nBandwidth; if (!dr.IsnPesoAdministrativoNull()) this.nPesoAdministrativo = dr.nPesoAdministrativo; if (!dr.IsidRouterANull()) this.idRouterA = dr.idRouterA; if (!dr.IsidRouterBNull()) this.idRouterB = dr.idRouterB; if (!dr.IscAfinidadNull()) this.idAfinidad = dr.idAfinidad; //var idRouterA = this.idRouterA; //var idRouterB = this.idRouterB; Router routerA = new LSR(idProyecto, this.idRouterA); Router routerB = new LSR(idProyecto, this.idRouterB); this.cNombreRouterA = routerA.cHostname; this.cNombreRouterB = routerB.cHostname; } List<Afinidad> listaAfinidades = Afinidad.SelectListaAfinidades(this.idProyecto); this.dpAfinidades = Afinidad.ConvertDropdownListaAfinidades(listaAfinidades); }
/// <summary> /// Devuelve la lista de nodos en un proyecto, o dado idRouter, la lista de nodos/enlaces adyacentes /// </summary> /// <param name="idProyecto"></param> /// <returns></returns> public static List<Router> SelectListaNodosDisponibles(int idProyecto, int? idRouter, int nBandwidthReservado) { List<Router> listaNodos = new List<Router>(); Data.dsTopologiaTableAdapters.NodosAdyacentesTableAdapter Adapter = new Data.dsTopologiaTableAdapters.NodosAdyacentesTableAdapter(); Data.dsTopologia.NodosAdyacentesDataTable dt = Adapter.SeleccionarNodosAdyacentes(idProyecto, idRouter, nBandwidthReservado); foreach (var dr in dt) { LSR temp = new LSR(dr.idProyecto, dr.idRouter != idRouter ? dr.idRouter : dr.idRouter2); temp.listaEnlaces = new List<Enlace>(); temp.listaEnlaces.Add(new Enlace(dr.idEnlace, dr.idProyecto)); listaNodos.Add(temp); } return listaNodos; }
public ActionResult selectNombresRouters(int idEnlace, int idProyecto) { Enlace e = new Enlace(idEnlace, idProyecto); var idRouterA = e.idRouterA; var idRouterB = e.idRouterB; Router routerA = new LSR(idRouterA, idProyecto); Router routerB = new LSR(idRouterB, idProyecto); return Json(new { nombreRouterA = routerA.cHostname, nombreRouterB = routerB.cHostname }, JsonRequestBehavior.AllowGet); }
public RouterJson(int idProyecto, int idRouter) { LSR temp = new LSR(idProyecto, idRouter); this.key = temp.idRouter; this.name = temp.cHostname; this.source = "/Content/Images/router.png"; this.loopback_ip = temp.cRouterID; if (temp.cx != 0 && temp.cy != 0) this.loc = temp.cx + " " + temp.cy; this.id_proyecto = temp.idProyecto; }
/// <summary> /// Genera una lista de routers y enlaces en base a los contenidos de la tabla CSV /// </summary> /// <param name="tablaDatos"></param> public void GenerarTopologia(List<Tabla> tablaDatos) { tablaDatos = tablaDatos.GroupBy(x => x.Hostname).Select(x => x.First()).ToList(); List<Router> listaRouters = new List<Router>(); List<Enlace> listaEnlaces = new List<Enlace>(); Dictionary<string, int> routerIDs = new Dictionary<string, int>(); for(int i = 0; i < tablaDatos.Count; ++i) { LSR temp = new LSR(); temp.idRouter = i + 1; temp.cHostname = tablaDatos[i].Hostname; temp.cRouterID = tablaDatos[i].OSPFRouterID.Trim(); temp.listaEnlaces = new List<Enlace>(); routerIDs.Add(temp.cRouterID, temp.idRouter); listaRouters.Add(temp); } foreach(var item in tablaDatos) { var values = item.OSPFNeighborRouterID.Split(','); foreach(var value in values) { Enlace temp = new Enlace(); int thisID = routerIDs[item.OSPFRouterID.Trim()]; int otherID = routerIDs[value.Trim()]; if (thisID < otherID) { temp.idRouterA = thisID; temp.idRouterB = otherID; listaRouters[thisID - 1].listaEnlaces.Add(temp); listaEnlaces.Add(temp); } else if (thisID > otherID) { temp.idRouterA = otherID; temp.idRouterB = thisID; listaRouters[thisID - 1].listaEnlaces.Add(temp); listaEnlaces.Add(temp); } } } listaEnlaces = listaEnlaces.GroupBy(d => new { d.idRouterA, d.idRouterB }) .Select(d => d.First()) .ToList(); for(int i = 0; i < listaEnlaces.Count; ++i) { listaEnlaces[i].idEnlace = i + 1; } this.listadoRouters = listaRouters; this.listadoEnlaces = listaEnlaces; this.InsertUpdateListaRouters(); this.InsertUpdateListaEnlaces(); }
/// <summary> /// Retorna el listado de routers en la topología de un proyecto /// </summary> /// <param name="idProyecto"></param> /// <returns></returns> public static List<Router> SelectListaRouters(int idProyecto) { List<Router> listaRouters = new List<Router>(); Data.dsTopologiaTableAdapters.RoutersTableAdapter Adapter = new Data.dsTopologiaTableAdapters.RoutersTableAdapter(); Data.dsTopologia.RoutersDataTable dt = Adapter.SelectRoutersProyecto(idProyecto); foreach (var dr in dt) { LSR temp = new LSR(); temp.idRouter = dr.idRouter; temp.idProyecto = dr.idProyecto; if (!dr.IscHostnameNull()) temp.cHostname = dr.cHostname.Trim(); if (!dr.IscRouterIDNull()) temp.cRouterID = dr.cRouterID.Trim(); if (!dr.IscXNull()) temp.cx = dr.cX; if (!dr.IscYNull()) temp.cy = dr.cY; listaRouters.Add(temp); } return listaRouters; }