状态机持久化工作流程

发布于 2024-08-03 10:45:29 字数 508 浏览 1 评论 0原文

大家好,我创建了一个 WinForms 来使用 Windows WorkFlow Foundation 处理持久性活动。我使用.NET 3.0 SQL和VS2005作为IDE,使用C#作为代码语言。此外,环境也是公司发展政策对我的要求。因此,在恐龙决定升级之前,我一直坚持使用 VS2005。

我的问题是这样的,我能够一次处理 1 个工作流程,并且我希望能够处理多个工作流程。就像当我单击表单上的“提交”按钮时,我希望能够创建一个新的工作流实例。

我创建了运行时并添加了所有适当的服务。我挂钩持久性,当我单击“提交”时,我启动了工作流的一个实例。我对 WorkFlow Foundation 比较陌生,MSDN 链接对我几乎没有提供任何帮助。如果有人可以在我的源代码中将我置于正确的方向,那将会很有帮助。

我已附上我的项目源代码的链接。

单击此处获取来源

提前致谢!

Hey all, I have created a WinForms to handle Persistence Activities using the Windows WorkFlow Foundation. I'm using the .NET 3.0 SQL and VS2005 as the IDE with C# as the code language. Also, the environment is mandated to me by the corporate policy for development. So until the dinosaurs decide to upgrade, I'm stuck with VS2005.

My probelm is this, I'm able to work with 1 workflow at a time, and I'd like to be able to handle Multiple workflows. As in when I click the Submit button on my form, I'd like to be able to create a new WorkFlow instance.

I created the runtime and add all the appropriate services. I hook in persistence, and when I click the Submit I start an instance of the WorkFlow. I'm relatively new to the WorkFlow Foundation, and the MSDN links have provided little to no help for me. If anyone could put me in the right direciton within my source code, that would be helpful.

I have attached a link to the source for my project.

Click Here for the Source

Thanks in Advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

过去的过去 2024-08-10 10:45:29

我看了一下,每次单击“提交”时,您似乎都在创建一个新的工作流程。我得到了一个新的实例 id,这是一个好兆头 :) PopulatePSUP(string instanceID) 捕获下拉列表的实例 id。但您一次仅在 Guid _instanceID 中存储一个实例 ID。然后,该表单级别变量将用于所有按钮事件。您可以直接使用 cboPSUPItems.Text。

类似于:

    private void btnPSUPApprove_Click(object sender, EventArgs e)
    {
        string instanceId = this.cboPSUPItems.Text;

        if ( instanceId.Length > 0 )
        {
            myArgs.Approved = true;
            approved = "Yes";
            this.resumeHistory[ instanceId ].Clear( );
            this.resumeHistory[ instanceId ].Add( "Name: " + applicantName );
            this.resumeHistory[ instanceId ].Add( "Email:" + applicantEmail );
            this.resumeHistory[ instanceId ].Add( "Text:" + applicantText );
            this.resumeHistory[ instanceId ].Add( "Approved:" + approved );
            this.resumeHistory[ instanceId ].Add( "Denied:" + denied );
            this.resumeHistory[ instanceId ].Add( "PD Approval Requested:" + pDRequest );
            resumeService.RaisePSUPApprovedEvent( new Guid(instanceId) , myArgs );
            this.cboPSUPItems.Items.Remove( this.cboPSUPItems.SelectedItem );
            txtPSUPNotes.Clear( );
        }
    }

您可能还想考虑使用集合/列表来存储instanceId。适用于任何工作流程范围的逻辑。

像这样的东西:

List<Guid> _instanceIds = new List<Guid>( );

...

_instanceIds.Add( instance.InstanceId );

I had a look and it appears that you are creating a new workflow each time you click submit. I get a new instance id, which is a good sign :) PopulatePSUP(string instanceID) captures the instance id for the dropdown. But you are only storing one instance id at a time in Guid _instanceID. This form level variable is then used for all the button events. You could insead use the cboPSUPItems.Text.

Something like:

    private void btnPSUPApprove_Click(object sender, EventArgs e)
    {
        string instanceId = this.cboPSUPItems.Text;

        if ( instanceId.Length > 0 )
        {
            myArgs.Approved = true;
            approved = "Yes";
            this.resumeHistory[ instanceId ].Clear( );
            this.resumeHistory[ instanceId ].Add( "Name: " + applicantName );
            this.resumeHistory[ instanceId ].Add( "Email:" + applicantEmail );
            this.resumeHistory[ instanceId ].Add( "Text:" + applicantText );
            this.resumeHistory[ instanceId ].Add( "Approved:" + approved );
            this.resumeHistory[ instanceId ].Add( "Denied:" + denied );
            this.resumeHistory[ instanceId ].Add( "PD Approval Requested:" + pDRequest );
            resumeService.RaisePSUPApprovedEvent( new Guid(instanceId) , myArgs );
            this.cboPSUPItems.Items.Remove( this.cboPSUPItems.SelectedItem );
            txtPSUPNotes.Clear( );
        }
    }

You might want to think about using a collection/list to store the instanceIds in as well. For any workflow wide logic.

Something like:

List<Guid> _instanceIds = new List<Guid>( );

...

_instanceIds.Add( instance.InstanceId );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文