unit unit_server;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  uRESTDWPoolerDB, uRESTDWBase;

type

  { TForm1 }

  TForm1 = class(TForm)
    ButtonStartStop: TButton;
    Button2: TButton;
    ButtonStartStop1: TButton;
    lserver: TLabel;
    Memo1: TMemo;
    RESTDWDataBase1: TRESTDWDataBase;
    RESTDWPoolerList1: TRESTDWPoolerList;
    RESTServicePooler1: TRESTServicePooler;
    procedure ButtonStartStop1Click(Sender: TObject);
    procedure ButtonStartStopClick(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private

  public

  end;

var
  Form1: TForm1;

implementation
uses unit_dm;
{$R *.frm}

{ TForm1 }

procedure TForm1.ButtonStartStopClick(Sender: TObject);
begin
  RESTServicePooler1.ServerMethodClass:=TServerMethodDataModule1;
  RESTServicePooler1.Active := not RESTServicePooler1.Active;
  if RESTServicePooler1.Active = true then begin
      caption:='Server started...';
      lserver.caption:=caption;
      ButtonStartStop.Caption:='Stop';
    end else begin
      caption:='Server not started...';
      lserver.caption:=caption;
      ButtonStartStop.Caption:='Start';
    end;
end;

procedure TForm1.ButtonStartStop1Click(Sender: TObject);
begin
  if memo1.Lines.count =0 then begin
      showmessage('No Pooler Configured, get list poolers');
      exit;
  end;
   RESTDWDataBase1.Active:=false;
   RESTDWDataBase1.PoolerName:=memo1.Lines[0];
   try
      RESTDWDataBase1.Active:=true;
      showmessage('Connected...');
   except
     showmessage('Connection error...');
   end;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  RESTDWPoolerList1.Active:=true;
  memo1.Text:=RESTDWPoolerList1.Poolers.Text;
//  showmessage(RESTDWPoolerList1.Poolers.Text);
end;

end.

