private ProcessEntity GetProcessEntity(string processUid, string billUid) { ProcessEntity entity = null; WfProcess wfProcess = _dataAccessor.Get <WfProcess>(processUid); if (wfProcess != null) { entity = new ProcessEntity(); dynamic bizData = _dataAccessor.Get(wfProcess.BillTable, billUid); var processInstance = _dataAccessor.QueryFirstOrDefaultWhere <WfProcessInstance>("ProcessUid=@ProcessUid and BillUid=@BillUid", new DynamicParameters(new { ProcessUid = processUid, BillUid = billUid })); if (processInstance == null) { WfDiagram diagram = _dataAccessor.Get <WfDiagram>(wfProcess.DiagramId); entity.XmlContent = diagram.XmlContent; } else { var diagramInstance = _dataAccessor.QueryFirstOrDefaultWhere <WfDiagramInstance>("ProcessInsUid=@ProcessInsUid", new DynamicParameters(new { ProcessInsUid = processInstance.Fid })); entity.XmlContent = diagramInstance.XmlContent; } entity.ProcessUid = wfProcess.Fid; entity.ProcessName = wfProcess.ProcessName; entity.AppType = wfProcess.ProcessGroupUid; entity.IsUsing = wfProcess.Status == WfProcessState.Using; entity.Version = wfProcess.Version; entity.BizData = bizData; } else { _logger.LogError($"数据库没有对应的流程定义记录,模板{processUid}"); } return(entity); }
public void UpgradeProcessTemplateDirectly(long id) { WfProcess wfProcess = _dataAccessor.Get <WfProcess>(id); if (wfProcess != null) { WfProcess newWfProcess = wfProcess.Clone() as WfProcess; //升级流程图 newWfProcess.Fid = UUIDUtils.Fid; newWfProcess.Version += 1; //升级流程图 WfDiagram wfDiagram = _dataAccessor.Get <WfDiagram>(wfProcess.DiagramId); if (wfDiagram != null) { wfDiagram.Version = newWfProcess.Version; wfDiagram.Fid = UUIDUtils.Fid; wfDiagram.ProcessUid = newWfProcess.Fid; _dataAccessor.Insert <WfDiagram>(wfDiagram); } //更新升级后的流程模板 newWfProcess.DiagramId = wfDiagram.Fid; _dataAccessor.Insert <WfProcess>(newWfProcess); //将原来的流程模板变成历史状态 wfProcess.Status = WfProcessState.Historical; _dataAccessor.Update <WfProcess>(wfProcess); } }
/// <summary> /// 设计 /// </summary> /// <returns></returns> public IActionResult Design(string fid) { WfProcess tmplate = _dbContext.Get <WfProcess>(fid); string diagramUid = tmplate.DiagramId; WfDiagram diagram = null; string xml = string.Empty; if (diagramUid.IsPresent()) { diagram = _dbContext.Get <WfDiagram>(diagramUid); } if (diagram == null) { diagram = new WfDiagram() { Fid = UUIDUtils.Fid, ProcessName = tmplate.ProcessName, XmlContent = "" }; } if (diagram.XmlContent.IsMissing()) { xml = string.Join("", new string[] { $"<mxGraphModel dx=\"1426\" dy=\"779\" grid=\"1\" gridSize=\"10\" guides=\"1\" tooltips=\"1\" connect=\"1\" arrows=\"1\" fold=\"1\" page=\"1\" pageScale=\"1\" pageWidth=\"827\" pageHeight=\"1169\" wfProcessUid=\"{fid}\" wfDiagramUid=\"{diagram.Fid}\" wfDiagramName=\"{diagram.ProcessName}\" wfDesc=\"\" wfResultNotice=\"1\" wfSuspendNotice=\"0\" wfMail=\"1\" wfMessage=\"1\" frmType=\"Internal\" billTable=\"\" background=\"#ffffff\">", " <root>", " <mxCell id=\"0\"/>", " <mxCell id=\"1\" parent=\"0\"/> ", " </root>", "</mxGraphModel>" }); } else { xml = diagram.XmlContent.Replace("workflowProcess", "mxGraphModel"); } ViewBag.XML = xml; return(View()); }
public void SaveProcessTemplate(string xml) { xml = xml.Replace("mxGraphModel", "workflowProcess"); XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); var workflowNode = doc.GetElementsByTagName("workflowProcess")[0]; string processUid = XMLHelper.GetXmlAttribute(workflowNode, "wfProcessUid"); string diagramUid = XMLHelper.GetXmlAttribute(workflowNode, "wfDiagramUid"); string diagramName = XMLHelper.GetXmlAttribute(workflowNode, "wfDiagramName"); string formType = XMLHelper.GetXmlAttribute(workflowNode, "frmType"); string billTable = XMLHelper.GetXmlAttribute(workflowNode, "billTable"); string formTemplate = XMLHelper.GetXmlAttribute(workflowNode, "billTemplate"); string notice = XMLHelper.GetXmlAttribute(workflowNode, "wfResultNotice"); string suspendNotice = XMLHelper.GetXmlAttribute(workflowNode, "wfSuspendNotice"); string wfMail = XMLHelper.GetXmlAttribute(workflowNode, "wfMail"); string wfMessage = XMLHelper.GetXmlAttribute(workflowNode, "wfMessage"); string messageSetting = $"{{'notice':{notice},'suspend':{suspendNotice},'mail':{wfMail},'message':{wfMessage}}}"; WfDiagram wfDiagram = _dataAccessor.Get <WfDiagram>(diagramUid); WfProcess wfProcess = _dataAccessor.Get <WfProcess>(processUid); wfProcess.DiagramId = diagramUid; wfProcess.ProcessName = diagramName; wfProcess.FormType = formType; wfProcess.FormTemplateUid = formTemplate; wfProcess.BillTable = billTable; wfProcess.MessageSetting = messageSetting; if (wfDiagram == null) { //新增 wfDiagram = new WfDiagram() { Fid = diagramUid, ProcessName = diagramName, ProcessUid = processUid, XmlContent = xml }; //保存流程图 _dataAccessor.Insert <WfDiagram>(wfDiagram); _dataAccessor.Update <WfProcess>(wfProcess); } else //更新 { wfDiagram.ProcessName = diagramName; wfDiagram.XmlContent = xml; //保存流程图 _dataAccessor.Update <WfDiagram>(wfDiagram); _dataAccessor.Update <WfProcess>(wfProcess); } }