BI ReportViewer呼び出しレポートサーバレポートソース
2105 ワード
//
ReportViewer1.SizeToReportContent = true;
ReportViewer1.ShowCredentialPrompts = false;
ReportViewer1.ZoomMode = ZoomMode.PageWidth;
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://192.168.1.1/ReportServer");
ReportViewer1.ServerReport.ReportPath = "/report/Report1";
ReportViewer1.ServerReport.ReportServerCredentials = new ReportSCredentials("", "", "");
List listCode = new List();
List parameters = new List
{
new ReportParameter(" ", "[ ].[ ].&[201901]"),
new ReportParameter(" ", "[ ].[ ].[All]"),
new ReportParameter(" ", listCode .ToArray())
};
ReportViewer1.ServerReport.SetParameters(parameters);
レポートには、レポート・サーバの認証も必要です.
public class ReportSCredentials : IReportServerCredentials
{
private string _UserName;
private string _PassWord;
private string _DomainName;
public ReportSCredentials(string UserName, string PassWord, string DomainName)
{
_UserName = UserName; _PassWord = PassWord; _DomainName = DomainName;
}
public WindowsIdentity ImpersonationUser
{
get { return null; }
}
public ICredentials NetworkCredentials
{
get
{
if (string.IsNullOrEmpty(_UserName) || string.IsNullOrEmpty(_PassWord)) { return null; }
else if (string.IsNullOrEmpty(_DomainName)) { return new NetworkCredential(_UserName, _PassWord); }
else { return new NetworkCredential(_UserName, _PassWord, _DomainName); }
}
}
public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
{
authCookie = null;
user = password = authority = null;
return false;
}
}