/// <summary> /// 打开一WEB页面 /// </summary> /// <param name="strWinTitle">窗口标题</param> /// <param name="strUrl">页面地址,如“http://www.123.com”</param> /// <param name="postData">向页面传递POST参数</param> public void ShowReports(string strWinTitle, string strReportPath, Object postData) { //AddRpParameterItem("strUser", "zhangbanghua"); //AddRpParameterItem("strVsl", "minwu"); strReportPath = strReportPath.StartsWith("/") ? strReportPath : "/" + strReportPath; reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote; this.reportViewer1.ServerReport.DisplayName = strWinTitle; this.reportViewer1.ServerReport.ReportServerUrl = new Uri(this.frmReportServicesPath); // (System.Configuration.ConfigurationManager.AppSettings["ReportServices"]);//"http://172.20.28.17/ReportServer" this.reportViewer1.ServerReport.ReportPath = strReportPath; // "/fdcf/fVslApTruckChargeSheet"; //string strUser = ConfigurationManager.AppSettings["MyReportViewerUser"]; //string strPsw = ConfigurationManager.AppSettings["MyReportViewerPassword"]; //string domain = ConfigurationManager.AppSettings["MyReportViewerDomain"]; //reportViewer1.ServerReport.ReportServerCredentials.SetFormsCredentials(null, strUser, strPsw, domain); Microsoft.Reporting.WinForms.ReportParameterInfoCollection RParameter = this.reportViewer1.ServerReport.GetParameters(); if (dtRpara != null && dtRpara.Rows.Count > 0) { RParameters = new Microsoft.Reporting.WinForms.ReportParameter[dtRpara.Rows.Count]; for (int i = 0; i < dtRpara.Rows.Count; i++) { RParameters[i] = new Microsoft.Reporting.WinForms.ReportParameter(); Microsoft.Reporting.WinForms.ReportParameter RParameterItem = new Microsoft.Reporting.WinForms.ReportParameter(); RParameterItem.Name = dtRpara.Rows[i]["RP_KEY"].ToString(); RParameterItem.Values.Add(dtRpara.Rows[i]["RP_VAL"].ToString()); RParameters[i] = RParameterItem; } this.reportViewer1.ServerReport.SetParameters(RParameters); } this.reportViewer1.ShowParameterPrompts = true; this.reportViewer1.RefreshReport(); // // Create a new webrequest to the mentioned URL. //// System.Net.WebRequest myWebRequest = System.Net.WebRequest.Create(strUrl); //// myWebRequest.PreAuthenticate=true; //// System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(strUserId,strUserPass); //// myWebRequest.Credentials = networkCredential; //// System.Net.WebResponse myWebResponse = myWebRequest.GetResponse(); // this.Text = strWinTitle; // Object optional = System.Reflection.Missing.Value; // if(postData == null) // postData = System.Reflection.Missing.Value; // this.axWebBrowser1.Navigate(strUrl,ref optional,ref optional,ref optional,ref optional); //// this.axWebBrowser1.Refresh2(0); // this.strFileType = "URL"; }
private void InitReportByUrl(string strRpUrl) { if (strRpUrl == string.Empty) { return; } int intS = strRpUrl.IndexOf("?/") + 2; int intE = strRpUrl.IndexOf("&"); if (intS == 1) { intS = strRpUrl.ToUpper().IndexOf("ReportServer".ToUpper()) + 12; } if (intS == 11) { intS = 0; } if (intE == -1) { intE = strRpUrl.Length; } string strRpPath = strRpUrl.Substring(intS, intE - intS); _strReportPath = strRpPath.StartsWith("/") ? strRpPath : "/" + strRpPath; reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote; this.reportViewer1.ServerReport.DisplayName = _strWinTitle; this.reportViewer1.ServerReport.ReportServerUrl = new Uri(this.frmReportServicesPath); // (System.Configuration.ConfigurationManager.AppSettings["ReportServices"]);//"http://172.20.28.17/ReportServer" this.reportViewer1.ServerReport.ReportPath = _strReportPath; // "/fdcf/fVslApTruckChargeSheet"; //string strUser = ConfigurationManager.AppSettings["MyReportViewerUser"]; //string strPsw = ConfigurationManager.AppSettings["MyReportViewerPassword"]; //string domain = ConfigurationManager.AppSettings["MyReportViewerDomain"]; //reportViewer1.ServerReport.ReportServerCredentials.SetFormsCredentials(null, strUser, strPsw, domain); Microsoft.Reporting.WinForms.ReportParameterInfoCollection RParameter = this.reportViewer1.ServerReport.GetParameters(); for (int r = 0; r < RParameter.Count; r++) { try { if (RParameter[r].Name == "strUser") { this.AddRpParameterItem(RParameter[r].Name, CApplication.App.CurrentSession.UserId.ToString()); } else if (RParameter[r].Name == "strDept") { this.AddRpParameterItem(RParameter[r].Name, CApplication.App.CurrentSession.DeptId.ToString()); } else if (RParameter[r].Name == "strFy") { this.AddRpParameterItem(RParameter[r].Name, CApplication.App.CurrentSession.FyId.ToString()); } else { string PRtemValue = StaticFunctions.GetFrmParamValue(strRpUrl, RParameter[r].Name, new char[] { '&' }); if (PRtemValue != string.Empty) { this.AddRpParameterItem(RParameter[r].Name, PRtemValue); } } } catch { } } if (dtRpara != null && dtRpara.Rows.Count > 0) { RParameters = new Microsoft.Reporting.WinForms.ReportParameter[dtRpara.Rows.Count]; for (int i = 0; i < dtRpara.Rows.Count; i++) { RParameters[i] = new Microsoft.Reporting.WinForms.ReportParameter(); Microsoft.Reporting.WinForms.ReportParameter RParameterItem = new Microsoft.Reporting.WinForms.ReportParameter(); RParameterItem.Name = dtRpara.Rows[i]["RP_KEY"].ToString(); RParameterItem.Values.Add(dtRpara.Rows[i]["RP_VAL"].ToString()); RParameters[i] = RParameterItem; } this.reportViewer1.ServerReport.SetParameters(RParameters); } this.reportViewer1.ShowParameterPrompts = true; this.reportViewer1.RefreshReport(); }