/// <summary> /// 获取环节信息 /// </summary> /// <param name="prodefIds"></param> /// <returns></returns> public static ActdefDataEntity GetActdefInfo(String[] prodefIds) { String url = StaticValue.ServicePath.ActdefPath; String userName = StaticValue.ServicePath.UserName; String passWord = StaticValue.ServicePath.PassWord; var tempEntity = new { processDefKeys = prodefIds }; string jsonData = JsonConvert.SerializeObject(tempEntity); String restult = RestUserLoginService.Post(url, jsonData, userName, passWord); ActdefDataEntity prodefData = JsonConvert.DeserializeObject <ActdefDataEntity[]>(restult)[0]; return(prodefData); }
/// <summary> /// 加载环节信息 /// </summary> /// <param name="nodeParent"></param> /// <param name="parentId"></param> public static void CreateActdef(Node nodeParent, String parentId) { ActdefDataEntity prodefData = GetActdefInfo(new string[] { parentId }); foreach (var actdef in prodefData.ListTaskInfor) { Node nodeChild = new Node(); nodeChild.Name = "ACTDEF_" + actdef.Task_id; nodeChild.Text = actdef.Task_name; nodeChild.Tag = actdef; nodeChild.Image = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + @"\icon\book.png"); nodeParent.Nodes.Add(nodeChild); nodeParent.Expanded = true; } }
/// <summary> /// 复制流程方案 /// </summary> /// <param name="prodefId"></param> /// <param name="lstSchemaId"></param> /// <param name="lstBCopy"></param> public static void CopyProdefSchemaToOtherProdef(String prodefId, List <String> lstSchemaId, List <Node> lstBCopy) { XmlDocument doc = new XmlDocument(); doc.Load(MProdefListXmlPath); XmlNode nodeRoot = doc.SelectSingleNode("Element"); XmlNode nodeProdef = doc.SelectSingleNode("//Prodef[@ID='" + prodefId + "']"); if (nodeProdef == null) { throw new Exception("找不到被复制对象的流程配置信息,请检查!"); } //所有选中的方案 List <XmlNode> lstSelectSchemaNode = new List <XmlNode>(); lstSchemaId.ForEach(p => { lstSelectSchemaNode.Add(nodeProdef.SelectSingleNode("ProdefChild[@ID='" + p + "']")); }); XmlNode nodeCopyToProdefXmlNode = null; XmlElement elementCopyToProdefXmlElement = null; XmlElement elementProdefSchema = null; lstBCopy.ForEach(p => { ProdefEntity prodefEntity = (ProdefEntity)p.Tag; PropackageEntity propackageEntity = (PropackageEntity)p.Parent.Tag; String copyToProdefId = prodefEntity.Id; String copyToProdefName = prodefEntity.Name; String copyToPropackageName = propackageEntity.Caption; nodeCopyToProdefXmlNode = doc.SelectSingleNode("//Prodef[@ID='" + copyToProdefId + "']"); if (nodeCopyToProdefXmlNode == null) { nodeCopyToProdefXmlNode = doc.CreateElement("Prodef"); nodeRoot.AppendChild(nodeCopyToProdefXmlNode); } elementCopyToProdefXmlElement = nodeCopyToProdefXmlNode as XmlElement; elementCopyToProdefXmlElement.SetAttribute("ID", copyToProdefId); elementCopyToProdefXmlElement.SetAttribute("Name", prodefEntity.Name); elementCopyToProdefXmlElement.SetAttribute("PackageName", propackageEntity.Caption); lstSelectSchemaNode.ForEach(t => { String newChildProdefId = Guid.NewGuid().ToString(); elementProdefSchema = doc.CreateElement("ProdefChild"); elementProdefSchema.SetAttribute("ID", newChildProdefId); elementProdefSchema.SetAttribute("Name", t.Attributes["Name"].Value + "_copy" + Guid.NewGuid().ToString()); elementCopyToProdefXmlElement.AppendChild(elementProdefSchema); //复制配置文件 String dictoryPath = AppDomain.CurrentDomain.BaseDirectory + @"\XML\"; String filePath = dictoryPath + string.Format("Prodef_{0}_{1}.xml", prodefId, t.Attributes["ID"].Value); String newFilePath = dictoryPath + string.Format("Prodef_{0}_{1}.xml", copyToProdefId, newChildProdefId); File.Copy(filePath, newFilePath, true); ActdefDataEntity actdefDataEntity = ProTree.GetActdefInfo(new string[] { prodefEntity.Key }); List <ActdefEntity> allActdef = actdefDataEntity.ListTaskInfor.ToList <ActdefEntity>(); XmlDocument docProdefDetailXml = new XmlDocument(); docProdefDetailXml.Load(newFilePath); XmlElement nodeDetailProdef = docProdefDetailXml.SelectSingleNode("//Prodef") as XmlElement; nodeDetailProdef.SetAttribute("ID", copyToProdefId); nodeDetailProdef.SetAttribute("Name", copyToProdefName); nodeDetailProdef.SetAttribute("PackageName", copyToPropackageName); allActdef.ForEach(o => { XmlNode nodeDetailActdef = nodeDetailProdef.SelectSingleNode("Actdef[@Name='" + o.Task_name + "']"); if (nodeDetailActdef != null) { XmlElement elementDetailActdef = nodeDetailActdef as XmlElement; elementDetailActdef.SetAttribute("ID", o.Task_id); } }); docProdefDetailXml.Save(newFilePath); }); }); doc.Save(MProdefListXmlPath); }