SSRS不会发布报告,但它会像成功一样返回成功

时间:2011-10-13 19:34:32

标签: c# reporting-services reporting ssrs-2008

public static void ListFolders()
{
    HomeFolderListing = new List<string>();

    ReportingServiceSoapClient rs = new ReportingServiceSoapClient();
    rs.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;

    CatalogItem[] HomeFolders = null;
    string reportPath = "/";
    rs.ListChildren(reportPath, true, out HomeFolders);

    foreach (var homeF in HomeFolders)
    {

        if (homeF.Name.ToString().ToLower().Contains("base"))
        {
            if (homeF.Path.ToString().ToLower().Contains("/data sources/"))
            {
            }
            else
            {
                Console.WriteLine("Adding reporting folder: " + homeF.Name.ToString());
                HomeFolderListing.Add(homeF.Path.ToString());
            }
        }

    }

}

public static void PublishReport()
{
    foreach (string HomeFold in HomeFolderListing)
    {
        ReportingServiceSoapClient rs = new ReportingServiceSoapClient();
        rs.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;

        BatchHeader bh = new BatchHeader();
        string batchID = null;
        rs.CreateBatch(out batchID);
        bh.BatchID = batchID;

        Byte[] definition = null;
        Warning[] warnings = null;

        try
        {
            FileStream stream = File.OpenRead(ReportInformation.Report2Deploy);
            definition = new Byte[stream.Length];
            stream.Read(definition, 0, (int)stream.Length);
            stream.Close();
        }
        catch (Exception ex)
        {

        }
        try
        {

            string filename = ReportInformation.ReportDeployNameOnly;
            Console.WriteLine("Deploying Report: " + filename + " to: " + HomeFold);
            rs.CreateReport(bh, filename, HomeFold, true, definition, null, out warnings);

            if (warnings != null)
            {
                foreach (Warning warning in warnings)
                {
                    Console.WriteLine(warning.Message);
                }
            }

            else
                Console.WriteLine("Report: {0} created successfully with no warnings", filename);


        }
        catch (Exception ex)
        {

        }
    }
}

当我执行rs.CreateReport()时,它会回来,好像它没有警告就成功了,但是,当我查看服务器时,它就不存在了。是的,我正在查看所有文件夹。

1 个答案:

答案 0 :(得分:0)

您确定没有错误吗?有一个空的挡块。文档说要抓住SoapException。试试这个:

catch (SoapException e)
 {
      //Do something with the error, sample code write to console
      Console.WriteLine(e.Detail.InnerXml.ToString());
 }

取自:

http://msdn.microsoft.com/en-us/library/aa225813(v=sql.80).aspx

相关问题