PSEC - Powershell Enhanced Capability
Version 1.2.1

Task Execute for: Example Copying Files

Properties

Implemented Functions

getTaskDesc Function Meta


    function getTaskDesc([Task]$task) {
      return "This copies the files from the download area on HM22 to the processing area on HZ03."
    }

params Function Meta



    # ---------- define task parameters
    function params([Task]$task) {
      $parms = @{};
      $parms.brief    = "$($task.statlocn)"
      $parms.name     = "$($task.name)"
      $parms.trap     = "$null"
      return  $parms
    }

options Function Meta



    # ---------- define task parameters
    function options([Object]$task) {
      $opts = @();
      return  ,$opts
    }

runScript Function Meta



    function runScript([object]$task, [hashtable]$parms, [hashtable]$status) {
      $tfs = $task.tfs;
      $appDir = "$($tfs.globMap.citGlobs.curDir)";
      $year = "$($tfs.globMap.citGlobs.year)"
      $bankSrc = "$($tfs.globMap.citGlobs.bankSrc)"

      hlogBoth("Running $($task.name) srcDir $($task.form.appGbl.bankSrc) year $year")
      #hlog("$($task.name) copy trans from $bankSrc")
      $src   = $bankSrc
      $nextYr = "$(([int]$year) + 1)"
      $curY  = $year.substring(3)
      $nxtY  = $nextYr.substring(3)
      $dest  = "$($appDir)\bank"
      $edest = "$($appDir)\estmts"
      $cdest  = "$($appDir)\chelps"
      hlog("$curY $nextYr $nxtY")
      # 1054-323, 1054-331, 4608-095
      $cgb = $tfs.globMap.citGlobs;
      forEach($set in $cgb.accts) {
        $set = $set -replace "-","."
        (copyFile "$($src)\$($year)\bmo.church\bmo.$($curY)1??.$($set).ofx" "$dest")
        (copyFile "$($src)\$($year)\bmo.church\bmo.$($curY)2??.$($set).ofx" "$dest")
        (copyFile "$($src)\$($year)\bmo.church\bmo.$($curY)3??.$($set).ofx" "$dest")
        (copyFile "$($src)\$($year)\bmo.church\bmo.$($curY)4??.$($set).ofx" "$dest")
        (copyFile "$($src)\$($year)\bmo.church\bmo.$($curY)5??.$($set).ofx" "$dest")
        (copyFile "$($src)\$($year)\bmo.church\bmo.$($curY)6??.$($set).ofx" "$dest")
        (copyFile "$($src)\$($year)\bmo.church\bmo.$($curY)7??.$($set).ofx" "$dest")
        (copyFile "$($src)\$($year)\bmo.church\bmo.$($curY)8??.$($set).ofx" "$dest")
        (copyFile "$($src)\$($year)\bmo.church\bmo.$($curY)9??.$($set).ofx" "$dest")
        (copyFile "$($src)\$($year)\bmo.church\bmo.$($curY)a??.$($set).ofx" "$dest")
        (copyFile "$($src)\$($year)\bmo.church\bmo.$($curY)b??.$($set).ofx" "$dest")
        (copyFile "$($src)\$($year)\bmo.church\bmo.$($curY)c??.$($set).ofx" "$dest")
        (copyFile "$($src)\$($year)\bmo.church\bmo.$($nxtY)1??.$($set).ofx" "$dest")
      }
      # e-statements
      forEach($set in $cgb.accts) {
        (copyFile "$($src)\$($year)\bmo.church\estmts\$($set)\eStatement_$($year)-*.pdf" "$edest\$($set)")
      }
      # NOTE: as convenience, also copy Canada Helps transactions
      (copyFile "d:\1\CharityDataDownload-$($year)-???.csv" "$cdest")
    }

copyFile func-copyFile



    function copyFile([string]$src,[string]$targ) {
      #hlog("copy $src to $dest")
      (copy-item -path $src -force -destination $targ -passthru)
      "`r`n$src copied`r`n"
    }

PSEC - Powershell Enhanced Capability
1.2.1

Copyright © 2018-2021, 2022, Rexcel System Inc.

 

 

 

 

 

X