code_junkie

Is it possible to integrate SSRS reports with webforms

Nov 11th, 2011
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. public void ProcessRequest(HttpContext context)
  2. {
  3. string report = null;
  4. int managerId = -1;
  5. int planId = -1;
  6. GetParametersFromSession(context.Session, out report, out managerId, out planId);
  7. if (report == null || managerId == -1 || planId == -1)
  8. {
  9. return;
  10. }
  11.  
  12. CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
  13.  
  14. List<ReportParameter> parameters = new List<ReportParameter>();
  15. parameters.Add(new ReportParameter("Prefix", report));
  16. parameters.Add(new ReportParameter("ManagerId", managerId.ToString()));
  17. parameters.Add(new ReportParameter("ActionPlanId", planId.ToString()));
  18. string language = Thread.CurrentThread.CurrentCulture.Name;
  19. language = String.Format("{0}_{1}", language.Substring(0, 2), language.Substring(3, 2).ToLower());
  20. parameters.Add(new ReportParameter("Lang", language));
  21.  
  22. ReportViewer rv = new ReportViewer();
  23. rv.ProcessingMode = ProcessingMode.Remote;
  24. rv.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServer"]);
  25. if (ConfigurationManager.AppSettings["DbYear"] == "2007")
  26. {
  27. rv.ServerReport.ReportPath = "/ActionPlanning/Plan";
  28. }
  29. else
  30. {
  31. rv.ServerReport.ReportPath = String.Format("/ActionPlanning{0}/Plan", ConfigurationManager.AppSettings["DbYear"]);
  32. }
  33. rv.ServerReport.SetParameters(parameters);
  34.  
  35. string mimeType = null;
  36. string encoding = null;
  37. string extension = null;
  38. string[] streamIds = null;
  39. Warning[] warnings = null;
  40. byte[] output = rv.ServerReport.Render("pdf", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
  41.  
  42. context.Response.ContentType = mimeType;
  43. context.Response.BinaryWrite(output);
  44. }
Add Comment
Please, Sign In to add comment