Let me know if this is already in the list of variables and I just overlooked it, but I want to add to an email that is sent out at the end of workflow, the amount of time it took to process the file from when the file was picked up in the watch folder till the file was sent to the destination folder.
I have a feeling it would need to be done with the populate processor, but have no idea how to do this. Any ideas or tips?
Thanks!
Time to Process Variable
Re: Time to Process Variable
hey @failsafe5000
long time not heared from you
It would be easy if we had some $datediff function but there are no date calc functions builtin yet. Also "$timecalc" is not helpful here.
So let's do a little trick. In a cmd executor node, insert this code, what it does is to use powershell to make a time difference between now and the date created of the job work folder.
You must also create a user variable and capture the output of the cmd to a variable, by setting "Read std-stream to variable" (e.g. %s_startdate%).
Before going on, please check if it works by inserting a populate proc after the cmd proc and set s_success to s_startdate. In the job status monitor you should see "outcome" set to some seconds value like 2.384549 (2 seconds and a few millis)
After that, we can use a populate processor to transform the seconds value from powershell to a timecode which is most likely what you want to show.
So, in a populate processor, set some variable (e.g. s_finaltime ) to this value:
Again, after this, make sure that it works again by setting s_success to "s_finaltime" and check if the status monitor shows a timecode form.
You can use hold processor to fake a longer job run time.
long time not heared from you
It would be easy if we had some $datediff function but there are no date calc functions builtin yet. Also "$timecalc" is not helpful here.
So let's do a little trick. In a cmd executor node, insert this code, what it does is to use powershell to make a time difference between now and the date created of the job work folder.
Code: Select all
powershell -ExecutionPolicy Bypass -Command "((Get-Date) - (get-item "%s_job_work%").CreationTime).TotalSeconds"
Before going on, please check if it works by inserting a populate proc after the cmd proc and set s_success to s_startdate. In the job status monitor you should see "outcome" set to some seconds value like 2.384549 (2 seconds and a few millis)
After that, we can use a populate processor to transform the seconds value from powershell to a timecode which is most likely what you want to show.
So, in a populate processor, set some variable (e.g. s_finaltime ) to this value:
Code: Select all
$inttotc("%s_startdate%",25)
You can use hold processor to fake a longer job run time.
emcodem, wrapping since 2009 you got the rhyme?
-
- Posts: 13
- Joined: Mon Oct 14, 2019 9:31 pm
Re: Time to Process Variable
Thanks for the help on this @encodem
I was able to simplify things a bit with just one powershell script to convert the time from seconds to HH:MM:SS:
Was having some issues with inttotc converting the time correctly, it kept just converting the time between processors so was never correct.
I can also confirm that this works perfectly in a farm.
I was able to simplify things a bit with just one powershell script to convert the time from seconds to HH:MM:SS:
Code: Select all
powershell -ExecutionPolicy Bypass -Command "New-TimeSpan -Start (Get-Item '%s_job_work%').CreationTime -End (Get-Date) | ForEach-Object { '{0:D2}:{1:D2}:{2:D2}' -f $_.Hours, $_.Minutes, $_.Seconds }"
I can also confirm that this works perfectly in a farm.
Re: Time to Process Variable
Hehe i thought it is "easier" with less scripting, not being aware that you are a powershell crack
emcodem, wrapping since 2009 you got the rhyme?