JavaScript is disabled on your browser.
# demo-options
#using module h:\psec\flows\run-gael\setup-run-gael.psm1;
#using module h:\psec\lib\lib-setup-run-gael.psm1;
set-strictmode -version 2.0
function defineFlowTask([Flow]$flow,[Task]$task) {
#--- define
$def = new-module -asCustomObject -scriptBlock {
function getTaskDesc([Task]$task) {
[string]$desc = @"
This illustrates how to manage the global workflow context for subsequent tasks.
"@
return $desc;
}
# ---------- prime the script when initially loaded. As a convenience the brief file is parsed and passed in.
# the existance of this methiod signals this is a context task. The method is called when the
# task is initally loaded.
#
#
function primeContextTask([Task]$task, [hashtable]$brief) {
$tfs = $task.tfs;
if (exists $brief lev1) {$tfs.globMap.devpGlobs.lev1 = $brief.lev1;}
if (exists $brief lev2) {$tfs.globMap.devpGlobs.lev2 = $brief.lev2;}
if (exists $brief lev3) {$tfs.globMap.devpGlobs.lev3 = $brief.lev3;}
if (exists $brief verstr) {$tfs.globMap.devpGlobs.verstr = $brief.verstr;}
hlogBoth("Running primeContextTask $($task.name) $($tfs.globMap.devpGlobs.lev1) $($tfs.globMap.devpGlobs.lev2) $($tfs.globMap.devpGlobs.lev3) $($tfs.globMap.devpGlobs.verstr)")
[void]($task.find("opt-lev1").setText("$($tfs.globMap.devpGlobs.lev1)"));
[void]($task.find("opt-lev2").setText("$($tfs.globMap.devpGlobs.lev2)"));
[void]($task.find("opt-lev3").setText("$($tfs.globMap.devpGlobs.lev3)"));
}
# ---------- define task parameters
<#
The $htOpts parms has the processed options. It can be modified or used to do
other changes to the setup.
#>
function params {
param([Object]$task,[hashtable]$htOpts)
$tfs = $task.tfs;
$htOpts.brief = "$($task.statlocn)"
return $htOpts
}
# ---------- define task options
function options {
param([Object]$task)
$opts = @();
$tfs = $task.tfs;
$opts += @{type='input'; parm="lev1"; label='Lev1'; place='levl 1 value'; regex='^[0-9]+$'}
$opts += @{type='input'; parm='lev2'; label='Lev2'; place='levl 2 value'; regex='^[0-9]+$'}
$opts += @{type='input'; parm='lev3'; label='Lev3'; place='levl 1 value'; regex='^[0-9]+$'}
$opts += @{type='input'; parm="verstr"; label='VerStr'; val="$($tfs.globMap.devpGlobs.verstr)"; readonly=$true;}
hlogBoth("fetch.options $($tfs.globMap.devpGlobs.verstr)")
return ,$opts
}
# ---------- the actual script
# TODO - fix issue when running more than once
function runScript([Task]$task, [hashtable]$parms, [hashtable]$status) {
$tfs = $task.tfs;
$status.lev1 = $tfs.globMap.devpGlobs.lev1 = $parms.lev1;
$status.lev2 = $tfs.globMap.devpGlobs.lev2 = $parms.lev2;
$status.lev3 = $tfs.globMap.devpGlobs.lev3 = $parms.lev3;
$tfs.globMap.devpGlobs.verstr = $status.verstr = "$($tfs.globMap.devpGlobs.lev1).$($tfs.globMap.devpGlobs.lev2).$($tfs.globMap.devpGlobs.lev3)";
hlogBoth("Running script $($task.name) $($tfs.globMap.devpGlobs.lev1) $($tfs.globMap.devpGlobs.lev2) $($tfs.globMap.devpGlobs.lev3) $($tfs.globMap.devpGlobs.verstr)")
[void]($task.find("opt-verstr").setText("$($tfs.globMap.devpGlobs.verstr)"));
}
Export-ModuleMember -Variable * -Function *
}
hlog("defineFlowTask $flow $task")
return $def;
}