views:

131

answers:

0

Possible Duplicate:
Persistent Objects in Windows XP/Delphi 7

Hi every body: I am deployment an Alarm System, and I have to registered alarms in a database. What happens if the connection to the database is broken?? I think to persist objects is a good idea: persist all alarms and when connection is restablished, register the persisted alarms in the database. My classes are declared like follow:

TAlarm = class
    Private
      FParams : TParams;
    Public
      Constructor Create;
      Destructor Destroy; Override;
      procedure Execute; virtual; abstract;
  end;

  TAlarmFailConnectAgent = class(TAlarm)
    public
      procedure Execute; override;
  end;

  TAlarmForcedCloseSession = class(TAlarm)
    public
      procedure Execute; override;
  end;

  TAlarmStationRecuperated = class(TAlarm)
    public
      procedure Execute; override;
  end;

  TAlarmServerServiceOut = class(TAlarm)
    public
      procedure Execute; override;
  end;

  TAlarmFailCloseSession = class(TAlarm)
    public
      procedure Execute; override;
  end;

  TAlarmFailAllowStation = class(TAlarm)
    public
      procedure Execute; override;
  end;

//....

TAlarmForcedCloseSessionParams = class(TParams)
    private
      FStationName : String;
      FStationGroup : String;
      FSessionTimeEstimated : Integer;
      FSessionStart : TDateTime;
      FPrefix : String;
      FSerialNumber : Int64;
      procedure SetStationName(const aName : String);
      procedure SetStationGroup(const aGroup : String);
      procedure SetSessionTimeEstimated(const aSesionTime : Integer);
      procedure SetSessionStart(const aSessionStart : TDateTime);
      procedure SetPrefix(const aPrefix : String);
      procedure SetSerialNumber(const aSerialNumber : Int64);
    public
      constructor Create;
      property StationName : String read FStationName write SetStationName;
      property StationGroup : String read FStationGroup write SetStationGroup;
      property SessionTimeEstimated : Integer read FSessionTimeEstimated write SetSessionTimeEstimated;
      property SessionStart : TDateTime read FSessionStart write SetSessionStart;
      property Prefix : String read FPrefix write SetPrefix;
      property SerialNumber : Int64 read FSerialNumber write SetSerialNumber;
  end;

  TAlarmStationRecuperatedParams = class(TParams)
    private
      FStationName : String;
      FStationGroup : String;
      procedure SetStationName(const aName : string);
      procedure SetStationGroup(const aGroup : String);
    public
      constructor Create;
      property StationName : String read FStationName write SetStationName;
      property StationGroup : String read FStationGroup write SetStationGroup;
  end;

  TAlarmFailCloseSessionParams = class(TParams)
    private
      FStationName : String;
      FStationGroup : String;
      FSessionTimeEstimated : Integer;
      FSessionStart : TDateTime;
      FPrefix : String;
      FSerialNumber : Int64; 
      procedure SetStationName(const aName : String);
      procedure SetStationGroup(const aGroup : String);
      procedure SetSessionTimeEstimated(const aSessionTime : Integer);
      procedure SetSessionStart(const aSessionStart : TDateTime);
      procedure SetPrefix(const aPrefix : String);
      procedure SetSerialNumber(const aSerialNumber : Int64);
    public
      constructor Create;
      property StationName : String read FStationName write SetStationName;
      property StationGroup : String read FStationGroup write SetStationGroup;
      property SessionTimeEstimated : Integer read FSessionTimeEstimated write SetSessionTimeEstimated;
      property SessionStart : TDateTime read FSessionStart write SetSessionStart;
      property Prefix : String read FPrefix write SetPrefix;
      property SerialNumber : Int64 read FSerialNumber write SetSerialNumber;
  end;

//.