App traverser - extract information from applications

The purpose of this sample is to illustrate how the Qlik Sense .NET SDK can be used to extract information from apps.

We recommend that you to download and run the appropriate example before you continuing reading. All the sample code for the connection examples are available on Github.

Note: The purpose of the sample code provided by Qlik is to demonstrate capabilities and use cases of the API. They are provided on an as-is basis, without any guarantees that they will work in all system configurations and future software releases. These code samples are released under: Wikipedia: MIT license.

The class Location is used as a handle from which to establish engine connections. A connection to an engine can be done by calling the QlikConnection constructor which takes a location and a session as arguments. The Qlik Sense .NET SDK includes an extension class for location that provides a number of convenience methods for interacting with a location. In particular, LocationExtension contains the method Hub that returns a hub for the location, and methods for listing what apps are available. The app traverser example uses the method GetAppIdentifiers to get a list of all apps available on the location, and the method App to open apps from the location based on an identifiers retrieved by GetAppIdentifiers.

Example:  

	
	private static void ListApps(ILocation location)
	{
		foreach (var appIdentifier in location.GetAppIdentifiers())
		{
			try
			{
				using (var app = location.App(appIdentifier))
				{
					Traversing.Traverse(app);
				}
			}
		...
		}
	}	

Traversal of the app is in this example performed in such a way as to illustrate how to retrieve data from the different levels of an app. An app consists of a number of sheets, sheets contain a number of cells and cells contain generic objects.

The example also illustrates the use of the TypeSwitchclass to retrieve data from generic objects. As objects are returned from the engine in the form of GenericObject instances, it will often be necessary to perform down casting of the objects to a specific type to be able to retrieve relevant information. The TypeSwitchclass provides a convenient and safe interface for doing this where each case represent what action to take for one possible type the source object can have.

Did this information help you?

Thanks for letting us know. Is there anything you'd like to tell us about this topic?

Can you tell us why it did not help you and how we can improve it?