Custom Properties and SQL Persistence

Hi,

Is there a way to access a custom property of a given workflow instance via the SqlPersistence stuff or does each workflow need to be loaded via the runtime and queried that way

I'm writing a very basic State Machine workflow to model an document approval process which will run under ASP.NET. I'd like to create a "Pending Approvals" kinda page where managers can get a list of their pending approvals. The workflows have custom properties to indicate document name and manager name.

Hacking the Workflow Monitor example I've got the SqlTrackingQuery stuff running but rather than displaying the workflow type I'd like to show some custom properties from the instance.

Any pointers

Thanks!


Shawn




Answer this question

Custom Properties and SQL Persistence

  • dutchie63

    Shawn - my best guess is that you'll also want to the the SqlTrackingService , use a custom TrackingProfile and query that database instead. AFAIK the persistence mechanism only persists the instance -so you'd have to deserialize the instance and query it to find out that information. Tracking on the other hand will show both live and persisted instances.

  • cerulean47

    Hi Shawn,

    I am new to WWF and have been trying to model a similar document approval wf beta2 for ASP.Net in VB with tracked Custom Properties. Results were unacceptable to me. If you can, please attach samples of how you were able to accomplish this as a starting point.

    Thank you in advance,
    --Emad

    emad@hammoud.com


  • rugger74

    Thanks Guys,

    Your posts have definitely helped. I'm now tracking data via the TrackData() function call and have completed my first "complete" workflow from initiation to approval / rejection via web forms.

    As I'm goofing around with the workflow definition I'm finding there are versioning issues (self-inflicted) and am wondering if there's a best practice defined
    on how to better manage this

    Eg, I add or remove a state, or add new eventhandlers - once that happens the sqltracking routines start kicking null value errors. I'm guessing it's not updating the workflow definition in the database.


    Again, thanks for your help!


    Shawn



  • Ame

    without more information, I'd recommend adding a new version of the tracking profile to the tracking database to reflect your changes. you might want to try using the tracking profile editor in the SDK for the Jan CTP.

    Matt



  • Bill Howell

    You'll want to use the SqlTrackingService which will allow you to track both the states as well as custom data. You can track properties on activities as well as your own custom data at runtime. You build a custom tracking profile where you define the activity data you want to collect as well as activities where custom data can be collected.

    Matt



  • Kevin Westhead

    Hi Emad,

    Unfortunately, the project I was working on is part of a bigger project which isn't something I can provide. But I'll try and describe it as I think it's pretty basic.

    The workflow is a State Machine Workflow with 3 top-level States:
    • WaitingForCaseStudyState - Initial state of workflow
      • EventDrivenActivity to defined Activities when Case Study is created
        • HandleExternalActivity which receives an OnCaseStudyCreatedEvent
        • A custom SendMailActivity which sends an email to the workflow manager
        • SetStateToPendingApproval

    • PendingApprovalState
      • EventDrivenActivity to define Activities when Case Study is Approved
        • HandleExternalActivity which received the OnCaseStudyApprovedEvent
        • A custom SendMailActivity which sends an email to to the originator of the Case Study
        • Some custom activities to post info to various databases
        • SetStateToCaseStudyProcessed

      • EventDrivenActivity to define Activities when Case Study is Rejected
        • HandleExternalActivity which receives the OnCaseStudyRejectedEvent
        • a custom SendMailActivity which sends the reject notice to the originator of the Case STudy
        • SetStateToCaseStudyProcessed

      • EventDrivenActivity to define Activities when Case Study is Discarded
        • HandleExternalActivity which receives the Discard event
        • A custom activity to clean up some temp stuff held while in approval state
        • SetStateToCaseStudyProcessed

    • CaseStudyProcessedState - Final state on Workflow
    Short and sweet and not too complex. On the workflow itself there's only a single custom property which contains the CaseStudyId that's being worked on and it's passed in via the CreateWorkflow call and is part of the custom EventArgs object created. All other Case Study data (eg, author, case study contents, etc.) is kept external to the workflow and retrieved when needed.

    So far, I've got a basic Case Study submission form which has the data fields needed and a Pending Approvals form which shows the manager all running Case Study workflows. The Case Study submission form raises the CaseStudyCreatedEvent. The Approvals form can raise either the CaseStudyApproved, CaseStudyRejected, or CaseStudyDiscarded events.

    The ASPX pages create the WorkflowRuntime object and add the appropriate SqlPersistenceService and SqlTrackingService. There's also a CaseStudyLocalService which handles the event management, and a LocalDataProvider for managing the persistence / retrieval of the case study info.

    This was all sorta modeled on the Order State Machine (LAB 04) provided in the download and from the help posted in this thread. Other labs used were LAB 01 for the very basics, and LAB 02 - Creating Custom Activities (SendMail).

    This is all new to me as well. I'm primarily a VB.NET programmer but did the above in C# so I was fighting a couple of learning curves. The stuff (eg, delegates, generics, etc.) used to program all this feels better in C#, IMHO. Of course, now in VB.NET I want to put a ";" at the end of every line - d'oh!

    Planned updates include some sort of listening / delay activities to manage timeouts in terms of manager response.

    If there's a specific problem you're encountering please post to this forum and can say from my personal experience, someone will try to help.

    I hope this helps!


    Shawn



  • Custom Properties and SQL Persistence