惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
N
Netflix TechBlog - Medium
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
The Cloudflare Blog
Blog — PlanetScale
Blog — PlanetScale
F
Full Disclosure
G
Google Developers Blog
罗磊的独立博客
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
A
About on SuperTechFans
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
GbyAI
GbyAI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
The Register - Security
The Register - Security
U
Unit 42
D
Docker
Martin Fowler
Martin Fowler
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
博客园_首页
Google DeepMind News
Google DeepMind News

博客园 - 不老仙翁

DataSet中DataRelation有个小BUG 招聘信息(沈阳) 冥王星归位 - 不老仙翁 宇宙的最初三分种(转) 也谈谈ORM 要看世界杯了 试用mapxtreme 2005 v6.6中的一个问题 关于软件开发团队的一些思考 程序员需要天真,写在六一 一个足球狂的军规:世界杯女友/老婆准则 这个项目团队能少了谁? 需求中的一例 vs2005中的小bug 继续说需求 vs 2005的中文版终于出来了 大话需求分析中的方法论(4) 大话需求分析中的方法论(3) 大话需求分析中的方法论(2) 大话需求分析中的方法论(1)
在aspnet中使用wwf的第一个实践
不老仙翁 · 2006-01-03 · via 博客园 - 不老仙翁


在winfx的主页上看到了aspnet form做wwf宿主的例子,由于本人刚刚删除了vs2005的bate2版以及wwf,装上了vs2005的professional,呵呵,只好按照提示,前装上了winfx的sdk,然后装上了Visual Studio 2005 Extensions for Windows Workflow Foundation Beta 1.2,运行了vs2005,发现了wwf的工程模板,只是与bate1有些变化,看来还是在不断进步中。
先是在本机上的sql server 2005建了runtime使用的三个数据库:workflowpersistence,workflowtimer,workflowtracking,然后在C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Windows Workflow Foundation\SQL(你自己的系统目录下)执行了所有的sql命令,先schema,后logic,呵呵。只是没空好好研究这几个家伙。

按网上例子的思路,开始了这个例子的实践:
建一个顺序工作流库的工程,我将其命名为mywebwwf,在workflow1中加入一个code活动,在code的executecode属性中写上“code_Excute”,在workflow1的代码中,定义一个字符串变量results,并在code_Excute方法中写下如下代码:
 this.results = string.Format("你好 {0} {1}", this.Parameters["FirstName"].Value.ToString(), this.Parameters["LastName"].Value.ToString());

 在workflow1的属性parameters中加入三个参数,其中FirstName与LastName为输入型string, Results为输出型string,其值(value)为变量results;
编译一下,形成dll文件。
在解决方案中加入一个新的web form项目,将其设为起动项目,然后加入mywebwwf.dll的引用。
可以开始写入网页代码了,先在网页窗体上加上两个textbox,当然可以加上相应的label做标题。
然后加上一个button做命令,
下面加上一个label做输出,并将其命名为:lblResults
在代码中还要加上事件:
WorkflowRuntime_WorkflowCompleted
下面是default.aspx的代码部份:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting.Web;


public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void button1_Click(object sender, EventArgs e)
    {
        this.StartWorkflow();
    }

    private void StartWorkflow()
    {
        // Define the parametes for the
        Dictionary<string, object> parameters = new Dictionary<string, object>();
        parameters.Add("FirstName", this.TextBox1.Text);
        parameters.Add("LastName", this.TextBox2.Text);


        // Get a reference to the Workflow Runtime through the WorkflowWebHostingModule
        // Http Module. 
        //
        // NOTE:  This requires the configuration section to be named "WorkflowRuntime".
        WorkflowRuntime workflowRuntime = WorkflowRequestContext.Current.WorkflowRuntime;

        // Attach to the WorkflowCompleted event
        workflowRuntime.WorkflowCompleted +=
            new EventHandler<WorkflowCompletedEventArgs>(WorkflowRuntime_WorkflowCompleted);

        // Start the Workflow1
        WorkflowInstance workflowInstance = workflowRuntime.StartWorkflow(
            typeof(mywebwwf.Workflow1), parameters);
    }


    void WorkflowRuntime_WorkflowCompleted(object sender, System.Workflow.Runtime.WorkflowCompletedEventArgs e)
    {
        this.lblResults.Text = e.OutputParameters["Results"].ToString();
    }
}
运行一下,成功了,是不是很简单。