git-svn-id: https://192.168.0.254/svn/Componentes.Terceros.RemObjects@2 b6239004-a887-0f4b-9937-50029ccdca16
91 lines
2.6 KiB
ObjectPascal
91 lines
2.6 KiB
ObjectPascal
unit DynSQLService_Impl;
|
|
|
|
{----------------------------------------------------------------------------}
|
|
{ This unit was automatically generated by the RemObjects SDK after reading }
|
|
{ the RODL file associated with this project . }
|
|
{ }
|
|
{ This is where you are supposed to code the implementation of your objects. }
|
|
{----------------------------------------------------------------------------}
|
|
|
|
interface
|
|
|
|
uses
|
|
{vcl:} Classes, SysUtils,
|
|
{RemObjects:} uROClientIntf, uROTypes, uROServer, uROServerIntf, uROSessions,
|
|
{Ancestor Implementation:} DataAbstractService_Impl,
|
|
{Used RODLs:} DataAbstract4_Intf, uDAInterfaces,
|
|
{Generated:} DynSQLLibrary_Intf, uDAClasses,
|
|
uDABin2DataStreamer, uDADataStreamer;
|
|
|
|
type
|
|
{ TDynSQLService }
|
|
TDynSQLService = class(TDataAbstractService, IDynSQLService)
|
|
DataStreamer: TDABin2DataStreamer;
|
|
Schema: TDASchema;
|
|
private
|
|
procedure Log(aStr: string);
|
|
function _GetConnection: IDAConnection;
|
|
protected
|
|
procedure MyUpdateData(const Delta: Binary);
|
|
end;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
uses
|
|
{Generated:} DynSQLLibrary_Invk, DynSQLServerMain, Dialogs, TypInfo, uDADelta;
|
|
|
|
procedure Create_DynSQLService(out anInstance: IUnknown);
|
|
begin
|
|
anInstance := TDynSQLService.Create(nil);
|
|
end;
|
|
|
|
{ TDynSQLService }
|
|
|
|
function TDynSQLService._GetConnection: IDAConnection;
|
|
begin
|
|
Result := DynSQLServerMainForm.DAConnectionManager.NewConnection('ADO');
|
|
end;
|
|
|
|
procedure TDynSQLService.Log(aStr: string);
|
|
begin
|
|
DynSQLServerMainForm.Log(aStr);
|
|
end;
|
|
|
|
procedure TDynSQLService.MyUpdateData(const Delta: Binary);
|
|
var
|
|
conn: IDAConnection;
|
|
realdelta: IDADelta;
|
|
i: integer;
|
|
sql: string;
|
|
begin
|
|
// Opens a connection
|
|
conn := _GetConnection;
|
|
|
|
// Creates a delta object
|
|
realdelta := NewDelta('tempDelta');
|
|
|
|
// Converts the binary stream we just received.
|
|
DataStreamer.Initialize(Delta, aiReadFromBeginning);
|
|
DataStreamer.ReadDelta(DataStreamer.DeltaNames[0], realdelta);
|
|
DataStreamer.Finalize;
|
|
|
|
// Builds a fake SQL string for updating and displays it
|
|
sql := 'Updating query "' + DataStreamer.DeltaNames[0] + '", fields ';
|
|
|
|
for i := 0 to (realdelta.LoggedFieldCount - 1) do
|
|
sql := sql + realdelta.LoggedFieldNames[i] + '(' + GetEnumName(TypeInfo(TDADataType), Ord(realdelta.LoggedFieldTypes[i])) + '), ';
|
|
|
|
sql := Copy(sql, 1, Length(sql) - 2);
|
|
|
|
Log(sql);
|
|
end;
|
|
|
|
initialization
|
|
TROClassFactory.Create('DynSQLService', Create_DynSQLService, TDynSQLService_Invoker);
|
|
|
|
finalization
|
|
|
|
end.
|
|
|