skeeter23
$HASP OK
- Local time
- Today, 05:42
- Joined
- Apr 26, 2011
- Messages
- 19
File staging/copying/moving system - better method?
Hello all!
It's been quite some time since I've been able to post here but I am in a bit of a quandry here redesigning a system I created a few years ago and hope someone can lend some help with a possible better solution for my code. I haven't been able to find anything here that really fits my scenario so I started a new thread. If this already exists please help point me to where it is.
Ok, so I have a system that monitors a folder for incoming files. When files arrive the file name is interrogated based on a "standard" structure for certain parameters specified in a table and an attribute text file is produced based on those values. The creation time of the file and size is also recorded.
The original file is then copied to a "retain" folder on the main server, the original file is then moved to a server location based off of the stored values in a reference table and the text file is placed with it for another system to pick it up.
To avoid "file not found" errors due to a transfer not being complete I set a "release time" based on the file size and time of appearance so for instance a 12gb file @ 15:00 is held until 15:10 to allow for full transfer before attempting to copy or move it.
The other issue I have is when the files are transferring the interface is "not responding" so nothing can be done until the files have finished processing. I've tried using DoEvents to return focus to the interface while the process runs in the background but this hasn't really worked too well. The interface shows things like what files are in the queue, what has moved, and allows for parameter changes (which obviously should not be changed while files are moving) and information lookup.
So I guess based on the above information my questions are:
-----------------------------------------
Dim attdb As DAO.Recordset
Set attdb = CurrentDb.OpenRecordset("ATT_qselReleased", dbOpenDynaset)
If attdb.BOF Or attdb.EOF Then
attdb.Close
Set attdb = Nothing
Exit Function
Else
Dim Prod As String
Prod = attdb!path & "\"
End If
Dim rsn As DAO.Recordset
Set rsn = CurrentDb.OpenRecordset("ATT_tblATTtemp", dbOpenDynaset)
If rsn.BOF Or rsn.EOF Then
Exit Function
Else
rsn.MoveFirst
End If
Dim FLN As String
FLN = rsn!FileName
'Create .att file in Prod folder
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("ATT_qselFileInfo", dbOpenDynaset)
Dim fs, TextFile
Set fs = CreateObject("Scripting.FileSystemObject")
Set TextFile = fs.CreateTextFile(Prod & FLN & ".att", True)
TextFile.WriteLine (rst!a)
TextFile.WriteLine (rst!b)
TextFile.WriteLine (rst!d)
TextFile.WriteLine (rst!e)
TextFile.WriteLine (rst!f)
TextFile.WriteLine (rst!g)
TextFile.WriteLine (rst!h)
TextFile.WriteLine (rst!i)
TextFile.Close
'End .att file
'Copy and move production jobs
FileCopy PTN & FLN, Prod & FLN
Name PTN & FLN As ret & FLN
attdb.Edit
attdb!Proc = 1
attdb.Update
Dim rsl As DAO.Recordset
Set rsl = CurrentDb.OpenRecordset("ATT_tblFileLOG", dbOpenDynaset)
'Add logfile
rsl.AddNew
rsl!FileName = FLN & ".att"
rsl.Update
Dim fsz As Integer
fsz = rsn!Size
rsl.AddNew
rsl!FileName = FLN
rsl!Size = fsz
rsl.Update
rsl.Close
Set rsl = Nothing
rsn.Close
Set rsn = Nothing
Loop
rsp.Close
Set rsp = Nothing
DoCmd.OpenQuery "ATT_qdelATTtemp"
Exit Function
---------------------------------------
Hopefully this makes sense
Hello all!
It's been quite some time since I've been able to post here but I am in a bit of a quandry here redesigning a system I created a few years ago and hope someone can lend some help with a possible better solution for my code. I haven't been able to find anything here that really fits my scenario so I started a new thread. If this already exists please help point me to where it is.
Ok, so I have a system that monitors a folder for incoming files. When files arrive the file name is interrogated based on a "standard" structure for certain parameters specified in a table and an attribute text file is produced based on those values. The creation time of the file and size is also recorded.
The original file is then copied to a "retain" folder on the main server, the original file is then moved to a server location based off of the stored values in a reference table and the text file is placed with it for another system to pick it up.
To avoid "file not found" errors due to a transfer not being complete I set a "release time" based on the file size and time of appearance so for instance a 12gb file @ 15:00 is held until 15:10 to allow for full transfer before attempting to copy or move it.
The other issue I have is when the files are transferring the interface is "not responding" so nothing can be done until the files have finished processing. I've tried using DoEvents to return focus to the interface while the process runs in the background but this hasn't really worked too well. The interface shows things like what files are in the queue, what has moved, and allows for parameter changes (which obviously should not be changed while files are moving) and information lookup.
So I guess based on the above information my questions are:
- Is there a better method than "timers" for triggering my copy/move process?
- Is there a more efficient way to handle the processing of the files (copy/move) and allow the interface to still be able to work while the files transfer in the background?

-----------------------------------------
Dim attdb As DAO.Recordset
Set attdb = CurrentDb.OpenRecordset("ATT_qselReleased", dbOpenDynaset)
If attdb.BOF Or attdb.EOF Then
attdb.Close
Set attdb = Nothing
Exit Function
Else
Dim Prod As String
Prod = attdb!path & "\"
End If
Dim rsn As DAO.Recordset
Set rsn = CurrentDb.OpenRecordset("ATT_tblATTtemp", dbOpenDynaset)
If rsn.BOF Or rsn.EOF Then
Exit Function
Else
rsn.MoveFirst
End If
Dim FLN As String
FLN = rsn!FileName
'Create .att file in Prod folder
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("ATT_qselFileInfo", dbOpenDynaset)
Dim fs, TextFile
Set fs = CreateObject("Scripting.FileSystemObject")
Set TextFile = fs.CreateTextFile(Prod & FLN & ".att", True)
TextFile.WriteLine (rst!a)
TextFile.WriteLine (rst!b)
TextFile.WriteLine (rst!d)
TextFile.WriteLine (rst!e)
TextFile.WriteLine (rst!f)
TextFile.WriteLine (rst!g)
TextFile.WriteLine (rst!h)
TextFile.WriteLine (rst!i)
TextFile.Close
'End .att file
'Copy and move production jobs
FileCopy PTN & FLN, Prod & FLN
Name PTN & FLN As ret & FLN
attdb.Edit
attdb!Proc = 1
attdb.Update
Dim rsl As DAO.Recordset
Set rsl = CurrentDb.OpenRecordset("ATT_tblFileLOG", dbOpenDynaset)
'Add logfile
rsl.AddNew
rsl!FileName = FLN & ".att"
rsl.Update
Dim fsz As Integer
fsz = rsn!Size
rsl.AddNew
rsl!FileName = FLN
rsl!Size = fsz
rsl.Update
rsl.Close
Set rsl = Nothing
rsn.Close
Set rsn = Nothing
Loop
rsp.Close
Set rsp = Nothing
DoCmd.OpenQuery "ATT_qdelATTtemp"
Exit Function
---------------------------------------
Hopefully this makes sense

Last edited: