report service研究

報表服務器

Overwritedatasources: true(是的重寫) false(不重寫)

TargetDatasourceFolder: 目標數據原始檔案夾,如果不存在,新建檔夾

TargetReportFolder:目標報表檔夾,如果不存在,新建檔夾

TargetServerUrl:目標報表的網址

在訪問遠端報表時,遇到了許可權問題。因為Sharepoint伺服器和報表伺服器分別在不同機器上。在Sharepoint伺服器上運行一切正常,但從其他機器訪問就報沒有許可權。
又是典型的double hop。
基本思想是在報表伺服器上建一個報表專用帳戶,讓Sharepoint伺服器以該用戶的身份調用報表服務。

用戶端 -〉(用戶真實身份) -〉SharePoint伺服器 -〉(類比報表專用帳戶身份)-〉SQL 2005報表伺服器

一、使用web service訪問的處理方法
處理比較簡單,在創建web service proxy類時,類比類比報表專用帳戶。
public ReportAdapter(string serverURL,string path)
{
ReportSvr = new ReportingServer.ReportingService();
ReportSvr.Credentials = new System.Net.NetworkCredential(“user”, “pwd”, “domain”);
…..
後面的代碼不變
}
二、使用ReportViewer控制項的處理方法

使用ReportViewer控制項時會麻煩很多。首先,我們不能直接用System.Net.NetworkCredential,必須自己實現一個介面Microsoft.Reporting.WebForms.IReportServerCredentials。
不過網上有很多現成的代碼,也不需要自己寫了。

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Reporting.WebForms;

/// <summary>
/// Summary description for CustomReportCredentials
/// </summary>
[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;
}
}
需要注意[Serializable],因為我的頁面設置EnableSessionState=”True”,所有的資料都需要可以序列化。
有了類CustomReportCredentials,下面的事情就簡單了
protected void ButtonViewReport_Click(object sender, EventArgs e)
{
DateTime StartDate = System.Convert.ToDateTime(TextBoxStartDate.Value);
DateTime EndDate = System.Convert.ToDateTime(TextBoxEndDate.Value);

ReportParameter[] Parameters = new ReportParameter[2];
Parameters[0] = new ReportParameter(“startdate”, StartDate.ToShortDateString());
Parameters[1] = new ReportParameter(“enddate”, EndDate.ToShortDateString());
try
{
ReportViewer1.ServerReport.ReportServerUrl = new Uri(“http://ctc-bar:81/reportserver“);
ReportViewer1.ServerReport.ReportPath = “/BARReports/EBCdetaillist”;
ReportViewer1.ServerReport.ReportServerCredentials = new CustomReportCredentials(“user”, “pwd)”, “domain”);
ReportViewer1.ServerReport.SetParameters(Parameters);
}
catch (Microsoft.Reporting.WebForms.ReportSecurityException ex)
{
Response.Write(ex.Message);
}
catch (Exception ex2)
{
Response.Write(ex2.Message);
}
}
很奇怪,在設置ReportServerCredentials前,要對 ReportViewer1.ServerReport.ReportServerUrl和ReportViewer1.ServerReport.ReportPath賦值。但我明明已經在ReportViewer1的設計器中設了這兩個值。
如果不設置ReportServerCredentials,則不需要這樣。

//搜索按鈕

protected void btn_search_Click(object sender, EventArgs e)

{

List<ReportParameter> list = new List<ReportParameter>();

if (this.TextBox1.Text != “”)

{

list.Add(new ReportParameter(“userid”, this.TextBox1.Text.Trim()));

}

else

{

list.Add(new ReportParameter(“userid”));

}

ReportViewer1.ServerReport.SetParameters(list);

}
当出现"Job for network.service failed because the control process exited with error code"的错误消息时,这表示在重启网络服务时,控制进程退出并返回了错误代码。要解决这个问题,我们可以执行以下步骤: 1. 首先,通过运行命令"systemctl status network.service"查看网络服务的状态和详细信息。这将提供更多关于错误的上下文和诊断信息。 2. 另外,也可以通过运行命令"journalctl -xe"来查看系统日志,以获取与网络服务相关的任何其他错误或异常情况。 3. 根据上述命令输出的结果,可以确定具体的错误原因。可能的原因包括配置文件错误、网络设备故障或其他与网络服务相关的问题。 4. 一旦确定了错误原因,就可以采取适当的措施来解决问题。例如,可以检查并修复配置文件错误,确保网络设备正常运行,或执行其他必要的操作来修复网络服务。 请注意,具体的解决方法可能因系统配置和具体错误而异。建议根据系统提供的详细信息和错误代码进行进一步的研究和排除故障。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [解决 Linux 网络 “Job for network.service failed because the control process exite”问题](https://blog.csdn.net/VariatioZbw/article/details/107482739)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Job for network.service failed because the control process exited with error code.](https://blog.csdn.net/weixin_53572775/article/details/119654356)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值