我使用SAS EG,并试图安排一些日常工作。SAS /计划订单清单中的订单清单代码
- 有没有办法安排一个订单列表,而不是安排整个过程流程?
- 如果没有,我期待着在执行命令列表中的代码,所以我只能在节目安排...
我使用SAS EG,并试图安排一些日常工作。SAS /计划订单清单中的订单清单代码
http://support.sas.com/kb/19/020.html
在设计上,选项,安排有序列表未启用。若要解决此问题,请从项目中选择并复制对象,然后将其粘贴到新的Process Flow中。然后按照您要求的顺序排列它们,最后安排处理流程。
有关您可以在EG中安排工作的所有方式的详细信息,这两篇论文都有很好的细节。 : http://blogs.sas.com/content/sasdummy/2012/04/17/doing-more-with-sas-enterprise-guide-automation/ http://support.sas.com/documentation/onlinedoc/guide/examples/SASGF2012/Hemedinger_298-2012.pdf
如果你愿意做一些脚本,无论是在VBScript或PowerShell的或.Net,这是可能的。然而,并不建议这样做,因为正如Keni所指出的那样,SAS显然没有使这一点成为可能,并且这样说(而不是忘记这么做)。所以我不确定这是为什么 - 所以这可能会导致问题。
但是:这是可能的。至少从技术的角度来看,API中的钩子可以运行有序列表。再次 - 我不知道这是否会造成冲突或其他任何风险,并且您可能需要考虑在SAS社区论坛上发帖,以查看Chris H或该论坛上的其他人是否可以通过您了解为什么它不是在IDE中成为可能。
基本上,您可以通过作为项目一部分的ContainerCollection通过API访问有序列表。该容器集合内部是一个名为“Ordered Lists”的容器。该容器内部是项目中每个有序列表的容器。因此,您可能通过project.ContainerCollection.Item(i).Items.Item(j)
访问,其中i
在我的初始测试中似乎始终为0(但不依赖于此,我不确定它是否始终为0),并且j
是特定有序列表中的数字正在运行。
为此,我创建了一个EGiside生成的VBScript副本,当您要求它调度一个过程流程并调整它以查找有序列表时。这非常糟糕 - 部分原因是因为我的VBScript知识是平庸和古老的,部分原因是希望更快完成这项工作。您可能需要进行更改才能完成此工作(除了调整prjName变量和containerName变量中的项目和项目文件名的路径(这应该是您的已排序列表名称)。
它所做的是循环遍历ContainerCollection中的所有容器,并测试它们是否被命名为“Ordered Lists”。然后,它循环遍历容器中的容器,并测试它们是否被命名为无论放置在containerName变量中(您的Ordered List的名称)。它找到一个,它退出for循环并运行该容器(即运行该有序列表)。
然后可以调度或直接运行(通过在Windows中双击或在控制台中使用cscript.exe
)如果你在非Windo中运行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 Function