public ActionResult Index() { var xml = XDocument.Load(Server.MapPath("~/Reports/Reportes.xml")); IList <Reporte> reportes = new List <Reporte>(); if (xml != null) { XNamespace ns = xml.Root.GetDefaultNamespace(); var x = xml.Descendants().Where(q => q.Name.LocalName == "Reportes").FirstOrDefault(); Reports.Controls controls = new Reports.Controls(); x.Descendants().ToList().ForEach((e) => { reportes.Add(new Reporte { name = e.Attribute("name").Value, text = e.Attribute("text").Value, description = e.Value }); }); } //ViewBag.Reportes = reportes; return(View(reportes)); }
public ActionResult ViewReport(string reporte) { Dictionary <string, string> parametros = new Dictionary <string, string>(); foreach (string i in Request.QueryString.AllKeys) { parametros.Add(i, Request.QueryString.Get(i)); } ViewBag.Reporte = reporte; var xml = XDocument.Load(Server.MapPath("~/Reports/" + reporte + ".data")); if (xml != null) { XNamespace ns = xml.Root.GetDefaultNamespace(); var x = xml.Descendants().Where(q => q.Name.LocalName == "Params").FirstOrDefault(); Reports.Controls controls = new Reports.Controls(); x.Descendants().ToList().ForEach((e) => { var type = e.Attribute("type").Value ?? "textbox"; var name = e.Attribute("name").Value; var label = e.Attribute("label").Value == null ? e.Attribute("name").Value.Replace('_', ' ') : e.Attribute("label").Value; var value = ""; if (parametros.ContainsKey(name)) { value = parametros[name]; } if (type == "textbox") { controls.AddTextBox(new { label = label, name = name, value = value }); } if (type == "date") { controls.AddDate(new { label = label, name = name, value = value }); } }); ViewBag.Parametros = controls.Render(); } return(View("ReportViewer")); }