Ok, I've tried every way I know how to do this without it getting EXTREMELY convoluted.
I think what we have here is a potential feature request instead of a solution.
Henrik, Based on a few different methods I was trying I think the following ideas might be good to implement, if possible.
1. On the CopyFiles SIZE criteria, instead of forcing a numeric value being typed or raised/lowered by the up/down arrows, give an option to specify a variable. This would have to potentially see a string value (numbers) and convert it to INT. I tried setting a variable to the output value of a read file task, which did read the numbers from his MIN/MAX files, but they were still strings and therefore I couldn't do much with it using any of the built-in stuff expecting an Int32 value.
2. Currently there is a List File(s) task, I think it would be beneficial to have a "Get File Attributes" task that could be used against a single file, especially within a loop. So we could do a List Files task, get the file name (or names), pass each one through a loop which would use a "Get File Attributes" task to get the size, or the date.. or whatever attribute (one attribute at a time to keep it simple). One task to get the date, One task to get the size, etc. We could then set variables to the output of these tasks and do all sorts of stuff :)
2. On a File Condition, we currently only have the option to see that it exists (true/false) or that the content matches/contains/etc.. a string you can input. It would be beneficial if other file attributes could be selected as criteria also. Such as:
File Size Greater Than (numeric choice or variable input):
File Size Less than (numeric choice or variable input):
File Date is greater/less/equal to 'x' whether that be a variable or selected number of days/weeks/etc old.
Basically, the same type of things we already have available when doing a Copy File(s) task, only use those same potential criteria for an exact file.... in a Condition.
Now, as for Kevin's request. I don't honestly see a way to cleanly do 'exactly' what Kevin requested and I described a few posts ago. I can do it in PowerShell (put code in powershell task) to determine the min/max and whether it's within the threshold, but native support would be ideal.. even if it takes several tasks in a loop to get there.
Since you need a solution, I'll provide this.. 🙂 It does work, and it's actually quite clean. It just requires powershell (language i'm comfortable with)
1 Job, 3 tasks.
Task 1: Process-->PowerShell
Code contents, for this example:
$File = gci C:\Temp\VisualCron\PSCNZO6407-20140318.DETAIL
[int]$Min = get-content C:\Temp\VisualCron\PSCNZO6407_MIN.txt
[int]$Max = get-content C:\Temp\VisualCron\PSCNZO6407_MAX.txt
[int]$Size = $file.length / 1kb
if ($Size -lt $Max -and $Size -gt $Min)
{return $True}
else
{return $False}
It will get the details of the PSCNZ06407-20140318.DETAIL file (can modify that to be dynamic so it's repeatable daily), read the contents of your 2 min/max files, does some math to determine that it is within the min/max (True) or not (false), and returns that true or false as the Output of the task.
Task 2: Copy File Task: Name it something like "Copy FILENAME - GOOD SIZE"
Simply configure it to copy the file where it should go, if it's a proper size.
Task 3: Same as above, only copy the file to the 'BAD' location and name it appropriately.
Now, for how this works. It's all dependant on the powershell task FLOW.
So, edit your powershell task and go to the FLOW tab. I have 3 items
1. On Complete, if Output equal "True" - Goto Task "Copy FILENAME - GOOD SIZE".
2. On Complete, if Output equal "False" - Goto Task "Copy FILENAME - BAD SIZE".
3. On Error, Stop Job
So, if your tasks are in this order:
Powershell
Copy Good
Copy Bad
........... Edit the Copy Good task and change it's FLOW tab to stop the job regardless. So on mine, I have 2 entries under FLOW.
1. On Success, Stop the Job
2. On Error, Stop the Job.
The reason for this is that The Powershell task got true... and launched this task. We do NOT want the NEXT task to run, because that's the Copy BAD task. So we quit now. Any tasks that run after the Copy Good task, will not run, which is desired.
Now, validate that your 'Copy Bad' task has a FLOW like the following:
On Success, continue with Next Task
On Error, Stop Job
Now you can add another task to send an e-mail also or you can make it a notification for 'Copy Bad'. Just add another 'On Complete' flow item that launches a notification. Either way works. If using the e-mail task, the only time it'll run is if the PowerShell task was 'False' since any other result ended in the job stopping. :)
Hopefully that makes sense. I'll attach screenshots detailing the 3 tasks (no e-mail).
Brian
bbusse attached the following image(s):