GitHub    Download    Forum
Overview
Tutorial
Database setup
Preparing the project
Establish the connection
Shut down the connection
DTDL types
Creating the schema
DADL classes
Entry point object
Write and read attributes
Write and read lists
Extending the schema
Modified entry point object
Write and read objects
Write and read object lists
C++ API
C# API
DTDL
DADL
Setup
C++
C#

Preparing the project

Create the project

We are now ready to create a new project, which we'll call TutorialCpp. For this tutorial, we create a C++ console application with precompiled headers.
We are now ready to create a new project, which we'll call TutorialCs. For this tutorial, we create a C# console application. Version 4.0 or higher of the .NET Framework can be used.

Preparing our main function

At program launch, we want the user to input their server address, the server port and the GUID of our domain. Since, for this example, we just have one storage, we always take storage ID 0. After that, we will connect to the domain.
Tutorial.cpp
Tutorial.cs
#include "pch.h"

int wmain(int argc, wchar_t* argv[])
{
	// ServerAddress, ServerPort
	const wchar_t* strServerAddress = argv[1]; 
	UINT16 usServerPort = (UINT16)_wtoi(argv[2]);

	// Domain-GUID
	GUID guidDomainId;
	::CLSIDFromString(argv[3], &guidDomainId);

	// Storage-ID (we are using the default 0 here)
	UINT32 ulStorageId = 0;
}
using System;

class Tutorial
{
	static void Main(string[] args)
	{
		// ServerAddress, ServerPort
		String strServerAddress = args[0];
		UInt16 usServerPort = UInt16.Parse(args[1]);

		// Domain-Guid
		Guid guidDomainId = Guid.Parse(args[2]);

		// Storage-ID (we are using the default 0 here)
		UInt32 ulStorageId = 0;
	}
}
For the purpose of this tutorial, we will code each major step as functions, so we can later use them independently.
init            / uninit
writeAttributes / readAttributes
writeList       / readList
writeObject     / readObject
writeObjectList / readObjectList
modifyObjectInList

Preparing the project for DataFS

To prepare the project for DataFS, some settings and dependencies have to be set. The easiest way to do this is to add a DADL file to the project and let the wizard do this for us.
A DADL file can be added to the project using "Add > New item…" and then selecting the "DADL file" from the DataFS folder. We will keep the suggested name "AccessDefinition.dadl". This will add an empty DADL file, make all the necessary modifications, and generate a DADL.h and DADL.cpp file.
When we want to use the generated classes or other DataFS classes, we can include "DADL.h". In this tutorial, we do this by including it directly in the precompiled header.
pch.h
#pragma once

#include <Windows.h>
#include <locale>
#include <iostream>
#include <string>
#include <conio.h>

#include "DADL.h"
using namespace DataFoundationAccess;
A DADL file can be added to the project using "Add > New item…" and then selecting the "DADL file" from the DataFS folder. This will add an empty DADL file and make all the necessary modifications.

Runtime DLLs

To run our application, we need the DataFS.dll and DataFSAccess.dll. They can be found in the Api\bin directory in the SDK's installation path (typically '%ProgramFiles(x86)%\Mobiland DataFS SDK\Api\bin').

Setting the startup parameters

Next, we have to set the command arguments for the project. We pass the IP address of the server, its port and the GUID of our domain.
127.0.0.1 9018 "{E9F56A1D-4FD9-483E-A4FE-7522666AB7C6}"
© 2022 Mobiland AG