public ActionResult GetSalidaTxtSIDEX(Int16 cicloID, int tipoCaracter) { try { string caract = TipoCaracterList.Where(e => e.TipoCaracterID == tipoCaracter).First().TipoCaracterVAL; string cnnString = ConfigurationManager.ConnectionStrings["MedinetWeb"].ConnectionString; string cmdString = "SP_MWS_SalidaTxtSIDEX"; SqlConnection cnn; SqlCommand cmd; using (cnn = new SqlConnection(cnnString)) { cmd = new SqlCommand(cmdString, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@ciclo", cicloID)); cnn.Open(); SqlDataReader sqlReader = cmd.ExecuteReader(); StringBuilder readerData = new StringBuilder(); readerData.Append(sqlReader.GetName(0) + caract + sqlReader.GetName(1) + caract + sqlReader.GetName(2) + caract + sqlReader.GetName(3) + caract + sqlReader.GetName(4) + caract + sqlReader.GetName(5) + caract + sqlReader.GetName(6) + caract + sqlReader.GetName(7) + caract + sqlReader.GetName(8) + caract + sqlReader.GetName(9) + caract + sqlReader.GetName(10) + caract + sqlReader.GetName(11)); readerData.Append(Environment.NewLine); while (sqlReader.Read()) { readerData.Append(sqlReader[0] + caract + sqlReader[1] + caract + sqlReader[2] + caract + sqlReader[3] + caract + sqlReader[4] + caract + sqlReader[5] + caract + sqlReader[6] + caract + sqlReader[7] + caract + sqlReader[8] + caract + sqlReader[9] + caract + sqlReader[10] + caract + sqlReader[11]); readerData.Append(Environment.NewLine); } byte[] byteArray = Encoding.ASCII.GetBytes(readerData.ToString()); MemoryStream stream = new MemoryStream(byteArray); return(File(stream, "text/plain", "NotasEntrega.txt")); } } catch (Exception ex) { Excepciones.LogException(ex, "SalidaSIDEXController", "GetSalidaSIDEX"); return(null); } }
public ActionResult GetSalidaXmlSIDEX(Int16 cicloID) { try { string cnnString = ConfigurationManager.ConnectionStrings["MedinetWeb"].ConnectionString; string cmdString = "SP_MWS_SalidaXmlSIDEX"; SqlConnection cnn; SqlCommand cmd; using (cnn = new SqlConnection(cnnString)) { cmd = new SqlCommand(cmdString, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@ciclo", cicloID)); cnn.Open(); string readerData = string.Empty; using (XmlReader reader = cmd.ExecuteXmlReader()) { while (reader.Read()) { readerData += reader.ReadOuterXml(); } } XDocument doc = XDocument.Parse(readerData); byte[] byteArray = Encoding.ASCII.GetBytes(doc.ToString()); MemoryStream stream = new MemoryStream(byteArray); return(File(stream, "application/xml", "NotasEntrega.xml")); } } catch (Exception ex) { Excepciones.LogException(ex, "SalidaSIDEXController", "GetSalidaSIDEX"); return(null); } }