public byte[] RenderPDFFromReportViewObject(string reportName, ReportParameter[] reportParameters) { CustomReportCredentials objCustomReportCredentials = null; Uri reportServerURL = null; try { SystemConfigurations systemConfigurations = SystemConfigurations.GetInstance(); reportServerURL = new Uri(systemConfigurations.ReportURL); string reportServerDomain = systemConfigurations.ReportServerDomain; string reportServerUserName = systemConfigurations.ReportServerUserName; string reportServerPassword = systemConfigurations.ReportServerPassword; string reportFolder = systemConfigurations.ReportFolder; string[] streamids; objCustomReportCredentials = new CustomReportCredentials(reportServerUserName, reportServerPassword, reportServerDomain); ReportViewer1.ServerReport.ReportServerCredentials = objCustomReportCredentials; ReportViewer1.ServerReport.ReportServerUrl = reportServerURL; ReportViewer1.ServerReport.ReportPath = "/" + reportFolder + "/" + reportName; ReportViewer1.ServerReport.SetParameters(reportParameters); ReportViewer1.ServerReport.Refresh(); return(ReportViewer1.ServerReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings)); } finally { if (reportServerURL != null) { reportServerURL = null; } if (objCustomReportCredentials != null) { objCustomReportCredentials = null; } } }
protected void BindSSRS() { try { ReportViewer1.ShowParameterPrompts = false; ReportViewer1.ShowToolBar = false; ReportViewer1.WaitMessageFont.Bold = true; ReportViewer1.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServerURL"].ToString()); ReportViewer1.ServerReport.ReportPath = "/EPGM_Beneficiarly_Details"; ReportViewer1.ProcessingMode = ProcessingMode.Remote; IReportServerCredentials irsc = new CustomReportCredentials(ConfigurationManager.AppSettings["RSDomainUserName"].ToString(), ConfigurationManager.AppSettings["RSDomainPassword"].ToString(), ConfigurationManager.AppSettings["RSDomainName"].ToString()); ReportViewer1.ServerReport.ReportServerCredentials = irsc; ReportViewer1.SizeToReportContent = true; ReportViewer1.Width = Unit.Percentage(100); ReportViewer1.Height = Unit.Percentage(100); List <ReportParameter> parmList = new List <ReportParameter>(); ReportParameterInfoCollection parameters; parameters = ReportViewer1.ServerReport.GetParameters(); for (int i = 0; i < parameters.Count; i++) { if (parameters[i].Name.ToLower() == "statecode") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), "52", false)); } if (parameters[i].Name.ToLower() == "distcode") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), "12", false)); } if (parameters[i].Name.ToLower() == "projectcode") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), " ", false)); } if (parameters[i].Name.ToLower() == "sectorcode") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), " ", false)); } if (parameters[i].Name.ToLower() == "centercode") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), " ", false)); } if (parameters[i].Name.ToLower() == "whotype") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), "All", false)); } } ReportViewer1.ServerReport.SetParameters(parmList); ReportViewer1.DataBind(); //ReportViewer1.ServerReport.Refresh(); } catch (Exception ex) { lblerror.Text = ex.Message; lblerror.ForeColor = Color.DarkRed; } }
public byte[] ReportGenerateCustom(out string mimeType, string ReportFormatType = "PDF", string UserName = null, List <ReportParameter> RParams = null, string ReportName = null) { mimeType = ""; byte[] Bytes; PrintedBy = UserName; FileType = ReportFormatType; string encoding; string fileNameExtension; string deviceinfo = "<DeviceInfo>" + " <OutputFormat>" + ReportFormatType + "</OutputFormat>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; ReportViewer reportViewer1 = new ReportViewer(); reportViewer1.ProcessingMode = ProcessingMode.Local; ServerReport serverReport = reportViewer1.ServerReport; // Set the report server URL and report path //serverReport.ReportServerUrl = // new Uri(ConfigurationManager.AppSettings["RSDomain"]); serverReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["RSServer"]); serverReport.ReportPath = ConfigurationManager.AppSettings["RSPath"] + ReportName; IReportServerCredentials irsc = new CustomReportCredentials(ConfigurationManager.AppSettings["RSID"], ConfigurationManager.AppSettings["RSPWD"], ConfigurationManager.AppSettings["RSDomain"]); serverReport.ReportServerCredentials = irsc; serverReport.SetParameters(RParams); Bytes = serverReport.Render( ReportFormatType, deviceinfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); //return reportViewer1; return(Bytes); }
public ActionResult ViewCustomReport(int?id, int Width, int Height) { string sUserName = ConfigurationManager.AppSettings["userName"].ToString(); string sPassword = ConfigurationManager.AppSettings["Password"].ToString(); string sUrl = ConfigurationManager.AppSettings["reportURL"].ToString(); ReportViewModel vm = new ReportViewModel(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ReportModel reportModel = db.ReportModels.Find(id); if (reportModel == null) { return(HttpNotFound()); } string Username = User.Identity.Name; if (!Utility.UserHasAccess(Username, id)) { return(RedirectToAction("Index")); } Utility.UserViewReport(Username, id); vm.rm = reportModel; ReportViewer reportviewer = new ReportViewer(); reportviewer.ProcessingMode = ProcessingMode.Remote; reportviewer.ServerReport.ReportServerUrl = new Uri(sUrl); IReportServerCredentials irsc = new CustomReportCredentials(sUserName, sPassword, ""); reportviewer.ServerReport.ReportServerCredentials = irsc; reportviewer.ServerReport.ReportPath = vm.rm.path; ReportParameterInfoCollection reportParameterInfos = reportviewer.ServerReport.GetParameters(); vm.reportParameters = new List <ReportParameter>(); foreach (ReportParameterInfo rpi in reportParameterInfos) { if (rpi.PromptUser && rpi.Visible) { ReportParameter p = new ReportParameter(); p.Name = rpi.Name; p.Visible = rpi.Visible; vm.reportParameters.Add(p); } } vm.reportParameterInfoCollection = reportParameterInfos; vm.Height = Height; vm.Width = Width; string sUrlBase = ConfigurationManager.AppSettings["UrlBase"]; string sUrlpath = String.Format(sUrlBase + "ViewCustomReport.aspx?Path={0}&Height={1}", vm.rm.path, Height); vm.ReportURL = sUrlpath; vm.lsOuputs = Utility.GetOutputs(); return(View(vm)); }
protected void ShowRpt(string rptPath) { IReportServerCredentials irsc = new CustomReportCredentials("Administrator", "Asdf123", ""); this.ReportViewer1.ServerReport.ReportServerCredentials = irsc; this.ReportViewer1.ServerReport.ReportServerUrl = new Uri(@"http://10.156.0.131/ReportServer"); this.ReportViewer1.ServerReport.ReportPath = rptPath; this.ReportViewer1.ServerReport.Refresh(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { IReportServerCredentials irsc = new CustomReportCredentials("soporte_ipd", "1002SOsg*", "ISAMDNT"); ReportViewer1.ServerReport.ReportServerCredentials = irsc; ReportViewer1.ServerReport.ReportPath = ConfigurationManager.AppSettings["ReportPath"].ToString() + ConfigurationManager.AppSettings["Reporte_Evaluacion_Colaboradores"].ToString(); ReportViewer1.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServerUrl"].ToString()); } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { ReportViewer1.ProcessingMode = ProcessingMode.Remote; IReportServerCredentials irsc = new CustomReportCredentials("hiroodaikai-001", "yanmarsucks66!", "ifc"); // e.g.: ("demo-001", "123456789", "ifc") ReportViewer1.ServerReport.ReportServerCredentials = irsc; ReportViewer1.ServerReport.Timeout = 600000; ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://sql5030.site4now.net/ReportServer"); ReportViewer1.ServerReport.ReportPath = "/hiroodaikai-001/DataDownload"; //e.g.: /demo-001/test ReportViewer1.ServerReport.Refresh(); } }
public ActionResult Report() { try { var ServerReportUrl = ApiDesencriptar.Desencriptar(Request.QueryString[0]); var UsuarioReporte = ApiDesencriptar.Desencriptar(Request.QueryString[1]); var ContrasenaReporte = ApiDesencriptar.Desencriptar(Request.QueryString[2]); var ReporteClientesPath = ApiDesencriptar.Desencriptar(Request.QueryString[3]); var parametros = new List <Parametro>(); for (int i = 4; i < Request.QueryString.AllKeys.Length; i++) { parametros.Add(new Parametro { Clave = ApiDesencriptar.Desencriptar(Request.QueryString.Keys[i]), Valor = ApiDesencriptar.Desencriptar(Request.QueryString[Request.QueryString.Keys[i]]) }); } ReportViewer rptViewer = new ReportViewer(); // ProcessingMode will be Either Remote or Local rptViewer.ProcessingMode = ProcessingMode.Remote; rptViewer.SizeToReportContent = true; rptViewer.ZoomMode = ZoomMode.PageWidth; rptViewer.Width = Unit.Percentage(100); rptViewer.Height = Unit.Percentage(100); rptViewer.AsyncRendering = true; IReportServerCredentials irsc = new CustomReportCredentials(UsuarioReporte, ContrasenaReporte); rptViewer.ServerReport.ReportServerCredentials = irsc; rptViewer.ServerReport.ReportServerUrl = new Uri(ServerReportUrl); rptViewer.ServerReport.ReportPath = ReporteClientesPath; if (parametros.Count > 0) { var parameters = AdicionarParaMetros(parametros); rptViewer.ServerReport.SetParameters(parameters); } ; rptViewer.ServerReport.Refresh(); ViewBag.ReportViewer = rptViewer; return(View()); } catch (Exception) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "El reporte solicitado no se ha podido mostrar...")); } }
/// <summary> /// /// </summary> /// <param name="connectionType"></param> /// <param name="reportName"></param> /// <param name="parameters"></param> /// <remarks></remarks> public void LoadReport(string reportName, Microsoft.Reporting.WebForms.ReportParameter[] parameters) { //ReportWS.ReportingService rs = new ReportWS.ReportingService(); ////Create an instance of the CredentialCache class. //System.Net.CredentialCache cache =new System.Net.CredentialCache(); //// Add a NetworkCredential instance to CredentialCache. //// Negotiate for NTLM or Kerberos authentication. ////cache.Add(new Uri(myProxy.Url), "Negotiate", new NetworkCredential("UserName", "Password", "Domain")); //cache.Add("192.168.1.30", 80, "Negotiate", new System.Net.NetworkCredential("wang", "smu", "grape-wang")); ////Assign CredentialCache to the Web service Client Proxy(myProxy) Credetials property. ////myProxy.Credentials = cache; //rs.Credentials = System.Net.CredentialCache.DefaultCredentials; string reportFolder = System.Web.Configuration.WebConfigurationManager.AppSettings.Get("ReportFolder"); string reportUserName = System.Configuration.ConfigurationManager.AppSettings["ReportUserName"]; string reportUserPwd = System.Configuration.ConfigurationManager.AppSettings["ReportUserPwd"]; string reportDomain = System.Configuration.ConfigurationManager.AppSettings["ReportDomain"]; reportName = "/" + reportFolder + "/" + reportName; this.rptViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote; IReportServerCredentials irsc = new CustomReportCredentials(reportUserName, reportUserPwd, reportDomain); //this.rptViewer.ServerReport.ReportServerCredentials = irsc; this.rptViewer.ServerReport.ReportServerUrl = new Uri(System.Web.Configuration.WebConfigurationManager.AppSettings.Get("ReportServer")); this.rptViewer.ServerReport.ReportPath = reportName; //Credentials //Microsoft.Reporting.WebForms.DataSourceCredentials[] cr = new Microsoft.Reporting.WebForms.DataSourceCredentials[1]; //cr[0] = new Microsoft.Reporting.WebForms.DataSourceCredentials(); //DataSource //string conn = string.Empty; //conn = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ERSConnectionString"].ConnectionString; //Parameters // ERROR: Not supported in C#: ReDimStatement //parameters[parameters.Length-1] = new Microsoft.Reporting.WebForms.ReportParameter("conn", conn); if (parameters != null && parameters.Length > 0) { this.rptViewer.ServerReport.SetParameters(parameters); } }
/// <summary> /// /// </summary> /// <param name="connectionType"></param> /// <param name="reportName"></param> /// <param name="parameters"></param> /// <remarks></remarks> public void LoadReport(string reportName, Microsoft.Reporting.WebForms.ReportParameter[] parameters) { //ReportWS.ReportingService rs = new ReportWS.ReportingService(); ////Create an instance of the CredentialCache class. //System.Net.CredentialCache cache =new System.Net.CredentialCache(); //// Add a NetworkCredential instance to CredentialCache. //// Negotiate for NTLM or Kerberos authentication. ////cache.Add(new Uri(myProxy.Url), "Negotiate", new NetworkCredential("UserName", "Password", "Domain")); //cache.Add("192.168.1.30", 80, "Negotiate", new System.Net.NetworkCredential("wang", "smu", "grape-wang")); ////Assign CredentialCache to the Web service Client Proxy(myProxy) Credetials property. ////myProxy.Credentials = cache; //rs.Credentials = System.Net.CredentialCache.DefaultCredentials; string reportFolder = System.Web.Configuration.WebConfigurationManager.AppSettings.Get("ReportFolder"); string reportUserName = System.Configuration.ConfigurationManager.AppSettings["ReportUserName"]; string reportUserPwd = System.Configuration.ConfigurationManager.AppSettings["ReportUserPwd"]; string reportDomain = System.Configuration.ConfigurationManager.AppSettings["ReportDomain"]; reportName = "/" + reportFolder + "/" + reportName; this.rptViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote; IReportServerCredentials irsc = new CustomReportCredentials(reportUserName, reportUserPwd, reportDomain); this.rptViewer.ServerReport.ReportServerCredentials = irsc; this.rptViewer.ServerReport.ReportServerUrl = new Uri(System.Web.Configuration.WebConfigurationManager.AppSettings.Get("ReportServer")); this.rptViewer.ServerReport.ReportPath = reportName; //Credentials //Microsoft.Reporting.WebForms.DataSourceCredentials[] cr = new Microsoft.Reporting.WebForms.DataSourceCredentials[1]; //cr[0] = new Microsoft.Reporting.WebForms.DataSourceCredentials(); //DataSource //string conn = string.Empty; //conn = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ERSConnectionString"].ConnectionString; //Parameters // ERROR: Not supported in C#: ReDimStatement //parameters[parameters.Length-1] = new Microsoft.Reporting.WebForms.ReportParameter("conn", conn); if (parameters != null && parameters.Length > 0) { this.rptViewer.ServerReport.SetParameters(parameters); } }
public async Task <ActionResult> ReporteClientesTrabajador(string id) { try { ApplicationDbContext db = new ApplicationDbContext(); var proceso = db.Procesos.Where(x => x.NIP == id).FirstOrDefault(); var cliente = await UserManager.FindByIdAsync(proceso.Id); var parameters = new List <ReportParameter>(); //Add parameter parameters.Add(new ReportParameter("NIP", id.ToString(), false)); parameters.Add(new ReportParameter("Identificacion", cliente.Identificacion.ToString(), false)); ReportViewer rptViewer = new ReportViewer(); // ProcessingMode will be Either Remote or Local rptViewer.ProcessingMode = ProcessingMode.Remote; rptViewer.SizeToReportContent = true; rptViewer.ZoomMode = ZoomMode.PageWidth; rptViewer.Width = Unit.Percentage(100); rptViewer.Height = Unit.Percentage(100); rptViewer.AsyncRendering = true; rptViewer.Visible = true; IReportServerCredentials irsc = new CustomReportCredentials(Constantes.UsuarioReport, Constantes.ContrasenaReporte); rptViewer.ServerReport.ReportServerCredentials = irsc; rptViewer.ServerReport.ReportServerUrl = new Uri(Constantes.ServerReportUrl); rptViewer.ServerReport.ReportPath = Constantes.ReporteClientesPath; rptViewer.ServerReport.SetParameters(parameters); rptViewer.ServerReport.Refresh(); ViewBag.ReportViewer = rptViewer; return(View()); } catch (Exception) { throw; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { IReportServerCredentials irsc = new CustomReportCredentials("Admin", "1234", "http://192.168.122.0/ReportServer"); ReportViewer1.ServerReport.ReportServerCredentials = irsc; ReportViewer1.ProcessingMode = ProcessingMode.Remote; ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://192.168.122.0/ReportServer"); ReportViewer1.ServerReport.ReportPath = "/Default/test"; ReportViewer1.ShowParameterPrompts = true; ReportViewer1.ShowPrintButton = true; ReportViewer1.ServerReport.Refresh(); } catch (Exception ex) { //ex.Message(); } } }
public ActionResult Details(string reportName, string serverPath, string reportFolder) { ReportViewer reportViewer = new ReportViewer(); reportViewer.ProcessingMode = ProcessingMode.Remote; reportViewer.SizeToReportContent = true; reportViewer.Width = Unit.Pixel(1100); reportViewer.Height = Unit.Pixel(525); IReportServerCredentials irsc = new CustomReportCredentials("weladapola-001", "Test@123", "ifc"); reportViewer.ServerReport.ReportServerCredentials = irsc; reportViewer.ServerReport.ReportServerUrl = new Uri(serverPath); reportViewer.ServerReport.ReportPath = @"/" + reportFolder + @"/" + reportName; ViewBag.ReportViewer = reportViewer; return(View()); //return Redirect("http://www.google.com"); }
private void ShowReport(ReportServerConfigVo reportServerConfigVo, ReportServerType reportType) { try { IReportServerCredentials irsc = new CustomReportCredentials(reportServerConfigVo.UserName, reportServerConfigVo.Password, reportServerConfigVo.Domain); rptViewer.ServerReport.ReportServerCredentials = irsc; rptViewer.ProcessingMode = ProcessingMode.Remote; // ProcessingMode will be Either Remote or Local rptViewer.ServerReport.ReportServerUrl = new Uri(reportServerConfigVo.ReportServerURL); //Set the ReportServer Url switch (reportType) { case ReportServerType.AssociateBrokerageComissionReport: rptViewer.ServerReport.ReportPath = reportServerConfigVo.ReportPath; //Passing the Report Path rptViewer.ServerReport.DisplayName = "Associate Consolidate Payout " + DateTime.Now.ToShortDateString(); break; } //Creating an ArrayList for combine the Parameters which will be passed into SSRS Report ArrayList reportParam = new ArrayList(); reportParam = ReportDefaultPatam(); ReportParameter[] param = new ReportParameter[reportParam.Count]; for (int k = 0; k < reportParam.Count; k++) { param[k] = (ReportParameter)reportParam[k]; } //pass parmeters to report rptViewer.ServerReport.SetParameters(CreateReportParameter(Request.QueryString["ReportCode"])); //Set Report Parameters rptViewer.ShowParameterPrompts = false; rptViewer.ServerReport.Refresh(); } catch (Exception ex) { throw ex; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ReportViewer1.ShowCredentialPrompts = true; //Microsoft.Reporting.WebForms.IReportServerCredentials irsc = new CustomReportCredentials("administrator", "a", "http://mlcv004/ReportServer"); //Microsoft.Reporting.WebForms.IReportServerCredentials irsc = new CustomReportCredentials("administrator", "a2.", "http://SGBAU/ReportServer"); Microsoft.Reporting.WebForms.IReportServerCredentials irsc = new CustomReportCredentials(ConfigurationManager.AppSettings["ReportLoginName"], ConfigurationManager.AppSettings["Password"], ConfigurationManager.AppSettings["Reportserver"]); // "http://SGBAU/ReportServer" ReportViewer1.ServerReport.ReportServerCredentials = irsc; Hashtable ht = new Hashtable(); ht = (Hashtable)Session["ht"]; ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote; ReportViewer1.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServer"].ToString()); ReportViewer1.ServerReport.ReportPath = ConfigurationManager.AppSettings["ReportProjectName"].ToString() + Session["Report"].ToString(); if (ht != null) { ReportParameter[] parm = new ReportParameter[ht.Count]; int i = 0; foreach (DictionaryEntry Dt in ht) { parm[i] = new ReportParameter(Convert.ToString(Dt.Key), Convert.ToString(Dt.Value)); i++; } //System.Drawing.Printing.PageSettings pg=new System.Drawing.Printing.PageSettings(); // pg.Margins.Top = 0; // pg.Margins.Bottom = 0; // pg.Margins.Left = 0; // pg.Margins.Right = 0; // pg.Landscape = false; // System.Drawing.Printing.PaperSize size = new PaperSize(); // size.RawKind = (int)PaperKind.A4; // pg.PaperSize = size; // ReportViewer1.SetPageSettings(pg); this.ReportViewer1.ServerReport.Refresh(); ReportViewer1.ServerReport.SetParameters(parm); ReportViewer1.ServerReport.Refresh(); } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.IsAuthenticated) { if (!IsPostBack) { try { string sUserName = ConfigurationManager.AppSettings["userName"].ToString(); string sPassword = ConfigurationManager.AppSettings["Password"].ToString(); string sUrl = ConfigurationManager.AppSettings["reportURL"].ToString(); string sPath = Request["Path"]; if (sPath == string.Empty) { throw new Exception(); } rvSiteMapping.Height = Unit.Pixel(Convert.ToInt32(Request["Height"]) - 58); rvSiteMapping.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote; rvSiteMapping.ServerReport.ReportServerUrl = new Uri(sUrl); IReportServerCredentials irsc = new CustomReportCredentials(sUserName, sPassword, ""); rvSiteMapping.ServerReport.ReportServerCredentials = irsc; rvSiteMapping.ServerReport.ReportPath = sPath; rvSiteMapping.KeepSessionAlive = false; rvSiteMapping.ServerReport.Refresh(); } catch (Exception ex) { throw ex; } } } else { Response.Redirect("~/Account/Login"); } }
public void function() { ReportViewer1.ShowCredentialPrompts = true; Microsoft.Reporting.WebForms.IReportServerCredentials irsc = new CustomReportCredentials(ConfigurationManager.AppSettings["UserName"].ToString(), ConfigurationManager.AppSettings["Password"].ToString(), ConfigurationManager.AppSettings["ReportServer"].ToString());//"http://occweb02/ReportServer"); ReportViewer1.ServerReport.ReportServerCredentials = irsc; Hashtable HT = new Hashtable(); HT = (Hashtable)Session["HT"]; ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote; ReportViewer1.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServer"].ToString()); ReportViewer1.ServerReport.ReportPath = ConfigurationManager.AppSettings["ReportProjectName"].ToString() + Session["Report"].ToString(); if (HT != null) { ReportParameter[] parm = new ReportParameter[HT.Count]; int i = 0; foreach (DictionaryEntry Dt in HT) { parm[i] = new ReportParameter(Convert.ToString(Dt.Key), Convert.ToString(Dt.Value)); i++; } ReportViewer1.ServerReport.SetParameters(parm); ReportViewer1.ServerReport.Refresh(); } }
// GET: Reports public ActionResult Report() { ReportViewer rptViewer = new ReportViewer(); // ProcessingMode will be Either Remote or Local rptViewer.ProcessingMode = ProcessingMode.Remote; rptViewer.SizeToReportContent = true; rptViewer.ZoomMode = ZoomMode.PageWidth; rptViewer.Width = Unit.Percentage(100); rptViewer.Height = Unit.Percentage(100); rptViewer.AsyncRendering = true; IReportServerCredentials irsc = new CustomReportCredentials(Constantes.UsuarioReport, Constantes.Contrasena); rptViewer.ServerReport.ReportServerCredentials = irsc; rptViewer.ServerReport.ReportServerUrl = new Uri(Constantes.ServerReportUrl); rptViewer.ServerReport.ReportPath = Constantes.ReporteCuelloPath; ViewBag.ReportViewer = rptViewer; return(View()); }
public void CategotyReport(string ReportName) { try { string UserName = ConfigurationManager.AppSettings["RtpUserName"].ToString(); string Password = ConfigurationManager.AppSettings["RtpPwd"].ToString(); string Domin = ConfigurationManager.AppSettings["RtpServer"].ToString(); Microsoft.Reporting.WebForms.IReportServerCredentials irsc = new CustomReportCredentials(UserName, Password, Domin); rtpVwrCategory.ProcessingMode = ProcessingMode.Remote; rtpVwrCategory.ServerReport.ReportServerCredentials = irsc; string urlReportServer = "http://" + Domin + "/ReportServer"; rtpVwrCategory.ServerReport.ReportServerUrl = new Uri(urlReportServer); switch (ReportName) { case "Category": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/Category"; break; case "Location": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/Location"; break; case "Material": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/Material"; break; case "PhysicalInventoryDetails": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/PhysicalInventory_Details"; break; case "PhysicalInventoryDifferendeDetails": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/PhysicalInventory_Differende_Details"; break; case "POReceive": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/POReceive"; break; case "PriceFile": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/PriceFile"; break; case "ReturnToSupplier": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/Return_To_Supplier"; break; case "StockReceiveDetails": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/Stock_Receive_Details"; break; case "SubCategory": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/Sub_Category"; break; case "Terminal": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/Terminal"; break; case "TransferToDisplay": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/Transfer_To_Display"; break; case "UOM": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/UOM"; break; case "Vendor": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/Vendor"; break; case "Stock": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/StockReport"; break; case "ItemCard": rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/ItemCardReport"; break; default: rtpVwrCategory.ServerReport.ReportPath = "/EASYPOS_Reports/Category"; break; } // rtpVwrCategory.ServerReport.Refresh(); } catch (Exception ex) { } }
private void setAuthentication() { IReportServerCredentials irsc = new CustomReportCredentials(ParameterServices.ReportUserName, ParameterServices.ReportPassword, ParameterServices.ReportDomainName); ctlMasterReportViewer.ServerReport.ReportServerCredentials = irsc; }
protected void BindSSRS() { try { ReportViewer1.ShowParameterPrompts = false; //ReportViewer1.ShowToolBar = false; ReportViewer1.WaitMessageFont.Bold = true; ReportViewer1.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServerURL"].ToString()); if (Request.QueryString["awccode"].ToString() != "0" && Request.QueryString["awccode"].ToString() != null) { ReportViewer1.ServerReport.ReportPath = "/DetailedBeneRegistrationsReport"; } else { ReportViewer1.ServerReport.ReportPath = "/BeneRegistrationsReport"; } ReportViewer1.ProcessingMode = ProcessingMode.Remote; IReportServerCredentials irsc = new CustomReportCredentials(ConfigurationManager.AppSettings["RSDomainUserName"].ToString(), ConfigurationManager.AppSettings["RSDomainPassword"].ToString(), ConfigurationManager.AppSettings["RSDomainName"].ToString()); ReportViewer1.ServerReport.ReportServerCredentials = irsc; ReportViewer1.SizeToReportContent = true; ReportViewer1.Width = Unit.Percentage(100); ReportViewer1.Height = Unit.Percentage(100); List <ReportParameter> parmList = new List <ReportParameter>(); ReportParameterInfoCollection parameters; parameters = ReportViewer1.ServerReport.GetParameters(); for (int i = 0; i < parameters.Count; i++) { if (parameters[i].Name.ToLower() == "centertypeid") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["CenterType"].ToString(), false)); } if (parameters[i].Name.ToLower() == "statecode") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["statecode"].ToString(), false)); } if (parameters[i].Name.ToLower() == "distcode") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["distcode"].ToString(), false)); } if (parameters[i].Name.ToLower() == "projectcode") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["projectcode"].ToString(), false)); } if (parameters[i].Name.ToLower() == "sectorcode") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["sectorcode"].ToString(), false)); } if (parameters[i].Name.ToLower() == "centercode") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["awccode"].ToString(), false)); } if (parameters[i].Name.ToLower() == "passeddatetime") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["month"].ToString() + "-" + "01" + "-" + Request.QueryString["year"].ToString(), false)); } if (parameters[i].Name.ToLower() == "month") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["month"].ToString(), false)); } if (parameters[i].Name.ToLower() == "year") { parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["year"].ToString(), false)); } } ReportViewer1.ServerReport.SetParameters(parmList); ReportViewer1.DataBind(); //ReportViewer1.ServerReport.Refresh(); } catch (Exception ex) { lblerror.Text = ex.Message; lblerror.ForeColor = Color.DarkRed; } }
protected void Page_Load(object sender, EventArgs e) { String rName = ""; if (!IsPostBack) { //lblRptName.Text = "OBL Staff Leave Application Report"; IReportServerCredentials irsc = new CustomReportCredentials("Administrator", "@dm1nP@ss", ""); //ReportViewer1.ServerReport.ReportServerCredentials = irsc; ////rName = Request.QueryString["rptName"].ToString(); ////rName = rName.Trim(); //ReportViewer1.ServerReport.ReportServerUrl = new Uri(@"http://10.156.0.105/ReportServer"); //ReportViewer1.ServerReport.ReportPath = "/RptOBLContactCenter/RptDetailReport";// + rName; //ReportViewer1.ShowToolBar = true; //ReportViewer1.Visible = true; //if (Request.QueryString["showName"].ToString() != String.Empty && Request.QueryString["showName"].ToString() != "") //{ // if (Request.QueryString["showName"].ToString().ToLower() == "staff leave application report") // { // Microsoft.Reporting.WebForms.ReportParameter[] parameter = new Microsoft.Reporting.WebForms.ReportParameter[2]; // parameter[0] = new Microsoft.Reporting.WebForms.ReportParameter(); // parameter[0].Name = "EmployeeID"; // parameter[0].Visible = false; // parameter[0].Values.Add(Request.QueryString["EmployeeID"].ToString()); // parameter[1] = new Microsoft.Reporting.WebForms.ReportParameter(); // parameter[1].Name = "CaseID"; // parameter[1].Visible = false; // parameter[1].Values.Add(Request.QueryString["CaseID"].ToString()); // ReportViewer1.ServerReport.SetParameters(parameter); // //ReportViewer1.LocalReport.SetParameters(parameter); // } // else if (Request.QueryString["showName"].ToString().ToLower() == "quiz report") // { // } // else if (Request.QueryString["showName"].ToString().ToLower() == "branch unauthorize list") // { // Microsoft.Reporting.WebForms.ReportParameter[] parameter = new Microsoft.Reporting.WebForms.ReportParameter[1]; // } // else if (Request.QueryString["showName"].ToString().ToLower() == "dept unauthorize List") // { // // Microsoft.Reporting.WebForms.ReportParameter[] parameter = new Microsoft.Reporting.WebForms.ReportParameter[1]; // } // else if (Request.QueryString["showName"].ToString().ToLower() == "south zone employee total marks") // { // // Microsoft.Reporting.WebForms.ReportParameter[] parameter = new Microsoft.Reporting.WebForms.ReportParameter[1]; // } // else if (Request.QueryString["showName"].ToString().ToLower() == "south zone employee particular marks") // { // // Microsoft.Reporting.WebForms.ReportParameter[] parameter = new Microsoft.Reporting.WebForms.ReportParameter[1]; // } // //strTitle = "Report Preview Of " + Request.QueryString["showName"].ToString() + "."; //} } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { string str = Request.QueryString["Report"]; //string LRNO="" ; //if (Request.QueryString["LRNO"].ToString()!="") //{ // LRNO = Request.QueryString["LRNO"].ToString(); //} ReportViewer1.Width = 1570; ReportViewer1.Height = 1000; //Parametr to report ReportParameter[] reportParameterCollection = new ReportParameter[13]; try { ReportViewer1.ProcessingMode = ProcessingMode.Remote; IReportServerCredentials irsc = new CustomReportCredentials("INNAV2013NASSerAcc", "IN76^2165b", "TecturaCorp");// e.g.: ("demo-001", "123456789", "ifc") username,password,domainname ReportViewer1.ServerReport.ReportServerCredentials = irsc; ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://indel-sqdev12nv/ReportServer"); //ReportViewer1.ServerReport.ReportServerCredentials = irsc; //ReportViewer1.ServerReport.ReportServerUrl = new Uri(" http://ccnhkgdsql15/ReportServer"); switch (str) { case "PaymentOutstandingReport": ReportViewer1.ServerReport.ReportPath = "/TMS_Portal_Reports/PaymentOutstandingReport"; //e.g.: /demo-001/test reportParameterCollection[0] = new ReportParameter(); reportParameterCollection[0].Name = "User"; reportParameterCollection[0].Values.Add(Session["UserName"].ToString()); ReportViewer1.ServerReport.SetParameters(reportParameterCollection[0]); break; case "PendingLRForProcessing": ReportViewer1.ServerReport.ReportPath = "/TMS_Portal_Reports/PendingLRProcess"; //e.g.: /demo-001/test reportParameterCollection[1] = new ReportParameter(); reportParameterCollection[1].Name = "User"; reportParameterCollection[1].Values.Add(Session["UserName"].ToString()); ReportViewer1.ServerReport.SetParameters(reportParameterCollection[1]); break; case "LRRejectionByReason": ReportViewer1.ServerReport.ReportPath = "/TMS_Portal_Reports/LrRejectionByReason"; //e.g.: /demo-001/test reportParameterCollection[2] = new ReportParameter(); reportParameterCollection[2].Name = "User"; reportParameterCollection[2].Values.Add(Session["UserName"].ToString()); ReportViewer1.ServerReport.SetParameters(reportParameterCollection[2]); break; case "PendingLrForPayment": ReportViewer1.ServerReport.ReportPath = "/TMS_Portal_Reports/PendingLRforPayment"; //e.g.: /demo-001/test reportParameterCollection[3] = new ReportParameter(); reportParameterCollection[3].Name = "User"; reportParameterCollection[3].Values.Add(Session["UserName"].ToString()); ReportViewer1.ServerReport.SetParameters(reportParameterCollection[3]); break; case "CarlsbergPaymentAdherenceIndex": ReportViewer1.ServerReport.ReportPath = "/TMS_Portal_Reports/CarlsbergPaymentAdherenceIndex"; //e.g.: /demo-001/test reportParameterCollection[4] = new ReportParameter(); reportParameterCollection[4].Name = "User"; reportParameterCollection[4].Values.Add(Session["UserName"].ToString()); ReportViewer1.ServerReport.SetParameters(reportParameterCollection[4]); break; case "VendorPaymentLedger": ReportViewer1.ServerReport.ReportPath = "/TMS_Portal_Reports/VendorPaymentLedger"; //e.g.: /demo-001/test reportParameterCollection[5] = new ReportParameter(); reportParameterCollection[5].Name = "User"; reportParameterCollection[5].Values.Add(Session["UserName"].ToString()); ReportViewer1.ServerReport.SetParameters(reportParameterCollection[5]); break; case "VehiclePlacementReliabilitySLA": ReportViewer1.ServerReport.ReportPath = "/TMS_Portal_Reports/VehiclePlacementReliabilitySLA"; //e.g.: /demo-001/test reportParameterCollection[6] = new ReportParameter(); reportParameterCollection[6].Name = "User"; reportParameterCollection[6].Values.Add(Session["UserName"].ToString()); ReportViewer1.ServerReport.SetParameters(reportParameterCollection[6]); break; case "PlantDetentionReportByTransporter": ReportViewer1.ServerReport.ReportPath = "/TMS_Portal_Reports/ReportPlantDetentionByTransporter"; //e.g.: /demo-001/test reportParameterCollection[7] = new ReportParameter(); reportParameterCollection[7].Name = "User"; reportParameterCollection[7].Values.Add(Session["UserName"].ToString()); ReportViewer1.ServerReport.SetParameters(reportParameterCollection[7]); break; case "TransitTimeAdherence": ReportViewer1.ServerReport.ReportPath = "/TMS_Portal_Reports/InTransitTimeAdherence"; //e.g.: /demo-001/test reportParameterCollection[8] = new ReportParameter(); reportParameterCollection[8].Name = "User"; reportParameterCollection[8].Values.Add(Session["UserName"].ToString()); ReportViewer1.ServerReport.SetParameters(reportParameterCollection[8]); break; case "FormforPhysicalLRManagementWhileSending": ReportViewer1.ServerReport.ReportPath = "/TMS_Portal_Reports/FormForPhysicalLRManagementWhileSending"; //e.g.: /demo-001/test reportParameterCollection[9] = new ReportParameter(); reportParameterCollection[9].Name = "User"; reportParameterCollection[9].Values.Add(Session["UserName"].ToString()); ReportViewer1.ServerReport.SetParameters(reportParameterCollection[9]); break; case "FormForPhysicalLRManagementAfterReceivingfromCrown": ReportViewer1.ServerReport.ReportPath = "/TMS_Portal_Reports/FormforphysicalLRManagementAfterReceivingfromCrown"; //e.g.: /demo-001/test reportParameterCollection[10] = new ReportParameter(); reportParameterCollection[10].Name = "User"; reportParameterCollection[10].Values.Add(Session["UserName"].ToString()); ReportViewer1.ServerReport.SetParameters(reportParameterCollection[10]); break; case "ReportDataDump": ReportViewer1.ServerReport.ReportPath = "/TMS_Portal_Reports/ReportDataDump"; //e.g.: /demo-001/test reportParameterCollection[11] = new ReportParameter(); reportParameterCollection[11].Name = "User"; reportParameterCollection[11].Values.Add(Session["UserName"].ToString()); ReportViewer1.ServerReport.SetParameters(reportParameterCollection[11]); break; case "TPTInvoiceReport": ReportViewer1.ServerReport.ReportPath = "/TMS_Portal_Reports/TPTInvoiceReport"; //e.g.: /demo-001/test reportParameterCollection[12] = new ReportParameter(); reportParameterCollection[12].Name = "LRNo"; reportParameterCollection[12].Values.Add(Session["LRNO"].ToString()); ReportViewer1.ServerReport.SetParameters(reportParameterCollection[12]); break; } //ReportViewer1.ServerReport.ReportPath = "/TMS_Report_New/PendingLRforPayment"; //e.g.: /demo-001/test ReportViewer1.ServerReport.Refresh(); //ReportParameter[] reportParameterCollection = new ReportParameter[1]; //Array size describes the number of paramaters. //reportParameterCollection[0] = new ReportParameter(); //reportParameterCollection[0].Name = ""; //Give Your Parameter Name //reportParameterCollection[0].Values.Add("Seattle"); //Pass Parametrs's value here. //ReportViewer1.ServerReport.SetParameters(reportParameterCollection); //ReportViewer1.ServerReport.Refresh(); } catch (Exception ex) { Response.Write(ex.ToString()); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { String reportFolder = System.Configuration.ConfigurationManager.AppSettings["SSRSReportFolder"].ToString(); String reportServerUrl = System.Configuration.ConfigurationManager.AppSettings["SSRSReportServerUrl"].ToString(); // Credenciales para el acceso al SSRS String credentialUser = System.Configuration.ConfigurationManager.AppSettings["CredentialUser"].ToString(); String credentialPassword = System.Configuration.ConfigurationManager.AppSettings["CredentialPassword"].ToString(); String credentialDomain = System.Configuration.ConfigurationManager.AppSettings["CredentialDomain"].ToString(); IReportServerCredentials irsc = new CustomReportCredentials(credentialUser, credentialPassword, credentialDomain); rvSiteMapping.ServerReport.ReportServerCredentials = irsc; rvSiteMapping.Height = Unit.Pixel(Convert.ToInt32(Request["Height"]) - 58); rvSiteMapping.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote; rvSiteMapping.ServerReport.ReportServerUrl = new Uri(reportServerUrl); // Add the Reporting Server URL rvSiteMapping.ServerReport.ReportPath = String.Format("/{0}/{1}", reportFolder, Request["ReportName"].ToString()); //Deshabilitar botones de descarga DeshabilitarBotonesDescarga("PPTX"); DeshabilitarBotonesDescarga("MHTML"); DeshabilitarBotonesDescarga("XML"); DeshabilitarBotonesDescarga("ATOM"); DeshabilitarBotonesDescarga("RGDI"); DeshabilitarBotonesDescarga("HTML4.0"); DeshabilitarBotonesDescarga("RPL"); CambiarNombreBotonDescarga("IMAGE", "Imagen"); //Pasando Parametros: if (Request["ReportParameters"] != "undefined") { JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); dynamic parametros = jsonSerializer.Deserialize <dynamic>(Request["ReportParameters"]); int numberParameters = parametros.Count; ReportParameter[] parameters = new ReportParameter[numberParameters]; int i = 0; if (numberParameters > 0) { foreach (var parametro in parametros) { parameters[i] = new ReportParameter(parametro.Key, parametro.Value.ToString()); i++; } rvSiteMapping.ShowParameterPrompts = false; rvSiteMapping.ServerReport.SetParameters(parameters); } } rvSiteMapping.ServerReport.Refresh(); } catch (Exception ex) { Regex reg = new Regex("Parameter (.*) does not exist on this report"); Match match = reg.Match(ex.Message.ToString()); if (match.Success) { var valor = match.Groups[1].Value; ReportErrorMessage.Text = "Ocurrió un problema: El parámetro " + valor + " no existe en este reporte"; } else { ReportErrorMessage.Text = "Ocurrió un problema: " + ex.Message.ToString(); } ReportErrorMessage.Visible = true; } } }
protected Tuple <byte[], string> generateExcel(string RefId, string Dept, string Applicant, string CreateDateStart, string CreateDateEnd, string CompletionDateStart, string CompletionDateEnd, string Keyword, string sort, string applicantEmpyNo) { try { using (var reportViewer = new ReportViewer()) { Warning[] warnings; string[] streamids; string mimeType; string encoding; string filenameExtension; reportViewer.ProcessingMode = ProcessingMode.Remote; IReportServerCredentials irsc = new CustomReportCredentials(ConfigurationManager.AppSettings.Get("SSRSLoginUser").ToString(), ConfigurationManager.AppSettings.Get("SSRSLoginPassword").ToString()); reportViewer.ServerReport.ReportServerCredentials = irsc; reportViewer.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings.Get("SSRSPath").ToString()); reportViewer.ServerReport.ReportPath = ConfigurationManager.AppSettings.Get("SSTSFolderPath").ToString(); reportViewer.ServerReport.SetParameters(new ReportParameter("RefId", RefId)); reportViewer.ServerReport.SetParameters(new ReportParameter("Dept", Dept)); reportViewer.ServerReport.SetParameters(new ReportParameter("Applicant", Applicant)); reportViewer.ServerReport.SetParameters(new ReportParameter("CreateDateStart", CreateDateStart)); reportViewer.ServerReport.SetParameters(new ReportParameter("CreateDateEnd", CreateDateEnd)); reportViewer.ServerReport.SetParameters(new ReportParameter("CompletionDateStart", CompletionDateStart)); reportViewer.ServerReport.SetParameters(new ReportParameter("CompletionDateEnd", CompletionDateEnd)); reportViewer.ServerReport.SetParameters(new ReportParameter("Keyword", Keyword)); reportViewer.ServerReport.SetParameters(new ReportParameter("ApplicantEmp", applicantEmpyNo)); if (!String.IsNullOrEmpty(sort)) { string[] tmp = sort.Split(','); List <string> tmpArr = new List <string>(); foreach (var i in tmp) { tmpArr.Add(changeSqlCode(i)); } var sqlValue = String.Join(",", tmpArr.ToArray()); if (sqlValue != "") { reportViewer.ServerReport.SetParameters(new ReportParameter("Sort", sqlValue)); } } byte[] resultByte = reportViewer.ServerReport.Render("Excel", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; //string saveExcel = ConfigurationManager.AppSettings.Get("SSRSSaveExcel").ToString(); //if (saveExcel == "1") //{ // using (FileStream fs = new FileStream(@ConfigurationManager.AppSettings.Get("SSRSSavePath").ToString() + fileName, FileMode.Create)) // { // fs.Write(resultByte, 0, resultByte.Length); // } //} return(Tuple.Create(resultByte, fileName)); } } catch (Exception ex) { throw ex; } }
public FileResult DownloadReport(string ReportName, string ReportFormat) { // Verify ReportFormat is passed if (!ReportFormats.ContainsKey(ReportFormat)) { ArgumentException ex = new ArgumentException(string.Format(@"Unrecognized report format ""?"".", ReportFormat)); throw ex; } // If DSR report, see if needs to be resegmented before reporting if (ReportName == "Dynamic Segmentation Records") { //Resegment(); //PH 2014.05.22 need user id //PipelineFeatureList.AppCode.AppLibrary.CopyToHistoryGenerateGradesDynamicSegmentation(Convert.ToInt64(Session["CurrentValveSection"].ToString()), 0, 0, 1); PipelineFeatureList.AppCode.AppLibrary.CopyToHistoryGenerateGradesDynamicSegmentation( Convert.ToInt64(Session["UserID"].ToString()), Convert.ToInt64(Session["CurrentValveSection"].ToString()), 0, 0, 1); //PH 2014.05.22 end edit Thread.Sleep(10000); } // Get connected database var sqlDB = new System.Data.SqlClient.SqlConnectionStringBuilder( System.Configuration.ConfigurationManager.ConnectionStrings["PipelineFeatureListDBContext"].ConnectionString); var dbName = sqlDB.InitialCatalog; var dbDataSource = sqlDB.DataSource; // Set report path ReportViewer rptViewer = new ReportViewer(); string urlReportServer = "http://" + dbDataSource + "/ReportServer"; // "http://g2dev.g2partnersllc.local/ReportServer"; rptViewer.ProcessingMode = ProcessingMode.Remote; // ProcessingMode will be Either Remote or Local rptViewer.ServerReport.ReportServerUrl = new Uri(urlReportServer); //Set the ReportServer Url rptViewer.ServerReport.ReportPath = "/" + dbName + "/" + ReportName; //Passing the Report Path //Creating an ArrayList for combine the Parameters which will be passed into SSRS Report ArrayList reportParam = new ArrayList(); reportParam = ReportDefaultParam(); ReportParameter[] param = new ReportParameter[reportParam.Count]; for (int k = 0; k < reportParam.Count; k++) { param[k] = (ReportParameter)reportParam[k]; } // pass crendentials IReportServerCredentials irsc = new CustomReportCredentials(); rptViewer.ServerReport.ReportServerCredentials = irsc; //pass parmeters to report rptViewer.ServerReport.SetParameters(param); //Set Report Parameters rptViewer.ServerReport.Refresh(); byte[] streamBytes = null; string mimeType = ""; string encoding = ""; string filenameExtension = ""; string[] streamids = null; Warning[] warnings = null; string filename = ReportName + "." + ReportFormats[ReportFormat]; streamBytes = rptViewer.ServerReport.Render(ReportFormat, null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); return(File(streamBytes, mimeType, filename)); }
protected void grdPandingDetails_RowCommand(object sender, GridViewCommandEventArgs e) { pnlReport.Visible = true; if (e.CommandName == "ShowPopup") { // int rwindex = int.Parse(e.CommandArgument.ToString()); // GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); //LinkButton lnkbtn = (LinkButton)row.FindControl("LinkButtonPrint"); //LinkButton lnkbtnpreview = (LinkButton)row.FindControl("LinkButtonEdit"); //lnkbtn.Visible = true; //lnkbtnpreview.Visible = false; LinkButton btndetails = (LinkButton)e.CommandSource; GridViewRow gvrow = (GridViewRow)btndetails.NamingContainer; dt = new DataTable(); dt = (DataTable)Session["PrintPopup"]; int rwindex = gvrow.RowIndex; if (dt.Rows.Count > 0) { LblApplicationNo.Text = dt.Rows[rwindex]["ApplicationId"].ToString(); LblRoll.Text = dt.Rows[rwindex]["RollNo"].ToString(); LblStuName.Text = dt.Rows[rwindex]["StudentName"].ToString(); LblDateApplication.Text = dt.Rows[rwindex]["EntryDate"].ToString(); LblLastDate.Text = dt.Rows[rwindex]["LastApprovalDate"].ToString(); } if (Session["DocType"].ToString() == "2") { Session["Report"] = "Report_4"; } else if (Session["DocType"].ToString() == "9") { Session["Report"] = "Report_6"; } else if (Session["DocType"].ToString() == "4") { Session["Report"] = "Report_8"; } else if (Session["DocType"].ToString() == "3") { Session["Report"] = "Report_9"; } else if (Session["DocType"].ToString() == "8") { Session["Report"] = "Report_10"; } else if (Session["DocType"].ToString() == "11") { Session["Report"] = "Report_11"; } else { lblMsg.Text = "Report Not Prepare till Now."; return; } Hashtable Ht = new Hashtable(); Ht.Add("Ind", 2); Ht.Add("UserID", Session["UserId"]); Ht.Add("LevelID", Session["UserTypeId"]); Ht.Add("ApplicationID", LblApplicationNo.Text); Ht.Add("DocType", Session["DocType"]); Session["HT"] = Ht; //HiddenField1.Value = Request.UrlReferrer.AbsoluteUri; ReportViewer1.ShowCredentialPrompts = true; Microsoft.Reporting.WebForms.IReportServerCredentials irsc = new CustomReportCredentials("administrator", ConfigurationManager.AppSettings["Password"].ToString(), ConfigurationManager.AppSettings["ReportServer"].ToString());//"http://occweb02/ReportServer"); ReportViewer1.ServerReport.ReportServerCredentials = irsc; Hashtable HT = new Hashtable(); HT = (Hashtable)Session["HT"]; ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote; ReportViewer1.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServer"].ToString()); // ReportViewer1.ServerReport.ReportPath = ConfigurationManager.AppSettings["ReportProjectName"].ToString() + Convert.ToString(ConfigurationSettings.AppSettings["Report"]); ReportViewer1.ServerReport.ReportPath = ConfigurationManager.AppSettings["ReportProjectName"].ToString() + Session["Report"].ToString(); if (HT != null) { ReportParameter[] parm = new ReportParameter[HT.Count]; int i = 0; foreach (DictionaryEntry Dt in HT) { parm[i] = new ReportParameter(Convert.ToString(Dt.Key), Convert.ToString(Dt.Value)); i++; } ReportViewer1.ServerReport.SetParameters(parm); ReportViewer1.ServerReport.Refresh(); } //downloadpdf(); } }
protected Tuple <byte[], string> generateExcel(dynamic stuff) { try { using (var reportViewer = new ReportViewer()) { Warning[] warnings; string[] streamids; string mimeType; string encoding; string filenameExtension; string RuleCode, UserId1, UserId2, Team, Department, DateFrom, DateTo, Criteria; int Rule, Score, Priority; int? LevelNo, GroupID, GroupID1, Grade1, Grade2, TeamFilter, Grade3, Grade4; RuleCode = stuff.RuleCode; Rule = stuff.Rule; Score = stuff.Score; UserId1 = stuff.UserId1; UserId2 = stuff.UserId2; Team = stuff.Team; Department = stuff.Department; DateFrom = stuff.DateFrom; DateTo = stuff.DateTo; Priority = stuff.Priority; Grade1 = this.TryParseNullable(stuff.Grade1.ToString()); Grade2 = this.TryParseNullable(stuff.Grade2.ToString()); Grade3 = this.TryParseNullable(stuff.Grade3.ToString()); Grade4 = this.TryParseNullable(stuff.Grade4.ToString()); LevelNo = this.TryParseNullable(stuff.LevelNo.ToString()); GroupID = this.TryParseNullable(stuff.GroupID.ToString()); GroupID1 = this.TryParseNullable(stuff.GroupID1.ToString()); TeamFilter = this.TryParseNullable(stuff.TeamFilter.ToString()); Criteria = ""; if (!string.IsNullOrEmpty(stuff.Criteria.ToString())) { foreach (var i in stuff.Criteria) { if (!string.IsNullOrEmpty(Criteria)) { Criteria += ';'; } Criteria += i; } if (!string.IsNullOrEmpty(Criteria)) { Criteria += ";"; } } reportViewer.ProcessingMode = ProcessingMode.Remote; IReportServerCredentials irsc = new CustomReportCredentials(ConfigurationManager.AppSettings.Get("SSRSLoginUser").ToString(), ConfigurationManager.AppSettings.Get("SSRSLoginPassword").ToString()); reportViewer.ServerReport.ReportServerCredentials = irsc; reportViewer.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings.Get("SSRSPath").ToString()); reportViewer.ServerReport.ReportPath = ConfigurationManager.AppSettings.Get("SSTSFolderPath").ToString(); reportViewer.ServerReport.SetParameters(new ReportParameter("RuleCode", RuleCode)); reportViewer.ServerReport.SetParameters(new ReportParameter("Template", Rule.ToString())); reportViewer.ServerReport.SetParameters(new ReportParameter("Score", Score.ToString())); reportViewer.ServerReport.SetParameters(new ReportParameter("UserEmployeeID", UserId2)); reportViewer.ServerReport.SetParameters(new ReportParameter("UserMinGradeLevel", Grade3.ToString())); reportViewer.ServerReport.SetParameters(new ReportParameter("UserMaxGradeLevel", Grade4.ToString())); if (GroupID1.GetValueOrDefault(0) != 0) { reportViewer.ServerReport.SetParameters(new ReportParameter("UserGroupID", GroupID1.ToString())); } reportViewer.ServerReport.SetParameters(new ReportParameter("UserDepartment", Department)); reportViewer.ServerReport.SetParameters(new ReportParameter("UserTeam", Team)); if (TeamFilter.GetValueOrDefault(0) != 0) { reportViewer.ServerReport.SetParameters(new ReportParameter("UserTeamFilter", TeamFilter.ToString())); } reportViewer.ServerReport.SetParameters(new ReportParameter("isDefault", Priority.ToString())); reportViewer.ServerReport.SetParameters(new ReportParameter("WorkerEmployeeID", UserId1)); reportViewer.ServerReport.SetParameters(new ReportParameter("WorkerMinGradeLevel", Grade1.ToString())); reportViewer.ServerReport.SetParameters(new ReportParameter("WorkerMaxGradeLevel", Grade2.ToString())); if (GroupID.GetValueOrDefault(0) != 0) { reportViewer.ServerReport.SetParameters(new ReportParameter("WorkerGroupID", GroupID.ToString())); } if (LevelNo.GetValueOrDefault(0) != 0) { reportViewer.ServerReport.SetParameters(new ReportParameter("WorkerOrgChartLevel", LevelNo.ToString())); } reportViewer.ServerReport.SetParameters(new ReportParameter("OtherCriteria", Criteria)); if (!string.IsNullOrEmpty(DateFrom)) { reportViewer.ServerReport.SetParameters(new ReportParameter("StartDate", DateFrom + " 00:00:00")); } if (!string.IsNullOrEmpty(DateTo)) { reportViewer.ServerReport.SetParameters(new ReportParameter("EndDate", DateTo + " 00:00:00")); } byte[] resultByte = reportViewer.ServerReport.Render("Excel", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; //string saveExcel = ConfigurationManager.AppSettings.Get("SSRSSaveExcel").ToString(); //if (saveExcel == "1") //{ // using (FileStream fs = new FileStream(@ConfigurationManager.AppSettings.Get("SSRSSavePath").ToString() + fileName, FileMode.Create)) // { // fs.Write(resultByte, 0, resultByte.Length); // } //} return(Tuple.Create(resultByte, fileName)); } } catch (Exception ex) { throw ex; } }