Beispiel #1
0
        /// <summary>
        /// Сериализовать параметр параметр
        /// </summary>
        /// <param name="doc">Документ в который сохраняется параметр</param>
        /// <returns>Узел в котором сохранен параметр</returns>
        public XmlNode SerializeToXmlNode(XmlDocument doc)
        {
            try
            {
                XmlNode root = doc.CreateElement(parameterRoot);

                XmlNode nameNode = doc.CreateElement(parameterName);
                XmlNode descNode = doc.CreateElement(descriptionName);

                XmlNode unitsNode = doc.CreateElement(unitsName);
                XmlNode alarmNode = doc.CreateElement(alarmValueName);

                XmlNode blockingNode     = doc.CreateElement(blockingValueName);
                XmlNode controlAlarmNode = doc.CreateElement(controlAlarmName);

                XmlNode controlBlockingNode = doc.CreateElement(controlBlockingName);
                XmlNode rangeNode           = range.SerializeToXml(doc);

                XmlNode isSaveToDBNode     = doc.CreateElement(saveToDBName);
                XmlNode intervalToSaveNode = doc.CreateElement(intervalToSaveName);

                XmlNode thresholdToBDNode = doc.CreateElement(thresholdToBDName);
                XmlNode channelNumberNode = doc.CreateElement(channelNumberName);

                XmlNode currentValueNode = doc.CreateElement(currentValueName);
                XmlNode selfIndexNode    = doc.CreateElement(selfIndexName);

                XmlNode guidNode = doc.CreateElement(guidName);

                XmlNode devManindexNode       = doc.CreateElement(devManindexName);
                XmlNode devManDescriptionNode = doc.CreateElement(devManDescriptionName);

                XmlNode transformationNode = null;
                if (transformation != null)
                {
                    transformationNode = transformation.CreateXmlNode(doc);
                }

                nameNode.InnerText = name;
                descNode.InnerText = description;

                unitsNode.InnerText = units;
                alarmNode.InnerText = alarmValue.ToString();

                blockingNode.InnerText     = blockingValue.ToString();
                controlAlarmNode.InnerText = controlAlarm.ToString();

                controlBlockingNode.InnerText = controlBlocking.ToString();
                isSaveToDBNode.InnerText      = saveToDB.ToString();

                intervalToSaveNode.InnerText = intervalToSave.ToString();
                thresholdToBDNode.InnerText  = thresholdToBD.ToString();

                channelNumberNode.InnerText = channelNumber.ToString();
                currentValueNode.InnerText  = currentValue.ToString();

                selfIndexNode.InnerText = selfIndex.ToString();
                guidNode.InnerText      = guid.ToString();

                devManindexNode.InnerText       = devManindex.ToString();
                devManDescriptionNode.InnerText = devManDescription;

                root.AppendChild(nameNode);
                root.AppendChild(descNode);

                root.AppendChild(unitsNode);
                root.AppendChild(alarmNode);

                root.AppendChild(blockingNode);
                root.AppendChild(controlAlarmNode);

                root.AppendChild(controlBlockingNode);
                if (rangeNode != null)
                {
                    root.AppendChild(rangeNode);
                }

                root.AppendChild(isSaveToDBNode);
                root.AppendChild(intervalToSaveNode);

                root.AppendChild(thresholdToBDNode);
                root.AppendChild(channelNumberNode);

                root.AppendChild(currentValueNode);
                root.AppendChild(selfIndexNode);

                root.AppendChild(devManindexNode);
                root.AppendChild(devManDescriptionNode);

                root.AppendChild(guidNode);
                if (transformationNode != null)
                {
                    root.AppendChild(transformationNode);
                }

                return(root);
            }
            catch { }
            return(null);
        }