Skip to main content Skip to complementary content

Implementing QvEventLogServer.cs

Creating the new class

Start by creating a new QvEventLogServer class. You need to implement two methods from the QvxServer class using the QlikView.Qvx.Library. A reference to this library is required in your class.

using QlikView.Qvx.QvxLibrary;

Implementing the CreateConnection() method

First implement the CreateConnection method.

CreateConnection() method.

This returns a new instance of QvEventLogConnection, which defines all of the tables and columns required and the method for retrieving the rows from the data source in QvEventLogConnection.cs, as shown in the following example:

public override QvxConnection CreateConnection() { return new QvEventLogConnection(); }

Implementing the CreateConnectionString() method

The second method, CreateConnectionString, is called by a QvxServer object to retrieve a connect string for your specific data source.

CreateConnectionString() method

Optionally, the results of the various methods can be logged by using the QvxLog class with the Log() method from QvxLibrary:

The following code example shows a combination of the CreateConnectionString() method with logging:

public override string CreateConnectionString() { QvxLog.Log(QvxLogFacility.Application,QvxLogSeverity.Debug,"CreateConnectionString()"); return "Server=localhost"; }

The EventLogElaborate example solution provided extends this capability by referencing a sample Login dialog window to capture the Server/UserId and password as shown below.

In the following example, the GetServer()/GetUsername() and GetPassword() methods are referenced from the Login dialog window.

public override string CreateConnectionString() { QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Debug, "CreateConnectionString()"); var login = CreateLoginWindowHelper(); login.ShowDialog(); string connectionString = null; if (login.DialogResult.Equals(true)) { connectionString = String.Format("Server={0};UserId={1};Password={2}", login.GetServer(), login.GetUsername(), login.GetPassword()); } return connectionString; } private Login CreateLoginWindowHelper() { // Since the owner of the loginWindow is a Win32 process we need to // use WindowInteropHelper to make it modal to its owner. var login = new Login(); var wih = new WindowInteropHelper(login); wih.Owner = MParentWindow; return login; }

Example

The following code example shows the final implementation (without the Login dialog window):

using System.Windows.Forms; using QlikView.Qvx.QvxLibrary; namespace QvEventLogConnectorSimple { internal class QvEventLogServer : QvxServer { public override QvxConnection CreateConnection() { return new QvEventLogConnection(); } public override string CreateConnectionString() { QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Debug, "CreateConnectionString()"); return "Server=localhost"; } } }

The next step is Implementing QvEventLogConnection.cs.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!