protected void Page_Load(object sender, EventArgs e) { int tipoPuntoId = 0; int departamentoId = 0; if (Request.QueryString.Get("tipoPunto") != string.Empty) { tipoPuntoId = Convert.ToInt32(Request.QueryString.Get("tipoPunto")); departamentoId = Convert.ToInt32(Request.QueryString.Get("departamentoId")); } Response.Expires = 0; Response.ContentType = "application/json"; XmlDocument oDocument = new XmlDocument(); StringBuilder sb = new StringBuilder(); GestorPuntos gestorPuntos = new GestorPuntos(); ListPunto ListPunto = gestorPuntos.GetManyPuntoByTipoId(tipoPuntoId, departamentoId); JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); string jsonString = javaScriptSerializer.Serialize(ListPunto); Response.Write(jsonString); Response.OutputStream.Flush(); Response.OutputStream.Close(); }
/// <summary> /// Trae el punto de origen del usuario de acuerdo a su registro de ubicacion de trabajo /// </summary> /// <returns>Data Table con los datos de la ubicacion</returns> public ListPunto GetManyPuntoByTipoId(int tipoPuntoId, int departamentoId) { ListPunto listPunto; try { var conector = new ConectorPuntos(); DataTable dtPuntos = conector.GetManyPuntoByTipoId(tipoPuntoId, departamentoId); listPunto = new ListPunto { success = true, message = String.Empty }; listPunto.listPunto = new List <Punto>(); foreach (var item in from DataRow row in dtPuntos.Rows select new Punto { PuntoId = Convert.ToInt32(row["PUNTO_ID_IN"]), Nombre = Convert.ToString(row["NOMBRE_NV"]), TipoPuntoDesc = Convert.ToString(row["TIPO_PUNTO"]), IconUrl = Convert.ToString(row["URL_IMAGE"]), DepartamentoDesc = Convert.ToString(row["DEPARTAMENTO"]), Latitud = Convert.ToDecimal(row["LATITUD_DC"]), Longitud = Convert.ToDecimal(row["LONGITUD_DC"]), Direccion = Convert.ToString(row["DIRECCION_NV"]), htmlDescripcion = Convert.ToString(row["HTML_DESCRIPCION"]) }) { listPunto.listPunto.Add(item); } } catch (Exception ex) { TextLogger.LogError(LogManager.GetCurrentClassLogger(), ex, "Error En el metodo: getManyPuntoByTipoId"); listPunto = new ListPunto { success = false, message = "Error al realizar la consulta" }; } return(listPunto); }