Date and Calendar Analytics
dbm_init.cpp

This file implement functions to initialzie (and shutdown) the logging, license and Calendar modules. The functions here are used by the remaining examples here.

Remarks

  1. Before using, replace the value of the license key (szLicenseKey) with your license key.
  2. Before using, replace the value of the activation code (szActivationCode) with the one you generated with the license key.
#include <windows.h>
#include <iostream>
#include <string>
#include "SFLOG.h"
#include "SFLUC.h"
#include "SFDBM.h"
// Global variables
static unsigned uLOGToken=unsigned(-1);
static unsigned uLUCToken=unsigned(-1);
static unsigned uDBMToken=unsigned(-1);
const TCHAR szProdKey[] =L"31223-200-169";
const TCHAR szLicenseKey[] =L"79F7-C8-A9-01-7777";
const TCHAR szActivationCode[] =L"2c07d642fe1ef089e5517d35e15f186814e17fb80b25cd950e77ade2e63c82c65d94ca639"
"a77475d11981fd0a06e3ece730ef09c53c1f2da6d89d9a1d453d5e3678e50786a42101f19"
"4ffd543c2b72b55576fa52796acfd42ea715e132abddbc0877a5d0ba9e071c5639d1cb956"
"7d49c8019ef86549321c577193f0cd6ecba852013730ccda7f9d3b25dd6b10ffca6628835"
"c52f4c4775d3cc295d814b542abe370abac97a2b71c5949736d7c007442b956deac50bdcf"
"f423e4b2304e7153fffc61d5a15361ada3444e67075f09f15a4eefaf1d6710d9e4e44b6ad"
"bf175caeb3446c64ead56333c8c0df6a487b549ec2b9bf5d733edbc062ce874986caf63756";
bool dbm_example_init(void){
std::wstring szLogDir =L"C:\\temp";
DWORD dwBackupFiles=7;
size_t ulMaxFileSize= (1024 * 1024); // 1 MB
int nRetCode = SFLOG_INITW(szAppName,szLogDir.c_str(), dwBackupFiles, ulMaxFileSize,&uLOGToken);
if(nRetCode == NDK_SUCCESS){
std::wcout << L" SUCCESS - Logging system is initialized" << std::endl;
nRetCode = SFLUC_INIT( szProdKey, szLicenseKey,szActivationCode, &uLUCToken);
if(nRetCode == NDK_SUCCESS){
std::wcout << L" SUCCESS - License module is initialized" << std::endl;
LCID dwLocale = 1033;
std::wstring szFileName(TEXT("spiderxl.db"));
nRetCode = SFDB_Init(szFileName.c_str(), NULL /* Use DLL folder */, dwLocale, &uDBMToken);
if(nRetCode == NDK_SUCCESS){
std::wcout << L" SUCCESS - Date and Calendar module is initialized" << std::endl;
return true;
}
// Failed to initialize DBM, shutdown license module
SFLUC_SHUTDOWN(uLUCToken);
uLUCToken = unsigned(-1)
}
// Failed to initialize calendar or license module, shutdown the logging module
SFLOG_SHUTDOWN(uLOGToken);
uLOGToken = unsigned(-1);
}
return false;
}
void dbm_example_shutdown(void){
int nRetCode = NDK_FAILED;
if(uDBMToken != unsigned(-1)){
SFDB_Shutdown(uDBMToken);
uDBMToken = unsigned(-1);
}
if( uLUCToken != unsigned(-1)){
SFLUC_SHUTDOWN(uLUCToken);
uLUCToken != unsigned(-1);
}
if( uLOGToken != unsigned(-1)){
SFLOG_SHUTDOWN(uLOGToken);
uLOGToken= unsigned(-1);
}
}
#define NDK_SUCCESS
#define NDK_FAILED
int __stdcall SFDB_Init(LPCWSTR szBaseFileName, LPCWSTR szResDir, DWORD dwLocale, unsigned int *pClientToken)
Initialize/Configure the date/calendar analytics module (SFDBM)
Definition SFDBM.cpp:66
int __stdcall SFDB_Shutdown(unsigned int uClientToken)
Shutdown the session (e.g. closes files, terminate database connection, etc.)
Definition SFDBM.cpp:217
int __stdcall SFLOG_INITW(LPCWSTR szAppName, LPCWSTR szLogDir, DWORD dwBackupFiles, size_t ulMaxFileSize, unsigned int *pClientToken)
int __stdcall SFLOG_SHUTDOWN(unsigned int uClientToken)
int __stdcall SFLUC_SHUTDOWN(unsigned int uLUCToken)
int __stdcall SFLUC_INIT(LPCWSTR argPRODKey, LPCWSTR argLicenseKey, LPCWSTR argActivationCode, unsigned *pClientToken)