public static ProcessSettingsEntity GetProcessSettings(int procSetId) { try { ProcessSettingsEntity entity = new ProcessSettingsEntity(); if (File.Exists(K2ProcessSettingsPath)) { XmlDocument doc = new XmlDocument(); doc.Load(K2ProcessSettingsPath); XmlNode node = doc.SelectSingleNode("/Root/Process[@ProcSetId='" + procSetId.ToString() + "']"); if (node != null) { entity.StartPage = GetNodeValue(node, "./StartPage"); entity.ViewPage = GetNodeValue(node, "./ViewPage"); entity.EditPage = GetNodeValue(node, "./EditPage"); entity.Description = GetNodeValue(node, "./Description"); } } return(entity); } catch { return(new ProcessSettingsEntity()); } }
private static string K2ProcessSettingsPath = HttpContext.Current.Server.MapPath("~/WorkSpace/XML/K2ProcessSettings.xml");//General.GetConstValue("K2ProcessSettingFile");// #region GetProcessSettings public static List <ProcessSettingsEntity> GetAllProcessSettings() { List <ProcessSettingsEntity> listProcSettings = new List <ProcessSettingsEntity>(); try { XmlDocument doc = new XmlDocument(); doc.Load(K2ProcessSettingsPath); XmlNodeList nodeList = doc.SelectNodes("/Root/Process"); if (nodeList != null && nodeList.Count > 0) { foreach (XmlNode node in nodeList) { if (node == null) { continue; } ProcessSettingsEntity entity = new ProcessSettingsEntity(); entity.StartPage = GetNodeValue(node, "./StartPage"); entity.ViewPage = GetNodeValue(node, "./ViewPage"); entity.EditPage = GetNodeValue(node, "./EditPage"); string Destription = GetNodeValue(node, "./Description"); entity.ProcessFullName = GetNodeValue(node, "./ProcessFullName"); if (Destription == "") { entity.Description = GetNodeValue(node, "./ProcessName"); } else { entity.Description = Destription; } listProcSettings.Add(entity); } } return(listProcSettings); } catch { return(listProcSettings); } }
public static void UpdateProcessSettings(ProcessSettingsEntity entity) { XmlDocument doc = new XmlDocument(); if (File.Exists(K2ProcessSettingsPath)) { doc.Load(K2ProcessSettingsPath); } else { doc.LoadXml("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><Root></Root>"); } XmlNode node = doc.SelectSingleNode("/Root/Process[@ProcSetId='" + entity.ProcSetId.ToString() + "']"); if (node == null) { XmlElement newNode = doc.CreateElement("Process"); newNode.SetAttribute("ProcSetId", entity.ProcSetId.ToString()); newNode.AppendChild(CreateChildNodeWidthValue(doc, "ProcessName", entity.ProcessName)); newNode.AppendChild(CreateChildNodeWidthValue(doc, "Folder", entity.Folder)); newNode.AppendChild(CreateChildNodeWidthValue(doc, "ProcessFullName", entity.ProcessFullName)); newNode.AppendChild(CreateChildNodeWidthValue(doc, "StartPage", entity.StartPage)); newNode.AppendChild(CreateChildNodeWidthValue(doc, "ViewPage", entity.ViewPage)); newNode.AppendChild(CreateChildNodeWidthValue(doc, "EditPage", entity.EditPage)); newNode.AppendChild(CreateChildNodeWidthValue(doc, "Description", entity.Description)); XmlNode rootNode = doc.SelectSingleNode("/Root"); rootNode.AppendChild(newNode); } else { XmlNode child; //Processname //child = node.SelectSingleNode("./ProcessName"); //if (child == null) //{ // node.AppendChild(CreateChildNodeWidthValue(doc, "ProcessName", entity.ProcessName)); //} //else //{ // child.InnerText = entity.ProcessName; //} //Folder //child = node.SelectSingleNode("./Folder"); //if (child == null) //{ // node.AppendChild(CreateChildNodeWidthValue(doc, "Folder", entity.Folder)); //} //else //{ // child.InnerText = entity.Folder; //} //ProcessFullName //child = node.SelectSingleNode("./ProcessFullName"); //if (child == null) //{ // node.AppendChild(CreateChildNodeWidthValue(doc, "ProcessFullName", entity.ProcessFullName)); //} //else //{ // child.InnerText = entity.ProcessFullName; //} //StartPage child = node.SelectSingleNode("./StartPage"); if (child == null) { node.AppendChild(CreateChildNodeWidthValue(doc, "StartPage", entity.StartPage)); } else { child.InnerText = entity.StartPage; } //ViewPage child = node.SelectSingleNode("./ViewPage"); if (child == null) { node.AppendChild(CreateChildNodeWidthValue(doc, "ViewPage", entity.ViewPage)); } else { child.InnerText = entity.ViewPage; } //EditPage child = node.SelectSingleNode("./EditPage"); if (child == null) { node.AppendChild(CreateChildNodeWidthValue(doc, "EditPage", entity.EditPage)); } else { child.InnerText = entity.EditPage; } //Description child = node.SelectSingleNode("./Description"); if (child == null) { node.AppendChild(CreateChildNodeWidthValue(doc, "Description", entity.Description)); } else { child.InnerText = entity.Description; } } doc.Save(K2ProcessSettingsPath); }