public HashSet <string> GenerarInventarioWS(string Ruta, ProcesoDto pdto, string Tipo) { try { using (StreamReader sr = new StreamReader(Ruta)) { IntDto.Nombre = string.Empty; IntDto.IP = string.Empty; IntDto.Middleware = string.Empty; while (sr.Peek() >= 0) { string LineaCodigo = sr.ReadLine().Trim(); //if (LineaCodigo.IndexOf("http://www.presidencia.gob.mx") > -1) // LineaCodigo = LineaCodigo; if (!String.IsNullOrEmpty(LineaCodigo)) { // Los datos para los servicios de C# se encuentran dentro de la misma línea if (Tipo.IndexOf("config") > -1) { IntDto = RI.ObtenerInventario(LineaCodigo, pdto); if (!string.IsNullOrEmpty(IntDto.Nombre) && !string.IsNullOrEmpty(IntDto.IP)) { InventarioWS.Add(IntDto.Nombre + "|" + IntDto.IP + "|" + IntDto.Tipo + "|" + IntDto.Middleware); } } // Los datos para los servicios de C# se encuentran dentro de la misma línea if (Tipo.IndexOf("asp") > -1) { IntDto = RI.ObtenerInventario(LineaCodigo, pdto); if (!string.IsNullOrEmpty(IntDto.Nombre) && !string.IsNullOrEmpty(IntDto.IP)) { InventarioWS.Add(IntDto.Nombre + "|" + IntDto.IP + "|" + IntDto.Tipo + "|" + IntDto.Middleware); } } //Los datos para los servicios Java se encuentran en varias líneas if (Tipo.IndexOf("wsdl") > -1) { //string Linea = LineaCodigo.ToLower(); Regex Regex = new Regex(@"service name=""\w+"); Match Match = Regex.Match(LineaCodigo); if (Match.Success) { string Nombre = Regex.Replace(Match.Value, @"service name=", string.Empty); Nombre = Nombre.Replace(@"""", string.Empty).Replace("Service", string.Empty); IntDto.Nombre = Nombre.Trim(); } Regex = new Regex(@"\bhttp://\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\S+\b"); Match = Regex.Match(LineaCodigo); if (Match.Success) { string IP = Match.Value; IntDto.IP = IP.Trim(); } if (!string.IsNullOrEmpty(IntDto.IP)) { if (ObtenMiddleware(pdto.UsuarioID)) { XmlDocument consultaxml = PAvanceXML; foreach (XmlNode Fila in consultaxml.DocumentElement.SelectSingleNode("Middleware").SelectNodes("row")) { if (IntDto.IP.IndexOf(Fila.Attributes["IP"].Value.ToString()) > -1) { IntDto.Middleware = Fila.Attributes["Middleware"].Value.ToString(); break; } } } } } } } if (!string.IsNullOrEmpty(IntDto.Nombre) && !string.IsNullOrEmpty(IntDto.IP)) { InventarioWS.Add(IntDto.Nombre + "|" + IntDto.IP + "|" + IntDto.Tipo + "|" + IntDto.Middleware); } } } catch (Exception Err) { EscribeLogWS("ParseadorWS.GenerarInventarioWS " + Err.Message.ToString()); ProcesoAvanceDto pdtoA = new ProcesoAvanceDto(); Proceso proc = new Proceso(); proc.SeteaAvance("Error", "OK", "X", "--", "--", Err.Message.ToString(), "Error al realizar la descompresión del archivo", pdtoA, pdto); proc.ActualizaProcesoAvance(pdtoA, pdto); } return(InventarioWS); }
public InterfacesDto ObtenerInventario(string LineaCodigo, ProcesoDto pdto) { try { InterfacesDto IntDto = new InterfacesDto(); LineaCodigo = LineaCodigo.Trim(); string Linea = LineaCodigo.ToLower(); //Extraer IP Regex Regex = new Regex(@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"); Match Match = Regex.Match(Linea); if (Match.Success) { Regex = new Regex(@"add key=""\w+.\w+"); Match = Regex.Match(LineaCodigo); if (Match.Success) { string Nombre = Match.Value.Replace(@"""", string.Empty); IntDto.Nombre = Nombre.Replace("add key=", string.Empty); } Regex = new Regex(@"\bhttp://\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\S+\b"); Match = Regex.Match(Linea); if (Match.Success) { string IP = Match.Value; IntDto.IP = IP.Trim(); } if (!string.IsNullOrEmpty(IntDto.Nombre) && !string.IsNullOrEmpty(IntDto.IP)) { IntDto.Tipo = "Out"; } if (!string.IsNullOrEmpty(IntDto.IP)) { if (Proceso.ObtenMiddleware(pdto.UsuarioID)) { XmlDocument consultaxml = Proceso.PAvanceXML; foreach (XmlNode Fila in consultaxml.DocumentElement.SelectSingleNode("Middleware").SelectNodes("row")) { if (IntDto.IP.IndexOf(Fila.Attributes["IP"].Value.ToString()) > -1) { IntDto.Middleware = Fila.Attributes["Middleware"].Value.ToString(); break; } } } } } //Extraer URL Regex RegexURL = new Regex(@"(http|ftp|https):\/\/([\w\-_]+(?:(?:\.[\w\-_]+)+))([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?"); Match MatchURL = RegexURL.Match(Linea); if (MatchURL.Success) { IntDto.Nombre = MatchURL.Value; IntDto.IP = MatchURL.Value; IntDto.Tipo = "Externo"; IntDto.Middleware = ""; } return(IntDto); } catch (Exception ex) { throw new Exception("RevisaInterfaces.ObtenerInventario ", ex); } }