public static TUpdateKepServRspBody LoadFromXMLNode(XmlNode node) { TUpdateKepServRspBody rlt = new TUpdateKepServRspBody(); rlt = IRAPXMLUtils.LoadValueFromXMLNode(GetEX(node), rlt) as TUpdateKepServRspBody; return(rlt); }
public ESBConfigurationParam(string fileName) { XmlDocument xml = new XmlDocument(); try { xml.Load(fileName); } catch (Exception) { return; } XmlNode parentNode = xml.SelectSingleNode("root/ESBParams"); foreach (XmlNode childNode in parentNode.ChildNodes) { if (childNode.Name == "ESBParam") { BrokeUri = IRAPXMLUtils.GetXMLNodeAttributeValue(childNode, "BrokeUri"); QueueName = IRAPXMLUtils.GetXMLNodeAttributeValue(childNode, "QueueName"); Filter = IRAPXMLUtils.GetXMLNodeAttributeValue(childNode, "Filter"); ExCode = IRAPXMLUtils.GetXMLNodeAttributeValue(childNode, "ExCode"); break; } } }
public static TIRAPTagT20Object CreateInstance(XmlNode node) { if (node.Name != "Row") { return(null); } TIRAPTagT20Object rlt = new TIRAPTagT20Object() { Ordinal = Tools.ConvertToInt32(IRAPXMLUtils.GetXMLNodeAttributeValue(node, "Ordinal"), 0), T20LeafID = Tools.ConvertToInt32(IRAPXMLUtils.GetXMLNodeAttributeValue(node, "T20LeafID"), 0), ParameterName = IRAPXMLUtils.GetXMLNodeAttributeValue(node, "ParameterName"), LowLimit = Tools.ConvertToInt64(IRAPXMLUtils.GetXMLNodeAttributeValue(node, "LowLimit"), 0), Criterion = IRAPXMLUtils.GetXMLNodeAttributeValue(node, "Criterion"), HighLimit = Tools.ConvertToInt64(IRAPXMLUtils.GetXMLNodeAttributeValue(node, "HighLimit"), 0), Scale = Tools.ConvertToInt32(IRAPXMLUtils.GetXMLNodeAttributeValue(node, "Scale"), 0), UnitOfMeasure = IRAPXMLUtils.GetXMLNodeAttributeValue(node, "UnitOfMeasure"), RecordingMode = Tools.ConvertToInt32(IRAPXMLUtils.GetXMLNodeAttributeValue(node, "RecordingMode"), 0), SamplingCycle = Tools.ConvertToInt32(IRAPXMLUtils.GetXMLNodeAttributeValue(node, "SamplingCycle"), 0), RTDBDSLinkID = Tools.ConvertToInt32(IRAPXMLUtils.GetXMLNodeAttributeValue(node, "RTDBDSLinkID"), 0), RTDBTagName = IRAPXMLUtils.GetXMLNodeAttributeValue(node, "RTDBTagName"), Reference = Tools.ConvertToInt32(IRAPXMLUtils.GetXMLNodeAttributeValue(node, "Reference"), 0), StartPosition = Tools.ConvertToInt32(IRAPXMLUtils.GetXMLNodeAttributeValue(node, "StartPosition"), 0), EndPosition = Tools.ConvertToInt32(IRAPXMLUtils.GetXMLNodeAttributeValue(node, "EndPosition"), 0), }; return(rlt); }
public XmlNode GenerateXMLNode() { XmlDocument xml = new XmlDocument(); XmlNode node = xml.CreateElement("Tag"); return(IRAPXMLUtils.GenerateXMLAttribute(node, this)); }
/// <summary> /// 根据 XMLNode 创建 TIRAPOPCTag 实例 /// </summary> /// <param name="node"></param> /// <returns></returns> public static TIRAPOPCTag CreateInstance(XmlNode node) { if (node.Name != "Tag") { return(null); } TIRAPOPCTag rlt = new TIRAPOPCTag(); rlt.TagLeafID = Tools.ConvertToInt32(IRAPXMLUtils.GetXMLNodeAttributeValue(node, "TagLeafID")); rlt.TagName = IRAPXMLUtils.GetXMLNodeAttributeValue(node, "TagName"); rlt.TagType = Tools.ConvertToInt32(IRAPXMLUtils.GetXMLNodeAttributeValue(node, "TagType")); rlt.TestItems.Clear(); foreach (XmlNode child in node.ChildNodes) { TIRAPTagT20Object item = TIRAPTagT20Object.CreateInstance(child); if (item != null) { rlt.TestItems.Add(item); } } return(rlt); }
public Settings(string fileName) { XmlDocument xml = new XmlDocument(); try { xml.Load(fileName); } catch { return; } XmlNode rootNode = xml.SelectSingleNode("root/SystemParams"); foreach (XmlNode node in rootNode.ChildNodes) { if (node.Name == "Param") { settings.Add( new Setting() { Key = IRAPXMLUtils.GetXMLNodeAttributeValue(node, "Key"), Value = IRAPXMLUtils.GetXMLNodeAttributeValue(node, "Value"), }); } } }
public XmlNode GenerateXMLNode() { XmlDocument xml = new XmlDocument(); XmlNode node = xml.CreateElement("OPCServer"); node = IRAPXMLUtils.GenerateXMLAttribute(node, this); return(node); }
/// <summary> /// 将注册到内存中的交易代码列表持久化到指定的本地 XML 文件中 /// </summary> /// <param name="dataFileName">持久化的本地 XML 文件名</param> public void Save(string dataFileName) { XmlDocument xml = new XmlDocument(); XmlNode rootNode = null; if (!File.Exists(dataFileName)) { xml.AppendChild(xml.CreateXmlDeclaration("1.0", "utf-8", "")); rootNode = xml.AppendChild(xml.CreateElement("root")); rootNode = rootNode.AppendChild(xml.CreateElement("Configuration")); } else { try { xml.Load(dataFileName); } catch (Exception error) { Debug.WriteLine(string.Format("加载[{0}]文件时出错:[{1}]", dataFileName, error.Message)); return; } rootNode = xml.SelectSingleNode("root/Configuration"); if (rootNode == null) { Debug.WriteLine( string.Format( "[{0}] 文件中不存在 root/Configuration 根节点")); return; } } // 在 rootNode 的第一层子节点中查找 ExCodes 节点,如果没有找到则创建 foreach (XmlNode node in rootNode.ChildNodes) { if (node.Name == "ExCodes") { rootNode.RemoveChild(node); } } XmlNode excodeNode = xml.CreateElement("ExCodes"); rootNode.AppendChild(excodeNode); foreach (TEntityExCode excode in excodes.Values) { XmlNode node = xml.CreateElement("ExCode"); node = IRAPXMLUtils.GenerateXMLAttribute(node, excode); excodeNode.AppendChild(node); } xml.Save(dataFileName); }
protected override XmlNode GenerateUserDefineNode() { XmlDocument xml = new XmlDocument(); XmlNode result = xml.CreateElement("Result"); XmlNode node = xml.CreateElement("Param"); node = IRAPXMLUtils.GenerateXMLAttribute(node, this); result.AppendChild(node); return(result); }
public static TGetKepServListRspDetail LoadFromXMLNode(XmlNode node) { if (node.Name != "Row") { return(null); } TGetKepServListRspDetail rlt = new TGetKepServListRspDetail(); rlt = IRAPXMLUtils.LoadValueFromXMLNode(node, rlt) as TGetKepServListRspDetail; return(rlt); }
public static TUpdateKepServReqBody LoadFromXMLNode(XmlNode node) { if (!node.HasChildNodes) { Exception error = new Exception(); error.Data["ErrCode"] = "900001"; error.Data["ErrText"] = string.Format("XML 节点 [{0}] 是空节点", node.Name); throw error; } // 筛选出第一个 Parameters 节点,其余的 Parameters 节点忽略 XmlNode paramNode = null; foreach (XmlNode child in node.ChildNodes) { if (child.Name == "Parameters") { paramNode = child; break; } } // 如果不存在 Parameters 节点,则返回 null 值 if (paramNode == null) { Exception error = new Exception(); error.Data["ErrCode"] = "900001"; error.Data["ErrText"] = string.Format("XML 节点 [{0}] 是空节点", paramNode.Name); throw error; } // 筛选出第一个 Param 节点并解析生成 TUpdateDeviceTagsReqBody 对象,其余节点忽略 TUpdateKepServReqBody rlt = null; foreach (XmlNode child in paramNode.ChildNodes) { if (child.Name == "Param") { rlt = new TUpdateKepServReqBody(); rlt = IRAPXMLUtils.LoadValueFromXMLNode(child, rlt) as TUpdateKepServReqBody; break; } } // 如果不存在 Param 节点,则返回 null 值 if (rlt == null) { Exception error = new Exception(); error.Data["ErrCode"] = "900001"; error.Data["ErrText"] = string.Format("XML 节点 [{0}] 中没有找到 Param 节点", paramNode.Name); throw error; } return(rlt); }
public static TIRAPOPCKepDeviceTagInfo LoadFromXMLNode(XmlNode node) { if (node.Name == "Tag" || node.Name == "Row") { TIRAPOPCKepDeviceTagInfo rlt = new TIRAPOPCKepDeviceTagInfo(); return(IRAPXMLUtils.LoadValueFromXMLNode(node, rlt) as TIRAPOPCKepDeviceTagInfo); } else { return(null); } }
public static TUpdateDeviceTagsReqDetail LoadFromXMLNode(XmlNode node) { if (node.Name != "Row") { return(null); } TUpdateDeviceTagsReqDetail rlt = new TUpdateDeviceTagsReqDetail(); rlt = IRAPXMLUtils.LoadValueFromXMLNode(node, rlt) as TUpdateDeviceTagsReqDetail; return(rlt); }
public static TDeviceTagValueRWReqBodyTag LoadFromXMLNode(XmlNode node) { if (node.Name != "Tag") { return(null); } TDeviceTagValueRWReqBodyTag rlt = new TDeviceTagValueRWReqBodyTag(); rlt = IRAPXMLUtils.LoadValueFromXMLNode(node, rlt) as TDeviceTagValueRWReqBodyTag; return(rlt); }
/// <summary> /// 从 XML 节点的子节点中导入已注册的交易代码列表 /// </summary> /// <param name="parentNode">XML 节点(ExCodes)</param> public void Load(XmlNode parentNode) { foreach (XmlNode node in parentNode.ChildNodes) { if (node.NodeType == XmlNodeType.Element) { TEntityClient client = new TEntityClient(); client = IRAPXMLUtils.LoadValueFromXMLNode(node, client) as TEntityClient; AddItem(client); } } }
/// <summary> /// 从 XML 节点的子节点中导入已注册的交易代码列表 /// </summary> /// <param name="parentNode">XML 节点(ExCodes)</param> public void Load(XmlNode parentNode) { foreach (XmlNode node in parentNode.ChildNodes) { if (node.NodeType == XmlNodeType.Element) { TEntityExCode exCode = new TEntityExCode(); exCode = IRAPXMLUtils.LoadValueFromXMLNode(node, exCode) as TEntityExCode; AddItem(exCode); } } }
public XmlNode GenerateXMLNode() { XmlDocument xml = new XmlDocument(); XmlNode node = xml.CreateElement("Device"); node = IRAPXMLUtils.GenerateXMLAttribute(node, this); foreach (TIRAPOPCKepDeviceTagInfo tag in tags) { node.AppendChild(xml.ImportNode(tag.GenerateXMLNode(), true)); } return(node); }
protected override XmlNode GenerateUserDefineNode() { XmlDocument xml = new XmlDocument(); XmlNode result = xml.CreateElement("Parameters"); XmlNode node = xml.CreateElement("Param"); node = IRAPXMLUtils.GenerateXMLAttribute(node, this); result.AppendChild(node); node = xml.CreateElement("ParamXML"); result.AppendChild(node); XmlNode rowSet = xml.CreateElement("TestData"); node.AppendChild(rowSet); for (int i = 0; i < testDatas.Count; i++) { testDatas[i].Ordinal = i + 1; XmlNode row = xml.CreateElement("Row"); row = testDatas[i].GenerateXMLNode(row); rowSet.AppendChild(row); } rowSet = xml.CreateElement("PossibleFailures"); node.AppendChild(rowSet); for (int i = 0; i < pfms.Count; i++) { pfms[i].Ordinal = i + 1; XmlNode row = xml.CreateElement("Row"); row = pfms[i].GenerateXMLNode(row); rowSet.AppendChild(row); } rowSet = xml.CreateElement("Recipe"); node.AppendChild(rowSet); for (int i = 0; i < recipes.Count; i++) { recipes[i].Ordinal = i + 1; XmlNode row = xml.CreateElement("Row"); row = recipes[i].GenerateXMLNode(row); rowSet.AppendChild(row); } return(result); }
public static TGetKepServListRspBody LoadFromXMLNode(XmlNode node) { TGetKepServListRspBody rlt = new TGetKepServListRspBody(); rlt = IRAPXMLUtils.LoadValueFromXMLNode(GetEX(node), rlt) as TGetKepServListRspBody; XmlNode paramxml = GetRspBodyNode(node); if (paramxml.FirstChild != null && paramxml.FirstChild.Name == "Row") { foreach (XmlNode child in paramxml.ChildNodes) { rlt.items.Add(TGetKepServListRspDetail.LoadFromXMLNode(child)); } } return(rlt); }
/// <summary> /// 从 XML 节点的子节点中导入已注册的交易代码列表 /// </summary> /// <param name="parentNode">XML 节点(ExCodes)</param> public void Load(XmlNode parentNode) { foreach (XmlNode node in parentNode.ChildNodes) { if (node.NodeType == XmlNodeType.Element) { TEntityDBConnection connection = new TEntityDBConnection(); connection = IRAPXMLUtils.LoadValueFromXMLNode( node, connection) as TEntityDBConnection; dbs.Add(connection); } } }
public static TGetDeviceTagsRspBody LoadFromXMLNode(XmlNode node) { TGetDeviceTagsRspBody rlt = new TGetDeviceTagsRspBody(); rlt = IRAPXMLUtils.LoadValueFromXMLNode(GetEX(node), rlt) as TGetDeviceTagsRspBody; XmlNode paramxml = GetRspBodyNode(node); if (paramxml != null && paramxml.ChildNodes.Count > 0) { foreach (XmlNode child in paramxml.ChildNodes) { rlt.Details.Add(TGetDeviceTagsRspDetail.LoadFromXMLNode(child)); } } return(rlt); }
public static TIRAPOPCServer LoadFromXMLNode(XmlNode node) { if (node.Name == "OPCServer") { TIRAPOPCServer server = new TIRAPOPCServer(); server = IRAPXMLUtils.LoadValueFromXMLNode(node, server) as TIRAPOPCServer; if ((server.Address != "") && (server.Name != "")) { return(server); } else { return(null); } } else { return(null); } }
protected override void ResolveExchangeXML(string stringXML) { XmlDocument xml = new XmlDocument(); try { xml.LoadXml(stringXML); XmlNode node = xml.SelectSingleNode("Parameters/Param"); if (node != null) { if (node.Attributes["ItemNumber"] != null) { itemNumber = node.Attributes["ItemNumber"].Value; } if (node.Attributes["LotNumber"] != null) { lotNumber = node.Attributes["LotNumber"].Value; } if (node.Attributes["Bin"] != null) { binFrom = node.Attributes["Bin"].Value; } if (node.Attributes["IssuedQuantity"] != null) { quantity = node.Attributes["IssuedQuantity"].Value; } if (node.Attributes["OrderNumber"] != null) { orderNo = node.Attributes["OrderNumber"].Value; } if (node.Attributes["LineNumber"] != null) { orderLineNo = node.Attributes["LineNumber"].Value; } } exchange.Add(IRAPXMLUtils.NodeToObject <TEntityXMLPICK08>(node)); } catch { } }
protected override void ResolveExchangeXML(string stringXML) { XmlDocument xml = new XmlDocument(); try { xml.LoadXml(stringXML); XmlNode node = xml.SelectSingleNode("Parameters/Param"); if (node != null) { if (node.Attributes["ItemNumber"] != null) { itemNumber = node.Attributes["ItemNumber"].Value; } if (node.Attributes["PONumber"] != null) { orderNo = node.Attributes["PONumber"].Value; } if (node.Attributes["POLineNumber"] != null) { orderLineNo = node.Attributes["POLineNumber"].Value; } if (node.Attributes["LotNumberDefault"] != null) { lotNumber = node.Attributes["LotNumberDefault"].Value; } if (node.Attributes["Bin1"] != null) { binTo = node.Attributes["Bin1"].Value; } if (node.Attributes["ReceiptQuantityMove1"] != null) { quantity = node.Attributes["ReceiptQuantityMove1"].Value; } } exchange.Add(IRAPXMLUtils.NodeToObject <TEntityXMLPORV01>(node)); } catch { } }
public WebAPIParam(string fileName) { XmlDocument xml = new XmlDocument(); try { xml.Load(fileName); } catch (Exception) { return; } XmlNode parentNode = xml.SelectSingleNode("root/WebAPI"); if (parentNode != null) { BrokeUri = IRAPXMLUtils.GetXMLNodeAttributeValue(parentNode, "BrokeUri"); ContentType = IRAPXMLUtils.GetXMLNodeAttributeValue(parentNode, "ContentType"); ClientID = IRAPXMLUtils.GetXMLNodeAttributeValue(parentNode, "ClientID"); } }
protected override XmlNode GenerateUserDefineNode() { XmlDocument xml = new XmlDocument(); XmlNode result = xml.CreateElement("Result"); XmlNode node = xml.CreateElement("Param"); node = IRAPXMLUtils.GenerateXMLAttribute(node, this); result.AppendChild(node); node = xml.CreateElement("ParamXML"); result.AppendChild(node); for (int i = 0; i < items.Count; i++) { items[i].Ordinal = i + 1; XmlNode child = xml.CreateElement("Row"); node.AppendChild(IRAPXMLUtils.GenerateXMLAttribute(child, items[i])); } return(result); }
public static TIRAPOPCLocDevice LoadFromXMLNode(XmlNode node) { if (node.Name == "Device" || node.Name == "Row") { TIRAPOPCLocDevice device = new TIRAPOPCLocDevice(); device = IRAPXMLUtils.LoadValueFromXMLNode(node, device) as TIRAPOPCLocDevice; foreach (XmlNode child in node.ChildNodes) { TIRAPOPCKepDeviceTagInfo tag = TIRAPOPCKepDeviceTagInfo.LoadFromXMLNode(child); if (tag != null) { device.Tags.Add(tag); } } return(device); } else { return(null); } }
public string GetXMLString() { return(IRAPXMLUtils.ObjectToXMLString(this, "Parameters", "Param")); }
/// <summary> /// 将 KepwareServer 信息持久化 /// </summary> /// <param name="type">编辑类别:1-保存;2-删除</param> /// <param name="server">KepwareServer对象</param> /// <param name="dataFileName">本地持久化文件名</param> public void ModifyDataFile(int type, TIRAPOPCServer server, string dataFileName) { XmlDocument xml = new XmlDocument(); XmlNode rootNode = null; if (!File.Exists(dataFileName)) { xml.AppendChild(xml.CreateXmlDeclaration("1.0", "utf-8", "")); rootNode = xml.CreateElement("root"); xml.AppendChild(rootNode); } else { try { xml.Load(dataFileName); } catch (Exception error) { Debug.WriteLine(string.Format("加载[{0}]文件时出错:[{1}]", dataFileName, error.Message)); return; } rootNode = xml.SelectSingleNode("root"); if (rootNode == null) { Debug.WriteLine( string.Format( "[{0}] 文件中不存在 root 根节点")); return; } } // 在第一层子节点中查找 Device 节点,若没有找到则创建该节点 XmlNode serversNode = null; foreach (XmlNode node in rootNode.ChildNodes) { if (node.Name == "OPCServers") { serversNode = node; break; } } if (serversNode == null) { serversNode = xml.CreateElement("OPCServers"); rootNode.AppendChild(serversNode); } // 在 OPCServers 节点中查找指定 Address 的 OPCServer 子节点,如果找到则从 Devices 节点中删除 XmlNode serverNode = IRAPXMLUtils.GetChildNodeWithPropertyValue( serversNode, server); if (serverNode != null) { serversNode.RemoveChild(serverNode); } if (type == 1) { #region 添加设备节点 serverNode = xml.ImportNode(server.GenerateXMLNode(), true); serversNode.AppendChild(serverNode); #endregion } // 保存 XML 到文件 xml.Save(dataFileName); }
public XmlNode GenerateXMLNode(XmlNode row) { return(IRAPXMLUtils.GenerateXMLAttribute(row, this)); }