//Method for Rendering Customer Report public ActionResult CustomerReport(string id) { //Specify Path/ Report Name LocalReport lr = new LocalReport(); string path = Path.Combine(Server.MapPath("~/Reports"), "CustomerInfo.rdlc"); if (System.IO.File.Exists(path)) { lr.ReportPath = path; } else { return(View("Index")); } //Make object List <Address> ad = new List <Address>(); List <Customer> cust = new List <Customer>(); List <Order> ord = new List <Order>(); //Get data from DB using (JunkoutDBModelContainer jo = new JunkoutDBModelContainer()) { ad = jo.Addresses.ToList(); cust = jo.Customers.ToList(); ord = jo.Orders.ToList(); } //Data source from Report ReportDataSource rd = new ReportDataSource("CustomerInfo", cust); lr.DataSources.Add(rd); string reportType = id; string mimeType; string encoding; string fileNameExtension; //Set Report string deviceInfo = "<DeviceInfo>" + " <OutputFormat>" + id + "</OutputFormat>" + " <PageWidth>8.5in</PageWidth>" + " <PageHeight>11in</PageHeight>" + " <MarginTop>0.5in</MarginTop>" + " <MarginLeft>1in</MarginLeft>" + " <MarginRight>1in</MarginRight>" + " <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"; //Rendering Report Warning[] warnings; string[] streams; byte[] renderedBytes; renderedBytes = lr.Render( reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings ); return(File(renderedBytes, mimeType)); }
//Method for Rendering Customer Report public ActionResult OrdersInCities(string id) { //set path LocalReport lr = new LocalReport(); string path = Path.Combine(Server.MapPath("~/Reports"), "OrdersInCities.rdlc"); if (System.IO.File.Exists(path)) { lr.ReportPath = path; } else { return(View("Index")); } //create object List <Address> ad = new List <Address>(); List <Customer> cust = new List <Customer>(); List <Order> ord = new List <Order>(); List <Bin> bins = new List <Bin>(); List <TransferStation> tf = new List <TransferStation>(); //Use db using (JunkoutDBModelContainer jo = new JunkoutDBModelContainer()) { ad = jo.Addresses.ToList(); cust = jo.Customers.ToList(); ord = jo.Orders.ToList(); bins = jo.Bins.ToList(); tf = jo.TransferStations.ToList(); } // data sourec ReportDataSource rd = new ReportDataSource("OrdersInCities", ad); lr.DataSources.Add(rd); string reportType = id; string mimeType; string encoding; string fileNameExtension; //Report Specifications string deviceInfo = "<DeviceInfo>" + " <OutputFormat>" + id + "</OutputFormat>" + " <PageWidth>8.5in</PageWidth>" + " <PageHeight>11in</PageHeight>" + " <MarginTop>0.5in</MarginTop>" + " <MarginLeft>1in</MarginLeft>" + " <MarginRight>1in</MarginRight>" + " <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] renderedBytes; //Render Report renderedBytes = lr.Render( reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings ); return(File(renderedBytes, mimeType)); }