Execute (TQueryExecuteTask )

De Wiki1000
(Différences entre les versions)
 
Ligne 45 : Ligne 45 :
 
var qbe:TQueryExecuteTask; doc:TxmlDocument; AStr,AReason:string;
 
var qbe:TQueryExecuteTask; doc:TxmlDocument; AStr,AReason:string;
 
begin
 
begin
   qbe := TQueryExecuteTask.Create;
+
   ...
 
+
   qbe.OutputContainerName := 'MyContainerName';  
  doc := CreateDescriptor();
+
  AStr := doc.SaveToString;
+
 
+
  // This will recreate the document with the correct classes
+
  qbe.Descriptor.Document.LoadFromString(AStr);
+
 
+
   qbe.OutputContainerName := 'TestSyfre';  
+
 
   qbe.OutputDocumentName := 'wfclassea';  
 
   qbe.OutputDocumentName := 'wfclassea';  
 
+
   ...
   if not qbe.canExecute then
+
  raise Exception.Create('can''t execute');
+
 
+
  if qbe.Execute(aReason)
+
  then showMessage('execute OK')
+
  else showMessage('execute NOK '+aReason)
+
 
end;
 
end;
 
</source>
 
</source>
Ligne 71 : Ligne 58 :
 
var qbe:TQueryExecuteTask; doc:TxmlDocument; AStr,AReason:string;
 
var qbe:TQueryExecuteTask; doc:TxmlDocument; AStr,AReason:string;
 
begin
 
begin
   qbe := TQueryExecuteTask.Create;
+
   ...
 
+
  doc := CreateDescriptor();
+
  AStr := doc.SaveToString;
+
 
+
  // This will recreate the document with the correct classes
+
  qbe.Descriptor.Document.LoadFromString(AStr);
+
  
 
   // @glbUserName will be translated to current user name
 
   // @glbUserName will be translated to current user name
Ligne 83 : Ligne 64 :
 
   qbe.OutputMailTo := '@glbUserName';
 
   qbe.OutputMailTo := '@glbUserName';
  
   if not qbe.canExecute then
+
   ...
  raise Exception.Create('can''t execute');
+
 
+
  if qbe.Execute(aReason)
+
  then showMessage('execute OK')
+
  else showMessage('execute NOK '+aReason)
+
 
end;
 
end;
 
</source>
 
</source>
  
 +
'''Export envoyé par email:'''
 +
 +
<source lang="delphi">
 +
//Procedure Test;
 +
var qbe:TQueryExecuteTask; doc:TxmlDocument; AStr,AReason:string;
 +
begin
 +
  ...
 +
 +
  // Will be send by email using configured smtp service
 +
  //
 +
  qbe.OutputMailTo := '[email protected]';
 +
  qbe.OutputMailBody := 'This is an export of ... from Sage FRP 1000';
 +
 +
  ...
 +
end;
 +
</source>
  
 
Voir aussi:
 
Voir aussi:

Version actuelle en date du 15 janvier 2020 à 09:16

function Execute(var aReason:string):boolean

Cette méthode exécute l'export.

aReason Raison de l'échec
Return True si l'export c'est exécuté

Exemple :

Export dans un fichier:

//Procedure Test;
var qbe:TQueryExecuteTask; doc:TxmlDocument; AStr,AReason:string;
begin
  qbe := TQueryExecuteTask.Create;
 
  doc := CreateDescriptor();
  AStr := doc.SaveToString;
 
  // This will recreate the document with the correct classes
  qbe.Descriptor.Document.LoadFromString(AStr);
 
  qbe.OutputFileName := 'c:\temp\exports\wfclassea.csv'; 
 
  if not qbe.canExecute then
   raise Exception.Create('can''t execute');
 
  if qbe.Execute(aReason) 
   then showMessage('execute OK')
   else showMessage('execute NOK '+aReason) 
end;

Export dans un containeur:

//Procedure Test;
var qbe:TQueryExecuteTask; doc:TxmlDocument; AStr,AReason:string;
begin
  ...
  qbe.OutputContainerName := 'MyContainerName'; 
  qbe.OutputDocumentName := 'wfclassea'; 
  ...
end;

Export dans une boîte à message:

//Procedure Test;
var qbe:TQueryExecuteTask; doc:TxmlDocument; AStr,AReason:string;
begin
  ...
 
  // @glbUserName will be translated to current user name
  //
  qbe.OutputMailTo := '@glbUserName';
 
  ...
end;

Export envoyé par email:

//Procedure Test;
var qbe:TQueryExecuteTask; doc:TxmlDocument; AStr,AReason:string;
begin
  ...
 
  // Will be send by email using configured smtp service
  //
  qbe.OutputMailTo := '[email protected]';
  qbe.OutputMailBody := 'This is an export of ... from Sage FRP 1000';
 
  ...
end;

Voir aussi:

TQueryExecuteTask_(class)Développement DSM





Whos here now:   Members 0   Guests 1   Bots & Crawlers 0
 
Outils personnels