locked
workflow 4 state machine load RRS feed

  • Question

  • Hi,

    I'm using StateMachine for WF4 from codeplex. I can save it to file very well, but when I load it again I see only the states not the connectors also. Same behavior can be reproduced by double clicking a state and then coming back to whole state machine.

    Could you please help me?

    Thank you very much

    Friday, September 10, 2010 4:41 PM

Answers

  • Do you mean the designer is hang? Can you open the variable designer or some other controls to see if the designer still functional?

    I may miss some points so that I can't repro your issue on my own machine. I just change the rehost sample code download from here: http://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=35ec8682-d5fd-4bc3-a51a-d8ad115a8792&displaylang=en, the DesignerRehosting project under  WF_WCF_Samples\WF\Basic\DesignerRehosting\Basic\cs. I've only changed the code in RehostingWFDesigner.xaml.cs. 1) Override the function OnInitialized(EventArgs e). 2) Add Microsoft.Activities.StateMachine and Microsoft.Activities.StateMachine.Designer as project's references.

    Here is what the code look like, I've highlighted what I've changed.

            protected override void OnInitialized(EventArgs e)

            {

                base.OnInitialized(e);

                // register metadata

                (new DesignerMetadata()).Register();

                new Microsoft.Activities.Statements.Design.DesignerMetadata().Register();

     

                // create the workflow designer

     

                wd.Load(@"NoConnectorState.xaml");

                DesignerBorder.Child = wd.View;

                PropertyBorder.Child = wd.PropertyInspectorView;

            }

    The content of NoConnectorState.xaml was just copied from your previous post. Then I can successfully show states and links in designer. 

     

    Could you give us some more information, maybe your project or screenshots, which will help us identify your issues. You could send your project to yuawan at microsoft dot com.

     

    Thanks,

    Yuanji Wang


    This posting is provided "AS IS" and confers no rights or warranties.
    Tuesday, September 14, 2010 1:41 PM

All replies

  • Hi,

    I'm using rehosted designer from WF4 samples. Did anybody test this?

    Thank you

    Friday, September 10, 2010 9:00 PM
  • Hi SL1234, 

    Would you mind copy your saved xaml file here?

    Thanks,

    Yuanji Wang


    This posting is provided "AS IS" and confers no rights or warranties.
    Sunday, September 12, 2010 11:12 AM
  • Here it is:

    <StateMachine mc:Ignorable="sap" InitialState="{x:Reference __ReferenceID4}" DisplayName="Test" sap:VirtualizedContainerService.HintSize="1500,636" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="clr-namespace:Microsoft.Activities.Statements;assembly=Microsoft.Activities.StateMachine" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <sap:WorkflowViewStateService.ViewState>
        <scg:Dictionary x:TypeArguments="x:String, x:Object">
          <x:Boolean x:Key="IsExpanded">False</x:Boolean>
          <x:Double x:Key="StateContainerWidth">1500</x:Double>
          <x:Double x:Key="StateContainerHeight">600</x:Double>
          <av:PointCollection x:Key="ConnectorLocation">60,300 90,300 90,291.5 110,291.5</av:PointCollection>
        </scg:Dictionary>
      </sap:WorkflowViewStateService.ViewState>
      <State x:Name="__ReferenceID4">
        <State.Transitions>
          <Transition DisplayName="">
            <sap:WorkflowViewStateService.ViewState>
              <scg:Dictionary x:TypeArguments="x:String, x:Object">
                <av:PointCollection x:Key="ConnectorLocation">168,291.5 250,291.5</av:PointCollection>
              </scg:Dictionary>
            </sap:WorkflowViewStateService.ViewState>
            <Transition.To>
              <State x:Name="__ReferenceID1">
                <State.Transitions>
                  <Transition DisplayName="">
                    <sap:WorkflowViewStateService.ViewState>
                      <scg:Dictionary x:TypeArguments="x:String, x:Object">
                        <av:PointCollection x:Key="ConnectorLocation">292.752,242.5 292.752,227.25 470,227.25</av:PointCollection>
                      </scg:Dictionary>
                    </sap:WorkflowViewStateService.ViewState>
                    <Transition.To>
                      <State x:Name="__ReferenceID2">
                        <State.Transitions>
                          <Transition DisplayName="">
                            <sap:WorkflowViewStateService.ViewState>
                              <scg:Dictionary x:TypeArguments="x:String, x:Object">
                                <av:PointCollection x:Key="ConnectorLocation">530,209 605,209 605,262.5</av:PointCollection>
                              </scg:Dictionary>
                            </sap:WorkflowViewStateService.ViewState>
                            <Transition.To>
                              <State x:Name="__ReferenceID0">
                                <sap:WorkflowViewStateService.ViewState>
                                  <scg:Dictionary x:TypeArguments="x:String, x:Object">
                                    <av:Point x:Key="ShapeLocation">590,262.5</av:Point>
                                    <av:Size x:Key="ShapeSize">60,75</av:Size>
                                  </scg:Dictionary>
                                </sap:WorkflowViewStateService.ViewState>
                              </State>
                            </Transition.To>
                          </Transition>
                        </State.Transitions>
                        <sap:WorkflowViewStateService.ViewState>
                          <scg:Dictionary x:TypeArguments="x:String, x:Object">
                            <av:Point x:Key="ShapeLocation">470,172.5</av:Point>
                            <av:Size x:Key="ShapeSize">60,73</av:Size>
                          </scg:Dictionary>
                        </sap:WorkflowViewStateService.ViewState>
                      </State>
                    </Transition.To>
                  </Transition>
                  <Transition DisplayName="">
                    <sap:WorkflowViewStateService.ViewState>
                      <scg:Dictionary x:TypeArguments="x:String, x:Object">
                        <av:PointCollection x:Key="ConnectorLocation">271.376,340.5 271.376,360.75 470,360.75</av:PointCollection>
                      </scg:Dictionary>
                    </sap:WorkflowViewStateService.ViewState>
                    <Transition.To>
                      <State x:Name="__ReferenceID3">
                        <State.Transitions>
                          <Transition DisplayName="">
                            <sap:WorkflowViewStateService.ViewState>
                              <scg:Dictionary x:TypeArguments="x:String, x:Object">
                                <av:PointCollection x:Key="ConnectorLocation">518,379 548,379 548,318.75 590,318.75</av:PointCollection>
                              </scg:Dictionary>
                            </sap:WorkflowViewStateService.ViewState>
                            <Transition.To>
                              <x:Reference>__ReferenceID0</x:Reference>
                            </Transition.To>
                          </Transition>
                        </State.Transitions>
                        <sap:WorkflowViewStateService.ViewState>
                          <scg:Dictionary x:TypeArguments="x:String, x:Object">
                            <av:Point x:Key="ShapeLocation">470,342.5</av:Point>
                            <av:Size x:Key="ShapeSize">48,73</av:Size>
                          </scg:Dictionary>
                        </sap:WorkflowViewStateService.ViewState>
                      </State>
                    </Transition.To>
                  </Transition>
                </State.Transitions>
                <sap:WorkflowViewStateService.ViewState>
                  <scg:Dictionary x:TypeArguments="x:String, x:Object">
                    <av:Point x:Key="ShapeLocation">250,242.5</av:Point>
                    <av:Size x:Key="ShapeSize">64,98</av:Size>
                  </scg:Dictionary>
                </sap:WorkflowViewStateService.ViewState>
              </State>
            </Transition.To>
          </Transition>
        </State.Transitions>
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <av:Point x:Key="ShapeLocation">110,242.5</av:Point>
            <av:Size x:Key="ShapeSize">58,98</av:Size>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </State>
      <x:Reference>__ReferenceID1</x:Reference>
      <x:Reference>__ReferenceID2</x:Reference>
      <x:Reference>__ReferenceID3</x:Reference>
      <x:Reference>__ReferenceID0</x:Reference>
    </StateMachine>

    Monday, September 13, 2010 7:10 AM
  • Saving is done like this
     SaveXamlFile(currentXamlPath, wd.Text);
    where wd is WorkflowDesigner and SaveXamlFile is 
      try
          {
            using (FileStream stream = new FileStream(path, FileMode.Create))
            {
              using (StreamWriter writer = new StreamWriter(stream))
              {
                writer.Write(markup);
              }
            }
          }
          catch (Exception exception)
          {
            Console.WriteLine("SaveXamlFile exception: {0}:{1}",
              exception.GetType(), exception.Message);
          }

    Monday, September 13, 2010 7:20 AM
  • Does the workflow still function, despite the disapperance of the connectors on the canvas?

     

    Tuesday, September 14, 2010 2:57 AM
  • I am just trying to show custom activities, didn't try that. All I can say is that the Canvas can't be used to draw new connectors after loading
    Tuesday, September 14, 2010 8:25 AM
  • Do you mean the designer is hang? Can you open the variable designer or some other controls to see if the designer still functional?

    I may miss some points so that I can't repro your issue on my own machine. I just change the rehost sample code download from here: http://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=35ec8682-d5fd-4bc3-a51a-d8ad115a8792&displaylang=en, the DesignerRehosting project under  WF_WCF_Samples\WF\Basic\DesignerRehosting\Basic\cs. I've only changed the code in RehostingWFDesigner.xaml.cs. 1) Override the function OnInitialized(EventArgs e). 2) Add Microsoft.Activities.StateMachine and Microsoft.Activities.StateMachine.Designer as project's references.

    Here is what the code look like, I've highlighted what I've changed.

            protected override void OnInitialized(EventArgs e)

            {

                base.OnInitialized(e);

                // register metadata

                (new DesignerMetadata()).Register();

                new Microsoft.Activities.Statements.Design.DesignerMetadata().Register();

     

                // create the workflow designer

     

                wd.Load(@"NoConnectorState.xaml");

                DesignerBorder.Child = wd.View;

                PropertyBorder.Child = wd.PropertyInspectorView;

            }

    The content of NoConnectorState.xaml was just copied from your previous post. Then I can successfully show states and links in designer. 

     

    Could you give us some more information, maybe your project or screenshots, which will help us identify your issues. You could send your project to yuawan at microsoft dot com.

     

    Thanks,

    Yuanji Wang


    This posting is provided "AS IS" and confers no rights or warranties.
    Tuesday, September 14, 2010 1:41 PM
  • Thanks for replying, I can't provide the code, but I will try to see if I reproduce the issue with your steps. 

    Basically, what I need is an interface for business users. Like I've said in other posts, the only approaches I've seen so far are ICustomView, exemplified by Tim Lovell in his post which he admits is buggy and hard to use and tweaking State Machine 4 (the approach I'm taking). Maybe my tweaking of StateMachine code caused the issue. Let me just test your approach and I'll provide feedback.

    However, what I hope is the next release will provide a way to make end user friendly interfaces because I can't ask somebody to learn VBA etc. All business wants to see is nice WPF ControlTemplate (and flowchart responding to click on nodes and connectors) to happily create flows. Everything else should be done from code.

    Thanks

    Wednesday, September 15, 2010 9:47 AM