ReportServer

 
                  <tr>
                    <td align="center" width="100%">
                    <rsweb:ReportViewer ID="reportViewer"  runat="server" Font-Names="Verdana" Width ="100%" 
                        Font-Size="8pt" AsyncRendering="False"  
                        ShowReportBody="True" SizeToReportContent="True">
                    </rsweb:ReportViewer>
                    </td>
                 </tr>

         </table>


  //訪問報表憑證用戶
        MyReportViewerCredential rp = new MyReportViewerCredential(MyReportViewerCredential.UserName, MyReportViewerCredential.Password, MyReportViewerCredential.domain);
        reportViewer.ServerReport.ReportServerCredentials = rp;
        reportViewer.ProcessingMode = ProcessingMode.Remote;
        reportViewer.ShowToolBar = false; 
        ServerReport serverReport = reportViewer.ServerReport;
        serverReport.ReportServerUrl = new Uri(CommonProc.ReportServerUrl);
        serverReport.ReportPath = "/投資批覆費用報表";



  //訪問報表憑證用戶
        ReportParameter param = new ReportParameter();
        param.Name = "StartDate";
        string strStratDate = PlanDateStartTime.SelectedDate.Trim();
        param.Values.Add(strStratDate);
        ReportParameter param1 = new ReportParameter();
        param1.Name = "EndDate";
        string strEndDate = PlanDateEndTime.SelectedDate.Trim();
        param1.Values.Add(strEndDate);
        reportViewer.ServerReport.SetParameters(new ReportParameter[] { param });
        reportViewer.ServerReport.SetParameters(new ReportParameter[] { param1 });


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Web.SessionState;
using System.Web.Security;
using Microsoft.Reporting.WebForms;
using System.Security.Principal;




/// <summary>
///ReportCertificate 的摘要說明
/// </summary>
public class MyReportViewerCredential:IReportServerCredentials 
{
    //配置報表用戶的用戶名,密碼和域
    public static string UserName = System.Configuration.ConfigurationSettings.AppSettings["UserReportServerName"].ToString();
    public static string Password = System.Configuration.ConfigurationSettings.AppSettings["UserReportServerPassword"].ToString();
    public static string domain = System.Configuration.ConfigurationSettings.AppSettings["Domain"].ToString();


    //私有變量
    private string _username;       //用戶名
    private string _password;      //密碼
    private string _domain;         //域


    /// <summary>
    /// 構造函數
    /// </summary>
    /// <param name="username">用戶名</param>
    /// <param name="password">密碼</param>
    /// <param name="domain">域</param>
    public MyReportViewerCredential(string username, string password, string domain)
    {
        _username = username;
        _password = password;
        _domain = domain;
    }




    /// <summary>
    /// 實現IReportServerCredentials接口的成員屬性(ImpersonateUser)
    /// </summary>
    public WindowsIdentity ImpersonationUser
    {
        get { return null; }
    }




    /// <summary>
    /// 實現IReportServerCredentials接口的成員屬性(NetworkCedentials)
    /// </summary>
    public System.Net.ICredentials NetworkCredentials
    {
        get { return new NetworkCredential(_username, _password, _domain); }
    }




    /// <summary>
    /// 實現IReportServerCredentials接口的成員方法(GetFormCedentials)
    /// </summary>
    /// <param name="authCookie">Cookie類對象</param>
    /// <param name="user">用戶名</param>
    /// <param name="password">密碼</param>
    /// <param name="authority">域</param>
    /// <returns></returns>
    public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
    {
        authCookie = null;
        user = _username;
        password = _password;
        authority = _domain;
        return false;
    }
}

 

http://www.cnblogs.com/BlueWoods/archive/2009/04/27/1444311.html

http://blog.csdn.net/hebeijg/article/details/7328932

http://www.microsoft.com/zh-cn/download/details.aspx?id=35747

http://blog.csdn.net/hebeijg/article/details/7328932

http://www.dotblogs.com.tw/yangxinde/archive/2012/11/07/80655.aspx

 

http://www.360doc.com/userhome.aspx?userid=7664736&cid=6#


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章