问题描述
我有一个即将实现自动化的 SSIS 包。一切正常。但是,为了实现自动化,我需要设置某种循环/任务来检查文本文件是否存在。如果是,则执行下一个要导入的任务,如果不是,则需要每分钟检查一次,直到文件存在。这些文件保存在另一个名为 AgencyReturnFile_yyyymmdd.txt 的组中。 yyyymmdd 是当前日期和保存这些内容的文件夹每天保存并保留为历史记录。
我设置了一些变量: Variables set up
在循环编辑器中,我有 InitExpression @FileExists = 0 EvalExpression @FileExists == 0
在脚本任务编辑器中使用VB2015虽然可以是C# 只读变量:用户::全路径 读写变量:用户::文件存在
脚本:
Public Sub Main()
Dim strFolderPathSource as String = CType(Dts.Variables("User::FullPath").Value,String)
Dim intNumberFilesFound As Integer = 0
Try
Dim collFilesInFolder As IEnumerable = Directory.EnumerateFiles(strFolderPathSource,"User::FullPath",SearchOption.TopDirectoryOnly)
For Each currentFile As String In CollFilesInFolder
intNumberFilesFound = intNumberFilesFound + 1
Next
Catch e As Exception
Concole.WriteLine(e.Message)
End Try
If intNumberFilesFound > 0 Then
Dts.Variables("User::FileExists).Value = 1
Else
Dts.Variables("User::FileExists).Value = 0
End If
Dts.TaskResult = ScriptResults.Success
End Sub
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)