/// <summary> /// 获取工作流设置信息 /// </summary> /// <param name="t">类型</param> /// <returns></returns> public static Neusoft.HISFC.Models.Base.WorkFlow GetWorkFlowSetting(string groupName, string state) { System.Xml.XmlDocument doc = Function.GetConfig("WorkFlow.xml"); if (doc == null) { return(null); } System.Xml.XmlNode wfNode = doc.SelectSingleNode(string.Format("/WorkFlow/Group[@ID='{0}']/State[@ID='{1}']", groupName, state)); if (wfNode != null) { Neusoft.HISFC.Models.Base.WorkFlow wfObject = new Neusoft.HISFC.Models.Base.WorkFlow(); wfObject.State = wfNode.Attributes["ID"].Value; wfObject.NextState = wfNode.Attributes["Next"].Value; System.Xml.XmlNode competenceNode = wfNode.SelectSingleNode(string.Format("/WorkFlow/Group[@ID='{0}']/State[@ID='{1}']/Competence", groupName, state)); wfObject.CompetenceList = new List <string>(); foreach (System.Xml.XmlNode node in competenceNode.ChildNodes) { if (node.Name == "IsNeed") { wfObject.IsNeedCompetence = Neusoft.FrameWork.Function.NConvert.ToBoolean(node.InnerText); } else if (node.Name == "Code") { foreach (System.Xml.XmlNode codeNode in node.ChildNodes) { if (codeNode.Name == "Value") { wfObject.CompetenceList.Add(codeNode.InnerText); } } } } System.Xml.XmlNode paramNode = wfNode.SelectSingleNode(string.Format("/WorkFlow/Group[@ID='{0}']/State[@ID='{1}']/Params", groupName, state)); wfObject.ParamList = new List <Neusoft.FrameWork.Models.NeuObject>(); foreach (System.Xml.XmlNode node in paramNode.ChildNodes) { if (node.NodeType != System.Xml.XmlNodeType.Comment) { Neusoft.FrameWork.Models.NeuObject info = new Neusoft.FrameWork.Models.NeuObject(); info.ID = node.Name; info.Name = node.InnerText; wfObject.ParamList.Add(info); } } return(wfObject); } return(null); }
/// <summary> /// 设置工作流设置信息 /// </summary> /// <param name="t">类型</param> /// <returns></returns> public static int SetWorkFlowSetting <T>(T t, string groupName, string state) { Neusoft.HISFC.Models.Base.WorkFlow wf = Function.GetWorkFlowSetting(groupName, state); if (wf == null) { return(-1); } Type type = typeof(T); try { foreach (Neusoft.FrameWork.Models.NeuObject property in wf.ParamList) { if (property.Name == "") { continue; } System.Reflection.PropertyInfo p = type.GetProperty(property.ID); if (p == null) { continue; } object pValue = null; switch (p.PropertyType.FullName) { case "System.String": pValue = property.Name; break; case "System.Boolenn": pValue = Neusoft.FrameWork.Function.NConvert.ToBoolean(property.Name); break; case "System.Int32": pValue = Neusoft.FrameWork.Function.NConvert.ToInt32(property.Name); break; case "System.Decimal": pValue = Neusoft.FrameWork.Function.NConvert.ToDecimal(property.Name); break; case "System.DateTime": pValue = Neusoft.FrameWork.Function.NConvert.ToDateTime(property.Name); break; case "System.Enum": pValue = Enum.Parse(p.PropertyType, property.Name); break; } p.SetValue(t, pValue, null); } } catch (Exception e) { MessageBox.Show(e.Message); } return(1); }