WEB开发网
开发学院软件开发C语言 学WF系列(八)——改善登录程序(下) 阅读

学WF系列(八)——改善登录程序(下)

 2010-10-01 08:25:37 来源:WEB开发网   
核心提示: namespaceWorkflowCreator{publicclassCreator{publicstaticWorkflowRuntimeCreateRuntime(){WorkflowRuntimeruntime=newWorkflowRuntime();ExternalDataExcha

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. 前台窗口

学WF系列(八)——改善登录程序(下)

我们做一个简单的登录界面。

接下来看看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
}

上一页  2 3 4 5 6 7 8  下一页

Tags:WF 系列 改善

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接