/// <summary> /// 添加一个方法对象到动作流中 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToolStripMenuItem_Add_Click(object sender, EventArgs e) { Type methodType = currNode.Tag as Type; string dafaultNewName = _methodFlow.GetDefaultNameWillAddMethod(methodType); BenameDialog bnd = new BenameDialog(); bnd.Text = "新方法节点命名"; bnd.SetName(dafaultNewName); if (DialogResult.OK != bnd.ShowDialog()) { return; } IJFMethod newMethod = JFMethodFlow.CreateMethod(methodType.Name); bool isOK = _methodFlow.Add(newMethod, bnd.GetName()); if (isOK) { ToolStripMenuItem_Insert.Enabled = true; ShowTips("添加动作节点成功!"); UpdateFlow2UI(); } else { MessageBox.Show("添加动作节点失败,请检查动作名称是否已存在于流程中!"); return; } }
private void ToolStripMenuItem_Insert_Click(object sender, EventArgs e) { int idx = toolStripComboBox_Index.SelectedIndex; if (idx < 0) { MessageBox.Show("请选择动作节点序号"); return; } Type methodType = currNode.Tag as Type; string dafaultNewName = _methodFlow.GetDefaultNameWillAddMethod(methodType); BenameDialog bnd = new BenameDialog(); bnd.Text = "新方法节点命名"; bnd.SetName(dafaultNewName); if (DialogResult.OK != bnd.ShowDialog()) { return; } IJFMethod newMethod = JFMethodFlow.CreateMethod(methodType.Name); bool isOK = _methodFlow.Insert(newMethod, idx, bnd.GetName()); if (isOK) { ShowTips("插入动作节点成功!"); UpdateFlow2UI(); } else { MessageBox.Show("插入动作节点失败,请检查\n节点序号是否超限/动作名称是否已存在于流程中!"); return; } }
/// <summary> /// 新建工作流 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btAdd_Click(object sender, EventArgs e) { FormAddFlow2Station dlg = new FormAddFlow2Station(); dlg.Text = _station.Name + " 添加工作流"; if (DialogResult.OK != dlg.ShowDialog()) { return; } string flowName2Add = dlg.WorkFlowName; string[] existNames = _station.WorkFlowNames; if (null != existNames) { foreach (string nm in existNames) { if (nm == flowName2Add) { MessageBox.Show("添加工作流失败!已存在同名称对象:" + flowName2Add); return; } } } JFMethodFlow flow2Add = new JFMethodFlow(); if (dlg.IsLoadedFromFile) { flow2Add.Load(dlg.FilePath); } flow2Add.Name = flowName2Add; _station.AddWorkFlow(flow2Add); _station.SaveCfg(); UpdateStation2UI(); }
void UpdateTypeTreeView() { if (InvokeRequired) { Invoke(new Action(UpdateTypeTreeView)); return; } trvMethodRoot.Nodes.Clear(); foreach (Type t in _methodTypes) { Type[] methodClassTypes = JFMethodFlow.AllChildClass(t); if (null != methodClassTypes) { foreach (Type methodCT in methodClassTypes) { JFCategoryLevelsAttribute[] categoryLevels = methodCT.GetCustomAttributes(typeof(JFCategoryLevelsAttribute), false) as JFCategoryLevelsAttribute[]; if (_IsUncategorized(categoryLevels)) { Add2Uncategorized(methodCT); } else { AddCategory(methodCT, categoryLevels[0].Levels); } } } } }
public void SetInnerFlow(JFMethodFlow innerFlow) { _methodFlow = innerFlow; if (isLoaded) { UpdateDataPoolRow(); UpdateSrc2UI(); } }
public void SetMethodFlow(JFMethodFlow methodFlow) { this.methodFlow = methodFlow; ucMethodFlow.SetMethodFlow(methodFlow); if (null != methodFlow) { ToolStripMenuItem_SaveAs.Enabled = true; } }
/// <summary> /// 设置需要调试的动作流对象 /// </summary> /// <param name="mf"></param> public void SetMethodFlow(JFMethodFlow mf) { _methodFlow = mf; _methodFlow.WorkStatusChanged += OnMFWorkStatusChanged; _methodFlow.CustomStatusChanged += OnMFCustomStatusChanged; _methodFlow.WorkMsg2Outter += OnMFMsgInfo; if (_isFormLoaded) { AdjustView(); } }
void DataGridViewCellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 1) //调试工作流 { FormStationWorkFlowCfg dlg = new FormStationWorkFlowCfg(); string workFlowName = dgvWorkFlows.Rows[e.RowIndex].Cells[0].Value as string; dlg.SetStationWorkFlow(_station, workFlowName); dlg.ShowDialog(); } else if (e.ColumnIndex == 2) //从文件中导入 { string workFlowName = dgvWorkFlows.Rows[e.RowIndex].Cells[0].Value as string; JFMethodFlow flow = _station.GetWorkFlow(workFlowName); OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "JF流程文件(*.jff) | *.jff"; //ofd.InitialDirectory = Application.StartupPath; ofd.ValidateNames = true; ofd.CheckPathExists = true; ofd.CheckFileExists = false; if (ofd.ShowDialog() == DialogResult.OK) { if (DialogResult.OK == MessageBox.Show(string.Format("确定将文件:{0} 导入到工作流{1}?", ofd.FileName, workFlowName))) { try { flow.Load(ofd.FileName); _station.SaveCfg(); MessageBox.Show("导入成功!"); } catch (Exception ex) { MessageBox.Show("载入失败!异常信息:" + ex.ToString()); } } } } else if (e.ColumnIndex == 3) //导出工作流到文件 { string workFlowName = dgvWorkFlows.Rows[e.RowIndex].Cells[0].Value as string; JFMethodFlow flow = _station.GetWorkFlow(workFlowName); OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "JF流程文件(*.jff) | *.jff"; //ofd.InitialDirectory = Application.StartupPath; ofd.ValidateNames = true; ofd.CheckPathExists = true; ofd.CheckFileExists = false; if (ofd.ShowDialog() == DialogResult.OK) { flow.Save(ofd.FileName); MessageBox.Show("导出文件成功!"); } } }
private void button1_Click(object sender, EventArgs e) { JFMethodFlow fl = new JFMethodFlow(); fl.Load("D:\\Project\\JoinFrame\\bin\\x64\\Debug\\123.jff"); if (string.IsNullOrEmpty(fl.Name)) { fl.Name = "Hehe"; fl.Save("D:\\Project\\JoinFrame\\bin\\x64\\Debug\\123.jff"); } string txt = fl.ToTxt(); JFMethodFlow anotherJF = new JFMethodFlow(); anotherJF.FromTxt(txt); anotherJF.Save("D:\\Project\\JoinFrame\\bin\\x64\\Debug\\456.jff"); }
/// <summary> /// 从文件中加载动作流 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToolStripMenuItem_LoadFromFile_Click(object sender, EventArgs e) { if (null != methodFlow) //保存现有对象 { if (null != currFilePath) //当前对象是从文件中载入的 { if (DialogResult.Yes == MessageBox.Show("载入新流程之前,是否保存当前动作流程?", "注意", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) { methodFlow.Save(currFilePath); } } else //当前对象还没有保存到文件中 { if (DialogResult.Yes == MessageBox.Show("是否将当前动作流程保存到文件中?", "注意", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "JF流程文件(*.jff)|*.jff"; //设置文件类型 sfd.FileName = "保存"; //设置默认文件名 sfd.DefaultExt = "jff"; //设置默认格式(可以不设) sfd.AddExtension = true; //设置自动在文件名中添加扩展名 if (sfd.ShowDialog() == DialogResult.OK) { methodFlow.Save(sfd.FileName); } } } } OpenFileDialog ofd = new OpenFileDialog();; ofd.Filter = "JF流程文件(*.jff) | *.jff"; ofd.InitialDirectory = Application.StartupPath; ofd.ValidateNames = true; ofd.CheckPathExists = true; ofd.CheckFileExists = false; if (ofd.ShowDialog() == DialogResult.OK) { currFilePath = ofd.FileName; methodFlow = new JFMethodFlow(); methodFlow.Load(currFilePath); tstbFilePath.Text = currFilePath; ucMethodFlow.SetMethodFlow(methodFlow); ToolStripMenuItem_Save.Enabled = true; ToolStripMenuItem_SaveAs.Enabled = true; } }
/// <summary>新建动作流</summary> private void ToolStripMenuItem_Create_Click(object sender, EventArgs e) { if (null != methodFlow) { if (null != currFilePath) //当前对象是从文件中载入的 { if (DialogResult.Yes == MessageBox.Show("建立新流程之前,是否保存当前动作流程?", "注意", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) { methodFlow.Save(currFilePath); } } else //当前对象还没有保存到文件中 { if (DialogResult.Yes == MessageBox.Show("是否将当前动作流程保存到文件中?", "注意", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "JF流程文件(*.jff)|*.jff"; //设置文件类型 sfd.FileName = "保存"; //设置默认文件名 sfd.DefaultExt = "jff"; //设置默认格式(可以不设) sfd.AddExtension = true; //设置自动在文件名中添加扩展名 if (sfd.ShowDialog() == DialogResult.OK) { methodFlow.Save(sfd.FileName); } } } } BenameDialog bnd = new BenameDialog(); bnd.SetName("未命名方法流"); if (DialogResult.OK != bnd.ShowDialog()) { return; } currFilePath = null; methodFlow = new JFMethodFlow(); methodFlow.Name = bnd.GetName(); ucMethodFlow.SetMethodFlow(methodFlow); tstbFilePath.Text = ""; ToolStripMenuItem_Save.Enabled = false; ToolStripMenuItem_SaveAs.Enabled = true; }
void UpdateFlow2UI() { if (InvokeRequired) { Invoke(new Action(UpdateFlow2UI)); return; } if (null == _station) { lbTital.Text = "工站:未设置"; btReload.Enabled = false; btSave.Enabled = false; _ucMethodFlow.Enabled = false; return; } lbTital.Text = "工站:\"" + _station.Name + "\""; if (string.IsNullOrEmpty(_workFlowName)) { lbTital.Text += " 工作流名称为空!"; btReload.Enabled = false; btSave.Enabled = false; _ucMethodFlow.Enabled = false; return; } JFMethodFlow mf = _station.GetWorkFlow(_workFlowName); if (null == mf) { lbTital.Text += " 工作流名称:\"" + _workFlowName + "\"在工站中不存在!"; btReload.Enabled = false; btSave.Enabled = false; _ucMethodFlow.Enabled = false; return; } lbTital.Text += " 工作流名称:\"" + _workFlowName + "\" "; btReload.Enabled = true; btSave.Enabled = true; _ucMethodFlow.Enabled = true; _ucMethodFlow.SetMethodFlow(mf); }
public void SetMethodFlow(JFMethodFlow methodFlow) { ucMethodFlow.SetMethodFlow(methodFlow); }
public JFWorkFlowThreadPool(JFMethodFlow mf, int threadCount, JFStationBase stationOwner) { }
public void SetFlow(JFMethodFlow mf) { _owner = mf; }
public void SetFlow(JFMethodFlow mf) { _jf = mf; }
internal JFWorkFlowThread(JFMethodFlow methodFlow, JFStationBase stationOwner) { _methodFlow = new JFMethodFlow(); _methodFlow.FromTxt(methodFlow.ToTxt()); _methodFlow.SetStation(stationOwner); }