IAnalyticReporting.GetDataSource (List<FieldForQdvFldConfigFile>, Boolean, String, Boolean) Method
Function GetDataSource( _
ByVal fields As List(Of FieldForQdvFldConfigFile), _
ByVal groupsAreCollapsed As Boolean, _
Optional ByVal headBranchIdentifier As String = "001000000000000000000000", _
Optional ByVal displayProgressWindows As Boolean = False _
) As IWorkbook
This language is not supported or no code example is available.
Parameters
- fields
- List<FieldForQdvFldConfigFile>
A list of FieldForQdvFldConfigFile which can be created programmatically or retrieved using the GetImageOfFieldsForDataSource function.
- groupsAreCollapsed
- bool
A value indicating whether the data source should have collapsed groups.
- headBranchIdentifier
- string
The task/branch for which to get the data. An empty string or '001000000000000000000000' means entire WBS tree.
- displayProgressWindows
- bool
When true, QDV will display a progress window in the center of the screen.
Return Value
IWorkbookA workbook containing all data of the data-source.
Not all WBS and minutes fields can have their FieldForQdvFldConfigFile.UseEightLevels set to true. WBS sum fields cannot apply, and only KindID and list minutes fields apply. If any WBS or minutes field in fields breaks this rule, no error is reported, but its FieldForQdvFldConfigFile.UseEightLevels property is ignored.
For historical reasons and for backward compatibility with old macros, this methods doesn't throw exceptions when an error is encountered. Instead, it sets a global error message. This allows to report just one (first) error. These global error messages are automatically displayed by QDV after a macro has finished.You can read this error info programmatically. You can get it from IQdvEnvironment.GlobalErrors property.
In macros, it's accessible from the Context
parameter:
Context.QdvManager.Environment.GlobalErrors
IAnalyticReporting aTools = es.CurrentVersion.GetAnalyticReportingTools(); // Get all available fields for data source and where applicable, set their "All levels" to True. IEnumerable<FieldForQdvFldConfigFile> fields = aTools.GetAvailableFieldsForDataSource(useEightLevelsWhereApplicable: true); // Now you can customize or remove individual fields, if needed. // Save the fields configuration into a qdvfldconfig file. This is an optional step. bool collapsed = true; aTools.SaveFieldsForDataSource(@"C:\test.qdvfldconfig", fields, collapsed); // Create the data source. IWorkbook dataSourceWorkbook = aTools.GetDataSource(new List<FieldForQdvFldConfigFile>(fields), collapsed); // Check the errors, because GetDataSource doesn't throw exceptions. if (dataSourceWorkbook == null) { // An error occurred, get the details. if (!String.IsNullOrEmpty(context.QdvManager.Environment.GlobalErrors.GlobalErrorMessage)) { // The error is reported in GlobalErrorMessage. string errText = context.QdvManager.Environment.GlobalErrors.GlobalErrorMessage; MessageBox.Show(errText, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (context.QdvManager.Environment.GlobalErrors.MessageStack.Count > 0) { // The error(s) is/are reported in MessageStack, display them all. string errText = ""; foreach (string err in context.QdvManager.Environment.GlobalErrors.MessageStack) { errText += err + "\n"; } MessageBox.Show(errText, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { // No error details. } }
This language is not supported or no code example is available.
' get the data source workbook Dim aTools As IAnalyticReporting = Es.CurrentVersion.GetAnalyticReportingTools() Dim fields As List(Of FieldForQdvFldConfigFile) = aTools.GetImageOfFieldsForDataSource("C:\data_source_fields.qdvfldconfig", collapsed) Dim dataSourceWorkbook As IWorkbook = aTools.GetDataSource(fields, False) ' Check the errors, because GetDataSource doesn't throw exceptions. If dataSourceWorkbook Is Nothing ' an error occurred, get the details If Not String.IsNullOrEmpty(Context.QdvManager.Environment.GlobalErrors.GlobalErrorMessage) ' The error is reported in GlobalErrorMessage. Dim errText As String = Context.QdvManager.Environment.GlobalErrors.GlobalErrorMessage MessageBox.Show(errText, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error) ElseIf Context.QdvManager.Environment.GlobalErrors.MessageStack.Count > 0 ' The error(s) is/are reported in MessageStack, display them all. Dim errText As String = "" For Each err As String In Context.QdvManager.Environment.GlobalErrors.MessageStack errText &= err & vbCrLf Next MessageBox.Show(errText, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error) Else ' no error details End If End If
This language is not supported or no code example is available.
The following example shows, how to correctly handle errors from GetDataSource method which uses the old error handling.