//
// Created by the DataSnap proxy generator.
// 2012/03/14 14:25:04
//

unit ServerMethodsClient;

interface

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

type
  TMyServerMethodsClient = class(TDSAdminClient)
  private
    FEchoStringCommand: TDBXCommand;
    FReverseStringCommand: TDBXCommand;
    FServerTimeCommand: TDBXCommand;
    FAdd33Command: TDBXCommand;
    FGetEmployeesCommand: TDBXCommand;
  public
    constructor Create(ADBXConnection: TDBXConnection); overload;
    constructor Create(ADBXConnection: TDBXConnection; AInstanceOwner: Boolean); overload;
    destructor Destroy; override;
    function EchoString(Value: string): string;
    function ReverseString(Value: string): string;
    function ServerTime: TDateTime;
    function Add33(X1: Integer; X2: Integer; X3: Integer; X4: Integer; X5: Integer; X6: Integer; X7: Integer; X8: Integer; X9: Integer; X10: Integer; X11: Integer; X12: Integer; X13: Integer; X14: Integer; X15: Integer; X16: Integer; X17: Integer; X18: Integer; X19: Integer; X20: Integer; X21: Integer; X22: Integer; X23: Integer; X24: Integer; X25: Integer; X26: Integer; X27: Integer; X28: Integer; X29: Integer; X30: Integer; X31: Integer; X32: Integer; X33: Integer): Integer;
    function GetEmployees: TDataSet;
  end;

implementation

function TMyServerMethodsClient.EchoString(Value: string): string;
begin
  if FEchoStringCommand = nil then
  begin
    FEchoStringCommand := FDBXConnection.CreateCommand;
    FEchoStringCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FEchoStringCommand.Text := 'TMyServerMethods.EchoString';
    FEchoStringCommand.Prepare;
  end;
  FEchoStringCommand.Parameters[0].Value.SetWideString(Value);
  FEchoStringCommand.ExecuteUpdate;
  Result := FEchoStringCommand.Parameters[1].Value.GetWideString;
end;

function TMyServerMethodsClient.ReverseString(Value: string): string;
begin
  if FReverseStringCommand = nil then
  begin
    FReverseStringCommand := FDBXConnection.CreateCommand;
    FReverseStringCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FReverseStringCommand.Text := 'TMyServerMethods.ReverseString';
    FReverseStringCommand.Prepare;
  end;
  FReverseStringCommand.Parameters[0].Value.SetWideString(Value);
  FReverseStringCommand.ExecuteUpdate;
  Result := FReverseStringCommand.Parameters[1].Value.GetWideString;
end;

function TMyServerMethodsClient.ServerTime: TDateTime;
begin
  if FServerTimeCommand = nil then
  begin
    FServerTimeCommand := FDBXConnection.CreateCommand;
    FServerTimeCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FServerTimeCommand.Text := 'TMyServerMethods.ServerTime';
    FServerTimeCommand.Prepare;
  end;
  FServerTimeCommand.ExecuteUpdate;
  Result := FServerTimeCommand.Parameters[0].Value.AsDateTime;
end;

function TMyServerMethodsClient.Add33(X1: Integer; X2: Integer; X3: Integer; X4: Integer; X5: Integer; X6: Integer; X7: Integer; X8: Integer; X9: Integer; X10: Integer; X11: Integer; X12: Integer; X13: Integer; X14: Integer; X15: Integer; X16: Integer; X17: Integer; X18: Integer; X19: Integer; X20: Integer; X21: Integer; X22: Integer; X23: Integer; X24: Integer; X25: Integer; X26: Integer; X27: Integer; X28: Integer; X29: Integer; X30: Integer; X31: Integer; X32: Integer; X33: Integer): Integer;
begin
  if FAdd33Command = nil then
  begin
    FAdd33Command := FDBXConnection.CreateCommand;
    FAdd33Command.CommandType := TDBXCommandTypes.DSServerMethod;
    FAdd33Command.Text := 'TMyServerMethods.Add33';
    FAdd33Command.Prepare;
  end;
  FAdd33Command.Parameters[0].Value.SetInt32(X1);
  FAdd33Command.Parameters[1].Value.SetInt32(X2);
  FAdd33Command.Parameters[2].Value.SetInt32(X3);
  FAdd33Command.Parameters[3].Value.SetInt32(X4);
  FAdd33Command.Parameters[4].Value.SetInt32(X5);
  FAdd33Command.Parameters[5].Value.SetInt32(X6);
  FAdd33Command.Parameters[6].Value.SetInt32(X7);
  FAdd33Command.Parameters[7].Value.SetInt32(X8);
  FAdd33Command.Parameters[8].Value.SetInt32(X9);
  FAdd33Command.Parameters[9].Value.SetInt32(X10);
  FAdd33Command.Parameters[10].Value.SetInt32(X11);
  FAdd33Command.Parameters[11].Value.SetInt32(X12);
  FAdd33Command.Parameters[12].Value.SetInt32(X13);
  FAdd33Command.Parameters[13].Value.SetInt32(X14);
  FAdd33Command.Parameters[14].Value.SetInt32(X15);
  FAdd33Command.Parameters[15].Value.SetInt32(X16);
  FAdd33Command.Parameters[16].Value.SetInt32(X17);
  FAdd33Command.Parameters[17].Value.SetInt32(X18);
  FAdd33Command.Parameters[18].Value.SetInt32(X19);
  FAdd33Command.Parameters[19].Value.SetInt32(X20);
  FAdd33Command.Parameters[20].Value.SetInt32(X21);
  FAdd33Command.Parameters[21].Value.SetInt32(X22);
  FAdd33Command.Parameters[22].Value.SetInt32(X23);
  FAdd33Command.Parameters[23].Value.SetInt32(X24);
  FAdd33Command.Parameters[24].Value.SetInt32(X25);
  FAdd33Command.Parameters[25].Value.SetInt32(X26);
  FAdd33Command.Parameters[26].Value.SetInt32(X27);
  FAdd33Command.Parameters[27].Value.SetInt32(X28);
  FAdd33Command.Parameters[28].Value.SetInt32(X29);
  FAdd33Command.Parameters[29].Value.SetInt32(X30);
  FAdd33Command.Parameters[30].Value.SetInt32(X31);
  FAdd33Command.Parameters[31].Value.SetInt32(X32);
  FAdd33Command.Parameters[32].Value.SetInt32(X33);
  FAdd33Command.ExecuteUpdate;
  Result := FAdd33Command.Parameters[33].Value.GetInt32;
end;

function TMyServerMethodsClient.GetEmployees: TDataSet;
begin
  if FGetEmployeesCommand = nil then
  begin
    FGetEmployeesCommand := FDBXConnection.CreateCommand;
    FGetEmployeesCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FGetEmployeesCommand.Text := 'TMyServerMethods.GetEmployees';
    FGetEmployeesCommand.Prepare;
  end;
  FGetEmployeesCommand.ExecuteUpdate;
  Result := TCustomSQLDataSet.Create(nil, FGetEmployeesCommand.Parameters[0].Value.GetDBXReader(False), True);
  Result.Open;
  if FInstanceOwner then
    FGetEmployeesCommand.FreeOnExecute(Result);
end;


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


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


destructor TMyServerMethodsClient.Destroy;
begin
  FreeAndNil(FEchoStringCommand);
  FreeAndNil(FReverseStringCommand);
  FreeAndNil(FServerTimeCommand);
  FreeAndNil(FAdd33Command);
  FreeAndNil(FGetEmployeesCommand);
  inherited;
end;

end.

