我使用SAS EG,并试图安排一些日常工作。
发布于 2016-02-12 17:24:47
http://support.sas.com/kb/19/020.html
根据设计,未启用安排有序列表的选项。为了避免这个问题,选择并复制项目中的对象并将它们粘贴到一个新的流程流中。然后按照你想要的顺序排列它们,最后,安排流程。
有关在EG中安排作业的所有方法的详细信息,这两篇论文都有很好的细节。:http://blogs.sas.com/content/sasdummy/2012/04/17/doing-more-with-sas-enterprise-guide-automation/ 298-2012.pdf
发布于 2016-02-12 21:13:32
如果您愿意使用VBScript、Powershell或.Net编写一些脚本,这是可能的。但是,不建议这样做,因为正如Keni所指出的,SAS并没有明确地使这成为可能,而是这么说的(而不是忘记这么做)。所以我不知道这是为什么-所以这可能会导致问题。
然而,这是可能的。API中的钩子存在以运行有序列表,至少从技术角度看是这样。再次-我不知道这是否有冲突或其他任何风险,你可能想考虑张贴在SAS社区论坛,看看克里斯H或论坛上的其他人是否可以提示你,为什么这是不可能在IDE。
基本上,您可以通过作为项目一部分的ContainerCollection通过API访问有序列表。在该容器集合中,有一个称为“有序列表”的容器。在该容器内是项目中每个有序列表的容器。因此,您可以通过project.ContainerCollection.Item(i).Items.Item(j)访问它,在最初的测试中,i似乎始终是0(但不要依赖它,我不确定它是否总是0),j是您正在运行的特定有序列表的数量。
要做到这一点,我创建了一个VBScript的副本,当您要求它调度一个流程流时,EGuide会生成它,并对它进行调整以找到有序列表。这在一定程度上是因为我的VBScript知识是平庸而古老的,部分原因是我渴望更快地完成这一任务。您可能需要进行更改才能完成这项工作(除了调整prjName变量和containerName变量(这应该是有序列表的名称)中的项目和项目文件名的路径之外)。
它所做的是遍历ContainerCollection中的所有容器,并测试它们是否被命名为“有序列表”。然后循环遍历容器中的容器,并测试它们是否被命名--不管您在containerName变量中放入什么(您的有序列表的名称)。当它找到其中一个时,它退出for循环并运行那个容器(即运行该有序列表)。
然后可以调度,也可以直接运行(通过在Windows中双击或在控制台中使用cscript.exe )。如果您在非Windows环境中运行EG,这可能仍然可以工作(如果您有一个VBScript编译器),但是我不确定API是否以相同的方式工作。( SAS环境应该无关紧要,应该是EG环境。)
Option Explicit
Dim app ' As SASEGuide.Application
Call dowork
'shut down the app
If not (app Is Nothing) Then
app.Quit
Set app = Nothing
End If
Sub dowork()
On Error Resume Next
'----
' Start up Enterprise Guide using the project name
'----
Dim prjName ' As String
Dim prjObject ' As SASEGuide.Project
Dim containerName ' As String
Dim containerObject ' As SASEGuide.Container
Dim containerColl ' As SASEGuide.ContainerCollection
dim orderedListObject ' as SASEguide.Container
prjName = "\\pathtoproject\test project.egp" ' Project Name
containerName = "My Ordered List" ' Name of the Ordered List
Set app = CreateObject("SASEGObjectModel.Application.7.1")
If Checkerror("CreateObject") = True Then
Exit Sub
End If
Set prjObject = app.Open(prjName,"")
If Checkerror("App.Open") = True Then
Exit Sub
End If
'-----
'Get The Container Collection and Object
'-----
Set containerColl = prjObject.ContainerCollection
If Checkerror("Project.ContainerCollection") = True Then
Exit Sub
End If
Dim i ' As Long
Dim j ' As Long
Dim count ' As Long
Dim count_OL ' as Long
count = containerColl.count
For i = 0 To count - 1
Set containerObject = containerColl.Item(i)
If Checkerror("ContainerCollection.Item") = True Then
Exit Sub
End If
If (containerObject.Name = "Ordered Lists") Then
count_OL = containerObject.items.count
For j = 0 to count_OL - 1
If Checkerror("ContainerCollection.Item") = True Then
Exit Sub
End If
Set orderedListObject = containerObject.items.item(j)
If (orderedListObject.name = containerName) then
exit for
Else
Set orderedListObject = Nothing
end if
Next
Exit For
Else
Set containerObject = Nothing
Set orderedListObject = Nothing
End If
Next
If not (orderedListObject is nothing) Then
'----
' Run the Container
'----
orderedListObject.Run
If Checkerror("Container.Run") = True Then
Exit Sub
End If
Else
wscript.echo "Not Found"
End If
'-----
' Save the new project
'-----
prjObject.Save
If Checkerror("Project.Save") = True Then
Exit Sub
End If
'-----
' Close the project
'-----
prjObject.Close
If Checkerror("Project.Close") = True Then
Exit Sub
End If
End Sub
Function Checkerror(fnName)
Checkerror = False
Dim strmsg ' As String
Dim errNum ' As Long
If Err.Number <> 0 Then
strmsg = "Error #" & Hex(Err.Number) & vbCrLf & "In Function " & fnName & vbCrLf & Err.Description
MsgBox strmsg 'Uncomment this line if you want to be notified via MessageBox of Errors in the script.
Checkerror = True
End If
End Functionhttps://stackoverflow.com/questions/35366638
复制相似问题