private void button2_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex > -1) { MessageBox.Show("警告:删除流程后将会影响到该流程模板中涉及到的所有执行者和审批者的工作!"); if (MessageBox.Show("确定要删除该流程么?", "删除提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { Flow flow = (Flow)listBox1.SelectedItem; if (flow != null) { if (FlowLogic.GetInstance().DeleteFlow(flow)) { MessageBox.Show("删除成功!"); int C = domainUpDown1.SelectedIndex; List <Flow> result = Search(textBox1.Text.Trim(), C); LoadFlows(result); } else { MessageBox.Show("删除失败!"); } } } } else { MessageBox.Show("请先选定要删除的流程!"); } }
public int AddTaskInfo(TaskInfo element) { string sql = "insert into TaskInfo (EntityId, FlowID, Sponsor, Remark) values (" + element.EntityId + ", " + element.Flow.ID + ", '" + element.Sponsor + "', '" + element.Remark + "'); select SCOPE_IDENTITY()"; object obj = sqlHelper.ExecuteSqlReturn(sql); int R; if (obj != null && obj != DBNull.Value && int.TryParse(obj.ToString(), out R)) { Flow flow = FlowLogic.GetInstance().GetFlow(element.Flow.ID); if (flow != null) { FlowTemplate temp = FlowTemplateLogic.GetInstance().GetFlowTemplate(flow.Template.ID); if (temp != null) { Alert alert = new Alert(); alert.提醒对象 = string.Join(",", temp.Stages[flow.CurrentIndex].Executors.ToArray()); alert.提醒方式 = 提醒方式.执行流程; alert.提醒时间 = DateTime.Now; alert.提醒项目 = flow.Name; alert.备注 = flow.ID.ToString(); AlertLogic.GetInstance().AddAlert(alert); Alert alert2 = new Alert(); alert2.提醒对象 = string.Join(",", temp.Stages[flow.CurrentIndex].Approvers.ToArray()); alert2.提醒方式 = 提醒方式.审批流程; alert2.提醒时间 = DateTime.Now; alert2.提醒项目 = flow.Name; alert.备注 = flow.ID.ToString(); AlertLogic.GetInstance().AddAlert(alert2); return(R); } } } return(0); }
private void FlowListForm_Load(object sender, EventArgs e) { List <Flow> flows = FlowLogic.GetInstance().GetAllFlows(); LoadFlows(flows); LoadFlowStatuses(); }
public static FlowLogic GetInstance() { if (instance == null) { instance = new FlowLogic(); } return(instance); }
public TaskInfo GetTaskInfoByEntityId(int entityId) { string sql = "select * from TaskInfo where EntityId=" + entityId; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { FlowLogic ftl = FlowLogic.GetInstance(); TaskInfo element = new TaskInfo(Convert.ToInt32(dt.Rows[0]["ID"]), Convert.ToInt32(dt.Rows[0]["EntityId"]), ftl.GetFlow(Convert.ToInt32(dt.Rows[0]["FlowID"])), dt.Rows[0]["Sponsor"].ToString(), dt.Rows[0]["Remark"].ToString()); return(element); } return(null); }
public List <TaskInfo> GetAllTaskInfos() { List <TaskInfo> elements = new List <TaskInfo>(); string sql = "select * from TaskInfo"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { FlowLogic ftl = FlowLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { TaskInfo element = new TaskInfo(Convert.ToInt32(dt.Rows[i]["ID"]), Convert.ToInt32(dt.Rows[i]["EntityId"]), ftl.GetFlow(Convert.ToInt32(dt.Rows[i]["FlowID"])), dt.Rows[i]["Sponsor"].ToString(), dt.Rows[i]["Remark"].ToString()); elements.Add(element); } } return(elements); }
private void button1_Click(object sender, EventArgs e) { DocObjectLogic dol = DocObjectLogic.GetInstance(); if (doc != null) { if (dol.UpdateDocObject(Document, this.User)) { MessageBox.Show("保存文档成功!"); if (appr > 0) { TaskInfo task = TaskInfoLogic.GetInstance().GetTaskInfoByEntityId(doc.ID); if (task != null) { bool flag = false; string err = ""; if (exeORapp == 0) { if (task.Flow.Execute()) { if (FlowLogic.GetInstance().UpdateFlow(task.Flow)) { if (TaskStageLogic.GetInstance().SetActualExec(task.Flow.Current.ID, this.User)) { flag = true; } else { err = "SetActualExec失败"; } } else { err = "UpdateFlow失败"; } } else { err = "Execute失败"; } } else if (exeORapp == 1) { if (task.Flow.Approve()) { if (FlowLogic.GetInstance().UpdateFlow(task.Flow)) { if (TaskStageLogic.GetInstance().SetActualAppr(task.Flow.Current.ID, this.User)) { flag = true; } else { err = "SetActualAppr失败"; } } else { err = "UpdateFlow失败"; } } else { err = "Approve失败"; } } if (flag) { AlertLogic.GetInstance().SetFlag(appr, 1); MessageBox.Show("执行审批成功!"); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBox.Show("执行审批失败。[exeORapp=" + exeORapp + ", err=" + err + "]"); } } else { MessageBox.Show("执行审批失败。"); } } else { this.DialogResult = System.Windows.Forms.DialogResult.OK; } } else { MessageBox.Show("保存文档失败或者您没有权限修改别人的文档!"); } } else { int id = dol.AddDocObject(Document); if (id > 0) { doc.ID = id; MessageBox.Show("新建文档成功!如果需要对该文档做流程,请在右下角点击【设置审批】来生成流程!"); } else { MessageBox.Show("新建文档失败!"); } } }
private void Next() { if (listBox1.SelectedIndex > -1) { FlowTemplate temp = listBox1.SelectedItem as FlowTemplate; if (temp != null) { List <TaskStage> stages = new List <TaskStage>(); foreach (TaskStageTemplate stage in temp.Stages) { TaskStage s = new TaskStage(0, stage.Name, stage, TaskStatus.Initiative, "", "", DateTime.MinValue, DateTime.MinValue, ""); int i = TaskStageLogic.GetInstance().AddTaskStage(s); if (i > 0) { s.ID = i; stages.Add(s); } } string docName = doc.Name; Flow flow = new Flow(0, docName + "(" + temp.Name + ")", temp, -1, "", stages); int r = FlowLogic.GetInstance().AddFlow(flow); if (r > 0) { flow.ID = r; if (FlowLogic.GetInstance().StartFlow(r)) { flow.StartFlow(); TaskInfo task = new TaskInfo(0, doc.ID, flow, this.User.Username, "创建时间:" + DateTime.Now.ToString()); if (TaskInfoLogic.GetInstance().AddTaskInfo(task) > 0) { MessageBox.Show("建立流程任务成功!"); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBox.Show("建立流程任务失败!"); this.DialogResult = System.Windows.Forms.DialogResult.Ignore; } } else { MessageBox.Show("启动流程失败!"); this.DialogResult = System.Windows.Forms.DialogResult.Ignore; } } else { MessageBox.Show("建立流程到数据库失败!"); this.DialogResult = System.Windows.Forms.DialogResult.Ignore; } //this.Close(); } else { MessageBox.Show("您选择的流程模板为空!"); } } else { MessageBox.Show("请先选择一个流程模板!"); } }
private List <Flow> Search(string name, int status) { return(FlowLogic.GetInstance().GetFlows(name, status)); }