private void exportCSVAll_Click(object sender, EventArgs e) { IExportFactory factory = new ExportFactory(); IExportFile exporter = factory.getFileExporter("CSV"); using (var folderDialog = new FolderBrowserDialog()) { if (folderDialog.ShowDialog() == DialogResult.OK) { StatusLabel.Text = exporter.export(new TicketServices().getTickets(), folderDialog.SelectedPath + "\\"); } } }
private void exportCSVSelected_Click(object sender, EventArgs e) { if (showIDText.Text == "") { StatusLabel.Text = "No show selected"; return; } IExportFactory factory = new ExportFactory(); IExportFile exporter = factory.getFileExporter("CSV"); using (var folderDialog = new FolderBrowserDialog()) { if (folderDialog.ShowDialog() == DialogResult.OK) { StatusLabel.Text = exporter.export(new TicketServices().getTicketsByShowID(Convert.ToInt32(showIDText.Text)), folderDialog.SelectedPath + "\\"); } } }
public Stream GenerateStudentProfileExport(EducationSecurityPrincipal user, StudentProfileExportModel model, string templatePath) { var students = RetrieveStudentsList(model); var configuration = new StudentProfileExportFieldDescriptor { BirthDateIncluded = model.BirthDateIncluded, ParentNameIncluded = model.ParentNameIncluded, SelectedServiceTypes = ServiceTypeRepository.Items.Where(t => model.SelectedServiceTypeIds.Contains(t.Id)).ToList() }; List <CustomField> displayFields = new List <CustomField>(); foreach (var field in CustomFieldRepository.Items.Where(f => model.SelectedCustomFieldIds.Contains(f.Id))) { IPermission permission = PermissionFactory.Current.Create("StudentProfileExportCustomFieldData", field); if (permission.TryGrantAccess(user)) { displayFields.Add(field); } } configuration.SelectedCustomFields = displayFields; byte[] templateData = File.ReadAllBytes(templatePath); MemoryStream stream = new MemoryStream(); stream.Write(templateData, 0, (int)templateData.Length); using (IExportFile export = ExportFileFactory.Current.Create(typeof(StudentProfileExportFile))) { var mapper = export.GenerateMapper(); List <IEnumerable <object> > data = new List <IEnumerable <object> >(); foreach (var student in students) { data.Add(mapper.MapData(configuration, student, user, Auditor)); } export.Create(stream); export.SetupColumnHeaders(mapper.MapColumnHeadings(configuration)); export.FillData(data); export.SetupFooter(CloudConfigurationManager.GetSetting("StudentProfileExportFooter")); RepositoryContainer.Save(); } return(stream); }
public ExportFilePresenter(IExportFile view) { employeeView = view; }