Vihang's Re-hosting Workflow Designer example Serialization problem  
Author Message
John Portnov





PostPosted: Windows Workflow Foundation, Vihang's Re-hosting Workflow Designer example Serialization problem Top

Vihang,

I have downloaded the code for Re-hosting the Workflow Designer and have commented out the part that recompiles the code behind (I just need to update and save the xoml for now).

The problem is that the namespace aliases get reversed when the following code executes:

protected override void PerformFlush(IDesignerSerializationManager manager)

{

IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

Activity rootActivity = host.RootComponent as Activity;

if (host != null && host.RootComponent != null)

{

if (rootActivity != null)

{

XmlTextWriter xmlWriter = new XmlTextWriter(this.xoml, Encoding.Default);

try

{

WorkflowMarkupSerializer xomlSerializer = new WorkflowMarkupSerializer();

xomlSerializer.Serialize(xmlWriter, rootActivity);

}

finally

{

xmlWriter.Close();

}

}

}

--------------------------------------------------------------------------------------------------------

If I load the following xoml (in Fig 1-1) and click the Save button (without making any changes), my output xoml (in Fig 1-2) will have different namespace aliases because the bolded code above executed.

--------------------------------------------------------------------------------------------------------

Fig 1-1 (xoml before clicking the Save button)

<ns0:BaseOrderWorkflow x:Name="XOMLBagTagWorkflow" EmailCreatedSendEmailActivity_ToEmail="{x:Null}" EmailCreatedSendEmailActivity_EmailBody="{x:Null}" EmailCreatedSendEmailActivity_FromEmail="{x:Null}" EmailCreatedSendEmailActivity_EmailSubject="{x:Null}" EmailCreatedSendEmailActivity_FromName="{x:Null}" MRSchedule="{p1:Null}" CompanyCode="{p1:Null}" ToEmail="{p1:Null}" ToEmailManager="{x:Null}" EmailSubject="{x:Null}" RegionID="{x:Null}" ResultsMessage="" EmailBody="{x:Null}" ResultsC1Report="{x:Null}" ToEmailAdmin="{x:Null}" FromName="{x:Null}" DynamicUpdateCondition="{x:Null}" FromEmail="{x:Null}" ReportName="{x:Null}" LocationID="{x:Null}" DataIn="{x:Null}" ResultsReport="{x:Null}" InitialStateName="WaitingForBagTagState" FileName="{x:Null}" ResultsData="{x:Null}" CompletedStateName="BagTagCompletedState" xmlns=" http://www.hide-link.com/ " xmlns:ns1="clr-namespace:BagTagActivity;Assembly=BagTagActivity, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" xmlns:ns2="clr-namespace:ADPSendEmail;Assembly=ADPSendEmail, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" xmlns:x=" http://www.hide-link.com/ " xmlns:p1=" http://www.hide-link.com/ " xmlns:ns0="clr-namespace:iServeWorkflows;Assembly=iServeWorkflows, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null">
 <StateActivity x:Name="WaitingForBagTagState">
  <EventDrivenActivity x:Name="BagTagCreatedEvent">
   <HandleExternalEventActivity Invoked="{ActivityBind XOMLBagTagWorkflow,Path=BagTagCreated_Invoked}" x:Name="BagTagCreatedHandleExternalActivity" EventName="BagTagCreated" InterfaceType="{x:Type p11:IOrderService,TypeName=OrderLocalServices.IOrderService}" xmlns:p11="clr-namespace:OrderLocalServices;Assembly=iServeWorkflows, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" />
   <IfElseActivity x:Name="CheckSourceEmail">
    <IfElseBranchActivity x:Name="ifValidSender">
     <IfElseBranchActivity.Condition>
      <RuleConditionReference ConditionName="Condition1" />
     </IfElseBranchActivity.Condition>
     <CodeActivity x:Name="ValidSenderEmailAddress" ExecuteCode="{ActivityBind XOMLBagTagWorkflow,Path=ValidSender}" />
    </IfElseBranchActivity>
    <IfElseBranchActivity x:Name="ifInvalidSender">
     <CodeActivity x:Name="InvalidSenderEmailAddress" ExecuteCode="{ActivityBind XOMLBagTagWorkflow,Path=InvalidSender}" />
    </IfElseBranchActivity>
   </IfElseActivity>
   <ns2:ADPWSSendEmail toA="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_ToEmail}" x:Name="BagTagInitializeEmailActivity" subj="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_EmailSubject}" name="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_FromName}" Description="Sends email that Creation of Bag Tag is starting." body="Starting to print the BagTag.   Hope this works." fromA="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_FromEmail}" xfilepath="{x:Null}" />
   <SetStateActivity x:Name="BagTagSetPrintStateActivity" TargetStateName="PrintBagTagState" />
  </EventDrivenActivity>
 </StateActivity>
 <StateActivity x:Name="PrintBagTagState">
  <EventDrivenActivity x:Name="PrintBagTagEvent">
   <HandleExternalEventActivity Invoked="{ActivityBind XOMLBagTagWorkflow,Path=PrintBagTag_Invoked}" x:Name="BagTagApprovedHandleExternalActivity" EventName="PrintBagTag" InterfaceType="{x:Type p11:IOrderService,TypeName=OrderLocalServices.IOrderService}" xmlns:p11="clr-namespace:OrderLocalServices;Assembly=iServeWorkflows, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" />
   <ns1:BagTagAct x:Name="bagTagActivity" mResultsReport="{ActivityBind XOMLBagTagWorkflow,Path=ResultsReport}" mFileName="{ActivityBind XOMLBagTagWorkflow,Path=FileName}" mResultsC1Report="{ActivityBind XOMLBagTagWorkflow,Path=ResultsC1Report}" mReportName="{ActivityBind XOMLBagTagWorkflow,Path=ReportName}" mResultMessage="{ActivityBind XOMLBagTagWorkflow,Path=ResultsMessage}" mDataIn="{ActivityBind XOMLBagTagWorkflow,Path=DataIn}" mResultsData="{ActivityBind XOMLBagTagWorkflow,Path=ResultsData}" />
   <ns2:ADPWSSendEmail toA="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_ToEmail}" x:Name="BagTagFirstConfirmPrintEmailActivity" subj="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_EmailSubject}" name="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_FromName}" Description="Sends email that Creation of Bag Tag is starting." body="Successfully Printed BagTag as a PDF file." fromA="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_FromEmail}" xfilepath="{x:Null}" />
   <!--ns2:ADPWSSendEmail toA="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_ToEmail}" x:Name="BagTagSecondConfirmPrintEmailActivity" subj="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_EmailSubject}" name="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_FromName}" Description="Sends second email that Creation of Bag Tag is starting." body="Just another reminder.  Successfully Printed BagTag as a PDF file." fromA="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_FromEmail}" xfilepath="{x:Null}" /-->
   <SetStateActivity x:Name="BagTagApprovedSetStateActivity" TargetStateName="BagTagCompletedState" />
  </EventDrivenActivity>
 </StateActivity>
 <StateActivity x:Name="BagTagCompletedState" />
</ns0:BaseOrderWorkflow>

----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------

Fig 1-2 (xoml after clicking the Save button)

<ns0:BaseOrderWorkflow EmailApprovedSendEmailActivity_FromEmail="{p1:Null}" EmailApprovedSendEmailActivity_EmailBody="{p1:Null}" EmailCancelledSendEmailActivity_FromEmail="{p1:Null}" BagTagProductCode="{p1:Null}" MRSchedule="{p1:Null}" CompanyCode="{p1:Null}" BagTagCity="{p1:Null}" EmailRejectedSendEmailActivity_EmailSubject="{p1:Null}" BagTagExtension="{p1:Null}" BagTagRequest_Date="{p1:Null}" BagTagStored_Label_Instruction="{p1:Null}" BagTagCompany_Name="{p1:Null}" ToEmail="{p1:Null}" x:Name="XOMLBagTagWorkflow" BagTagRequest_Day="{x:Null}" EmailRejectedSendEmailActivity_ToEmail="{x:Null}" EmailRejectedSendEmailActivity_FromEmail="{x:Null}" ToEmailManager="{x:Null}" EmailRejectedSendEmailActivity_EmailBody="{x:Null}" EmailSubject="{x:Null}" BagTagUser_Label_Instruction_1="{x:Null}" RegionID="{x:Null}" ResultsMessage="" BagTagBarCode="{x:Null}" BagTagActionType="{x:Null}" EmailCancelledSendEmailActivity_ToEmail="{x:Null}" EmailBody="{x:Null}" BagTagExchange="{x:Null}" BagTagLocationNumber="{x:Null}" BagTagTrip_Number="{x:Null}" BagTagName2="{x:Null}" BagTagDelivery_Method="{x:Null}" EmailCancelledSendEmailActivity_FromName="{x:Null}" ResultsC1Report="{x:Null}" ToEmailAdmin="{x:Null}" EmailCreatedSendEmailActivity_ToEmail="{x:Null}" EmailCancelledSendEmailActivity_EmailSubject="{x:Null}" BagTagWrap_Instructions="{x:Null}" BagTagUser_Label_Instruction_2="{x:Null}" BagTagPackageMethod="{x:Null}" BagTagCompany_Code="{x:Null}" FromName="{x:Null}" EmailCreatedSendEmailActivity_EmailBody="{x:Null}" BagTagAddress_1="{x:Null}" BagTagContact_Name="{x:Null}" BagTagMRSchedule="{x:Null}" DynamicUpdateCondition="{x:Null}" BagTagPhoneNumber="{x:Null}" FromEmail="{x:Null}" EmailCreatedSendEmailActivity_FromEmail="{x:Null}" ReportName="{x:Null}" LocationID="{x:Null}" BagTagAreaCode="{x:Null}" EmailCreatedSendEmailActivity_EmailSubject="{x:Null}" BagTagLocationId="{x:Null}" DataIn="{x:Null}" BagTagPhone="{x:Null}" BagTagState="{x:Null}" EmailCreatedSendEmailActivity_FromName="{x:Null}" ResultsReport="{x:Null}" BagTagClientAddressSequence="{x:Null}" InitialStateName="WaitingForBagTagState" FileName="{x:Null}" EmailRejectedSendEmailActivity_FromName="{x:Null}" EmailApprovedSendEmailActivity_ToEmail="{x:Null}" BagTagRequest_Time="{x:Null}" ResultsData="{x:Null}" EmailCancelledSendEmailActivity_EmailBody="{x:Null}" EmailApprovedSendEmailActivity_EmailSubject="{x:Null}" BagTagClientAddressType="{x:Null}" CompletedStateName="BagTagCompletedState" BagTagZip="{x:Null}" BagTagAddress_2="{x:Null}" EmailApprovedSendEmailActivity_FromName="{x:Null}" BagTagLocationID="{x:Null}" xmlns=" http://www.hide-link.com/ " xmlns:ns1="clr-namespace:ADPSendEmail;Assembly=ADPSendEmail, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" xmlns:ns2="clr-namespace:BagTagActivity;Assembly=BagTagActivity, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" xmlns:x=" http://www.hide-link.com/ " xmlns:p1=" http://www.hide-link.com/ " xmlns:ns0="clr-namespace:iServeWorkflows;Assembly=iServeWorkflows, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null">
 <StateActivity x:Name="WaitingForBagTagState">
  <EventDrivenActivity x:Name="BagTagCreatedEvent">
   <HandleExternalEventActivity Invoked="{ActivityBind XOMLBagTagWorkflow,Path=BagTagCreated_Invoked}" x:Name="BagTagCreatedHandleExternalActivity" EventName="BagTagCreated" InterfaceType="{x:Type OrderLocalServices.IOrderService}" />
   <IfElseActivity x:Name="CheckSourceEmail">
    <IfElseBranchActivity x:Name="ifValidSender">
     <IfElseBranchActivity.Condition>
      <RuleConditionReference ConditionName="Condition1" />
     </IfElseBranchActivity.Condition>
     <CodeActivity x:Name="ValidSenderEmailAddress" ExecuteCode="{ActivityBind XOMLBagTagWorkflow,Path=ValidSender}" />
    </IfElseBranchActivity>
    <IfElseBranchActivity x:Name="ifInvalidSender">
     <CodeActivity x:Name="InvalidSenderEmailAddress" ExecuteCode="{ActivityBind XOMLBagTagWorkflow,Path=InvalidSender}" />
    </IfElseBranchActivity>
   </IfElseActivity>
   <ns1:ADPWSSendEmail toA="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_ToEmail}" x:Name="BagTagInitializeEmailActivity" subj="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_EmailSubject}" name="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_FromName}" Description="Sends email that Creation of Bag Tag is starting." body="Starting to print the BagTag.   Hope this works." fromA="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_FromEmail}" xfilepath="{x:Null}" />
   <SetStateActivity x:Name="BagTagSetPrintStateActivity" TargetStateName="PrintBagTagState" />
  </EventDrivenActivity>
 </StateActivity>
 <StateActivity x:Name="PrintBagTagState">
  <EventDrivenActivity x:Name="PrintBagTagEvent">
   <HandleExternalEventActivity Invoked="{ActivityBind XOMLBagTagWorkflow,Path=PrintBagTag_Invoked}" x:Name="BagTagApprovedHandleExternalActivity" EventName="PrintBagTag" InterfaceType="{x:Type OrderLocalServices.IOrderService}" />
   <ns2:BagTagAct x:Name="bagTagActivity" mResultsData="{ActivityBind XOMLBagTagWorkflow,Path=ResultsData}" mFileName="{ActivityBind XOMLBagTagWorkflow,Path=FileName}" mResultsC1Report="{ActivityBind XOMLBagTagWorkflow,Path=ResultsC1Report}" mReportName="{ActivityBind XOMLBagTagWorkflow,Path=ReportName}" mResultMessage="{ActivityBind XOMLBagTagWorkflow,Path=ResultsMessage}" mDataIn="{ActivityBind XOMLBagTagWorkflow,Path=DataIn}" mResultsReport="{ActivityBind XOMLBagTagWorkflow,Path=ResultsReport}" />
   <ns1:ADPWSSendEmail toA="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_ToEmail}" x:Name="BagTagFirstConfirmPrintEmailActivity" subj="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_EmailSubject}" name="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_FromName}" Description="Sends email that Creation of Bag Tag is starting." body="Successfully Printed BagTag as a PDF file." fromA="{ActivityBind XOMLBagTagWorkflow,Path=EmailCreatedSendEmailActivity_FromEmail}" xfilepath="{x:Null}" />
   <SetStateActivity x:Name="BagTagApprovedSetStateActivity" TargetStateName="BagTagCompletedState" />
  </EventDrivenActivity>
 </StateActivity>
 <StateActivity x:Name="BagTagCompletedState" />
</ns0:BaseOrderWorkflow>

-----------------------------------------------------------------------------------------------------------------------------------

Why are the namespace aliases for BagTagActivity and ADPSendEmail activity reversed (the namespace aliases are bolded above)

I look forward to your reply.  Thanks in advance.

 

Sincerely,

John Portnov




Software Development for Windows Vista16  
 
 
Jon Flanders





PostPosted: Windows Workflow Foundation, Vihang's Re-hosting Workflow Designer example Serialization problem Top

John - can I ask why it matters The namespace prefixes are arbitrary and dont really matter in terms of what they are.

 
 
John Portnov





PostPosted: Windows Workflow Foundation, Vihang's Re-hosting Workflow Designer example Serialization problem Top

When I save the xoml via the Re-hosting the Workflow Designer example, I get xoml that is content different (all the public properties are listed in the root node and the namespace aliases are wrong) from the xoml that I loaded into the designer. It may not make a functional difference, but if I choose to add the WFPad xoml option to this Re-hosting designer, the user is going to be surprised to see the xoml change after clicking the save button (even if they did not do anything).

Sincerely,

John Portnov



 
 
Jon Flanders





PostPosted: Windows Workflow Foundation, Vihang's Re-hosting Workflow Designer example Serialization problem Top

Well - my first response is that anyone who can edit xoml by hand will know that the namespace prefixes aren't important ;-)

But - I *believe* (but have not tried it) you can accomplish your goal by creating your own WorflowMarkupSerializerManager (specifically the GetXmlQualifiedName method is the one you want to override).



 
 
John Portnov





PostPosted: Windows Workflow Foundation, Vihang's Re-hosting Workflow Designer example Serialization problem Top

Jon,

Thanks. Can you offer any code samples on how to do this

Sincerely,

John Portnov