public Flow GetFlow(int id) { string sql = "select * from Flow where ID=" + id; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { int templateId = Convert.ToInt32(dt.Rows[0]["TemplateID"]); FlowTemplate template = FlowTemplateLogic.GetInstance().GetFlowTemplate(templateId); List <TaskStage> stages = new List <TaskStage>(); string stagesIds = dt.Rows[0]["Stages"].ToString(); string[] stageIdList = stagesIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (string stageId in stageIdList) { TaskStage stage = TaskStageLogic.GetInstance().GetTaskStage(Convert.ToInt32(stageId)); if (stage != null) { stages.Add(stage); } } Flow element = new Flow(Convert.ToInt32(dt.Rows[0]["ID"]), dt.Rows[0]["Name"].ToString(), template, Convert.ToInt32(dt.Rows[0]["CurrentIndex"]), dt.Rows[0]["Remark"].ToString(), stages); return(element); } return(null); }
public List <Flow> GetAllFlows() { List <Flow> elements = new List <Flow>(); string sql = "select * from Flow order by ID desc"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { TaskStageLogic tsl = TaskStageLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { FlowTemplate template = FlowTemplateLogic.GetInstance().GetFlowTemplate(Convert.ToInt32(dt.Rows[i]["TemplateID"])); List <TaskStage> stages = new List <TaskStage>(); string stagesIds = dt.Rows[i]["Stages"].ToString(); string[] stageIdList = stagesIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (string stageId in stageIdList) { TaskStage stage = TaskStageLogic.GetInstance().GetTaskStage(Convert.ToInt32(stageId)); if (stage != null) { stages.Add(stage); } } Flow element = new Flow(Convert.ToInt32(dt.Rows[i]["ID"]), dt.Rows[i]["Name"].ToString(), template, Convert.ToInt32(dt.Rows[i]["CurrentIndex"]), dt.Rows[i]["Remark"].ToString(), stages); elements.Add(element); } } return(elements); }
private void button1_Click(object sender, EventArgs e) { if (alert != null) { switch (alert.提醒方式) { case 提醒方式.系统提示: bool f = AlertLogic.GetInstance().SetFlag(alert.ID, 1); if (!f) { MessageBox.Show("已阅置位失败!"); } else { this.Close(); } break; case 提醒方式.执行流程: DocObject doc = DocObjectLogic.GetInstance().GetDocObject(Convert.ToInt32(alert.备注)); if (doc != null) { TaskInfo task = TaskInfoLogic.GetInstance().GetTaskInfoByEntityId(doc.ID); if (task != null) { TaskStageLogic.GetInstance().SetReceiveToExec(task.Flow.Current.ID); } DocEditForm def = new DocEditForm(this.User, this.owner, doc.Form, doc, alert.ID); if (def.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.Close(); } } break; case 提醒方式.审批流程: DocObject doc2 = DocObjectLogic.GetInstance().GetDocObject(Convert.ToInt32(alert.备注)); if (doc2 != null) { TaskInfo task = TaskInfoLogic.GetInstance().GetTaskInfoByEntityId(doc2.ID); if (task != null) { TaskStageLogic.GetInstance().SetReceiveToExec(task.Flow.Current.ID); } DocEditForm def = new DocEditForm(this.User, this.owner, doc2.Form, doc2, alert.ID); if (def.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.Close(); } } break; default: break; } } }
public static TaskStageLogic GetInstance() { if (instance == null) { instance = new TaskStageLogic(); } return(instance); }
/// <summary> /// 获取指定的流程 /// </summary> /// <param name="name"></param> /// <param name="status">1为未完成,2为已完成,其他为所有</param> /// <returns></returns> public List <Flow> GetFlows(string name, int status) { List <Flow> elements = new List <Flow>(); string where = "where (1=1)"; if (!string.IsNullOrEmpty(name)) { where += " and Name like '%" + name + "%'"; } string sql = "select * from Flow " + where + " order by ID desc"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { TaskStageLogic tsl = TaskStageLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { FlowTemplate template = FlowTemplateLogic.GetInstance().GetFlowTemplate(Convert.ToInt32(dt.Rows[i]["TemplateID"])); List <TaskStage> stages = new List <TaskStage>(); string stagesIds = dt.Rows[i]["Stages"].ToString(); string[] stageIdList = stagesIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (string stageId in stageIdList) { TaskStage stage = TaskStageLogic.GetInstance().GetTaskStage(Convert.ToInt32(stageId)); if (stage != null) { stages.Add(stage); } } int currentIndex = Convert.ToInt32(dt.Rows[i]["CurrentIndex"]); Flow element = new Flow(Convert.ToInt32(dt.Rows[i]["ID"]), dt.Rows[i]["Name"].ToString(), template, currentIndex, dt.Rows[i]["Remark"].ToString(), stages); if (status == 1) { if ((currentIndex < stages.Count - 1) || (currentIndex == stages.Count - 1 && stages[stages.Count - 1].Status != TaskStatus.Finished)) { elements.Add(element); } } else if (status == 2) { if (currentIndex == stages.Count - 1 && stages[stages.Count - 1].Status == TaskStatus.Finished) { elements.Add(element); } } else { 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("请先选择一个流程模板!"); } }