I want SSIS to trap an error, branch and then exit with success - event-handling

I have googled around and think I have tried just about every suggestion I've seen but I can't seem to get this to work the way I want to. I'm CONVINCED that SSIS can do this.
I have an SSIS package that has 4 tasks, they execute in order: task A, then B, then C. The 4th task D I am using as an end-point if B fails... more on that in a minute.
Task A does some unrelated work. I'm including it because there's processing at the start of the package and should any of it fail, then I want the package to fail - just the SSIS default, exit the package with a return code of 1 if task A fails.
B is a DFT with a flat-file source, it transfers data to be processed in step C. B is the crux of my question because I want to deal with errors in task B differently than the rest. It's not uncommon for the flat-file source to not exist or to be corrupt and I want to capture/trap that but not cause the entire package to fail. If B does have an error though, I do NOT want to process task C.
C processes the data I transferred in DFT B when B does not have an error.
I am trapping errors in DFT-B with an "OnError" eventhandler that executes a SQL task that sends an email. I then use an "on completion" precidence constraint to divert the control flow to an endpoint - task D. (D does nothing, it's just a dummy end-point that I'm using partially for debugging, partially to give the event handler somewhere to "go" - I am not certain D is even required).
Anyway, when I run the package and trigger an error in B my package performs the event handler (sends the email just fine), it even continues on to task "D", and in the debugger, "D" ends with success (shows green). The problem is, my package fails with an exit code of "1".
I've tried messing with all sorts of things... ForceExecutionValue/ ForceExecutionResult/ MaximumErrorcount. Now I have a package that actually doesn't even contiune to my "task D" and I'm not sure how I got there (but the exception handler SQL is faithfully sending me an email!).
I do not want that exit code of 1! I want a 0!
help! thanks!

Have you tried something like this:
To get the different conditions on the transition lines, just double click on the line you wish to edit. A red line indicates the control flow in case the previous task fails
EDIT: I believe i misread the question! From what i got, you can already control the flow as intended. Your issue comes with the exit code. Have you tried setting the propagate variable to false in the event handler screen?
Check the following link for more information on it:
http://simonworth.wordpress.com/2009/11/11/ssis-event-handler-variables-propagate/

Related

Function block not updating variable

Alright, so I'm learning codesys in school and I'm using Function-Blocks. However they didn't seem to update when updating local variables, so I made a test, the one you can see below.
As you can see, in the FB below, "GVL.sw1" becomes True, but "a" doesen't. Why does it not become True? I tested a friends code and his worked just fine, but mine doesen't...
https://i.stack.imgur.com/IpPPZ.png
Comment from reddit
You are showing the source code for a program called "main". You have
a task running called "Main_Task". The program and task are not
directly related.
Is "main" being called anywhere.
So i added main to the "main task" and it worked. I have no idea why it didn't work in the real assignment but maybe I'll solve it now that i have gotten this far.
In your example you have 2 programs (PRG): main and PLC_PRG.
Creating a program doesn't mean that it will be executed/run. For that you need to add the program to a Task in the Task Configuration. Each Task will be, by default, executed on every cycle according to the priority they are configured with (you could also have them be executed on an event and etc. instead). When a Task is executed, each program added to that Task will be executed in the order they are placed (you can reorder them any time).
With that said, if you look at your Task Configuration, the MainTask only has the program PLC_PRG added, so only that program will run. The main program that you are inspecting is never even run.

VSTS Test fails but vstest.console passes; the assert executes before the code for some reason?

Well the system we have has a bunch of dependencies, but I'll try to summarize what's going on without divulging too much details.
Test assembly in the form of a .dll is the one being executed. A lot of these tests call an API.
In the problematic method, there's 2 API calls that have an await on them: one to write a record to that external interface, and another to extract all records and then read the last one in that external interface, both via API. The test is simply to check if writing the last record was successful in an end-to-end context, that's why there's both a write and then a read.
If we execute the test in Visual Studio, everything works as expected. I also tested it manually via command lining vstest.console.exe, and the expected results always come out as well.
However, when it comes to VS Test task in VSTS, it fails for some reason. We've been trying to figure it out, and eventually we reached the point where we printed the list from the 'read' part. It turns out the last record we inserted isn't in the data we pulled, but if we check the external interface via a different method, we confirmed that the write process actually happened. What gives? Why is VSTest getting like an outdated set of records?
We also noticed two things:
1.) For the tests that passed, none of the Console.WriteLine outputs appear in the logs. Only on Failed test do they do so.
2.) Even if our Data.Should.Be call is at the very end of the TestMethod, the logs report the fail BEFORE it prints out the lines! And even then, the printing should happen after reading the list of records, and yet when the prints do happen we're still missing the record we just wrote.
Is there like a bottom-to-top thing we're missing here? It really seems to me like VSTS vstest is executing the assert before the actual code. The order of TestMethods happen the right order though (the 4th test written top-to-bottom in the code is executed 4th rather than 4th to last) and we need them to happen in the right order because some of the later tests depend on the former tests succeeding.
Anything we're missing here? I'd put a source code but there's a bunch of things I need to scrub first if so.
Turns out we were sorely misunderstanding what 'await' does. We're using .Wait() instead for the culprit and will also go back through the other tests to check for quality.

Recursive Workflow in Powershell

I'm trying to automate a lengthy process that can be broken down into several steps. (say Steps 1-5)
I have written a script that separates these into functions and call them sequentially.
However, we now have the additional requirement of making the script restartable. That is, if it fails in any one of the steps, rerunning the script would cause it to skip all completed steps and retry from the failed one.
Is this at all possible without referencing an external log file?
I've tried using workflows but it seems like recursion isn't supported.
Any ideas?
Some options aside from using a log file.
Use the registry
you can set a registry value to a number depending on what step you stopped on, this removes the need for a log file but is somewhat similar in terms of 'external' storage
Check the task status on each run
depending on the tasks you could have the script 'test', for example, step 3 to see if it has already been completed, then check step 4, 5 etc. until it encounters one it needs to run and continue from there, this may be impossible or require a lot of overhead code though for not much payoff.
Allow the user to continue from within the script.
this is probably the best way of doing it (aside from just using a log file), run the script in blocks, and when an error is encountered you can prompt the user to fix the issue before pressing 'enter' to re-run the previous script block, this makes it easy to provide information about what failed as well.
the main thing here is that once a script 'quits', in order to know what happened in it's last run it needs an external source of information, or to handle it in another way.

Why does Matlab standalone application exit with error "TooManyOutputs"?

I have created a standalone application in Matlab, actually it works, it displays the desired output but it closes immediately, not even enough time to examine the output and read the error message on DOS (standalone mode) that says:
MATLAB:TooManyOutputs
Warning: 1 visible figure(s) exist at MCR Termination
If your application has terminated unexpectedly, please note that
applications generated by the MATLAB Compiler terminate when there are no
visible figure windows. See the documentation for WaitForFiguresToDie and
WAITFORCALLBACKS for more information.
Any help would be appreciated.
Looking at the first line of your message, TooManyOutputs suggests that you have an assignment somewhere of the form
[a b] = somefunction(parameters)
so you want the outputs of somefunction to be put in a and b, but somefunction only returns one parameter. This bug causes your program to terminate, and then MCR realizes the program exits without closing your figure window, causing the later error messages.
If I'm right about TooManyOutputs, you should already have that error message when running your code directly in Matlab; have you tried that before creating a standalone application?
If this doesn't help, you should probably post some of your code to make it clearer where the problem could come from.

Simulink: Synchronizing and timing

in order to simulate some processes I have a problem with getting a predefined working order of my self modeled blocks.
How can I be sure, that for example Block A must be finished before Block B and C start working?
The problem is, that some Blocks shall work after some others and some shall not. I must admit I have not much experience with Simulink in order of doing time-depending things (althought basic knowledge of simulink is available).
For instance this scenario shall be realised:
A -> B, C -> D, E, F
The main thing is, that all blocks A-F have no logic correlation to each other, they all do several things. My aim is to make B and C start working, after A has finished. And D/E/F after B AND C have finished.
In this case, the word "parallel" was the wrong word, this does not have to be calculated really parallely. Just making sure, that this complies with a predifined steady order.
Edit:
My new idea is to use the matlab workspace als buffer, so my block A can push its results to workspace (by the "to workspace" block). But now I have to make sure, that block B and C may read the results (with "From workspace") of A AFTER A pushed its information to workspace...how to do this?
Edit2:
Here's a screenshot which should make some thinks clearer:
As the documentation of "Sorted order" refers, the set up seems to be ok (including the subsystems timing). But unfortunately problem still exists. The variable "simin" is loaded from workspace, before it was written :( As you see, the display shows "1", which it shouldn't do. In the very first run of the simulation I get an exception, that the variable "simin" does not exist.
It would be nice, if you can help me with my issue.
Greets, poeschlorn
So in your example, if you have Block A connected with the same wire to both B and C, when Block A is finished, Block B and C will work in parallel.
EDIT:
I am using the same blocks as you are, but it works for me. I think you are over complicating things. The way you are setting block priorities is no different than how Simulink runs the blocks without them. Below you can see my setup and the output on both binary displays.
The error you see on the first run is due to Simulink not creating the variable until the first time step is being executed. When Simulink builds the simulation it sees that the variable used as input from the workspace is not created.
If the connection between the block are not enough to set the order, you can use block priorities.
A tip to test the execution order is to add an "embedded Matlab block" with a disp command displaying the name of the block.
It's not really clear what you're asking. When you say that Block A must be finished, do you mean the Output function? The way simulation works in Simulink is that the blocks are run serially, so Block B and C would never run until Block A finished it's Output function.
I don't know of any obvious way of running blocks B and C in parallel currently in Simulink.