public XmlNode exportXMLnode() { XmlDocument xmlDoc = new XmlDocument(); StringWriter stringWriter = new StringWriter(); XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter); XmlNode rootNode = null; if (isNodeComment) { rootNode = xmlDoc.CreateComment(comment); xmlDoc.AppendChild(rootNode); return(rootNode); } rootNode = xmlDoc.CreateElement(ainType.ToString()); #region MasterType IEC61850 if (masterType == MasterTypes.IEC61850Client) { foreach (string attr in arrAttributes) { XmlAttribute attrName = xmlDoc.CreateAttribute(attr); attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this); rootNode.Attributes.Append(attrName); } XmlAttribute attr1 = xmlDoc.CreateAttribute("ResponseType"); attr1.Value = Iec61850ResponseType.ToString(); rootNode.Attributes.Append(attr1); XmlAttribute attr2 = xmlDoc.CreateAttribute("Index"); attr2.Value = Iec61850Index.ToString(); rootNode.Attributes.Append(attr2); XmlAttribute attFC = xmlDoc.CreateAttribute("FC"); attFC.Value = FC.ToString(); rootNode.Attributes.Append(attFC); XmlAttribute attr3 = xmlDoc.CreateAttribute("SubIndex"); attr3.Value = SubIndex.ToString(); rootNode.Attributes.Append(attr3); //XmlAttribute attr4 = xmlDoc.CreateAttribute("DataType"); //attr4.Value = DataType.ToString(); //rootNode.Attributes.Append(attr4); XmlAttribute attr5 = xmlDoc.CreateAttribute("Multiplier"); attr5.Value = Multiplier.ToString(); rootNode.Attributes.Append(attr5); XmlAttribute attr6 = xmlDoc.CreateAttribute("Constant"); attr6.Value = Constant.ToString(); rootNode.Attributes.Append(attr6); XmlAttribute attr7 = xmlDoc.CreateAttribute("Description"); attr7.Value = Description.ToString(); rootNode.Attributes.Append(attr7); } #endregion MasterType IEC61850 #region MasterType IEC103,ADR,IEC101,MODBUS,Virtual if ((masterType == MasterTypes.IEC103) || (masterType == MasterTypes.ADR) || (masterType == MasterTypes.IEC101) || (masterType == MasterTypes.MODBUS) || (masterType == MasterTypes.Virtual)) { foreach (string attr in arrAttributes) { XmlAttribute attrName = xmlDoc.CreateAttribute(attr); attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this); rootNode.Attributes.Append(attrName); } } #endregion MasterType IEC103,ADR,IEC101,MODBUS,Virtual return(rootNode); }
public XmlNode exportXMLnode() { XmlDocument xmlDoc = new XmlDocument(); StringWriter stringWriter = new StringWriter(); XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter); XmlNode rootNode = null; if (isNodeComment) { rootNode = xmlDoc.CreateComment(comment); xmlDoc.AppendChild(rootNode); return(rootNode); } rootNode = xmlDoc.CreateElement(ainType.ToString()); //Ajay: 01/11/2018 Commented - added attributes directly in arrAttributes Array #region MasterType IEC61850 if (masterType == MasterTypes.IEC61850Client) { foreach (string attr in arrAttributes) { XmlAttribute attrName = xmlDoc.CreateAttribute(attr); attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this); rootNode.Attributes.Append(attrName); } XmlAttribute attr1 = xmlDoc.CreateAttribute("ResponseType"); attr1.Value = Iec61850ResponseType.ToString(); rootNode.Attributes.Append(attr1); XmlAttribute attr2 = xmlDoc.CreateAttribute("Index"); attr2.Value = Iec61850Index.ToString(); rootNode.Attributes.Append(attr2); XmlAttribute attFC = xmlDoc.CreateAttribute("FC"); attFC.Value = FC.ToString(); rootNode.Attributes.Append(attFC); XmlAttribute attr3 = xmlDoc.CreateAttribute("SubIndex"); attr3.Value = SubIndex.ToString(); rootNode.Attributes.Append(attr3); XmlAttribute attr5 = xmlDoc.CreateAttribute("Multiplier"); attr5.Value = Multiplier.ToString(); rootNode.Attributes.Append(attr5); XmlAttribute attr6 = xmlDoc.CreateAttribute("Constant"); attr6.Value = Constant.ToString(); rootNode.Attributes.Append(attr6); //Ajay: 01/11/2018 EventEnable added XmlAttribute attr7 = xmlDoc.CreateAttribute("EventEnable"); attr7.Value = EventEnable.ToString(); rootNode.Attributes.Append(attr7); XmlAttribute attr8 = xmlDoc.CreateAttribute("Description"); attr8.Value = Description.ToString(); rootNode.Attributes.Append(attr8); } #endregion MasterType IEC61850 #region MasterType IEC103,ADR,IEC101,MODBUS,Virtual, LoadProfile if ((masterType == MasterTypes.IEC103) || (masterType == MasterTypes.ADR) || (masterType == MasterTypes.IEC104) || (masterType == MasterTypes.IEC101) || (masterType == MasterTypes.MODBUS) || (masterType == MasterTypes.Virtual) || (masterType == MasterTypes.SPORT) || (masterType == MasterTypes.LoadProfile)) //Ajay: 31/07/2018 LoadProfile Added { foreach (string attr in arrAttributes) { XmlAttribute attrName = xmlDoc.CreateAttribute(attr); attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this); rootNode.Attributes.Append(attrName); } } #endregion return(rootNode); }