workflow 4.0 bookmark not updating in database‏ - workflow-foundation-4

I am working on Windows Workflow Foundation 4.0 project having native and service host activities in it. I am using SQL 2008 R2 as my backend.
I have several activities in the workflow, most of which should place bookmark in the database so that next activity could be resumed from there. when the first activity places a bookmark in the database, it is resumed by the second activity quite well, but when the second activity wants to place a bookmark in the database, the bookmark is not updating itself from the previous bookmark and also, no exception is raised in the code.
I am new to Workflow foundation, please advise if i am doing something wrong ?
Thanks

The best way to know what is going on is to capture the tracking data. Just create a class which derives from TrackingParticipant and add it to the Extensions collection.

Related

Initializing an asp.net deployment

I have a basic webforms asp.net site. Currently its working on pre-created sql tables and I have to manually triger it to update data. Moving towards a live deployment though, I'd like to make it more comfortable.
How would I make it so that whenever the server software loads it up, the first thing it does before accepting any requests is to run an initialization sub? Just so I can make sure all the tables are there and if not I would create them etc.
Also, I'd like to run another sub that would trigger the data update periodically every few hours. I was thinking that if I could get my initialization sub, I could just spawn a background thread to deal with that but if theres a built-in option, I'll take it.
whenever the server software loads it up
In asp.net, you have the global.asax file - open the code behind for that and look at the possible overrides. Among them will be:
protected void Application_Start()
This always runs when the application starts up and you could use this to check the DB.
If you're in an "in-house" environment where there's a single live database server and a single live application server, then it should be ok to assume that the database is deployed before the application and you won't need this. If you're providing an application to a third-party or providing it on the web, then this is a good place to check. How you generate the DB is up to you, but checking here is a good idea. You could also have a (hidden) admin page on your site that checks the database connection etc.
trigger the data update periodically
This won't be built-in to asp.net as asp.net waits for requests and responds to them. There are ways around this, but generally triggered externally to the application. The easiest is a simple windows scheduled task that hits a page to trigger the check.
This is what's referred to as "deployment".
If your web site is deployed via MSI, this step should be done in MSI.
If your web site is deployed via Visual Studio "publish" option, this is where you need to create tables.
Some applications indeed do as you say, e.g.: create SQL tables on the 1st run. The problem with this approach is that your app will need sa rights, instead or simple read/write. This could lead to security issues.
Code which runs on web site launch (which is where initialization belongs to) is located in global.asax in:
protected void Application_Start()

How can I undo the previous step in Windows Workflow Foundation?

I have a project that uses Windows Workflow and I have a database in SQL Server 2008 with Workflow tables.
I want to Edit Record in Project so want to go back to a previous Activity without condition, and update the workflow instance in database.
How can I undo the previous step in Windows Workflow Foundation?
Not really. There is a bit if hack though that might be useful. When you use a workflow instance store and tell the workflow to abandon it's state when an unhandled exception occurs the last saved state in the instance store is unchanged. So you can reload the workflow from that state and continue as if the next activity never executed. The problem is in controlling when the workflow persist. You get to control that for the most part but there are some circumstances where a workflow will always persist.

WF4 versioning - how do I cancel / terminate an invalid instance?

I've got a state machine workflow implemented using WorkflowFoundation 4.1. I'm using the SQL Server persistence store and the WorkflowApplication class for loading and running workflows.
I'm making changes to the state machine workflow model, and am finding that existing instances break very easily. I've written code that can replay the workflow back into the correct state, which is basically a migration, which works fine, however I need to be able to clear out the old workflow instance as well.
The main issue is that if the workflow is invalid, I can't even load it, so I can't terminate or cancel it either.
Is there a way to use the workflow API to remove a workflow without loading it (ie, some command on the SqlPersistenceStore), or do I have to clean the database manually?
The SqlWorkflowInstanceStore doesn't allow you to do so directly. You will need to go into the database and delete the record there. If you are using AppFabric there is actually a command to delete a workflow instance without loading it first for just that purpose. There should be a PowerShell command to do that using code.

Flash Builder 4.5 (Mobile) - Rolling out Database Updates

This is my first question on here so please be kind lol.
I am working on a mobile application with Flash Builder 4.5.
It uses a custom sql-lite database (tables are created on program load if they don't exist) to store the data. The data gets inserted by a sync process which connects to a web service.
I'm looking to ensure that changes to the database tables won't break the program.
For example I need to add a new field to an existing database table. I already know the SQL command (ALTER TABLE) for this but I'm not sure how to tie this to the update of the program i.e. when upgrading the program to 0.1 it should add the new field. But obviously I don't want it to try and add the field more than once.
Is there any way of knowing inside the program when it has been updated by the android/ios stores? Or any suggestions on how to handle these database changes?
The following answer has helped point me in the right direction:
database updates answer

In a .Net web site, what are my options for sending email alerts when folder contents change?

I don't know much about the .Net environment, so my first idea was to just write a console app that scans the folder for new content, and then emails alerts out. Then put the .exe as a scheduled task on the server, executing every few minutes. This seems pretty archaic to me though. Is there a more elegant way to do this for my website?
No matter what type of application you choose the way to get notifications about folder changes in .NET is through the FileSystemWatcher class. A good approach would be to create a Windows Service which will run in background and listen for notifications.
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
You can use the FileSystemWatcher. Create a Windows Service that constantly runs, and attach an Event to the Watcher to send out emails.
Note that this reports every change, sometimes multiple ones (e.g., moving a file is a delete and create I think), so you may want to limit the number of emails you sent. Experiment a bit before sending hundreds of emails or so - been there, done that :)

Resources