订阅报告服务

时间:2010-03-06 19:20:09

标签: reporting-services

我想订阅2008年报告服务中特定时间表的报告。即报告将按计划自动向用户发送。我正在使用visual studio 2008.我已经通过refrence msdn完成了配置设置(rsreportserver.config,在添加了asmx文件的引用之后的app.config)。代码运行正常(没有异常发生),我也通过调用create subscription获得订阅ID,表示一切正常。但是在运行代码后,在ReportServer数据库的Subscription表中没有输入任何条目。而且也没有收到任何邮件。通过报表服务器Web工具,我可以获得电子邮件,也可以在数据库中输入,但不能从coe。请有人帮助我。我错过了什么。 Plz帮助

代码如下:(请记住,我使用的是VS2008)

void SendReportEmail()
{
RSServiceReference.ReportingService2005SoapClient rs=new RSServiceReference.ReportingService2005SoapClient();

rs.ClientCredentials.Windows.AllowedImpersonationLevel = new System.Security.Principal.TokenImpersonationLevel(); 

string batchID = string.Empty;
RSServiceReference.ServerInfoHeader infoHeader = rs.CreateBatch(out batchID);
BatchHeader bh = new BatchHeader()
{
    BatchID = batchID,
    AnyAttr = infoHeader.AnyAttr
};

string report = "/PCMSR6Reports/PaymentRequestStatusMIS";
string desc = "Send email from code to Hisham@comsoft.com";
string eventType = "TimedSubscription";

string scheduleXml="<ScheduleDefinition xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><StartDateTime xmlns=\"http://schemas.microsoft.com/sqlserver/2006/03/15/reporting/reportingservices\">2010-03-06T15:15:00.000+05:00</StartDateTime></ScheduleDefinition>";

RSServiceReference.ParameterValue[] extensionParams = new RSServiceReference.ParameterValue[7];     

extensionParams[0] = new RSServiceReference.ParameterValue();
extensionParams[0].Name = "TO";
extensionParams[0].Value = "Hisham@comsoft.com";

extensionParams[1] = new RSServiceReference.ParameterValue();
extensionParams[1].Name = "IncludeReport";
extensionParams[1].Value = "True";

extensionParams[2] = new RSServiceReference.ParameterValue();
extensionParams[2].Name = "RenderFormat";
extensionParams[2].Value = "MHTML";

extensionParams[3] = new RSServiceReference.ParameterValue();
extensionParams[3].Name = "Subject";
extensionParams[3].Value = "@ReportName was executed at @ExecutionTime";

extensionParams[4] = new RSServiceReference.ParameterValue();
extensionParams[4].Name = "Comment";
extensionParams[4].Value = "Here is your test report for testing purpose";

extensionParams[5] = new RSServiceReference.ParameterValue();
extensionParams[5].Name = "IncludeLink";
extensionParams[5].Value = "True";

extensionParams[6] = new RSServiceReference.ParameterValue();
extensionParams[6].Name = "Priority";
extensionParams[6].Value = "NORMAL";

RSServiceReference.ParameterValue[] parameters = new RSServiceReference.ParameterValue[10];

parameters[0] = new RSServiceReference.ParameterValue();
parameters[0].Name = "BranchId";
parameters[0].Value = "1";

parameters[1] = new RSServiceReference.ParameterValue();
parameters[1].Name = "UserName";
parameters[1].Value = "admin";

parameters[2] = new RSServiceReference.ParameterValue();
parameters[2].Name = "SupplierId";
parameters[2].Value = "0";

string matchData = scheduleXml;
RSServiceReference.ExtensionSettings extSettings = new RSServiceReference.ExtensionSettings();
extSettings.ParameterValues = extensionParams;
extSettings.Extension = "Report Server Email";
try
{
   string sub="";
   RSServiceReference.ServerInfoHeader SubID = rs.CreateSubscription(bh, report, extSettings, desc, eventType, matchData, parameters, out sub);

   rs.FireEvent(bh, "TimedSubscription", sub); 

}
catch (Exception e)
{
   Console.WriteLine(e);
}
}                        

详细回复将被高度评价。

1 个答案:

答案 0 :(得分:1)

尝试在xml字符串的开头添加@ @“