public static Report ListViewModelToReport <T>(this List <T> list) { var report = new Report(list.ToReportSource()); foreach (var item in typeof(T).GetProperties()) { Object[] myAttributes = item.GetCustomAttributes(true); if (myAttributes.Length > 0) { foreach (var itemAtt in myAttributes) { if (itemAtt.GetType() == typeof(IsTotalAttribute)) { report.DataFields[item.Name].ShowTotals = true; } else { report.DataFields[item.Name].HeaderText = (itemAtt as DisplayNameAttribute).Name + " "; } } } else { report.DataFields[item.Name].Hidden = true; } } return(report); }
// // Sample URLs: // http://localhost:X/Home/Index/Reporting/Expando/Expando.html // http://localhost:X/Home/Index/Reporting/Expando/Expando.xls // http://localhost:X/Home/Index/Reporting/Expando/Expando.txt // http://localhost:X/Home/Index/Reporting/Expando/Expando.pdf (REQUIRES ABCPDF INSTALLED) // public ReportResult Expando() { var all = new List <ExpandoObject>(); dynamic d = new ExpandoObject(); d.DistrictNumber = 1566; d.SchoolId = 1; d.FullName = "Matt Hidinger"; dynamic d2 = new ExpandoObject(); d2.DistrictNumber = 13566; d2.SchoolId = 1; d2.FullName = "Bob Jones"; all.Add(d); all.Add(d2); var report = new Report(all.ToReportSource()); // Customize the Text Fields report.TextFields.Title = "Expando Report"; report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works"; report.TextFields.Footer = "Copyright 2011 (c) The Doddle Project"; report.TextFields.Header = string.Format(@"Report Generated: {0}", DateTime.Now); report.DataFields["SchoolId"].HeaderText = "School"; // Render hints allow you to pass additional hints to the reports as they are being rendered report.RenderHints.BooleanCheckboxes = true; return(new ReportResult(report)); }
private void btnPrint_Click(object sender, EventArgs e) { frmRaporDialog frm = new frmRaporDialog(true, true, true, false); frm.ShowDialog(); try { ReportTo?dest = frm.GetReportDestination(); if (dest.HasValue) { if (dest.Value != ReportTo.CrytalReport) { // Create the report and turn our query into a ReportSource var report = new Report(_data.ToReportSource()); // Customize the Text Fields report.TextFields.Title = "Gün gün Kasa Raporu"; report.TextFields.Header = string.Format(@" Kasa :{0} Rapor Tarihi: {1} Tarih Aralığı:{2} ", cmboxKasalar.Text, DateTime.Now, GetTarihAraligi()); // Render hints allow you to pass additional hints to the reports as they are being rendered report.DataFields["Gelir"].ShowTotals = true; report.DataFields["Gider"].ShowTotals = true; report.DataFields["Bakiye"].ShowTotals = true; // Customize the data fields report.RenderHints["HtmlStyle"] = "th { font-size: 14px !important;font-weight:bold !important}"; report.DataFields["Gelir"].DataFormatString = "{0:F2}"; report.DataFields["Gider"].DataFormatString = "{0:F2}"; report.DataFields["Bakiye"].DataFormatString = "{0:F2}"; report.DataFields["Tarih"].DataFormatString = "{0:d}"; string fileName = "gunGunKasaRaporu.xls"; IReportWriter writer = new ExcelReportWriter(); if (dest.Value == ReportTo.Html) { writer = new HtmlReportWriter(); fileName = "gunGunKasaRaporu.html"; } else if (dest.Value == ReportTo.Csv) { writer = new DelimitedTextReportWriter(); fileName = "gunGunKasaRaporu.txt"; } string file = Path.Combine(Engine.DokumanPath(), fileName); FileStream fs = new FileStream(file, FileMode.Create); writer.WriteReport(report, fs); fs.Close(); Process prc = new Process(); prc.StartInfo.FileName = file; prc.Start(); } } } catch (Exception exc) { MessageBox.Show(exc.Message); LogWrite.Write(exc); } }
private static Report PrepPartyReport(List <PartyControl> parts) { Report partiesReport = new Report(parts.ToReportSource()); partiesReport.TextFields.Title = "Parties"; partiesReport.DataFields["IsInDesignMode"].Hidden = true; partiesReport.DataFields["InvalidVotes"].Hidden = true; return(partiesReport); }
public ReportResult ListOfObjects() { var list = new List <object>(); list.Add(new { FirstName = "Matt", LastName = "Hidinger" }); var report = new Report(list.ToReportSource()); return(new ReportResult(report)); }
private Report PrepCandReport(List <CandidateControl> cands) { var voters = _dataBaseManager.Voter.Get(); Report candReport = new Report(cands.ToReportSource()); var valid = voters.Count(x => x.Voted && x.VoteValid); var invalid = voters.Count(x => x.Voted && !x.VoteValid); candReport.TextFields.Header = $"Votes valid/invalid - {valid}/{invalid} " + Environment.NewLine + $"Blocked attempts {_dataBaseManager.Statistic.Get()}" + Environment.NewLine; candReport.TextFields.Title = "Candidates"; candReport.DataFields["Vote"].Hidden = true; candReport.DataFields["InvalidVotes"].Hidden = true; candReport.DataFields["IsInDesignMode"].Hidden = true; return(candReport); }
/// <summary> /// Converts a list of elements to a report source /// </summary> /// <param name="elements"> /// An enumerable of elements /// </param> /// <param name="keys"> /// They keys with which the values can be fetched from one element /// </param> /// <param name="valueSelector"> /// The function with which one value can be fetched given one key and one element /// </param> /// <returns>The report source that was created from the elements</returns> public static IReportSource ToReportSource <T>(IEnumerable <T> elements, string[] keys, Func <T, string, object> valueSelector) { var expandos = new List <ExpandoObject>(); foreach (var element in elements) { var expando = new ExpandoObject(); var expandoDictionary = (IDictionary <string, object>)expando; foreach (var key in keys) { var value = valueSelector(element, key); expandoDictionary[key] = value; } expandos.Add(expando); } return(expandos.ToReportSource()); }
public ReportResult Index() { var list = new List <AnnotatedProduct>(); list.Add(new AnnotatedProduct { Name = "Product 1", Price = 500 }); list.Add(new AnnotatedProduct { Name = "Product 2", Price = 600 }); list.Add(new AnnotatedProduct { Name = "Product 3", Price = 700 }); var report = new Report(list.ToReportSource()); // Adavanced data field formatting using a callback delegate report.DataFields["OutOfStock"].FormatAs <bool>(value => value ? "Yes" : "No"); return(new ReportResult(report)); }
internal ReportResult AllSamples(LongLineTrip trip) { var repo = TubsDataService.GetRepository<LongLineCatch>(MvcApplication.CurrentSession); var samples = repo.FilterBy(s => s.FishingSet.Trip.Id == trip.Id).OrderBy(s => s.FishingSet.SetNumber); // It would be cool if I could use LINQ like I do for Purse Seine, but NHibernate doesn't like the // cool LINQ project necessary to find the Lat/Lon for the start of set // Latitude = s.FishingSet.EventList.Where(sh => sh.ActivityType == Spc.Ofp.Tubs.DAL.Common.HaulActivityType.StartOfSet).First().Latitude IList<LengthSampleLineItem> items = new List<LengthSampleLineItem>(samples.Count()); foreach (var sample in samples) { string latitude = String.Empty; string longitude = String.Empty; string eez = String.Empty; var startOfSet = sample.FishingSet.EventList.Where(sh => sh.ActivityType == Spc.Ofp.Tubs.DAL.Common.HaulActivityType.StartOfSet).FirstOrDefault(); if (null != startOfSet) { latitude = startOfSet.Latitude; longitude = startOfSet.Longitude; eez = startOfSet.EezCode; } items.Add(new LengthSampleLineItem() { SetDate = sample.FishingSet.SetDate, Latitude = latitude, Longitude = longitude, Eez = eez, SetNumber = sample.FishingSet.SetNumber.HasValue ? sample.FishingSet.SetNumber.Value : -1, SequenceNumber = sample.SampleNumber.HasValue ? sample.SampleNumber.Value : -1, // All 1 for obstrip_id 4177? SpeciesCode = sample.SpeciesCode, Length = sample.Length.HasValue ? sample.Length.Value : -1 }); } var report = new Report(items.ToReportSource()); report.TextFields.Title = string.Format("Length frequency summary for trip {0}", trip.SpcTripNumber); return new ReportResult(report); }
private void btnPrint_Click(object sender, EventArgs e) { frmRaporDialog frm = new frmRaporDialog(true, true, true, false); frm.ShowDialog(); ReportTo?dest = frm.GetReportDestination(); if (dest.HasValue) { try { if (dest != ReportTo.CrytalReport) { List <DurumGelirGider> liste = new List <DurumGelirGider>(); liste.Add(_gelirler); var report = new Report(liste.ToReportSource()); // Customize the Text Fields report.RenderHints.IncludePageNumbers = true; report.TextFields.Title = "Genel Durum Raporu"; report.TextFields.Header = string.Format(@" Rapor Tarihi:{0} Toplam Gelir:{1:F} Toplam Gider:{2:F} Bakiye:{3:F} Rapor Tarih Aralığı:{4} ", DateTime.Now, toplamGelir(), toplamGider(), bakiye(), GetTarihAraligi()); //report.DataFields["Alacak"].DataFormatString = "{0:F2}"; //report.DataFields["Borc"].DataFormatString = "{0:F2}"; //report.DataFields["AlacakBakiyesi"].DataFormatString = "{0:F2}"; //report.DataFields["BorcBakiyesi"].DataFormatString = "{0:F2}"; string fileName = "genelDurumRaporu.xls"; IReportWriter writer = new ExcelReportWriter(); if (dest.Value == ReportTo.Html) { writer = new HtmlReportWriter(); fileName = "genelDurumRaporu.html"; } else if (dest.Value == ReportTo.Csv) { writer = new DelimitedTextReportWriter(); fileName = "genelDurumRaporu.txt"; } string file = Path.Combine(Engine.DokumanPath(), fileName); FileStream fs = new FileStream(file, FileMode.Create); writer.WriteReport(report, fs); fs.Close(); Process prc = new Process(); prc.StartInfo.FileName = file; prc.Start(); } else { //frmStokHareketDokumuForCrytalReport frm2 = new frmStokHareketDokumuForCrytalReport(_source); //frm2.Show(); } } catch (Exception exc) { MessageBox.Show(exc.Message); LogWrite.Write(exc); } } }
public ReportResult ExportIndex(string tufman, string gear, string vesselName, string year, string fleet, string criteria, string fishingCompany, int? minNbDays) { GetUserDetails(); if (_role == RoleList.Country && !tufman.Equals(_country)) { WebSecurity.Logout(); return null; } fleet = (String.IsNullOrEmpty(fleet) || fleet.Equals("0")) ? null : fleet; fishingCompany = (String.IsNullOrEmpty(fishingCompany) || fishingCompany.Equals("0")) ? null : fishingCompany; List<VmsTufmanReconModel> modelLst = new List<VmsTufmanReconModel>(); List<VmsTufmanRecon> reconLst = _reconRepo.FilterRecon(tufman, gear, vesselName, year, fleet, criteria, fishingCompany); string eez; if (fleet != null && fleet.Equals(_nationalFleetCode)) { foreach (VmsTufmanRecon recon in reconLst) modelLst.Add(new VmsTufmanReconModel(recon, true)); eez = "WCPFC Convention Area"; } else { foreach (VmsTufmanRecon recon in reconLst) modelLst.Add(new VmsTufmanReconModel(recon, false)); eez = _repo.Get<Entity>(tufman).Label; } //Remove any Recon where the logsheet or the vms duration is less than the minNbDays parameter if (minNbDays > 0) modelLst.RemoveAll(x => ((x.VmsTripId != 0 && x.VmsNbDays < minNbDays) || (x.LogsheetTripId != 0 && x.LogsheetNbDays < minNbDays))); var report = new Report(modelLst.ToReportSource()); report.TextFields.Title = "VMS - Logsheet Reconciliation Detail"; report.DataFields["VmsTripId"].Hidden = true; report.DataFields["VesselId"].Hidden = true; report.DataFields["LogsheetTripId"].Hidden = true; report.DataFields["Country"].Hidden = true; report.DataFields["VesselFlag"].FormatAs<Entity>(x => x.Label); report.DataFields["Gear"].FormatAs<Gear>(x => x.Label); report.RenderHints.Orientation = ReportOrientation.Landscape; year = (String.IsNullOrEmpty(year) ? "ALL" : year); fishingCompany = (String.IsNullOrEmpty(fishingCompany) || fishingCompany.Equals("0")) ? "ALL" : fishingCompany; //var gearRepo = new Repository<Gear>(MvcApplication.UnitOfWork.Session); string gearDesc = _repo.Get<Gear>(gear).Label; string fleetDesc = (String.IsNullOrEmpty(fleet)) ? "ALL" : _repo.Get<Entity>(fleet).Label; report.TextFields.Header = string.Format(@" Gear: {0} Fleet: {1} Year: {2} EEZ: {3} Fishing Company: {4} Criteria: {5} Min Trip Duration: {6}", gearDesc, fleetDesc, year, eez, fishingCompany, criteria, minNbDays); return new ReportResult(report); }
public ReportResult DynamicNulls() { var all = new List <ExpandoObject>(); var product = new Product { Id = 1, Name = "Hammer", Description = "Unit Tester Widget", Price = 42, OrderCount = 10, UnitsInStock = 4 }; dynamic item = new ExpandoObject(); item.Id = product.Id; item.Name = product.Name; item.Description = product.Description; item.Price = product.Price; item.OrderCount = product.OrderCount; item.LastPuchase = product.LastPurchase; item.UnitsInStock = product.UnitsInStock; item.LowStock = product.LowStock; all.Add(item); product = new Product { Id = 2, Name = "Secret", Price = 84.42, OrderCount = 1, UnitsInStock = 2 }; item = new ExpandoObject(); item.Id = product.Id; item.Name = product.Name; item.Description = product.Description; item.Price = product.Price; item.OrderCount = product.OrderCount; item.LastPuchase = product.LastPurchase; item.UnitsInStock = product.UnitsInStock; item.LowStock = product.LowStock; all.Add(item); var report = new Report(all.ToReportSource()); // Customize the Text Fields report.TextFields.Title = "Dynamic Report with NULL values present"; report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works"; report.TextFields.Footer = "Copyright 2011-2012 (c) The Doddle Project"; report.TextFields.Header = string.Format(@"Report Generated: {0}", DateTime.Now); report.DataFields["OrderCount"].HeaderText = "Order Count"; report.DataFields["UnitsInStock"].HeaderText = "Units in Stock"; report.DataFields["LowStock"].HeaderText = "Stock Low"; // Render hints allow you to pass additional hints to the reports as they are being rendered report.RenderHints.BooleanCheckboxes = true; return(new ReportResult(report)); }