This content has been machine translated dynamically.
Dieser Inhalt ist eine maschinelle Übersetzung, die dynamisch erstellt wurde. (Haftungsausschluss)
Cet article a été traduit automatiquement de manière dynamique. (Clause de non responsabilité)
Este artículo lo ha traducido una máquina de forma dinámica. (Aviso legal)
此内容已动态机器翻译。 放弃
このコンテンツは動的に機械翻訳されています。免責事項
This content has been machine translated dynamically.
This content has been machine translated dynamically.
This content has been machine translated dynamically.
This article has been machine translated.
Dieser Artikel wurde maschinell übersetzt. (Haftungsausschluss)
Ce article a été traduit automatiquement. (Clause de non responsabilité)
Este artículo ha sido traducido automáticamente. (Aviso legal)
この記事は機械翻訳されています.免責事項
이 기사는 기계 번역되었습니다.
Este artigo foi traduzido automaticamente.
这篇文章已经过机器翻译.放弃
Translation failed!
转发路径示例
此示例将指导您完成创建简单的转发路径方案和任务脚本的过程。
创建方案
-
从 AppDNA 菜单中,选择配置 > 转发路径。
-
在“正向路径逻辑编辑器”的工具栏上,单击“新建方案”。
-
在“转发路径脚本名称”对话框中,输入新方案的名称和描述,然后单击“确定”。
这将创建一个新方案并在编辑器中打开它。新方案脚本如下所示:
1 Public Function ForwardPath(ByVal currentApplication As Application) As Output 2 ' TODO: Your new Forward Path Logic definition must be defined here. 3 ' Refer to the sample Forward Path scripts which have been provided. 4 Dim myForwardpathresult As New Output() 5 6 myForwardpathresult.Outcome = "Sample Outcome" 7 myForwardpathresult.Cost = 100 8 myForwardpathresult.RAG = RAG.Green 9 10 ForwardPath = myForwardpathresult 11 12 End Function
-
这是一个功能性的场景脚本,虽然它没有任何实际用途。要了解它的工作原理,请单击“编辑器”工具栏上的“测试”。
这将根据当前在“应用程序列表”中选择的应用程序评估方案,并在“输出”选项卡上打开结果。
请注意,结果列中的值为每个应用程序的“示例结果”,同样,RAG 和成本列中的值为“绿色”,所有选定应用程序的值为 100。这是因为这些列的值在脚本第 6-8 行中是“硬编码”的。
请注意,描述和 CustomField 列为空,因为方案不提供这些列的值。
-
更改 RAG 列的值,以反映 Windows 7 报告的应用程序的实际 RAG。更改方案脚本中的第 8 行,如下所示:
myForwardpathresult.RAG = currentApplication.Modules.Windows7.RAG
这会将“RAG”列中的值设置为应用程序的 Windows 7 RAG 状态。(这假定已经为 Windows 7 报告分析了应用程序。如果此报告不可用,请选择另一个可用报告。使用属性资源管理器了解如何引用其他报告。)
-
单击测试以查看结果。
RAG 列中的值反映了实际的 RAG 值。
-
接下来,使结果列中的值取决于 Windows 7 RAG 状态。要做到这一点,用 IF 语句替换第 6 行,如下所示:
If (currentApplication.Modules.Windows7.RAG = RAG.Green) Then myForwardpathresult.Outcome = "OK for Windows 7" Else If (currentApplication.Modules.Windows7.RAG = RAG.Amber) Then myForwardpathresult.Outcome = "Remediation required" Else myForwardpathresult.Outcome = "Redevelopment required" End If End If
此语句测试应用程序的 Windows 7 RAG 状态是否为绿色。如果是,脚本会在“结果”列中写入“Windows 7”,如果没有,则会测试 Windows 7 RAG 状态是否为琥珀色。如果它是琥珀色的,脚本将“需要修复”写入“结果”列,否则将“需要重建”写入“结果”列,因为如果 RAG 状态不是绿色或琥珀色,则必须是红色的(假设应用程序已被分析并解锁)。
-
单击测试以查看结果。
请注意,现在“结果”列中的值反映了“IF”语句中的逻辑。
这是一个故意简单的例子,旨在介绍转发路径的工作原理。若要查看一些更真实的示例,请使用方案资源管理器浏览 AppDNA 附带的示例方案,并使用属性资源管理器探索方案脚本可用的属性。
注意: 输出对象在属性资源管理器中显示为 ForwardPathReportOutput。
例如,您可以使用 Output.Display 属性来控制报告中标准列的宽度和可见性,如下所示:
myForwardpathresult.Display.Application.Width = 250
myForwardpathresult.Display.Manufacturer.Width = 100
myForwardpathresult.Display.Version.Width = 50
myForwardpathresult.Display.SourcePath.Visible = false
myForwardpathresult.Display.Outcome.Width = 400
同样,您可以使用 Output.CustomFieldn.Display 属性来控制自定义字段列的宽度和可见性:
myForwardpathresult.CustomField1.Display.Width = 50
myForwardpathresult.CustomField2.Display.Width = 100
这些属性控制运行报告时列的显示。它们不控制“正向路径逻辑编辑器”中“输出”选项卡上的列。
创建任务脚本
现在,我们将创建一个任务脚本,该脚本与我们的示例方案脚本创建的“结果”列中的“需要重新开发”值相关联。
-
在编辑器中打开我们在上一步中创建的示例脚本。
-
在主工具栏上,单击“新建任务脚本”。
此操作将打开“转发路径任务脚本”对话框,其中列出了在编辑器中打开的方案的“结果”列中的可能值。
-
从下拉列表中,选择需要重建,输入描述,然后单击确定。
这将创建一个新的任务脚本并在编辑器中打开它。新的任务脚本如下所示:
1 ' This sample script kicks off an Install Capture of the given file 2 ' as well as interacts with the gui 3 LoadAssembly System.Windows.Forms.dll 4 5 Imports AppDNA.AppTitude.Scripting 6 Imports System.Collections.Generic 7 8 Public Class ScriptClass 9 10 Public Function Start(controller As IActionController) As TaskStatusEnum 11 ' If you need to override or provide replaceable to the 12 ' execution profiles add then to this dictionary 13 14 Dim replaceables As Dictionary(Of String, String) 15 ' replaceables.Add( "replaceablename", "value") 16 17 ' This informs the controller that it can abort if the user cancels 18 controller.AbortOnCancel() 19 20 ' This lets you run the execution profile for a given app using a given VM 21 ProductionManager.RunExecutionProfile(controller, "Snapshot", replaceables, "Default VM Configuration") 22 23 ' Add you own actions 24 controller.GUI.ProgressPercent = 100 25 Start = TaskStatusEnum.Complete 26 End Function 27 28 End Class
这是一个用于启动安装捕获的骨架任务脚本。
-
我们将更改与安装捕获(第 11 行-21 行)相关的行,使用将发送电子邮件的代码。但是,首先,我们将在第 6 行之后添加以下行来导入我们需要发送电子邮件的命名空间:
Imports System.Net.Mail Imports System.Net
-
现在将安装捕获代码(现在是第 13-23 行)替换为以下内容:
' This informs the controller that it can abort if the user cancels controller.AbortOnCancel() Dim myClient As New SmtpClient("<validsmtpserver>") myClient.Credentials = New NetworkCredential("<emailaccountusername>", "<emailaccountpassword>") Dim MainMessage As String = "" Dim Message As New MailMessage() Dim Address As New MailAddress("<fromaddress>", "AppDNA Notification") Dim ToAddress As New MailAddress("<recipientemailaddress>") MainMessage = MainMessage + "<html>" MainMessage = MainMessage + "<head>" MainMessage = MainMessage + "<title>AppDNA Notification</title>" MainMessage = MainMessage + "</head>" MainMessage = MainMessage + "<body>" MainMessage = MainMessage + "Hello," MainMessage = MainMessage + "<br />" MainMessage = MainMessage + "<br />" MainMessage = MainMessage + "Application needs redevelopment." MainMessage = MainMessage + "<br />" MainMessage = MainMessage + "Application Name: " + controller.Application.Name MainMessage = MainMessage + "<br />" MainMessage = MainMessage + "Source Path: " + controller.Application.SourcePath MainMessage = MainMessage + "<br />" MainMessage = MainMessage + "Goodbye." MainMessage = MainMessage + "<br />" MainMessage = MainMessage + "</body>" MainMessage = MainMessage + "</html>" Message.Body = MainMessage Message.IsBodyHtml = True Message.From = Address Message.To.Add(ToAddress) Message.Subject = "AppDNA Notification" myClient.Send(Message)
-
替换 <validsmtpserver>、<emailaccountusername> <emailaccountpassword>、<fromaddress> 和 <recipientemailaddress> 为您的环境使用适当的值。
-
单击“保存”以保留您的更改。
-
现在让我们运行任务脚本:
- 从 AppDNA 侧栏中,选择报告:应用程序 > 转发路径。
- 在“转发路径”报告查看器中,选择我们之前创建的“转发路径”方案。
- 点击评估任务。
这将打开“正向路径任务排序”屏幕,该屏幕列出了“正向路径”方案已处理的应用程序,并显示它们是否具有与其关联的任务脚本。
-
选择具有关联任务脚本的应用程序,然后单击工具栏上的“开始”。
这将运行该应用程序的任务脚本。“状态”列显示脚本是否已成功运行。出现错误时,它会显示在屏幕的下部。在此示例中,如果您没有为您的环境输入适当的邮件参数(上面的步骤 6),脚本将失败。
- 要查看更多示例,请使用任务脚本资源管理器浏览 AppDNA 附带的示例任务脚本。
- 有关从任务脚本运行执行配置文件的信息,请参阅运行执行配置文件。
分享:
分享:
This Preview product documentation is Citrix Confidential.
You agree to hold this documentation confidential pursuant to the terms of your Citrix Beta/Tech Preview Agreement.
The development, release and timing of any features or functionality described in the Preview documentation remains at our sole discretion and are subject to change without notice or consultation.
The documentation is for informational purposes only and is not a commitment, promise or legal obligation to deliver any material, code or functionality and should not be relied upon in making Citrix product purchase decisions.
If you do not agree, select Do Not Agree to exit.