//
// Created by the DataSnap proxy generator.
// 13.09.2015 23:46:16
//

unit ClientMethods_9_1;

interface

uses System.JSON, Data.DBXCommon, Data.DBXClient, Data.DBXDataSnap, Data.DBXJSON, Datasnap.DSProxy, System.Classes, System.SysUtils, Data.DB, Data.SqlExpr, Data.DBXDBReaders, Data.DBXCDSReaders, Data.DBXJSONReflect;

type
  TServerMethods1Client = class(TDSAdminClient)
  private
    FZeroGlobalBufferCommand: TDBXCommand;
    FGlobalBufferToMySQLCommand: TDBXCommand;
    FGetstreamByPacketsCommand: TDBXCommand;
    FApplyUpdatesCommand: TDBXCommand;
    FHelloCommand: TDBXCommand;
  public
    constructor Create(ADBXConnection: TDBXConnection); overload;
    constructor Create(ADBXConnection: TDBXConnection; AInstanceOwner: Boolean); overload;
    destructor Destroy; override;
    procedure ZeroGlobalBuffer;
    procedure GlobalBufferToMySQL;
    procedure GetstreamByPackets(stream: TMemoryStream; packetsize: Int64);
    procedure ApplyUpdates;
    procedure Hello;
  end;

implementation

procedure TServerMethods1Client.ZeroGlobalBuffer;
begin
  if FZeroGlobalBufferCommand = nil then
  begin
    FZeroGlobalBufferCommand := FDBXConnection.CreateCommand;
    FZeroGlobalBufferCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FZeroGlobalBufferCommand.Text := 'TServerMethods1.ZeroGlobalBuffer';
    FZeroGlobalBufferCommand.Prepare;
  end;
  FZeroGlobalBufferCommand.ExecuteUpdate;
end;

procedure TServerMethods1Client.GlobalBufferToMySQL;
begin
  if FGlobalBufferToMySQLCommand = nil then
  begin
    FGlobalBufferToMySQLCommand := FDBXConnection.CreateCommand;
    FGlobalBufferToMySQLCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FGlobalBufferToMySQLCommand.Text := 'TServerMethods1.GlobalBufferToMySQL';
    FGlobalBufferToMySQLCommand.Prepare;
  end;
  FGlobalBufferToMySQLCommand.ExecuteUpdate;
end;

procedure TServerMethods1Client.GetstreamByPackets(stream: TMemoryStream; packetsize: Int64);
begin
  if FGetstreamByPacketsCommand = nil then
  begin
    FGetstreamByPacketsCommand := FDBXConnection.CreateCommand;
    FGetstreamByPacketsCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FGetstreamByPacketsCommand.Text := 'TServerMethods1.GetstreamByPackets';
    FGetstreamByPacketsCommand.Prepare;
  end;
  FGetstreamByPacketsCommand.Parameters[0].Value.SetStream(stream, FInstanceOwner);
  FGetstreamByPacketsCommand.Parameters[1].Value.SetInt64(packetsize);
  FGetstreamByPacketsCommand.ExecuteUpdate;
end;

procedure TServerMethods1Client.ApplyUpdates;
begin
  if FApplyUpdatesCommand = nil then
  begin
    FApplyUpdatesCommand := FDBXConnection.CreateCommand;
    FApplyUpdatesCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FApplyUpdatesCommand.Text := 'TServerMethods1.ApplyUpdates';
    FApplyUpdatesCommand.Prepare;
  end;
  FApplyUpdatesCommand.ExecuteUpdate;
end;

procedure TServerMethods1Client.Hello;
begin
  if FHelloCommand = nil then
  begin
    FHelloCommand := FDBXConnection.CreateCommand;
    FHelloCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FHelloCommand.Text := 'TServerMethods1.Hello';
    FHelloCommand.Prepare;
  end;
  FHelloCommand.ExecuteUpdate;
end;


constructor TServerMethods1Client.Create(ADBXConnection: TDBXConnection);
begin
  inherited Create(ADBXConnection);
end;


constructor TServerMethods1Client.Create(ADBXConnection: TDBXConnection; AInstanceOwner: Boolean);
begin
  inherited Create(ADBXConnection, AInstanceOwner);
end;


destructor TServerMethods1Client.Destroy;
begin
  FZeroGlobalBufferCommand.DisposeOf;
  FGlobalBufferToMySQLCommand.DisposeOf;
  FGetstreamByPacketsCommand.DisposeOf;
  FApplyUpdatesCommand.DisposeOf;
  FHelloCommand.DisposeOf;
  inherited;
end;

end.

