📄 servermanagerform.cs
字号:
if (this.listBox3.SelectedItem != null)
{
string s = this.listBox3.SelectedItem.ToString();
WFEM.ResumeInstance(s);
}
}
//暂停实例
private void btSuspendInstance_Click(object sender, EventArgs e)
{
if (this.listBox3.SelectedItem != null)
{
string s = this.listBox3.SelectedItem.ToString();
WFEM.SuspendInstance(s, "test");
}
}
//终止实例
private void btTerminateInstance_Click(object sender, EventArgs e)
{
if (this.listBox3.SelectedItem != null)
{
string s = this.listBox3.SelectedItem.ToString();
WFEM.TerminateInstance(s, "test");
}
}
//持久化实例
private void btPersist_Click(object sender, EventArgs e)
{
if (this.listBox3.SelectedItem != null)
{
WFEM.PersistInstance(this.listBox3.SelectedItem.ToString(),true);
}
}
#endregion
#region 实例展现
//显示实例的结构
private void btShow_Click(object sender, EventArgs e)
{
this.treeView1.Nodes[0].Nodes.Clear();
this.treeView1.Nodes[0].Text = "空";
this.txtxomlview.Text = "";
wxdWFSequentialView1.ShowWorkflow(new SequentialWorkflowActivity());
if (this.listBox3.SelectedItem != null)
{
//树
WorkflowInstance temp;
temp = WFEM.GetInstance(this.listBox3.SelectedItem.ToString());
if (temp == null)
{
return;
}
this.treeView1.Nodes[0].Text = this.listBox3.SelectedItem.ToString();
listnode(temp.GetWorkflowDefinition(), this.treeView1.Nodes[0]);
this.treeView1.ExpandAll();
//类视图
try
{
wxdWFSequentialView1.ShowWorkflow((SequentialWorkflowActivity)temp.GetWorkflowDefinition());
}
catch
{
}
//xoml字串
this.txtxomlview.Text = WFEM.GetWorkflowInstanceXomlString(temp.InstanceId.ToString());
}
}
//例结点算法
public void listnode(object obj, TreeNode v)
{
if (obj is System.Workflow.ComponentModel.CompositeActivity)
{
System.Workflow.ComponentModel.CompositeActivity wxd;
wxd = (System.Workflow.ComponentModel.CompositeActivity)obj;
string s;
s = string.Format("{1}[{2}]({0})", wxd.Description, wxd.QualifiedName, wxd.GetType().ToString());
System.Windows.Forms.TreeNode n = new TreeNode();
n.Text = s;
v.Nodes.Add(n);
foreach (object temp in wxd.Activities)
{
listnode(temp, n);
}
}
else
{
if (obj is System.Workflow.ComponentModel.Activity)
{
System.Workflow.ComponentModel.Activity wxd;
wxd = (System.Workflow.ComponentModel.Activity)obj;
string s;
s = string.Format("{1}[{2}]({0})", wxd.Description, wxd.QualifiedName, wxd.GetType().ToString());
System.Windows.Forms.TreeNode n = new TreeNode();
n.Text = s;
v.Nodes.Add(n);
}
}
}
//刷新实例列表框
private void btShowA_Click(object sender, EventArgs e)
{
this.listBox3.Items.Clear();
foreach (string temp in WFEM.GetInstanceList())
{
this.listBox3.Items.Add(temp);
}
}
//显示持久化列表
private void btShowB_Click(object sender, EventArgs e)
{
this.dataGridView1.DataSource = sqlpersistence.GetAllWorkflows().Tables[0];
}
//计时器
private void timer1_Tick(object sender, EventArgs e)
{
label5.Text = string.Format("实例计数:{0},已启动实例:{1},已完成实例:{2},活动实例:{3}", WFEM.NCreateInstance.ToString(), WFEM.NStarteInstance.ToString(), WFEM.NCompletedInstance.ToString(), WFEM.NActiveINstance.ToString());
}
//将持久化的实例ID号添加到控制器列表中
private void btLoad_Click(object sender, EventArgs e)
{
if (dataGridView1.CurrentRow != null)
{
listBox3.Items.Add(dataGridView1.CurrentRow.Cells[0].Value);
}
}
#endregion
#region 加载模板
//浏览XOML文件
private void btBrowseXoml_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "xoml 文件 (*.xoml)|*.xoml|所有文件 (*.*)|*.*";
openFileDialog.FilterIndex = 1;
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
this.txtXomlfilepath.Text = openFileDialog.FileName;
System.Xml.XmlDataDocument doc = new XmlDataDocument();
doc.Load(this.txtXomlfilepath.Text);
this.txtXomlstring.Text = doc.OuterXml;
}
}
catch
{
MessageBox.Show("文件错误");
}
}
//浏览DLL文件
private void btBrowseDll_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "DLL 文件 (*.dll)|*.dll|所有文件 (*.*)|*.*";
openFileDialog.FilterIndex = 1;
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
System.Reflection.Assembly workflowAssembly;
txtWorkflowClassFile.Text = openFileDialog.FileName;
string classfile = txtWorkflowClassFile.Text; //盘符路径dll文件名
workflowAssembly = System.Reflection.Assembly.LoadFrom(classfile);
foreach (System.Type tp in workflowAssembly.GetTypes())
{
if (tp.IsSubclassOf(typeof(System.Workflow.ComponentModel.Activity)))
{
this.listBox5.Items.Add(tp.FullName);
}
}
}
}
#endregion
private void btNext_Click(object sender, EventArgs e)
{
object o = this.dataGrid5[this.dataGrid5.CurrentRowIndex, 0];
if (o != null)
{
string gid = o.ToString();
System.Data.DataSet ds = (System.Data.DataSet)this.dataGrid3.DataSource;
controlObject.NextStep(gid, "ok", ds, "");
this.btNext.Enabled = false;
this.btGet.Enabled =true ;
}
}
private void btGet_Click(object sender, EventArgs e)
{
object o = this.dataGrid5[this.dataGrid5.CurrentRowIndex, 0];
if (o != null)
{
string gid = o.ToString();
this.dataGrid3.DataSource = controlObject.GetDataForm(gid);
this.dataGrid3.DataMember = this.dataGrid5[this.dataGrid5.CurrentRowIndex, 2].ToString();
this.dataGrid4.DataSource = controlObject.GetDataForm(gid);
this.btNext.Enabled = true;
this.btGet.Enabled = false;
}
}
private void btGetTask_Click(object sender, EventArgs e)
{
this.dataGrid5.DataSource =controlObject.GetCurrentlyTaskList(this.txUsername.Text).Tables[0];
}
private void btCreateaTask_Click(object sender, EventArgs e)
{
controlObject.TempletName = txtXomlfilepath.Text;
controlObject.CreateTask("");
}
private void btWCFStart_Click(object sender, EventArgs e)
{
controlObject.TempletName = txtXomlfilepath.Text;
host = new ServiceHost(controlObject, new Uri(this.txWCFServerURL.Text));
host.AddServiceEndpoint(typeof(wxwinter.wf.WCFCommunication.ItestControl), new BasicHttpBinding(), this.txWCFServerName.Text);
host.Open();
listBox6.Items.Add("服务已开启");
}
private void btWCFStop_Click(object sender, EventArgs e)
{
host.Close();
listBox6.Items.Add("服务已关闭");
}
}
}
////
// if (e.WorkflowDefinition is wxwinter.wf.TestWorkflow.helloworld)
// {
// int i = (int)e.OutputParameters["I"];
// System.Console.WriteLine(i);
// }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -