TDASessionLog

Overview

TDASessionLog is used by the TDAServerLog class to collect information related to a session. You may expand the repertoire of the accumulated information:

  • derived from the TDASessionLog class.
  • set up your own log collector with the TDAServerLog.

Use case

This simple example demonstrates how you can customize the session log:

program TDASessionLog_Demo;
{$APPTYPE CONSOLE}

uses
  Classes, ActiveX, SysUtils, uROTypes, uROClasses, uROSessions, uDAServerLog;

type
  TSpecialLoginInfo = class (TROComplexType)
  private
    FAccountNo: integer;
    FUserID: string;
  published
    property  UserID      : string read FUserID write FUserID;
    property  AccountNo   : integer read FAccountNo write FAccountNo;
  end;

  TSpecialSessionLog = class (TDASessionLog)
  private
    FSpecialSessionInfo: string;
    //to use our class as aSessionLogClass
    //DALogClassesDefinitionHandler declared here for the sake of simplicity
    procedure DALogClassesDefinitionHandler (Sender: TDAServerLog;
                                         var aSessionLogClass: TDASessionLogClass;
                                         var aSQLCommandLogClass: TDASQLCommandLogClass;
                                         var aSQLErrorLogClass: TDASQLErrorLogClass);
  public
    //Only to setup DALogClassesDefinitionHandler
    constructor Create; reintroduce;
  published
    property  SpecialSessionInfo  : string read FSpecialSessionInfo write FSpecialSessionInfo;
  end;

{ TSpecialSessionLog }

constructor TSpecialSessionLog.Create;
begin
end;

procedure TSpecialSessionLog.DALogClassesDefinitionHandler(
  Sender: TDAServerLog; var aSessionLogClass: TDASessionLogClass;
  var aSQLCommandLogClass: TDASQLCommandLogClass;
  var aSQLErrorLogClass: TDASQLErrorLogClass);
begin
  aSessionLogClass := TSpecialSessionLog;
end;

type
  //Just a trick to emulate component loading
  TLoadedAccessor = class (TComponent)
  public
    procedure Loaded; override;
  end;

{ TLoadedAccessor }
procedure TLoadedAccessor.Loaded;
begin
  inherited;
end;

procedure doDemo;
var
  dummy       : TSpecialSessionLog;
  session     : TROSession;
  loginInfo   : TSpecialLoginInfo;
  serverLog   : TDAServerLog;
begin
  //insides of DA SDK
  session := TROSession.Create (NewGuid);
  serverLog := TDAServerLog.Create (nil);

  //to hook OnLogClassesDefinition (you set it in the Object Inspector)
  dummy := TSpecialSessionLog.Create;
  serverLog.OnLogClassesDefinition := dummy.DALogClassesDefinitionHandler;

  //Emulation of a component loading -> fires OnLogClassesDefinition
  TLoadedAccessor (serverLog).Loaded;

  serverLog.Active := true;

  loginInfo := TSpecialLoginInfo.Create;
  loginInfo.FUserID := 'Special User ID';
  loginInfo.FAccountNo := 123;

  with serverLog.AddSessionLog (session, loginInfo) AS TSpecialSessionLog do
    SpecialSessionInfo := 'Some special session info';

  WriteLn (serverLog.FindSessionLog (session).ContentAsString);

  dummy.Free;
  serverLog.Free;
  session.Free;
end;

begin
  try
    CoInitialize (nil);
    doDemo;
  except on E : Exception do
    WriteLn ('Exception: ', E.Message);
  end;
end.

Location


 

constructor Create  reintroduce overload virtual    (declared in TROComplexType)

Creates a new instance.

constructor Create

constructor Create (TCollection)  overload override    (declared in TROComplexType)

Creates a new instance with given parameter.

constructor Create(aCollection: TCollection)

Parameters:

  • aCollection: collection

constructor Create (TDAServerLog, TROSession)  reintroduce    (declared in TDALogItem)

Creates a new instance with given parameters.

constructor Create(aServerLog: TDAServerLog; aSession: TROSession)

Parameters:

  • aServerLog: References to the TDAServerLog object that stores this log item.
  • aSession: References to the session object.

constructor Create (TDAServerLog, TROSession, TROComplexType)

Constructs an instance for the specified TDAServerLog and TROSession with the associated aLoginInfo property bag.

constructor Create(aServerLog: TDAServerLog; aSession: TROSession; aLoginInfo: TROComplexType)

Parameters:

  • aServerLog: Passed to TDALogItem.Create
  • aSession: Passed to TDALogItem.Create
  • aLoginInfo: Stored into LoginInfo

Assign  override    (declared in TROComplexType)

Copies data from a given source.

procedure Assign(Source: TPersistent)

Parameters:

  • Source: Instance whose properties will be copied

AssignLoginInfo  protected virtual

procedure AssignLoginInfo(aLoginInfo: TROComplexType)

Parameters:

  • aLoginInfo:

AssignSession  protected virtual    (declared in TDALogItem)

Reads the SessionID property from the provided session object. If aSession is nil, the empty GUID will be assigned to the SessionID.

procedure AssignSession(aSession: TROSession)

Parameters:

  • aSession: Specified session.

AssignTo  override    (declared in TROComplexType)

Copies the properties of an object to a destination object.

procedure AssignTo(iDest: TPersistent)

Parameters:

  • iDest: destination object.

Clone    (declared in TROComplexType)

Creates and returns a second copy of the struct.

The new instance will be a deep copy of the original struct, all nested members that are arrays, structs or binaries will be duplicated as part of the cloning process, so that the new instance and its members will be completely independent from the original class.

function Clone: TROComplexType

ContentAsString    (declared in TROComplexType)

Returns the structure of the type in a string format.

property ContentAsString: string read

ContentAsXml    (declared in TROComplexType)

Returns the XML structure of the type in a string format.

property ContentAsXml: ROUTF8String read

CreationTime    (declared in TDALogItem)

Holds the time of the log item creation. This property is automatically set at object creation.

property CreationTime: TDateTime read

FieldCount    (declared in TROComplexType)

property FieldCount: Integer read

FieldInfo    (declared in TROComplexType)

property FieldInfo[Index: Integer]: PTypeInfo read

FieldName    (declared in TROComplexType)

property FieldName[Index: Integer]: string read

FreeInternalProperties  protected virtual    (declared in TROComplexType)

procedure FreeInternalProperties

GetAttributeCount  virtual    (declared in TROComplexType)

Returns the number of custom attributes defined for the class.

class function GetAttributeCount: Integer

GetAttributeName  virtual    (declared in TROComplexType)

Returns the name of custom attribute defined for the class, with the specified index.

class function GetAttributeName(aIndex: Integer): string

Parameters:

  • aIndex: The index of attribute.

GetAttributeValue  virtual    (declared in TROComplexType)

Returns the value of custom attribute defined for the class, with the specified index.

class function GetAttributeValue(aIndex: Integer): string

Parameters:

  • aIndex: The index of attribute.

GetContentAsXml  protected    (declared in TROComplexType)

Returns the xml structure of the struct in a string format.

function GetContentAsXml: ROUTF8String

GetContentAsXml2  protected virtual    (declared in TROComplexType)

procedure GetContentAsXml2(const aXMLNode: IUnknown)

Parameters:

  • aXMLNode:

GetFieldNames    (declared in TROComplexType)

procedure GetFieldNames(aList: TStrings)

Parameters:

  • aList:

GetFieldValue    (declared in TROComplexType)

function GetFieldValue(const aFieldName: string): Variant

Parameters:

  • aFieldName:

LoginInfo

Published property which provides access to specific login information as explained in Session Management. It is a readonly property whose value is determined by the aLoginInfo of the Create or the AssignLoginInfo.

property LoginInfo: TROComplexType read

ReadComplex  virtual    (declared in TROComplexType)

Deserializes current class instance using provided serializer.

procedure ReadComplex(ASerializer: TObject)

Parameters:


ServerLog    (declared in TDALogItem)

References to the TDAServerLog object that stores this log item.

property ServerLog: TDAServerLog read

SessionID    (declared in TDALogItem)

Holds the unique session GUID.

property SessionID: TGUID read

SessionIDAsString    (declared in TDALogItem)

Returns a string representation of the session GUID.

property SessionIDAsString: string read

SetFieldValue    (declared in TROComplexType)

procedure SetFieldValue(const aFieldName: string; const aValue: Variant)

Parameters:

  • aFieldName:
  • aValue:

SmartAssign    (declared in TROComplexType)

Copies specific data from a given source.

procedure SmartAssign(Source: TPersistent; TypeKinds: TTypeKinds)

Parameters:

  • Source: Instance whose properties will be copied
  • TypeKinds: Specifies which properties should be copied

TryGetAttribute    (declared in TROComplexType)

class function TryGetAttribute(aName: string; out aValue: string): Boolean

Parameters:

  • aName:
  • aValue:

WriteComplex  virtual    (declared in TROComplexType)

Serializes current class instance using provided serializer.

procedure WriteComplex(ASerializer: TObject)

Parameters:

 

ContentAsString    (declared in TROComplexType)

Returns the structure of the type in a string format.

property ContentAsString: string read

ContentAsXml    (declared in TROComplexType)

Returns the XML structure of the type in a string format.

property ContentAsXml: ROUTF8String read

CreationTime    (declared in TDALogItem)

Holds the time of the log item creation. This property is automatically set at object creation.

property CreationTime: TDateTime read

FieldCount    (declared in TROComplexType)

property FieldCount: Integer read

FieldInfo    (declared in TROComplexType)

property FieldInfo[Index: Integer]: PTypeInfo read

FieldName    (declared in TROComplexType)

property FieldName[Index: Integer]: string read

LoginInfo

Published property which provides access to specific login information as explained in Session Management. It is a readonly property whose value is determined by the aLoginInfo of the Create or the AssignLoginInfo.

property LoginInfo: TROComplexType read

ServerLog    (declared in TDALogItem)

References to the TDAServerLog object that stores this log item.

property ServerLog: TDAServerLog read

SessionID    (declared in TDALogItem)

Holds the unique session GUID.

property SessionID: TGUID read

SessionIDAsString    (declared in TDALogItem)

Returns a string representation of the session GUID.

property SessionIDAsString: string read

 

GetAttributeCount  virtual    (declared in TROComplexType)

Returns the number of custom attributes defined for the class.

class function GetAttributeCount: Integer

GetAttributeName  virtual    (declared in TROComplexType)

Returns the name of custom attribute defined for the class, with the specified index.

class function GetAttributeName(aIndex: Integer): string

Parameters:

  • aIndex: The index of attribute.

GetAttributeValue  virtual    (declared in TROComplexType)

Returns the value of custom attribute defined for the class, with the specified index.

class function GetAttributeValue(aIndex: Integer): string

Parameters:

  • aIndex: The index of attribute.

TryGetAttribute    (declared in TROComplexType)

class function TryGetAttribute(aName: string; out aValue: string): Boolean

Parameters:

  • aName:
  • aValue:

 

constructor Create  reintroduce overload virtual    (declared in TROComplexType)

Creates a new instance.

constructor Create

constructor Create (TCollection)  overload override    (declared in TROComplexType)

Creates a new instance with given parameter.

constructor Create(aCollection: TCollection)

Parameters:

  • aCollection: collection

constructor Create (TDAServerLog, TROSession)  reintroduce    (declared in TDALogItem)

Creates a new instance with given parameters.

constructor Create(aServerLog: TDAServerLog; aSession: TROSession)

Parameters:

  • aServerLog: References to the TDAServerLog object that stores this log item.
  • aSession: References to the session object.

constructor Create (TDAServerLog, TROSession, TROComplexType)

Constructs an instance for the specified TDAServerLog and TROSession with the associated aLoginInfo property bag.

constructor Create(aServerLog: TDAServerLog; aSession: TROSession; aLoginInfo: TROComplexType)

Parameters:

  • aServerLog: Passed to TDALogItem.Create
  • aSession: Passed to TDALogItem.Create
  • aLoginInfo: Stored into LoginInfo

Assign  override    (declared in TROComplexType)

Copies data from a given source.

procedure Assign(Source: TPersistent)

Parameters:

  • Source: Instance whose properties will be copied

AssignLoginInfo  protected virtual

procedure AssignLoginInfo(aLoginInfo: TROComplexType)

Parameters:

  • aLoginInfo:

AssignSession  protected virtual    (declared in TDALogItem)

Reads the SessionID property from the provided session object. If aSession is nil, the empty GUID will be assigned to the SessionID.

procedure AssignSession(aSession: TROSession)

Parameters:

  • aSession: Specified session.

AssignTo  override    (declared in TROComplexType)

Copies the properties of an object to a destination object.

procedure AssignTo(iDest: TPersistent)

Parameters:

  • iDest: destination object.

Clone    (declared in TROComplexType)

Creates and returns a second copy of the struct.

The new instance will be a deep copy of the original struct, all nested members that are arrays, structs or binaries will be duplicated as part of the cloning process, so that the new instance and its members will be completely independent from the original class.

function Clone: TROComplexType

FreeInternalProperties  protected virtual    (declared in TROComplexType)

procedure FreeInternalProperties

GetContentAsXml  protected    (declared in TROComplexType)

Returns the xml structure of the struct in a string format.

function GetContentAsXml: ROUTF8String

GetContentAsXml2  protected virtual    (declared in TROComplexType)

procedure GetContentAsXml2(const aXMLNode: IUnknown)

Parameters:

  • aXMLNode:

GetFieldNames    (declared in TROComplexType)

procedure GetFieldNames(aList: TStrings)

Parameters:

  • aList:

GetFieldValue    (declared in TROComplexType)

function GetFieldValue(const aFieldName: string): Variant

Parameters:

  • aFieldName:

ReadComplex  virtual    (declared in TROComplexType)

Deserializes current class instance using provided serializer.

procedure ReadComplex(ASerializer: TObject)

Parameters:


SetFieldValue    (declared in TROComplexType)

procedure SetFieldValue(const aFieldName: string; const aValue: Variant)

Parameters:

  • aFieldName:
  • aValue:

SmartAssign    (declared in TROComplexType)

Copies specific data from a given source.

procedure SmartAssign(Source: TPersistent; TypeKinds: TTypeKinds)

Parameters:

  • Source: Instance whose properties will be copied
  • TypeKinds: Specifies which properties should be copied

WriteComplex  virtual    (declared in TROComplexType)

Serializes current class instance using provided serializer.

procedure WriteComplex(ASerializer: TObject)

Parameters: