URL erişimi kullanarak Reporting Services'i entegre edin - Windows uygulaması

Rapor sunucusuna URL erişimi Web ortamı için optimize edilmiş olsa da, URL erişimini Reporting Services raporlarını Microsoft Windows bir uygulamaya gömmek için de kullanabilirsiniz. Ancak, Windows Forms'u içeren URL erişimi yine de web tarayıcı teknolojisi kullanmanızı gerektirir. URL erişimi ve Windows Forms ile aşağıdaki entegrasyon senaryolarını kullanabilirsiniz:

  • Bir Windows Form uygulamasından bir raporu programatik olarak bir web tarayıcısı başlatarak gösterin.

  • Bir raporu görüntülemek için Windows Form'daki kontrolü kullanınWebBrowser.

Internet Explorer'ı Windows Formundan başlatın

Sınıfı bilgisayarda çalışan bir sürece erişmek için kullanabilirsiniz Process . Sınıf, Process uygulamaları başlatmak, durdurmak, kontrol etmek ve izlemek için faydalı bir Microsoft .NET Framework yapısıdır. Rapor sunucusu veritabanınızda belirli bir raporu görmek için IExplore sürecini başlatabilir ve rapora URL iletebilirsiniz. Aşağıdaki kod örneği, kullanıcı Windows Formunda bir buton seçtiğinde belirli bir rapor URL'sini başlatmak ve Microsoft Internet Explorer iletmek için kullanılabilir.

Private Sub viewReportButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles viewReportButton.Click  
   ' Build the URL access string based on values supplied by a user  
   Dim url As String = serverUrlTextBox.Text + "?" & reportPathTextBox.Text & _  
   "&rs:Command=Render" & "&rs:Format=HTML4.0"  
  
   ' If the user does not select the toolbar check box,  
   ' turn the toolbar off in the HTML Viewer  
   If toolbarCheckBox.Checked = False Then  
      url += "&rc:Toolbar=False"  
   End If  
   ' load report in the Web browser  
   Try  
      System.Diagnostics.Process.Start("IExplore", url)  
   Catch  
      MessageBox.Show("The system could not start the specified report using Internet Explorer.", _  
      "An error has occurred", MessageBoxButtons.OK, MessageBoxIcon.Error)  
   End Try  
End Sub 'viewReportButton_Click  
// Sample click event for a Button control on a Windows Form  
private void viewReportButton_Click(object sender, System.EventArgs e)  
{  
   // Build the URL access string based on values supplied by a user  
   string url = serverUrlTextBox.Text + "?" + reportPathTextBox.Text +  
      "&rs:Command=Render" + "&rs:Format=HTML4.0";  
  
   // If the user does not check the toolbar check box,  
   // turn the toolbar off in the HTML Viewer  
   if (toolbarCheckBox.Checked == false)  
      url += "&rc:Toolbar=False";  
  
   // load report in the Web browser  
   try  
   {  
      System.Diagnostics.Process.Start("IExplore", url);  
   }  
  
   catch (Exception)  
   {  
      MessageBox.Show(  
         "The system could not open the specified report using Internet Explorer.",   
         "An error has occurred", MessageBoxButtons.OK, MessageBoxIcon.Error);  
   }  
}  

Bir Windows Form'a tarayıcı kontrolü gömmek

Raporunuzu harici bir web tarayıcısında görüntülemek istemiyorsanız, kontrol WebBrowser kullanarak Windows Form'unuzun bir parçası olarak bir web tarayıcısını sorunsuzca gömebilirsiniz.

WebBrowser kontrolünü Windows Form'unuza eklemek için
  1. Yeni bir Windows uygulaması Microsoft C# veya Microsoft Visual Basic ile oluşturun.

  2. Kontrol birimini Toolbox Diyalog Kutusu'nda bulunWebBrowser.

    Eğer Araç Kutusu görünmüyorsa, menü öğesini seçipAraç Kutusu'nu seçerek erişebilirsiniz.

  3. Kontrolü WebBrowserWindows Form'unuzun tasarım yüzeyine sürükleyin.

    WebBrowserWebBrowser1 adlı kontrol Form'a eklenir

WebBrowser Kontrolü URL'ye yönlendirirsiniz, onun Navigate metodunu çağırırsınız. Aşağıdaki örnekte gösterildiği gibi, çalışma zamanında kontrolünize WebBrowser belirli bir URL erişim dizisi ataabilirsiniz.

Dim url As String = "https://localhost/reportserver?/" & _  
                    "AdventureWorks Sample Reports/" & _  
                    "Company Sales&rs:Command=Render"  
WebBrowser1.Navigate(url)  
string url = "https://localhost/reportserver?/" +  
             "AdventureWorks Sample Reports/" +  
             "Company Sales&rs:Command=Render";  
webBrowser1.Navigate(url);