Ver Mensaje Individual
  #11  
Antiguo 12-09-2010
chelard chelard is offline
Miembro
 
Registrado: nov 2009
Posts: 12
Reputación: 0
chelard Va por buen camino
Capturando Eventos con Unidac

Hola Yapt:
Muchas gracias nuevamente funciona perfecto.

Bueno y como me lo pediste dejo aca el codigo para que funcione con los componentes Unidac.

Primeramente el trigger y la BD, igual como tu lo hiciste, el formulario quedo asi

Código Delphi [-]
object Form1: TForm1
  Left = 438
  Top = 103
  Width = 349
  Height = 289
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Memo1: TMemo
    Left = 8
    Top = 80
    Width = 329
    Height = 169
    Lines.Strings = (
      'Memo1')
    TabOrder = 0
  end
  object btn1: TButton
    Left = 121
    Top = 45
    Width = 75
    Height = 25
    Caption = 'DeSuscribir'
    TabOrder = 1
    OnClick = btn1Click
  end
  object btn2: TButton
    Left = 121
    Top = 16
    Width = 75
    Height = 25
    Caption = 'Suscribir'
    TabOrder = 2
    OnClick = btn2Click
  end
  object btn3: TButton
    Left = 8
    Top = 53
    Width = 75
    Height = 25
    Caption = 'Desconectar'
    TabOrder = 3
    OnClick = btn3Click
  end
  object btn4: TButton
    Left = 8
    Top = 8
    Width = 75
    Height = 25
    Caption = 'Conectar'
    TabOrder = 4
    OnClick = btn4Click
  end
  object unipg1: TPostgreSQLUniProvider
    Left = 208
    Top = 8
  end
  object con1: TUniConnection
    ProviderName = 'PostgreSQL'
    Port = 5432
    Database = 'BasedeDatos'
    Username = 'Usuario'
    Password = 'clave'
    Server = 'localhost'
    Connected = True
    LoginPrompt = False
    Left = 208
    Top = 32
  end
  object ale1: TUniAlerter
    Connection = con1
    Events = 'pgEventoInsert'
    OnEvent = ale1Event
    Left = 240
    Top = 8
  end
end

... Y el codigo quedo de esta manera,

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, DB, DBAccess, Uni, UniProvider,
  PostgreSQLUniProvider, DAAlerter, UniAlerter;

type
  TForm1 = class(TForm)
    unipg1: TPostgreSQLUniProvider;
    con1: TUniConnection;
    ale1: TUniAlerter;
    Memo1: TMemo;
    btn1: TButton;
    btn2: TButton;
    btn3: TButton;
    btn4: TButton;
    procedure btn4Click(Sender: TObject);
    procedure btn2Click(Sender: TObject);
    procedure btn1Click(Sender: TObject);
    procedure btn3Click(Sender: TObject);
    procedure ale1Event(Sender: TDAAlerter; const EventName,
      Message: String);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btn4Click(Sender: TObject);
begin
  con1.Connect;
end;

procedure TForm1.btn2Click(Sender: TObject);
begin
  ale1.Active := True;


end;

procedure TForm1.btn1Click(Sender: TObject);
begin
        ale1.Active := False;
end;

procedure TForm1.btn3Click(Sender: TObject);
begin
  con1.Disconnect;
end;

procedure TForm1.ale1Event(Sender: TDAAlerter; const EventName,
  Message: String);
begin
    Memo1.Lines.Add('['+TimeToStr(now)+']'+'El proceso:  ha lanzado el evento: ' + EventName);
end;

end.
Responder Con Cita