Execute (TQueryExecuteTask )
De Wiki1000
(Différences entre les versions)
(Page créée avec « <source lang='delphi'>function Execute(var aReason:string):boolean</source> Cette méthode exécute l'export. {|class="wikitable" |- |aReason |Raison de l'échec |- |Ret... ») |
|||
Ligne 13 : | Ligne 13 : | ||
Exemple : | Exemple : | ||
+ | |||
+ | '''Export dans un fichier:''' | ||
<source lang="delphi"> | <source lang="delphi"> | ||
+ | //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; | ||
</source> | </source> | ||
+ | |||
+ | '''Export dans un containeur:''' | ||
+ | |||
+ | <source lang="delphi"> | ||
+ | //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.OutputContainerName := 'TestSyfre'; | ||
+ | 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; | ||
+ | </source> | ||
+ | |||
+ | '''Export dans une boîte à message:''' | ||
+ | |||
+ | <source lang="delphi"> | ||
+ | //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); | ||
+ | |||
+ | // @glbUserName will be translated to current user name | ||
+ | // | ||
+ | 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; | ||
+ | </source> | ||
+ | |||
Voir aussi: | Voir aussi: |
Version du 14 janvier 2020 à 17:10
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 := TQueryExecuteTask.Create; 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'; 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 une boîte à message:
//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); // @glbUserName will be translated to current user name // 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;
Voir aussi: