標籤:controls cat null entity rtc class .config client method
分幾步進行,第一步要實現:IReportServerCredentials 介面
第二步:拖入ReportViewer控制項
第三步:進行報表傳參控制。具體如描述。。。。代碼部分參考下附件
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using TajimaOA.UI;using System.Data;using Microsoft.Reporting.WebForms; namespace TajimaOA.UI.BISSRSViewer{ public partial class BISSRSViewer : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //string l_ReportServerUrl = System.Web.Configuration.WebConfigurationManager.AppSettings["BIReportServerUrl"];//擷取報表格服務地址 if (!IsPostBack) { string l_CompanyID = this.Request["CompanyID"]; string l_DepartmentID = this.Request["DepartmentID"]; string l_EmployeeID = this.Request["EmployeeID"]; string l_IsGetCurrentUserID = this.Request["GetUser"]; //項目 string l_ProjectID = this.Request["ProjectID"];//2014-04-18 add by WesChen 項目ID string l_ProjectState = this.Request["ProjectState"];//2014-04-18 add by WesChen 項目狀態 //任務 string l_TaskID = this.Request["TaskID"];//2014-04-18 add by WesChen 專案工作ID string l_TaskState = this.Request["TaskState"];//2014-04-18 add by WesChen 專案工作ID string l_TaskStponeCode = this.Request["TaskStponeCode"];//2014-04-18 add by WesChen 專案工作延期編號 string l_ReportCode = this.Request["ReportCode"]; TajimaOA.UI.Areas.BI.Controllers.SSRSReport.SSRSManagerController l_ServiceClient = new Areas.BI.Controllers.SSRSReport.SSRSManagerController(); DataTable l_dt = l_ServiceClient.GetReportSettingByReportCode(l_ReportCode); if (l_dt == null || l_dt.Rows.Count == 0) { } else { string l_ReportServerUrl = l_dt.Rows[0]["ServerUrl"].ToString(); string l_ReportFolder = l_dt.Rows[0]["FolderCode"].ToString(); string l_Report = l_dt.Rows[0]["ReportCode"].ToString(); string l_SSRSUser = System.Web.Configuration.WebConfigurationManager.AppSettings["BISSRS-User"];//擷取憑證使用者名稱 string l_SSRSPassword = System.Web.Configuration.WebConfigurationManager.AppSettings["BISSRS-Password"];//擷取憑證口令 string l_SSRSDomainName = System.Web.Configuration.WebConfigurationManager.AppSettings["BISSRS-DomainName"];//擷取憑證域 BI_RptViewer.ServerReport.ReportServerCredentials = new CustomReportCredentials(l_SSRSUser, l_SSRSPassword, l_SSRSDomainName); BI_RptViewer.ServerReport.ReportServerUrl = new Uri(l_ReportServerUrl.Trim()); BI_RptViewer.ServerReport.ReportPath = l_ReportFolder + l_Report; BI_RptViewer.ShowBackButton = true; BI_RptViewer.ShowPrintButton = true; //2014-03-05 add by WesChen 增加報表參數 List<ReportParameter> l_ParList = new List<ReportParameter>(); if (l_IsGetCurrentUserID == "Y") { ReportParameter l_RptPar_CurrentUserID = new ReportParameter(); l_RptPar_CurrentUserID.Name = "CurrentUserID"; Guid l_CurrentUserID = TajimaOA.UI.Common.ComonMethods.GetCurrentUserID();//當前登陸使用者ID l_RptPar_CurrentUserID.Values.Add(l_CurrentUserID.ToString()); l_ParList.Add(l_RptPar_CurrentUserID); } if (!string.IsNullOrEmpty(l_CompanyID)) { ReportParameter l_RptPar_CompanyID = new ReportParameter(); l_RptPar_CompanyID.Name = "CompanyID"; l_RptPar_CompanyID.Values.Add(l_CompanyID); l_ParList.Add(l_RptPar_CompanyID); } if (!string.IsNullOrEmpty(l_DepartmentID)) { ReportParameter l_RptPar_DepartmentID = new ReportParameter(); l_RptPar_DepartmentID.Name = "DepartmentID"; l_RptPar_DepartmentID.Values.Add(l_DepartmentID); l_ParList.Add(l_RptPar_DepartmentID); } if (!string.IsNullOrEmpty(l_EmployeeID)) { ReportParameter l_RptPar_EmployeeID = new ReportParameter(); l_RptPar_EmployeeID.Name = "EmployeeID"; l_RptPar_EmployeeID.Values.Add(l_EmployeeID); l_ParList.Add(l_RptPar_EmployeeID); } //------------------------------------------- //2014-04-18 add by WesChen 項目ID if (!string.IsNullOrEmpty(l_ProjectID)) { ReportParameter l_RptPar_ProjectID = new ReportParameter(); l_RptPar_ProjectID.Name = "ProjectID"; l_RptPar_ProjectID.Values.Add(l_ProjectID); l_ParList.Add(l_RptPar_ProjectID); } //2014-04-18 add by WesChen 項目狀態 if (!string.IsNullOrEmpty(l_ProjectState)) { ReportParameter l_RptPar_ProjectState = new ReportParameter(); l_RptPar_ProjectState.Name = "ProjectState"; l_RptPar_ProjectState.Values.Add(l_ProjectState); l_ParList.Add(l_RptPar_ProjectState); } //------------------------------------------ //2014-04-18 add by WesChen 專案工作ID if (!string.IsNullOrEmpty(l_TaskID)) { ReportParameter l_RptPar_ProjectTaskID = new ReportParameter(); l_RptPar_ProjectTaskID.Name = "ProjectTaskID"; l_RptPar_ProjectTaskID.Values.Add(l_TaskID); l_ParList.Add(l_RptPar_ProjectTaskID); } //2014-04-18 add by WesChen 專案工作ID if (!string.IsNullOrEmpty(l_TaskState)) { ReportParameter l_RptPar_TaskState = new ReportParameter(); l_RptPar_TaskState.Name = "TaskState"; l_RptPar_TaskState.Values.Add(l_TaskState); l_ParList.Add(l_RptPar_TaskState); } //2014-04-18 add by WesChen 專案工作是否延期 if (!string.IsNullOrEmpty(l_TaskStponeCode)) { ReportParameter l_RptPar_TaskStponeCode = new ReportParameter(); l_RptPar_TaskStponeCode.Name = "TaskStponeCode"; l_RptPar_TaskStponeCode.Values.Add(l_TaskStponeCode); l_ParList.Add(l_RptPar_TaskStponeCode); } if (l_ParList.Count > 0) { BI_RptViewer.ServerReport.SetParameters(l_ParList); } } } } } [Serializable] public class CustomReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials { // local variable for network credential. private string _UserName; private string _PassWord; private string _DomainName; public CustomReportCredentials(string UserName, string PassWord, string DomainName) { _UserName = UserName; _PassWord = PassWord; _DomainName = DomainName; } public System.Security.Principal.WindowsIdentity ImpersonationUser { get { return null; // not use ImpersonationUser } } public System.Net.ICredentials NetworkCredentials { get { // use NetworkCredentials return new System.Net.NetworkCredential(_UserName, _PassWord, _DomainName); } } public bool GetFormsCredentials(out System.Net.Cookie authCookie, out string user, out string password, out string authority) { // not use FormsCredentials unless you have implements a custom autentication. authCookie = null; user = password = authority = null; return false; } }}
http://www.flybi.net/question/2835
SSRS整合至Web