学WF系列(八)——改善登录程序(下)
2010-10-01 08:25:37 来源:WEB开发网namespace WorkflowCreator
{
public class Creator
{
public static WorkflowRuntime CreateRuntime()
{
WorkflowRuntime runtime = new WorkflowRuntime();
ExternalDataExchangeService service = new ExternalDataExchangeService();
runtime.AddService(service);
service.AddService(new UserValidator.Validator());
return runtime;
}
}
}
7. 前台窗口
我们做一个简单的登录界面。
接下来看看Winform1.cs的完整代码:
public partial class Form1 : Form,IEvent,IAlert
{
private WorkflowRuntime runtime;
private ExternalDataExchangeService service;
private WorkflowInstance instance;
public Form1()
{
InitializeComponent();
runtime = WorkflowCreator.Creator.CreateRuntime();
service = new ExternalDataExchangeService();
runtime.AddService(service);
service.AddService(this);
}
private void button1_Click(object sender, EventArgs e)
{
instance = runtime.CreateWorkflow(typeof(WorkflowConsoleApplication9.Workflow1));
instance.Start();
UserInfo user = new UserInfo(instance.InstanceId, this.textBox1.Text, this.textBox2.Text);
Login(null, user);
}
#region IEvent 成员
public event EventHandler<System.Workflow.Activities.ExternalDataEventArgs> Login;
#endregion
#region IAlert 成员
public void AlertNull()
{
MessageBox.Show("用户名和密码不能为空");
}
public void AlertFailed()
{
MessageBox.Show("用户名或密码错误");
}
public void AlertSuccess()
{
MessageBox.Show("登录成功");
}
#endregion
}
- ››改善SQL Server的内存管理
- ››WF 4.0 beta1中的跟踪机制
- ››WF 4.0的建模风格:顺序和Flowchart
- ››WF4.0 Beta1之旅(5):规则引擎的变化
- ››WF 4.0 beta1活动概览(1):Procedural
- ››WF4.0 Beta1之旅(4):Bookmark的使用
- ››WF4.0 Beta1之旅:基本介绍
- ››WF4.0 Beta1之旅(2):异常处理
- ››WF4.0 Beta1之旅(3):全新的FlowChart
- ››WF 应用场景指南: SharePoint 与工作流(上)
- ››WF 应用场景指南: 展现流(Presentation Flow)
- ››WF单元测试系列1:测试基本的Activity
更多精彩
赞助商链接