Main Page | Report Page

 

  Computers Forum Index » Computer - Databases - Progress » Search Subdirectories...

Author Message
Freddy...
Posted: Thu Jan 28, 2010 5:42 pm
 
We have a new ERP system that uses a Progress OpenEdge backend. A project
manager will type in a CAD file number, and the system will pull in metadata
(e.g. dimensions, materials, machine routing, etc.) from the appropriate
ArtiosCAD file previously created by a designer on a FreeBSD file server.

The ERP vendor says the system can only search in one directory for CAD
files, and cannot search subdirectories. This is a problem, as the designers
have hundreds of thousands of CAD files stored by client, year, job and job
type.

Either we figure out a way to automatically copy newly created CAD files
into a single repository directory, or the ERP vendor figures out a way to
search subdirectories. I was thinking a cron job using rsync might work for
the single directory idea, but I don't think rsync recursion will omit
subdirectories - it copies them as well.

Is there a way that Progress can search subdirectories?

Thanks in advance.
 
DeSudet...
Posted: Fri Jan 29, 2010 1:25 am
 
Freddy wrote:
Quote:
We have a new ERP system that uses a Progress OpenEdge backend. A project
manager will type in a CAD file number, and the system will pull in metadata
(e.g. dimensions, materials, machine routing, etc.) from the appropriate
ArtiosCAD file previously created by a designer on a FreeBSD file server.

The ERP vendor says the system can only search in one directory for CAD
files, and cannot search subdirectories. This is a problem, as the designers
have hundreds of thousands of CAD files stored by client, year, job and job
type.

Either we figure out a way to automatically copy newly created CAD files
into a single repository directory, or the ERP vendor figures out a way to
search subdirectories. I was thinking a cron job using rsync might work for
the single directory idea, but I don't think rsync recursion will omit
subdirectories - it copies them as well.

Is there a way that Progress can search subdirectories?

Thanks in advance.



We're using 9.1E, so I don't know how well it would translate to
OpenEdge, but... I've had to parse multiple subdirectories for some of
my projects and have put together logic that can dig down into an
infinite number of them. It isn't the prettiest code I've ever written,
but it works for me. And of course as I look for the code to paste a
snippet, it dawns on me that it was on my old workstation and didn't
survive the hard drive failing. Quick hack it is then:

/***************************************************************/
DEFINE VARIABLE cStartDir AS CHARACTER NO-UNDO.
DEFINE VARIABLE cTarget AS CHARACTER NO-UNDO.

DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFilePath AS CHARACTER NO-UNDO.
DEFINE VARIABLE cAttrib AS CHARACTER NO-UNDO.
DEFINE VARIABLE lFound AS LOGICAL INIT FALSE NO-UNDO.
DEFINE VARIABLE cTargetLoc AS CHARACTER NO-UNDO.

DEFINE TEMP-TABLE ttSubDirs
FIELD cDir AS CHARACTER.

INPUT FROM OS-DIR("C:\temp\").

REPEAT WHILE NOT lFound:
IMPORT cFileName cFilePath cAttrib.
IF INDEX(cAttrib,"D") <> 0
AND NOT cFileName BEGINS "." THEN
DO:
CREATE ttSubDirs.
ASSIGN ttSubDirs.cDir = cFilePath.
RELEASE ttSubDirs.
END.
IF cFileName = cTarget THEN
ASSIGN lFound = TRUE
cTargetLoc = cFilePath.
END.

DO WHILE CAN-FIND(FIRST ttSubDirs NO-LOCK)
AND NOT lFound:
FIND FIRST ttSubDirs EXCLUSIVE-LOCK.
INPUT FROM OS-DIR(ttSubDirs.cDir).
DELETE ttSubDirs.
REPEAT WHILE NOT lFound:
IMPORT cFileName cFilePath cAttrib.
IF INDEX(cAttrib,"D") <> 0
AND NOT cFileName BEGINS "." THEN
DO:
CREATE ttSubDirs.
ASSIGN ttSubDirs.cDir = cFilePath.
RELEASE ttSubDirs.
END.
IF cFileName = cTarget THEN
ASSIGN lFound = TRUE
cTargetLoc = cFilePath.
END.
END.

EMPTY TEMP-TABLE ttSubDirs.
INPUT CLOSE.
/***************************************************************/

This will search directory cStartDir and all subdirectories for a file
named cTarget. If found, it will stop and place the full path of
cTarget into cTargetLoc, from which you can do whatever you like with
it. You'll probably want to change the INPUT and IMPORT statements to
use streams, but I'm sure you've got someone up for that little task.

Alternatively, if you expect the file to be in in the propath, you can
just use the SEARCH("filename") function. Only problem being that it
won't check subdirectories if they aren't defined as part of the propath.

Best of luck!
 
DeSudet...
Posted: Fri Jan 29, 2010 1:42 am
 
DeSudet wrote:
Quote:
Freddy wrote:
We have a new ERP system that uses a Progress OpenEdge backend. A
project manager will type in a CAD file number, and the system will
pull in metadata (e.g. dimensions, materials, machine routing, etc.)
from the appropriate ArtiosCAD file previously created by a designer
on a FreeBSD file server.

The ERP vendor says the system can only search in one directory for
CAD files, and cannot search subdirectories. This is a problem, as the
designers have hundreds of thousands of CAD files stored by client,
year, job and job type.

Either we figure out a way to automatically copy newly created CAD
files into a single repository directory, or the ERP vendor figures
out a way to search subdirectories. I was thinking a cron job using
rsync might work for the single directory idea, but I don't think
rsync recursion will omit subdirectories - it copies them as well.

Is there a way that Progress can search subdirectories?

Thanks in advance.


We're using 9.1E, so I don't know how well it would translate to
OpenEdge, but... I've had to parse multiple subdirectories for some of
my projects and have put together logic that can dig down into an
infinite number of them. It isn't the prettiest code I've ever written,
but it works for me. And of course as I look for the code to paste a
snippet, it dawns on me that it was on my old workstation and didn't
survive the hard drive failing. Quick hack it is then:

/***************************************************************/
DEFINE VARIABLE cStartDir AS CHARACTER NO-UNDO.
DEFINE VARIABLE cTarget AS CHARACTER NO-UNDO.

DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFilePath AS CHARACTER NO-UNDO.
DEFINE VARIABLE cAttrib AS CHARACTER NO-UNDO.
DEFINE VARIABLE lFound AS LOGICAL INIT FALSE NO-UNDO.
DEFINE VARIABLE cTargetLoc AS CHARACTER NO-UNDO.

DEFINE TEMP-TABLE ttSubDirs
FIELD cDir AS CHARACTER.

INPUT FROM OS-DIR("C:\temp\").

REPEAT WHILE NOT lFound:
IMPORT cFileName cFilePath cAttrib.
IF INDEX(cAttrib,"D") <> 0
AND NOT cFileName BEGINS "." THEN
DO:
CREATE ttSubDirs.
ASSIGN ttSubDirs.cDir = cFilePath.
RELEASE ttSubDirs.
END.
IF cFileName = cTarget THEN
ASSIGN lFound = TRUE
cTargetLoc = cFilePath.
END.

DO WHILE CAN-FIND(FIRST ttSubDirs NO-LOCK)
AND NOT lFound:
FIND FIRST ttSubDirs EXCLUSIVE-LOCK.
INPUT FROM OS-DIR(ttSubDirs.cDir).
DELETE ttSubDirs.
REPEAT WHILE NOT lFound:
IMPORT cFileName cFilePath cAttrib.
IF INDEX(cAttrib,"D") <> 0
AND NOT cFileName BEGINS "." THEN
DO:
CREATE ttSubDirs.
ASSIGN ttSubDirs.cDir = cFilePath.
RELEASE ttSubDirs.
END.
IF cFileName = cTarget THEN
ASSIGN lFound = TRUE
cTargetLoc = cFilePath.
END.
END.

EMPTY TEMP-TABLE ttSubDirs.
INPUT CLOSE.
/***************************************************************/

This will search directory cStartDir and all subdirectories for a file
named cTarget. If found, it will stop and place the full path of
cTarget into cTargetLoc, from which you can do whatever you like with
it. You'll probably want to change the INPUT and IMPORT statements to
use streams, but I'm sure you've got someone up for that little task.

Alternatively, if you expect the file to be in in the propath, you can
just use the SEARCH("filename") function. Only problem being that it
won't check subdirectories if they aren't defined as part of the propath.

Best of luck!


Forgot to mention that I'm obviously using a windows client on this end.
Not sure what tweaks may be required for a linux/unix environment.
 
Arvind...
Posted: Sat Feb 06, 2010 11:13 pm
 
Freddy:
Since you have Open Edge you should have access to the .NET frame work. Using this you can create a routine which uses the relevant classes for recursive directoy search.
The System.IO namespace classes provide many options for working with files and directories. The System.IO namespace not only provides classes that you can instantiate, it also provides file and directory utility classes. These classes contain static methods that you can call without having to declare a variable of that type. For example, you can use the Directory object to obtain the subdirectories of a given directory.


---
frmsrcurl: http://compgroups.net/comp.databases.progress/Search-Subdirectories
 
 
Page 1 of 1    
All times are GMT
The time now is Fri Apr 18, 2014 1:30 pm