unit ClientForm;
interface
uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Data.SqlExpr, Data.DBXDataSnap,
  IndyPeerImpl, Data.DBXCommon, Vcl.StdCtrls, Data.DBXTrace,
  Datasnap.DSClientRest;

type
  TForm1 = class(TForm)
    SQLConnection1: TSQLConnection;
    Button1: TButton;
    SQLMonitor1: TSQLMonitor;
    Button2: TButton;
    DSRestConnection1: TDSRestConnection;
    procedure Button1Click(Sender: TObject);
    procedure SQLMonitor1Trace(Sender: TObject; TraceInfo: TDBXTraceInfo;
      var LogTrace: Boolean);
    procedure SQLConnection1AfterConnect(Sender: TObject);
    procedure SQLConnection1AfterDisconnect(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
uses
  ServerMethodsClient,
  CodeSiteLogging,
  DataSnap.DSHTTPLayer, ClientClassesUnit1; // to add https communication layer

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  Server: ServerMethodsClient.TMyServerMethodsClient;
begin
  SQLConnection1.Connected := True; // just in case...
  Server := ServerMethodsClient.TMyServerMethodsClient.Create(SQLConnection1.DBXConnection);
  try
    ShowMessage(DateTimeToStr(Server.ServerTime))
  finally
    Server.Free
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  MyServerMethodsClient: ClientClassesUnit1.TMyServerMethodsClient;
begin
  MyServerMethodsClient := ClientClassesUnit1.TMyServerMethodsClient.Create(DSRestConnection1);
  try
    ShowMessage(MyServerMethodsClient.ReverseString('abc'));
  finally
    MyServerMethodsClient.Free
  end;
end;

procedure TForm1.SQLConnection1AfterConnect(Sender: TObject);
begin
  CodeSite.Send('After Connect');
end;

procedure TForm1.SQLConnection1AfterDisconnect(Sender: TObject);
begin
  CodeSite.Send('After Disconnect');
end;

procedure TForm1.SQLMonitor1Trace(Sender: TObject; TraceInfo: TDBXTraceInfo;
  var LogTrace: Boolean);
begin
  CodeSite.SendMsg('SQLMonitor.Trace: ' + TraceInfo.Message);
  LogTrace := True;
end;

end.
