分几步进行,第一步要实现: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的更多相关文章

  1. Spring 4 官方文档学习(十三)集成其他web框架

    重点是通用配置,非常建议看一下!有助于理解Spring的ApplicationContext与Servlet Container的关系! 1.介绍 Spring Web Flow SWF目标是成为we ...

  2. 使用Apache CXF和Spring集成创建Web Service(zz)

    使用Apache CXF和Spring集成创建Web Service 您的评价:       还行  收藏该经验       1.创建HelloWorld 接口类 查看源码 打印? 1 package ...

  3. 5.把报表集成到Web应用程序中-生成网页和导出两种方式

    转自:https://wenku.baidu.com/view/104156f9770bf78a65295462.html 第四部分,把报表集成到Web应用程序中 用MyEclipse新建一个Web ...

  4. Spark与Spring集成做web接口

    需要实现的功能: 写访问spark的接口,也就是从web上输入网址就能把我们需要的信息通过提交一个job然后返回给我们json数据. 成果展示: 通过url请求,然后的到一个wordcount的jso ...

  5. SignalR SelfHost实时消息,集成到web中,实现服务器消息推送

    先前用过两次SignalR,但是中途有段时间没弄了,今天重新弄,发现已经忘得差不多了,做个笔记! 首先创建一个控制台项目Nuget添加引用联机搜索:Microsoft.AspNet.SignalR.S ...

  6. SharePoint RBS 安装(集成Office Web Apps)

    前言 本文完全原创,转载请说明出处,希望对大家有用. 本篇博客是个人总结,一方面以便日后查看,另一方面希望能为其他人提供一些便利. 阅读目录 安装RBS 为多个内容数据库开启RBS 正文 目的:在Sh ...

  7. Python Tornado集成JSON Web Token方式登录

    本项目github地址 前端测试模板如下: Tornado restful api 项目 项目结构如下: 项目组织类似于django,由独立的app模块构成. 登录接口设计 模式:post -> ...

  8. .Net Core集成Office Web Apps(二)

    想要使用OWA需要一台单独的服务器来部署,这对很多人造成困难.而写该文的目的是为了分享有个OWA的集成步骤,它不仅适用于.Net开发环境,其它语言也是一样的,只要实现了需要的服务接口.并且该文不局限与 ...

  9. .Net Core集成Office Web Apps(一)

    最近开始学习.Net Core,并使用Visual Studio Code工具来开发.感觉开发起来特别的方便,但是有个头疼的地方:许多的类库被修改了,一时半会儿还熟悉不了,需要查阅官方API... M ...

随机推荐

  1. 问题:如何在固定大小的DIV层插入N多个图片

    这是贴友问的一个问题,具体需求是: 如何在固定大小的DIV层插入N多个图片,使其一行排列,超出层宽时出现滑动条? 原以为利用overflow属性可以实现,但是测试失败.后来利用div层叠实现了效果. ...

  2. ffmpeg常见命令

    一.安装       下载ffmpeg,解压之后配置环境变量即为安装 打开dos界面,进入目标文件夹例如:E:/ cd E:\BaiduYunDownload\ffmpeg\ffmpeg_simple ...

  3. [读书笔记]了不起的node.js(四)

    这周的学习主要是nodejs的数据库交互上,并使用jade模板一起做了一个用户验证的网站.主要是遇到了一下几个问题. 1.mongodb版本过低 npm ERR! Not compatible wit ...

  4. 29个你必须知道的Linux命令

    虽然Linux发行版支持各种各样的饿GUI(graphical user interfaces),但在某些情况下,Linux的命令行接口(bash)仍然是简单快速的.Bash和 Linux Shell ...

  5. hdoj 2050 折线分割平面

    折线分割平面 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...

  6. IOS应用安全(五):高级Runtime分析和操作

    在前一篇文章,我们学习如何安装Cycript在你的苹果设备,hook进程获取其相关属性信息.这一篇文章,我们将介绍高级的runtime分析技术,在应用运行时获取或者修改指定class的信息(方法.实例 ...

  7. Dijkstra in python

    下面是一段由python实现的Dijkstra算法,一些地方的处理实在非常棒,相比于C,代码的数量已经缩减到了60行,所以我想通过本文简单的介绍一下这段代码的细节之处,首先给出源程序: from sy ...

  8. oracle 修改索引现有表空间

    工作日记之<修改索引现有表空间> //dba_indexes可查询所有索引,以及索引部分信息,可以灵活运用于其他用途 //假设用户USER1现有表空间TS1.TS2,需要迁移其下所有表空间 ...

  9. 3.x的触摸响应机制

    第一种是采用函数回调,主要是用于MenuItem [cpp] view plaincopy // a selector callback void menuCloseCallback(Object*  ...

  10. Sql Server 带参数的存储过程执行方法

    Sql Server 带参数的存储过程执行方法 Visual C# 动态操作 SQL Server 数据库实例教程(4):带参数的存储过程执行方法 上一篇文章介绍了带参数的SQL语句执行方法和不带参数 ...