![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Ok, now that I lost you, here is my problem... I have a folder structure like A 1 1.xml 1.htm 1a.htm 2 2.xml 2.htm 2a.htm 3 3.xml 3.htm 3.html And I need to loop through all the files and every xml file I need to continue the workflow and insert values into the database. Looking at the example I can do pretty much everything but deal with the recursive loop Set Params --> Start Loop --> XML Parsing --> SQL Task (call Sproc) --> Loop Here is the Start Loop step Function Main() dim pkg, conTextFile, stpEnterLoop, stpFinished set pkg = DTSGlobalVariables.Parent set stpEnterLoop = pkg.Steps("DTSStep_DTSActiveScriptTask_5") set stpFinished = pkg.Steps("DTSStep_DTSActiveScriptTask_6") if ShouldILoop = True then msgbox DTSGlobalVariables("File").Value stpEnterLoop.DisableStep = False stpFinished.DisableStep = True stpEnterLoop.ExecutionStatus = DTSStepExecStat_Waiting ELSE msgbox "none" stpEnterLoop.DisableStep = True stpFinished.DisableStep = False stpFinished.ExecutionStatus = DTSStepExecStat_Waiting End If Main = DTSTaskExecResult_Success End Function Function ShouldILoop dim fso, fil, fold, pkg, counter dim fsoSubFold, strPath strPath = DTSGlobalVariables("ImportFolder").Value set pkg = DTSGlobalVariables.Parent set fso = CreateObject("Scripting.FileSystemObject") set fold = fso.GetFolder(strPath) ' counter = fold.files.count ' msgbox counter ' if counter >=1 THEN for each fil in fold.files If right(fil.path,3) = "xml" Then msgbox "xml" 'DTSGlobalVariables("File").Value = fil.path DTSGlobalVariables("File_Name").Value = fil.path ShouldILoop = CBool(True) Else ShouldILoop = CBool(False) End If next ' Else ' ShouldILoop = CBool(False) ' End If ' Next ' else ' ShouldILoop = CBool(False) ' End If For each fsoSubFold in fold.SubFolders DTSGlobalVariables("ImportFolder").Value = fsoSubFold.Path ' ShouldILoop(fsoSubFold.Path) ShouldILoop Next End Function Need some help, burning too many cycles here TIA |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
I have made some modifications Function Main() dim pkg, conTextFile, stpEnterLoop, stpFinished dim fso, folder, subFolder Set fso = createObject("scripting.FileSystemObject") set folder = fso.GetFolder(DTSGlobalVariables("ImportFolder").V alue) set pkg = DTSGlobalVariables.Parent set stpEnterLoop = pkg.Steps("DTSStep_DTSActiveScriptTask_5") set stpFinished = pkg.Steps("DTSStep_DTSActiveScriptTask_6") If LoopFolders = True Then if ShouldILoop = True then stpEnterLoop.DisableStep = False stpFinished.DisableStep = True stpEnterLoop.ExecutionStatus = DTSStepExecStat_Waiting ELSE stpEnterLoop.DisableStep = True stpFinished.DisableStep = False stpFinished.ExecutionStatus = DTSStepExecStat_Waiting End If Else stpEnterLoop.DisableStep = True stpFinished.DisableStep = False stpFinished.ExecutionStatus = DTSStepExecStat_Waiting End IF Main = DTSTaskExecResult_Success End Function Function LoopFolders dim fso, folder, subFolder, folderCounter Set fso = createObject("scripting.FileSystemObject") set folder = fso.GetFolder(DTSGlobalVariables("ImportFolder").V alue) folderCounter = folder.SubFolders.count If folderCounter >=1 Then For Each subFolder in Folder.SubFolders DTSGlobalVariables("SubFolder").Value = subfolder.path LoopFolders = CBool(True) Next Else LoopFolders = CBool(False) End If End Function Function ShouldILoop dim fso, fil, fold, pkg, counter dim fsoSubFold, strPath dim stpEnterLoop, stpFinished strPath = DTSGlobalVariables("SubFolder").Value set pkg = DTSGlobalVariables.Parent set fso = CreateObject("Scripting.FileSystemObject") set fold = fso.GetFolder(strPath) counter = fold.files.count if counter >=1 THEN for each fil in fold.files If right(fil.path,3) = "xml" Then DTSGlobalVariables("File_Name").Value = fil.path ShouldILoop = CBool(True) End IF next Else ShouldILoop = CBool(False) End If End Function I can loop through all the folders, subfolders, find if it is an XML doc and even return true for ShouldILoop. The problem appears to be that if ShouldILoop is true, it is not entering the workflow and looping back. This task keeps looping until the very last XML file is found and then it enters the workflow and processes the XML file. What I need to happen is, if an XML file is found, about 6000 XML files out of 85,000 files, it should enter the workflow for each one. This is not currently happening. Thanks for the help *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
![]() |
| Thread Tools | |
| Display Modes | |
| |