public FileResult Modificar(ro_rdep_Info model) { string nombre_file = "RDEP-" + model.pe_anio.ToString(); string xml = ""; rdep RDEP = new rdep(); int IdEmpresa = Convert.ToInt32(SessionFixed.IdEmpresa); RDEP = bus_ro_rpde.get_info_xml(model.IdEmpresa, model.Id_Rdep); var ms = new MemoryStream(); var xw = XmlWriter.Create(ms); var serializer = new XmlSerializer(RDEP.GetType()); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); serializer.Serialize(xw, RDEP, ns); xw.Flush(); ms.Seek(0, SeekOrigin.Begin); using (var sr = new StreamReader(ms, Encoding.UTF8)) { xml = sr.ReadToEnd(); } byte[] fileBytes = ms.ToArray(); return(File(fileBytes, "application/xml", nombre_file + ".xml")); }
public ActionResult Index(Rdep_Info model) { string nombre_file = "RDEP"; string xml = ""; rdep rdep = new rdep(); int IdEmpresa = Convert.ToInt32(SessionFixed.IdEmpresa); int IdSucursal = Convert.ToInt32(SessionFixed.IdSucursal); rdep = bus_rpde.get_list(IdEmpresa, Convert.ToInt32(model.pe_anio), model.IdEmpleado); var ms = new MemoryStream(); var xw = XmlWriter.Create(ms); var serializer = new XmlSerializer(rdep.GetType()); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); serializer.Serialize(xw, rdep, ns); xw.Flush(); ms.Seek(0, SeekOrigin.Begin); using (var sr = new StreamReader(ms, Encoding.UTF8)) { xml = sr.ReadToEnd(); } byte[] fileBytes = ms.ToArray(); return(File(fileBytes, "application/xml", nombre_file + ".xml")); }