***************************************************************
Copyright:   : MARX(R) CryptoTech LP
Project      : CBIOSServerEventLog Sample
Last Changed : 30Jan2023
Tools        : C#.NET 2005-2022
Description  : CBIOS4NET sample, demonstrating monitoring of network licensing process
OS           : Win11/Win10/Win8/Win7
****************************************************************
VER       DATE         WHO   DETAIL
****************************************************************
1.00   29-JUL-2006      VG   Initial version (local + network)
1.01   30-JAN-2023      AM   Bugfixes
****************************************************************}

Description: This CBIOS4NET based sample demonstrates monitoring of Network licenses with the CYPTO-BOX

Environment: Microsoft Visual Studio 2005 and higher


1. Monitoring of network licensing - Overview
---------------------------------------------

The CBIOS Network Server ver. 2.9 and up supports monitoring of the network licensing process. 
This functionality allows customers to get real statistics and information on their network licensing process. 
Standard System Event Log is used for logging. Its main advantage - it is easy to access System Event Log 
from any application (even remotely).
   
Any application can subscribe through standard API and then be notified on new records of "CBIOSServer" type. 
The Server sends the following notification codes and logs corresponding types of events:  
    * Server Started
    * Server Stopped
    * License Locked
    * License Unlocked

NOTE:
Latest CBIOS Network Server can be downloaded from here:
https://www.marx.com/en/support/downloads#networktools
See included readme file for installation and configuration options.


2. Technical details
--------------------

The log is saved as a special category of events: "CBIOSServer". It can be viewed by starting Event Viewer Console 
(type eventvwr.msc in search bar).

After being launched the CBIOS Server starts issuing notifications on lock/release license activity.
To get access to the log the following C# code can be used: 

    eventLog_CBIOSServer = new EventLog();
    eventLog_CBIOSServer.Source = "CBIOSServer";
    eventLog_CBIOSServer.Log = "CBIOSServer";
    eventLog_CBIOSServer.EnableRaisingEvents = true;

To get notifications it is necessary to subscribe to notifications on corresponding events (C#):

    eventLog_CBIOSServer.EntryWritten += new EntryWrittenEventHandler(eventLog_CBIOSServer_EntryWritten);

The Server sends the following notification codes and logs corresponding types of events:

	Server Started
	Server Stopped
	License Locked
	License Unlocked

with the following parameters: 
 
	Box Handle
	User computer name
	User app file name
	Box name (CRYPTO-BOX Serialnumber)
	App Id (Partition of the CYPTO-BOX used for licensing)
	Free licenses (number of network licenses left)


3. Sample content
-----------------

The sample contains two projects:
	- CBIOSServerLPM_Sample demonstrating monitoring of network licensing activity;
	- LPM_Simulation_Sample simulating network licensing activity 

The CBIOSServerLPM_Sample must be launched on the same computer where the Server is running, because it requires 
access to the System Event Log (remote access needs additional implementation, out of the scope of this sample).
It can be started before or after CBIOS Server startup. If being started with CBIOS Server already running, the 
sample will look for the most recent record of CBIOSServer type in the System Even Log and will start processing 
events coming after that record. All previous events are ignored.

The LPM_Simulation_Sample can be started on any computer in the same network with access to the CBIOS Network Server.


4. Step by step evaluation guide
--------------------------------

1. Connect a CRYPTO-BOX with demo codes and start CBIOS Server on this computer. When being launched for the first 
time it will register itself in the System Event Log.
2. Launch \ReleaseAnyCPU\CBIOSServerLPM_Sample.exe
3. Launch \ReleaseAnyCPU\LPM_Simulation_Sample.exe

The following two items (4 and 5) are optional:

4. Stop CBIOS Server and get "Server Stopped" notification in the running instance of CBIOSServerLPM_Sample.
5. Launch CBIOS Server and get "Server Started" notification in the running instance of CBIOSServerLPM_Sample.

6. Press "Start" in the running instance of LPM_Simulation_Sample. 
It will lock/release licenses which will lead to corresponding records for the demo CRYPTO-BOX in 
CBIOSServerLPM_Sample. It demonstrates how to get and process network licensing activity.


NOTE:
This sample uses reference on strong-named CBIOS4NET assembly. If exists in the GAC (Global
Assembly Cache) this assembly will be loaded from there. To install CBIOS4NET assembly into GAC 
"CBIOS4NET Setup" can be used (can be downloaded from here):
https://www.marx.com/en/support/downloads
(see included readme.txt for details)

Developer's Guide "CBIOS4NET/Smarx4NET API Reference for C#.NET Developers" is here:
https://www.marx.com/en/support/documents#whitepapers


**** Copyright (c) 2002, 2023 MARX(R) Cryptotech LP **** 