文件不会上传到报表服务器

时间:2011-03-16 15:47:07

标签: c# report webclient reportserver

我正在尝试将报告从文件系统上传到报告服务器,但由于某种原因,我上传时报告不会显示

以下是代码部分:

WebClient reptserv = new WebClient();
        File.WriteAllLines(@"C:\HereGoesNothing.rdl", lines);
        Uri address = new Uri("http://localhost/reportserver");
        reptserv.UploadFileAsync(address, @"C:\HereGoesNothing.rdl");           

该报告在报告生成器中运行得很好,所以我知道这不是问题,但在此之后我感到难过。

1 个答案:

答案 0 :(得分:2)

请看下面这么问题的答案,这是实现你想做的更好的方法...... Upload a report file to Report manager via .net application?

基本上,您将服务引用添加到报表服务器,然后通过代理类上传,同时查看:http://msdn.microsoft.com/en-us/library/aa237438%28SQL.80%29.aspx

public static void createReport()
{
  ReportingService rs = new ReportingService();
  rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

  Byte[] definition = null;
  Warning[] warnings = null;
  string name = "HereGoesNothing";

  try
  {
     FileStream stream = File.OpenRead(@"C:\HereGoesNothing.rdl");
     definition = new Byte[stream.Length];
     stream.Read(definition, 0, (int) stream.Length);
     stream.Close();
  }

  catch(IOException e)
  {
     Console.WriteLine(e.Message);
  }

  try
  {
     warnings = rs.CreateReport(name, "/", false, definition, null);

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

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

  catch (SoapException e)
  {
     Console.WriteLine(e.Detail.InnerXml.ToString());
  }

}