Yaron Munz · Oct 16, 2019

Ensemble dynamic archive path


Is there an elegant way to define a dynamic "Archive path" for EnsLib.File.InboundAdapter ?

What i mean is to have a sub-folders structure (under the root archive path) with a name similar to: yyyymmdd
This way the adapter "could" store the files on those sub-folders (and create a new one for the 1st file for a specific date).

When a production is processing hundreds of thousands of files every day, we might end up with an archive with huge number of files (many millions) which is then hard to handle (read, search) especially on Windows O/S.

Of course that there is always a "programmatic" way to move/distribute the files from archive root (as a background task), but before going to that direction, I would like to know, if there is an "out of the box" solution.



1 245
Discussion (1)2
Log in or sign up to continue

Haven't tried this directly yet so this is more of a suggestion for discussion - subclass EnsLib.File.InboundAdapter and override getArchiveFilename:

Method getArchiveFilename(pWorkFilename As %String) As %String [ Internal ]
    Set tDateStamp = $ZD($Horolog, 3)
    Set tArchivePath = ##class(%File).NormalizeDirectory(tDateStamp, ..ArchivePath) 

    If ('##class(%File).DirectoryExists(tArchivePath))
         Do ##class(%File).CreateDirectoryChain(tArchivePath, .tRet)

    Quit ..CreateTimestamp(##class(%File).GetFilename(pWorkFilename),$S(""'=..WorkPath&&(..WorkPath'=..FilePath):"%f",1:$Case(..AppendTimestamp,"":"%f",0:"%f",1:"%f_%Q%!+(_a)",:..AppendTimestamp)),,tArchivePath)


Probably a lot wrong with that but it's a starting point.