This is a
functional scenario script, although it is not of any practical use. To
understand how it works, click
Test on the Editor toolbar.

This
evaluates the scenario against the applications that are currently selected in
the Application List and opens the results on the
Output tab.

Notice that
the value in the
Outcome column is "Sample Outcome" for each
application, and similarly the value in the
RAG and
Cost columns are "Green" and 100 for all of the
selected applications. This is because the values for these columns are
"hard-coded" in the script in lines 6-8.

Notice that
the
Description and
Customfield columns are empty because the
scenario does not provide values for these columns.

Change the value of the
RAG column to reflect the application's actual RAG
for the Windows 7 report. Change line 8 in the scenario script as follows:

myForwardpathresult.RAG = currentApplication.Modules.Windows7.RAG

This sets
the value in the
RAG column to the application's Windows 7 RAG
status. (This assumes that the application has already been analyzed for the
Windows 7 report. If this report is not available, choose another report that
is available. Use the
Property Explorer to discover how to refer to the
other reports.)

Click
Test to see the results.

The values in the
RAG column reflect the actual RAG values.

Next make the value in the
Outcome column depend on the Windows 7 RAG status.
To do this, replace line 6 with an
If statement, like this:

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

This
statement tests whether the application's Windows 7 RAG status is green. If it
is, the script writes "OK for Windows 7" in the
Outcome column and if not, it tests whether the
Windows 7 RAG status is amber. If it is amber, the script writes "Remediation
required" into the
Outcome column and otherwise writes "Redevelopment
required" to the
Outcome column – because if the RAG status is not
green or amber, it must be red (assuming the application has been analyzed and
unlocked).

Click
Test to see the results.

Notice that
now the values in the
Outcome column reflect the logic in the If
statement.

This is a
deliberately trivial example that is designed to introduce how Forward Path
works. To see some more realistic examples, use the
Scenarios Explorer to browse the sample scenarios
that come with AppDNA and use the
Property Explorer to explore the properties that are
available to the scenario scripts.

Note: The
Output object is shown as
ForwardPathReportOutput in the Property Explorer.

For example, you
can use the
Output.Display property to control the width and
visibility of the standard columns in reports, like this:

These properties
control the display of the columns when you run the report. They do not control
the columns on the
Output tab in the Forward Path Logic Editor.

Create a task
script

We will now create a task script that is associated with the "Redevelopment required" value in the Outcome column created by our example scenario script.

Open the example script we created in the previous step in the Editor.

On the main toolbar, click New Task Script.

This opens the Forward Path Task Script dialog box, which lists the possible values in the Outcome column for the scenario that is open in the Editor.

From the drop-down list, select Redevelopment required, enter a description, and click OK.

This creates a new task script and opens it in the Editor. The new task script is as follows:

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

This is a skeleton task script that starts an Install Capture.

We will change the lines that relate to Install Capture (lines 11 – 21) with code that will send an email. However, first we will add the following lines after line 6 to import the namespaces we need to send an email:

In the Forward Path report viewer, select the Forward Path scenario we created earlier.

Click Evaluate Tasks.

This opens the Forward Path Task Sequencing screen, which lists the applications that have been processed by the Forward Path scenario and shows whether they have a task script associated with them.

Select an application that has a task script associated and click Start on the toolbar.

This runs the task script for that application. The Status column shows whether the script was run successfully. When an error occurs, it is shown in the lower part of the screen. In this example, the script fails if you have not entered appropriate mail parameters for your environment (step 6 above).

To see some more examples, use the Task Scripts Explorer to browse the sample task scripts that come with AppDNA.