ImportByFormatDef (rtl)

De Wiki1000
(Redirigé depuis IntegrateByFormatDef (rtl))

<source lang="delphi">Procedure ImportbyFormatDef(const aCodeFormat:string; const aData:TStrings; aRefObject:TitObject; const aLogLevel:FormatLogLevel);</source>

Cette méthode permet d'importer un fichier en utilisant un format.

Paramètre Usage
aCodeFormat Code du format à utiliser pour l'import.
aData Contenu du fichier à importer.
aRefObject Objet racine tous les objets qui seront créés.
aLogLevel Niveau de journalisation.

Le journal généré se situe dans répertoire [container L1000]/logs

Trois niveaux de journalisation sont possibles :

  • Format_Log_Level_None
aucune trace
  • Format_Log_Level_Data_Errors
trace les erreurs d'accès au données (formule erronée...) utile pour la mise au point des nouveaux formats
  • Format_Log_Level_Verbose
trace l'exploration du fichier / du modèle (trace importante en taille) + Format_Log_Level_Data_Errors

Exemple

<source lang="delphi"> //Procedure _doImport; var

vFormatCode : String;
vFormatIntegrationFichier : TFormatIntegrationFichier;
vidxRem  : Integer;
vTimeOrg : LongInt;
vTimeInt : LongInt;
vTimeLst : LongInt;
vTimeCom : LongInt;
vTrackingMode : FormatLogLevel;

begin

 // Locate the format definition
 // Recherche du format en dur
 vFormatCode := 'INT_SEPA_SCT_PAIN.001.001.03';
 vFormatIntegrationFichier := TFormatIntegrationFichier.Find('(code=%1)',,true,[vFormatCode]);
 // Set logging mode
 if estVerbeux then
   vTrackingMode := Format_Log_Level_Verbose
 else
   vTrackingMode := Format_Log_Level_None;
 if Assigned(vFormatIntegrationFichier) then
 begin
  // Start a long transaction
  ClassManager.BeginLongTran(1,'TImportRemiseBancaire');
  try
    CreerSessionImport;
    // Load the source file in a TStrings
    ProgressMessage(Format(_TP('Chargement du fichier %s.'),[FichierImport]));
    content.LoadFromFile(FichierImport);
    vTimeOrg := GetTickCount;
    ProgressMessage(Format(_TP('Intégration du fichier %s.'),[FichierImport]));
    // Import the source file here
    ImportbyFormatDef(vFormatIntegrationFichier.GetFileFormatNameRef,Content.Strings,self,vTrackingMode);
    vTimeInt := GetTickCount;
    ProgressMessage(Format(_TP('Intégration en %s ms.'),[TickToString(vTimeInt-vTimeOrg)]));
    ProgressMessage(_TP('Fermeture de la transaction.'));
    ClassManager.CommitlongTran; 
    vTimeCom := GetTickCount;
    ProgressMessage(Format(_TP('Clôture transaction en %s Ms, sur un total de %s Ms.'),[TickToString(vTimeCom-vTimeLst),TickToString(vTimeCom-vTimeOrg)]));
  except
    ClassManager.RollBacklongTran;
    ProgressMessage(Format(_TP('Erreur dimport : %s'),[e.Message]));
    raise;
  end;
end
else
  ERule.Create(Format(_TP('Le format %s na pas été trouvé.'),[vFormatCode]));

end; </source>

Voir aussi:

{{#if:Développement DSM|

{{#if:Développement DSM|— Développement DSM |}} — Développement DSM

|

{{#if:|— [[{{{1}}}]] |}} — Développement DSM

}}