2010-06-25 101 views
3

我有一個現有的類結構,希望/需要將它用作使用vb和2005的一系列報告的數據源(儘管我們幾乎已準備好移至2010 ,所以,如果今天將解決這一招病!)報告查看器 - 帶有嵌套列表對象的對象

使用gotreportviewer sample嵌套對象香港專業教育學院增加了一個reportmanager類暴露其香港專業教育學院填充了我的所有數據和返回(的對象)列表的GetData方法。數據在數據綁定點存在且正確,我可以添加和引用頂級屬性,但無論我嘗試什麼語法,都無法引用嵌套類/列表中的字段。我得到各種各樣的消息,從輸出字段中的「#Error」到任何內容,都不會編譯。

我的階級結構大致是這樣的縮略形式:

Assembly0 
    Class ReportManager 
    TheData as List(Of Object) 
    New() 'that populates TheData from the class structure below 
    GetData() as List(of Object)  

    Assembly1 
    Class Test 
    aProperty1 as String 
    aProperty2 as Int 
    aProperty3 as String 
    aProperty4 as String 
    aProperty4 as List(of aType1) 

    Assembly2 
    Class AaType1 
    aProperty1 as String 
    aProperty2 as Int 
    aProperty3 as String 
    aProperty4 as String 
    aProperty4 as List(of aType2) 
    aProperty4 as List(of aType3) 
    aProperty4 as String 

    Assembly3 
    Class aType2 
    aProperty1 as Boolean 
    aProperty1 as String 
    you get the idea 

    and so on..... 
我主要的應用程序

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
' Create an instance of our ReportManager Class 
Try 
    ' trust assemblies used in get data 
    ReportViewer1.LocalReport.ExecuteReportInCurrentAppDomain(Assembly.GetExecutingAssembly().Evidence) 
    ReportViewer1.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("assy1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1234") 
    ReportViewer1.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("assy2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1234") 
    ' etc through ALL dependant assemblies 

    ' create datamanager, that will populate its TheData property 
    Dim reportMan As Data.Reporting.Manager = New Data.Reporting.Manager(18) ' test id sent 

    ' this is the method from the gotreportviewer sample, which only allows you to reference top level properties, regardless of syntax used. i.e. =Fields!Prop.Value.SubProp 
    ' doesnt work 
    'ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DummyDataSource", reportMan.GetData)) 
    'Me.ReportingDataBindingSource.DataSource = reportMan.GetData 


    ' this is the only method i have found that allows me to reference an objects nested property and its fields.....? 
    Data = reportMan.GetData() 
    Me.ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local 
    Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("Data_Reporting_ReportingData", Data)) 

    ' fortnatley there is only ever one test in the list, HOWEVER there will be 4 specimens and n stages below that and so on.. 
    Dim SpecimenData As SpecimenList = Data(0).Specimens 
    Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("Tests_Specimen", SpecimenData)) 

    ' so this method is no good either. currently only a test its just returning the first specimen. 
    'Dim StageData As Tests.Stages = Data(0).Specimens(0).Stages 
    'Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("Tests_Specimen", SpecimenData)) 

    ' render report 
    Me.ReportViewer1.RefreshReport() 
Catch ex As Exception 
    MessageBox.Show(ex.Message) 
End Try 

末次

修復我在網上找到/谷歌搜索:

  • 你必須添加「ExecuteReportInCurrentAppDomain」, 做了沒有區別。

  • 您必須添加 Assembly:AllowPartiallyTrustedCallers()到AssemblyInfo.vb,沒有區別。

  • 必須強烈名字,你依賴程序,做到這一點和它沒有擺脫 關於呼叫的錯誤報告 (本地化)的「代碼」屬性正在取得進展。

  • 已嘗試使用= Fields!Property.Value.SubProperty語法並且它不工作!不管我嘗試什麼樣的變化。

    「在RDLC - 此語法同樣適用於頂級性能
    = SUM(!字段TestVersion.Value,‘Data_Reporting_ReportingData’)

    」使用在上面的代碼替代方法列表這個作品
    =第一(場!Index.Value, 「Tests_Specimen」)

    ',但這些不爲其子屬性
    =第一(場!Specimens.Value.Index, 「Data_Reporting_ReportingData」)
    =領域!Specimens.Value 。索引
    =領域!Specimens.Value.Index.Value

    這是否意味着IM布萊恩得到別無選擇,只有創造這樣 昏暗SpecimenData作爲Tests.SpecimenList =數據(0).Specimens爲每一個嵌套的對象嗎?也是由於顯而易見的原因,而不是必須將整個數據結構變得龐大。

我已經試過所有我能找到關於這一點,實在太少了,一切都點回到同一三四文章/博客文章,僅僅的arent爲我工作,thier樣品未修改的工作,但他們都不當應用於嵌套列表或嵌套的繼承列表類型的對象時工作。

有沒有人有任何使用嵌套列表實際工作的對象的示例代碼?因爲我可以找到除了最簡單的情景之外的其他工具。即一個程序集或一個代碼文件,或者不包含嵌套列表或簡單/本地類型。

我一直在這一週的最佳部分!即時通訊現在禿頭和強調請幫助。

失敗,任何人都可以建議一個支持這種事情的第三方供應商? 沒有水晶?卵石?

appologies文本的牆...... MATMA

回答

2

I'm尋找幾乎相同,只是,我有一個有物業的其他對象,沒有對象的列表,任何方式,你的對象問水晶報表是否做這種事情,這樣做有點困難,但確實如此。

我不知道爲什麼在現在這樣的日子裏想這麼難。因爲我們一直在使用持久性框架,比如實體框架等,所以,您使用Persistance做了一個糟糕的工作,而當您訪問報表時,如果您想輕鬆工作,則需要返回到DataBase模型! 浪費時間!

我剛剛發現,it's可能這樣做的報表查看器,但它在Visual Studio 2010中的一個問題,it's固定在SP1,但你需要設置所有的類都被用作嵌套對象爲Serializable

請閱讀:http://wraithnath.blogspot.com.br/2011/04/reportviewer-object-datasource-nested.html

+0

呀,這似乎是一種解決,但我不看中經歷的籃球執行解決方案從啓動對象IM是傳統的東西,必須在整個有200個對象它的整個heirachy – Matma 2012-11-13 09:35:02