uDataTableUtils.pas: Arreglo de la función CopyDataTableDA5 para que funcione correctamente y se empiece a usar.
git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@378 0c75b7a4-871f-7646-8a2f-f78d34cc349f
This commit is contained in:
parent
8750e65053
commit
cde55cdfcd
@ -58,12 +58,11 @@ uses
|
||||
Dialogs, Variants, uDBSelectionListUtils, uROClasses, uDADataStreamer, uDABin2DataStreamer;
|
||||
|
||||
|
||||
procedure CopyDataTableDA5(ASource : TDADataTable;
|
||||
ATarget: TDADataTable;
|
||||
const OnlySelectedRows : Boolean);
|
||||
procedure CopyDataTableDA5(ASource : TDADataTable; ATarget: TDADataTable;
|
||||
const OnlySelectedRows : Boolean = False);
|
||||
var
|
||||
AStream : Binary;
|
||||
AStream2 : Binary;
|
||||
DABin: Binary;
|
||||
DADataStreamer : TDABin2DataStreamer;
|
||||
AFilter : String;
|
||||
AFiltered : Boolean;
|
||||
AObj : ISeleccionable;
|
||||
@ -72,15 +71,6 @@ begin
|
||||
AFilter := '';
|
||||
AFiltered := False;
|
||||
|
||||
if not Assigned(ASource) then
|
||||
raise Exception.Create ('No se ha asignado la tabla de origen (CopyDataTable)');
|
||||
|
||||
if not Assigned(ATarget) then
|
||||
raise Exception.Create ('No se ha asignado la tabla de destino (CopyDataTable)');
|
||||
|
||||
if not ATarget.Active then
|
||||
ATarget.Active := True;
|
||||
|
||||
if OnlySelectedRows then
|
||||
begin
|
||||
if not Supports(ASource, ISeleccionable, aObj) then
|
||||
@ -107,20 +97,26 @@ begin
|
||||
ASource.Filtered := True;
|
||||
end;
|
||||
|
||||
if not ASource.Active then
|
||||
ASource.Open;
|
||||
DABin := Binary.Create;
|
||||
DADataStreamer := TDABin2DataStreamer.Create(nil);
|
||||
|
||||
AStream := Binary.Create;
|
||||
DesconectarTabla(ATarget);
|
||||
ShowHourglassCursor;
|
||||
ASource.DisableControls;
|
||||
ATarget.DisableControls;
|
||||
try
|
||||
ASource.SaveToStream(AStream);
|
||||
AStream2 := AStream.Clone;
|
||||
ATarget.LogicalName := ASource.LogicalName; // We need to specify new dataset LogicalName
|
||||
ATarget.RemoteFetchEnabled := False; // "Desconectamos" la tabla destino del servidor
|
||||
|
||||
if not ASource.Active then
|
||||
ASource.Open;
|
||||
ASource.First;
|
||||
|
||||
DADataStreamer.WriteDataset(DABin, ASource, [woRows, woSchema], -1);
|
||||
DADataStreamer.ReadDataset(DABin, ATarget, True);
|
||||
DADataStreamer.Finalize;
|
||||
|
||||
ATarget.RemoteFetchEnabled := True; // "Conectamos" la tabla del servidor otra vez
|
||||
|
||||
// ShowMessage(AStream.ToReadableString);
|
||||
ATarget.LoadFromStream(AStream2); ///->>>>>>>>>>>>>>>>>>>>>>>>>>ERRORRRR
|
||||
finally
|
||||
FreeAndNil(AStream);
|
||||
ConectarTabla(ATarget);
|
||||
// Dejar el filtro de la tabla origen como estaba
|
||||
if OnlySelectedRows then
|
||||
begin
|
||||
@ -129,11 +125,17 @@ begin
|
||||
if AFiltered then
|
||||
ASource.Filtered := True;
|
||||
end;
|
||||
|
||||
finally
|
||||
FreeAndNil(DABin);
|
||||
FreeAndNil(DADataStreamer);
|
||||
ASource.EnableControls;
|
||||
ATarget.EnableControls;
|
||||
HideHourglassCursor;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function SetFieldNull(ATarget: TDADataTable; const FieldName: String): Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
@ -149,34 +151,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{procedure EliminarNoSeleccionados(const ASource : IDADataset;
|
||||
var ATarget : TDADataTable);
|
||||
var
|
||||
AObj : ISelectedRowList;
|
||||
i : Integer;
|
||||
begin
|
||||
if not Supports(ASource, ISelectedRowList, aObj) then
|
||||
Exit;
|
||||
|
||||
// ATarget.DisableControls;
|
||||
// ATarget.DisableEventHandlers;
|
||||
ShowHourglassCursor;
|
||||
try
|
||||
ATarget.Open;
|
||||
ATarget.Last;
|
||||
while ATarget.RecordCount > AObj.SelectedRows.Count do
|
||||
begin
|
||||
if AObj.SelectedRows.IndexOf(ATarget.RecIDValue) < 0 then
|
||||
ATarget.Delete
|
||||
else
|
||||
ATarget.Prior;
|
||||
end;
|
||||
finally
|
||||
// ATarget.EnableControls;
|
||||
// ATarget.EnableControls;
|
||||
HideHourglassCursor;
|
||||
end;
|
||||
end;}
|
||||
|
||||
function DataTableModified (const ADataTable : TDADataTable): Boolean;
|
||||
var
|
||||
@ -296,15 +270,11 @@ var
|
||||
begin
|
||||
with ATarget do
|
||||
begin
|
||||
// ****** Inicio migración DA 5
|
||||
{RemoteService := ASource.GetRemoteService;
|
||||
Adapter := ASource.GetAdapter;}
|
||||
|
||||
if not Assigned(ASource.RemoteDataAdapter) then
|
||||
raise Exception.Create('No está asignado RemoteDataAdapter (' + ASource.Name + ')');
|
||||
|
||||
RemoteDataAdapter.Assign(ASource.RemoteDataAdapter);
|
||||
// ****** Fin migración DA 5
|
||||
|
||||
BusinessRulesID := ASource.BusinessRulesID;
|
||||
Randomize;
|
||||
@ -316,77 +286,8 @@ begin
|
||||
if Assigned(ASource.LocalSchema) then
|
||||
LocalSchema := ASource.LocalSchema
|
||||
else begin
|
||||
// ****** Inicio migración DA 5
|
||||
{
|
||||
with SchemaCall do
|
||||
begin
|
||||
MethodName := ASource.SchemaCall.MethodName;
|
||||
for i := 0 to ASource.SchemaCall.Params.Count - 1 do
|
||||
begin
|
||||
with Params.Add do begin
|
||||
Name := ASource.SchemaCall.Params[i].Name;
|
||||
ParamType := ASource.SchemaCall.Params[i].ParamType;
|
||||
DataType := ASource.SchemaCall.Params[i].DataType;
|
||||
Value := ASource.SchemaCall.Params[i].Value;
|
||||
UserClassName := ASource.SchemaCall.Params[i].UserClassName;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
}
|
||||
// ****** Fin migración DA 5
|
||||
ATarget.Fields.AssignFieldCollection(ASource.Fields); // o también ATarget.LoadSchema;
|
||||
end;
|
||||
|
||||
// ****** Inicio migración DA 5
|
||||
{
|
||||
with DataUpdateCall do
|
||||
begin
|
||||
MethodName := ASource.DataUpdateCall.MethodName;
|
||||
for i := 0 to ASource.DataUpdateCall.Params.Count - 1 do
|
||||
begin
|
||||
with Params.Add do begin
|
||||
Name := ASource.DataUpdateCall.Params[i].Name;
|
||||
ParamType := ASource.DataUpdateCall.Params[i].ParamType;
|
||||
DataType := ASource.DataUpdateCall.Params[i].DataType;
|
||||
Value := ASource.DataUpdateCall.Params[i].Value;
|
||||
UserClassName := ASource.DataUpdateCall.Params[i].UserClassName;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
with ScriptCall do
|
||||
begin
|
||||
MethodName := ASource.ScriptCall.MethodName;
|
||||
for i := 0 to ASource.ScriptCall.Params.Count - 1 do
|
||||
begin
|
||||
with Params.Add do begin
|
||||
Name := ASource.ScriptCall.Params[i].Name;
|
||||
ParamType := ASource.ScriptCall.Params[i].ParamType;
|
||||
DataType := ASource.ScriptCall.Params[i].DataType;
|
||||
Value := ASource.ScriptCall.Params[i].Value;
|
||||
UserClassName := ASource.ScriptCall.Params[i].UserClassName;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
with DataRequestCall do
|
||||
begin
|
||||
MethodName := ASource.DataRequestCall.MethodName;
|
||||
for i := 0 to ASource.DataRequestCall.Params.Count - 1 do
|
||||
begin
|
||||
with Params.Add do begin
|
||||
begin
|
||||
Name := ASource.DataRequestCall.Params[i].Name;
|
||||
ParamType := ASource.DataRequestCall.Params[i].ParamType;
|
||||
DataType := ASource.DataRequestCall.Params[i].DataType;
|
||||
Value := ASource.DataRequestCall.Params[i].Value;
|
||||
UserClassName := ASource.DataRequestCall.Params[i].UserClassName;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
}
|
||||
// ****** Fin migración DA 5
|
||||
|
||||
with MasterParamsMappings do
|
||||
for i := 0 to ASource.MasterParamsMappings.Count - 1 do
|
||||
@ -481,6 +382,9 @@ begin
|
||||
DABin := Binary.Create;
|
||||
DAAdapter := TDABINAdapter.Create(nil);
|
||||
|
||||
ShowHourglassCursor;
|
||||
ASource.DisableControls;
|
||||
ATarget.DisableControls;
|
||||
try
|
||||
ATarget.LogicalName := ASource.LogicalName; // We need to specify new dataset LogicalName
|
||||
ATarget.RemoteFetchEnabled := False; // "Desconectamos" la tabla destino del servidor
|
||||
@ -508,6 +412,9 @@ begin
|
||||
finally
|
||||
FreeAndNil(DABin);
|
||||
FreeAndNil(DAAdapter);
|
||||
ASource.EnableControls;
|
||||
ATarget.EnableControls;
|
||||
HideHourglassCursor;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user