Get the Name of the Workflow from within Custom Activity - workflow-foundation-4

I am trying to create a custom activity for windows workflow that needs to get the name of the workflow file that uses it. Is there a way to achieve this?

One way I can think of is to write a tracking participant and add it to the workflows' extensions collection. Your tracker would simply remember the name of the initial activity that launches.
Then your custom activity can query the activity context for an instance of your tracker, and read the "initial" activity executed from it.
I'll give a code example when I'm back in my laptop later today.

Related

Elsa work flow trigger and integration with exe

I want to build Elsa workflow for the below requirement:
Can be trigger from database table trigger when new row inserted.
Can execute exe file to get some information.
To read data from the database.
I agree with #fatihyildizhan and #vahidnaderi, but if I interpret the question as "How to do these 3 steps with Elsa from a high-level overview - can someone give me any pointers?" then I can answer as follows:
If all you really need are the 3 steps you mentioned, then don't use Elsa; it is overkill for what you want to do.
Here's why:
Although you can achieve all of this with Elsa, you can't do it with Elsa out of the box; you will have to write custom activities and support services to trigger your workflows, which is a little bit more work than simply doing your thing from your "row inserted" application handler.
If, on the other hand, you are planning on implementing multiple workflows that are potentially more complicated and perhaps even long-running, then it might be worthwhile to consider Elsa after all.
Doing this with Elsa requires you the following up-front work:
1. Trigger Workflow When New Row Inserted
To trigger a workflow when a new row is inserted, you need to implement a handler that responds to that event (this you would need to do regardless of whether you use Elsa or not).
Next, you need to implement a custom activity that represents the "row inserted" event as a trigger, e.g. called RowInserted. You can then use that activity as a starting point in any of your workflows or even as a resumption point (e.g. for workflows where you began some work that might insert some eventual addition of a database row, which is the event you want to handle), which would be triggered whenever a new row is inserted. You probably want to be able to configure for which database table to trigger this event, so you might add a TableName property to your activity.
Then, in order to make Elsa actually trigger workflows with your custom activity, you will need to do the following:
Implement a bookmark model and provider for Elsa to index and invoke. E.g.
NewRowBookmark : IBookmark with a single property called TableName. Bookmarks are Elsa's way of starting & resuming workflows.
Update your "row inserted" handler described earlier to invoke IWorkflowLaunchpad.CollectAndDispatchWorkflowsAsync, passing in the appropriate bookmark/trigger model containing the table name into which the row was inserted, and provide the inserted row as input (assuming you want the workflow to do something with the inserted row).
2. Execute File
To execute a file, you need to create another custom activity that does this. You can make this activity as specific or generic as you need.
3. Read From Database
Same as with #2, you need to create another custom activity that reads from the database. You can make this activity as specific or generic as you need.
The above should give you a rough idea of the work involved to implement this with Elsa. And as mentioned earlier, this might be overkill if all you are looking to do is do the 3 steps mentioned.

Flex PureMVC: Can proxy keep reference of a View component in following case?

I am learning pureMVC and trying to implement the framework into one of my application. I have follwing case:
My main application has Canvas which is used to add different kind of custom components. One of the custom component is a "Search Component" (multiple instances are created on page). My search component has a textfiled and a search button and initiate search in following steps:
1-Clicking search button dispatches a custom event, that custom event keeps reference of search component as a property.
2-My AppMediator listens the custom event and get the reference of current search component along with search text.
3-Mediator send a notification (sentNotification(AppConstants.SEARCH_CLICKED, component)).
4-I have registered a command with SEARCH_CLICKED notification.
5-Command retrieve a WebserviceProxy and invokes its Search(text) method.
6-WebserviceProxy talks to remote webservice and uses asyncToken to get results.
My Questions is:
My Command has the reference to the custom search component when it start search but search webservice takes some time and get the result. How can i handle the results back to custom search component that initiated the search. Since i have multiple instances of search component. What is the best place to keep the reference of that component, should i add a variables in WebserviceProxy to keep that reference and hand the results over to it, or i have to create a Global Proxy to keep references of such components?
Thanks
I have been using PureMVC for some years and I like it!
I think you have not yet understood roles and collaboration of main components.
You should not have any dependencies between Commands and UI-elements. Your Mediator has to get the concrete value from your UI-component and send it through the Notification. In this case the Command and the Proxy will get only a text value and it is no matter, what is the source of it! Suppose you will change your UI after some time and you will have another components on the user side to determine the search value. In your case you would have to change the Proxy and the Command. It would be bad.
Proxy may not have any information about Commands and Mediators. It can only offer its functions to let another components interact with it AND it sends Notifications with new information after getting it without knowing who is interesting in it.
Read the description of the framework once more and write your questions.
I had some problems with understanding the stuff too, I see your problem.
Based on Anton's answer, i re-think and tried to separate dependencis. As a result, i tried to mediate each instance of Search Widget with "SearchMediator" separately by providing different ID to the constructor of Mediator. Now, when search widget intiates a new search, it's mediator invokes the Command, Command invokes a method of Proxy to do actual search and fetch results from DB and sends a Notification. SearchMediator takes care about that notification and hands over the results to appropriate UI.

Promoted properties not restored?

I'm using the promoted activity (http://msdn.microsoft.com/en-us/library/ff642473.aspx) to store information needed to track a workflow.
During execution values are correctly stored and I can query them using the view but, if the workflow is persisted, the view becomes empty and I can't find information anymore.
Can someone explain me how to keep those values until the natural completion of the workflow?
Thanks
update
a few more details
I'm using IIS to store workflows
I promote values at the beginning of the workflow and I wouldn't like to do it again on every persistence property (this was the first workaround I thought)
Each time a workflow is persisted the complete state is persisted. There is no incremental addition. So by not adding the promoted properties on subsequent persists you are effectively removing them from the instance store.
I finally found the problem.
In the web.config I was adding my extension after the element, but order matters.
My configuration looks like this now:
..
Everythings works fine now and promoted values are always available.

Architecture that displays messages (like downtime) in application

I'm thinking of a architectural way of displaying messages in our application (Flex-Asp.NET-SqlServer), mostly messages that announce for instance a downtime.
Currently I was thinking of creating a table FlexMessage that holds the name of a message (based on that name I now where to put in Flex) and the value (the message itself). As a result however, someone will have to create these messages and also delete them when they are no longer valid. So, thinking further, I thought of creating messages having a startdate and enddate, so an interval in which they need to be displayed. Like this, someone could login to the management part and create a message that needs to be displayed from a certain date until a certain date.
I could also hardcode it in the Flex Application, but that would mean putting a new build online (of the swf) each time something changes with a certain message. No good idea I guess.
Is there a better way for this that I haven't thought about?
One way to do this is to place your messages in an RSS feed, then read that feed from the Flex application.
There is an example of how to do this here: http://www.artima.com/weblogs/viewpost.jsp?thread=23819

Mate Framework - Check data before making remote call

Until recently I have been using cairngorm as a framework for flex. However, in this latest project I have switched to Mate. It's` still confusing me a little as I kind of got used to leaving data in the model. I have a couple of components which rely on the same dataset(collection).
In the component the creation complete handler sends a 'GiveMeMyDataEvent' which is caught by one of the eventmaps. Now in cairngorm in my command class I would have had a quick peek in the model to decide whether I need to get the data from the server or not and then either returned the data from the model or called the db.
How would I do this in Mate? Or is there a better way to go about this, I'm trying to utilize the data that has already been recieved from the server, but at the same time I'm not sure I have loaded the data or not. If a component which uses that same data has been instantiated then the answer is yes otherwise no.
Any help/hints greatly appreciated.
Most things in Mate are indirect. You have managers that manage your data, and you set up injectors (which are bindings) between the managers and your views. The injectors make sure your views are synchronized with your managers. That way the views always have the latest data. Views don't get updated as a direct consequence of dispatching an event, but as an indirect consequence.
When you want to load new data you dispatch an event which is caught by an event map, which in turn calls some service, which loads data and returns it to the event map, and the event map sticks it into the appropriate manager.
When the manager gets updated the injectors make sure that the views are updated.
By using injectors you are guaranteed to always have the latest data in your views, so if the views have data the data is loaded -- unless you need to update periodically, in which case it's up to you to determine if data is stale and dispatch an event that triggers a service call, which triggers an update, which triggers the injectors to push the new data into the views again, and round it goes.
So, in short the answer to your question is that you need to make sure you use injectors properly. If this is a too high-level answer for you I know you can get more help in the Mate forums.
I ran into a similiar situation with the app I am working on at the moment, and found that it is easily implemented in Mate when you start thinking about having two events.
The first event being something like DataEvent.REFRESH_MY_DATA. This event is handled by some DataManager, which can decide to either ignore it (since data is already present in the client and considered up to date), or the manager can dispatch an event like DataEvent.FETCH_MY_DATA.
The FETCH_MY_DATA event triggers a service call in the event map, which updates a value in the manager. This update is property-injected into the view, happy days :)

Resources