public static byte[] ExportSessionCompanyToExcel(SessionCompanyCollection sessionCompanyCollection, string templatePath) { Dictionary<string, object> model = new Dictionary<string, object>(); model["sessionCompanyCollection"] = sessionCompanyCollection; return ExportToExcel(model, templatePath); }
public virtual SessionCompanyCollection GetSessionCompanyHoseList(DateTime UpdateLETime) { try { Database database = DatabaseFactory.CreateDatabase("OnlinePriceConnection"); DbCommand dbCommand = database.GetStoredProcCommand("spAGStock_HOSE_SessionCompanyGet"); database.AddInParameter(dbCommand, "@UpdateLETime", DbType.DateTime, UpdateLETime); SessionCompanyCollection sessionCompanyCollection = new SessionCompanyCollection(); using (IDataReader reader = database.ExecuteReader(dbCommand)) { while (reader.Read()) { SessionCompany sessionCompany = CreateSessionCompanyFromReader(reader); sessionCompanyCollection.Add(sessionCompany); } reader.Close(); } return sessionCompanyCollection; } catch (Exception ex) { // log this exception log4net.Util.LogLog.Error(ex.Message, ex); // wrap it and rethrow throw new ApplicationException(SR.DataAccessGetCustomerListException, ex); } }
private void ExportSessionCompany() { SessionCompanyCollection sessionCompanyCollection = new SessionCompanyCollection(); if (exportSessionCompanySelect.Value == "HOSE") { sessionCompanyCollection = SessionCompanyService.GetSessionCompanyHoseList(ApplicationHelper.ConvertStringToDate(this.exportDateInput.Text)); } else { sessionCompanyCollection = SessionCompanyService.GetSessionCompanyHastcList(ApplicationHelper.ConvertStringToDate(this.exportDateInput.Text)); } ExportService.getMarket = exportSessionCompanySelect.Value; ExportService.TotalSymbol = sessionCompanyCollection.Count; byte[] data = ExportService.ExportSessionCompanyToExcel(sessionCompanyCollection, ApplicationHelper.GetFullPath(ApplicationHelper.ExportSessionCompany)); Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment; filename=\"Thongtin3gia_ngay_" + this.exportDateInput.Text + ".xls\""); Response.AddHeader("Content-Length", data.Length.ToString()); Response.OutputStream.Flush(); Response.OutputStream.Write(data, 0, data.Length); Response.OutputStream.Flush(); }