public string ExportFilterData(CampusFilter campusFilter) { DataTable dt = new DataTable(); string currentConnection = ConfigurationManager.ConnectionStrings["staar"].ConnectionString; using (SqlConnection connection = new SqlConnection(currentConnection)) { string query = getFilterQuery(campusFilter); connection.Open(); SqlCommand command = new SqlCommand(query, connection); command.AddArrayParameters(campusFilter.Demographic, "demo"); command.AddArrayParameters(campusFilter.Campus, "campus"); command.AddArrayParameters(campusFilter.Year, "year"); SqlDataReader reader = command.ExecuteReader(); dt.Load(reader); connection.Close(); } dt.TableName = "Table1Name"; var fileName = getFileName(); ExcelExportHelper.GenerteExcel(dt, getHeaderMapping(), Path.GetTempPath() + fileName); return fileName; }
public List<Dictionary<string, object>> GetCampusReport(CampusFilter campusFilter) { List<Dictionary<string, object>> campusResult; string currentConnection = ConfigurationManager.ConnectionStrings["staar"].ConnectionString; using (SqlConnection connection = new SqlConnection(currentConnection)) { string query = getFilterQuery(campusFilter); connection.Open(); SqlCommand command = new SqlCommand(query, connection); command.AddArrayParameters(campusFilter.Demographic, "demo"); command.AddArrayParameters(campusFilter.Campus, "campus"); command.AddArrayParameters(campusFilter.Year, "year"); SqlDataReader reader = command.ExecuteReader(); campusResult = reader.GetAllRecords(); connection.Close(); } return campusResult; }