workflow - Trying to get Persistence Participant Promotion to work with a xamlx service in WF4 -


i have implemented workflow persistence participant promotion, shown here on microsoft's website:http://msdn.microsoft.com/en-us/library/ee364726%28vs.100%29.aspx , while seems works. not see data saving database when query? think missing step or microsoft missed something.

i using workflow application .xamlx service , have overridden workflowservicehost. seems working fine, not sure problem can be?

so question here have real working example of how implement persistence participant?

i tried few different takes on this

but cannot seem work.

just fyi-this code works when changed xnamespaces match. maurice

workflowservicehost code:

public class servicehostfactory :workflowservicehostfactory {     private static readonly string m_connectionstring =             "data source=localhost;initial catalog=workflowinstancestore;integrated security=true";      protected override workflowservicehost createworkflowservicehost(activity activity, uri[] baseaddresses)     {          return base.createworkflowservicehost(activity, baseaddresses);      }      protected override workflowservicehost createworkflowservicehost(workflowservice service, uri[] baseaddresses)     {          workflowservicehost host = base.createworkflowservicehost(service, baseaddresses);         host.durableinstancingoptions.instancestore = setupinstancestore();          sqlworkflowinstancestorebehavior sqlworkflowinstancestorebehavior = new sqlworkflowinstancestorebehavior(m_connectionstring);         xnamespace xns = xnamespace.get("http://contoso.com/documentstatus");         list<xname> variantproperties = new list<xname>()          {             xns.getname("username"),             xns.getname("approvalstatus"),             xns.getname("documentid"),             xns.getname("lastmodifiedtime")          };         sqlworkflowinstancestorebehavior.promote("documentstatus", variantproperties, null);         host.description.behaviors.add(sqlworkflowinstancestorebehavior);          //add persistence extension here:         host.workflowextensions.add<documentstatusextension>(()=>new documentstatusextension());;         host.description.behaviors.add(new servicemetadatabehavior() { httpgetenabled = true });                      // handle unknownmessagereceived event.         host.unknownmessagereceived += delegate(object sender, unknownmessagereceivedeventargs e)         {             console.writeline(string.format(cultureinfo.invariantculture, "unknow message recieved:{0}", e.message));         };           return host;     }      private static sqlworkflowinstancestore setupinstancestore()     {           sqlworkflowinstancestore sqlworkflowinstancestore = new sqlworkflowinstancestore(m_connectionstring)         {             instancecompletionaction = instancecompletionaction.deleteall,             instancelockedexceptionaction = instancelockedexceptionaction.basicretry,             hostlockrenewalperiod = system.timespan.parse("00:00:05")         };         instancehandle handle = sqlworkflowinstancestore.createinstancehandle();            //instancehandle handle = sqlworkflowinstancestore.createinstancehandle();         //instanceview view = sqlworkflowinstancestore.execute(handle, new createworkflowownercommand(), timespan.fromseconds(30));         //handle.free();         //sqlworkflowinstancestore.defaultinstanceowner = view.instanceowner;          return sqlworkflowinstancestore;     } 

documentstatusextension code:

        public string documentid;     public string approvalstatus;     public string username;     public datetime lastupdatetime;      private xnamespace xns = xnamespace.get("http://contoso.com/");      protected override void collectvalues(out idictionary<xname, object> readwritevalues, out idictionary<xname, object> writeonlyvalues)     {         readwritevalues = new dictionary<xname, object>();         readwritevalues.add(xns.getname("username"), this.username);         readwritevalues.add(xns.getname("approvalstatus"), this.approvalstatus);         readwritevalues.add(xns.getname("documentid"), this.documentid);         readwritevalues.add(xns.getname("lastmodifiedtime"), this.lastupdatetime);          writeonlyvalues = null;     }      protected override idictionary<xname, object> mapvalues(idictionary<xname, object> readwritevalues, idictionary<xname, object> writeonlyvalues)     {         return base.mapvalues(readwritevalues, writeonlyvalues);     } 

updateextension code:

public sealed class updateextension : codeactivity {     // define activity input argument of type string     public inargument<string> text { get; set; }      // if activity returns value, derive codeactivity<tresult>     // , return value execute method.     protected override void execute(codeactivitycontext context)     {         // obtain runtime value of text input argument         context.getextension<documentstatusextension>().documentid = guid.newguid().tostring();         context.getextension<documentstatusextension>().username = "john smith";         context.getextension<documentstatusextension>().approvalstatus = "approved";         context.getextension<documentstatusextension>().lastupdatetime = datetime.now;     } } 

i have them working, unfortunately no sample code can share now. persistenceparticipant can bit tricky setup xnames involved have match up. additionally there bug using boolean values stops whole process without warning make sure avoid booleans.

update: using different xml namespaces in code. createworkflowservicehost() uses http://contoso.com/documentstatus define property promotion , collectvalues() uses http://contoso.com/ xml namespace of values collected. both should same.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -