Ejemplo n.º 1
0
        /// <summary>
        /// Сохранение конфигурационных даных в  XML файл
        /// </summary>
        /// <param name="Node"></param>
        /// <param name="FileName"></param>
        public static void SaveXmlDocument(XMLObj obj)
        {
            string XmlSetting = "XmlSetting";

            lock (XmlSetting)
            {
                XmlDocument xmlDoc  = NewXML("", "PluginConfiguration", "");
                XmlElement  xmlRoot = xmlDoc.DocumentElement;
                XmlElement  Elem    = xmlDoc.CreateElement("", "RootElement", "");



                XmlElement NameClientLibrary       = xmlDoc.CreateElement("", "NameClientLibrary", "");
                XmlText    value_NameClientLibrary = xmlDoc.CreateTextNode(obj._NameClientLibrary);
                NameClientLibrary.AppendChild(value_NameClientLibrary);
                Elem.AppendChild(NameClientLibrary);


                XmlElement MainConnectionString       = xmlDoc.CreateElement("", "MainConnectionString", "");
                XmlText    value_MainConnectionString = xmlDoc.CreateTextNode(obj._MainConnectionString);
                MainConnectionString.AppendChild(value_MainConnectionString);
                Elem.AppendChild(MainConnectionString);

                XmlElement SecondaryConnectionString       = xmlDoc.CreateElement("", "SecondaryConnectionString", "");
                XmlText    value_SecondaryConnectionString = xmlDoc.CreateTextNode(obj._SecondaryConnectionString);
                SecondaryConnectionString.AppendChild(value_SecondaryConnectionString);
                Elem.AppendChild(SecondaryConnectionString);

                XmlElement TypeRDBMS       = xmlDoc.CreateElement("", "TypeRDBMS", "");
                XmlText    value_TypeRDBMS = xmlDoc.CreateTextNode(obj._TypeRDBMS);
                TypeRDBMS.AppendChild(value_TypeRDBMS);
                Elem.AppendChild(TypeRDBMS);

                XmlElement LocationOrmSchema       = xmlDoc.CreateElement("", "LocationOrmSchema", "");
                XmlText    value_LocationOrmSchema = xmlDoc.CreateTextNode(obj._ORMSchema);
                LocationOrmSchema.AppendChild(value_LocationOrmSchema);
                Elem.AppendChild(LocationOrmSchema);

                XmlElement LocationCurrentConfFile       = xmlDoc.CreateElement("", "LocationCurrentConfFile", "");
                XmlText    value_LocationCurrentConfFile = xmlDoc.CreateTextNode(obj._XMLSetting);
                LocationCurrentConfFile.AppendChild(value_LocationCurrentConfFile);
                Elem.AppendChild(LocationCurrentConfFile);

                XmlElement LocationDefaultConfFile       = xmlDoc.CreateElement("", "LocationDefaultConfFile", "");
                XmlText    value_LocationDefaultConfFile = xmlDoc.CreateTextNode(obj._DefaultXMLSetting);
                LocationDefaultConfFile.AppendChild(value_LocationDefaultConfFile);
                Elem.AppendChild(LocationDefaultConfFile);

                XmlElement LocationLogFile       = xmlDoc.CreateElement("", "LocationLogFile", "");
                XmlText    value_LocationLogFile = xmlDoc.CreateTextNode(obj._NameLogFile);
                LocationLogFile.AppendChild(value_LocationLogFile);
                Elem.AppendChild(LocationLogFile);

                XmlElement NamePlugin       = xmlDoc.CreateElement("", "NamePlugin", "");
                XmlText    value_NamePlugin = xmlDoc.CreateTextNode(obj._NamePlugin);
                NamePlugin.AppendChild(value_NamePlugin);
                Elem.AppendChild(NamePlugin);

                XmlElement LocationPlugin       = xmlDoc.CreateElement("", "LocationPlugin", "");
                XmlText    value_LocationPlugin = xmlDoc.CreateTextNode(obj._LocationPlugin);
                LocationPlugin.AppendChild(value_LocationPlugin);
                Elem.AppendChild(LocationPlugin);

                XmlElement StrUploadPath       = xmlDoc.CreateElement("", "StrUploadPath", "");
                XmlText    value_StrUploadPath = xmlDoc.CreateTextNode(obj._StrUploadPath);
                StrUploadPath.AppendChild(value_StrUploadPath);
                Elem.AppendChild(StrUploadPath);

                XmlElement StrUploadServerPath       = xmlDoc.CreateElement("", "StrUploadServerPath", "");
                XmlText    value_StrUploadServerPath = xmlDoc.CreateTextNode(obj._StrUploadServerPath);
                StrUploadServerPath.AppendChild(value_StrUploadServerPath);
                Elem.AppendChild(StrUploadServerPath);



                // Создаем атрибут
                Elem.SetAttribute("ListPlugins", "SettingFileSaveListPlugins");

                xmlRoot.AppendChild(Elem);

                xmlDoc.Save(file_name_current);
            }
        }
Ejemplo n.º 2
0
        public static XMLObj GetXmlSettings(string FileName)
        {
            string XmlSetting = "XmlSetting";

            lock (XmlSetting)
            {
                XMLObj       obj    = new XMLObj();
                XmlDocument  xmlDoc = new XmlDocument();
                StreamReader xml    = new StreamReader(FileName);
                xmlDoc.Load(new StringReader(xml.ReadToEnd()));
                XmlElement root = xmlDoc.DocumentElement;

                XmlNodeList NameClientLibrary = xmlDoc.GetElementsByTagName("NameClientLibrary");
                if (NameClientLibrary.Count > 0)
                {
                    XmlNode el = NameClientLibrary[0];
                    obj._NameClientLibrary = el.InnerText;
                }

                XmlNodeList MainConnectionString = xmlDoc.GetElementsByTagName("MainConnectionString");
                if (MainConnectionString.Count > 0)
                {
                    XmlNode el = MainConnectionString[0];
                    obj._MainConnectionString = el.InnerText;
                }

                XmlNodeList SecondaryConnectionString = xmlDoc.GetElementsByTagName("SecondaryConnectionString");
                if (SecondaryConnectionString.Count > 0)
                {
                    XmlNode el = SecondaryConnectionString[0];
                    obj._SecondaryConnectionString = el.InnerText;
                }

                XmlNodeList TypeRDBMS = xmlDoc.GetElementsByTagName("TypeRDBMS");
                if (TypeRDBMS.Count > 0)
                {
                    XmlNode el = TypeRDBMS[0];
                    obj._TypeRDBMS = el.InnerText;
                }

                XmlNodeList LocationOrmSchema = xmlDoc.GetElementsByTagName("LocationOrmSchema");
                if (LocationOrmSchema.Count > 0)
                {
                    XmlNode el = LocationOrmSchema[0];
                    obj._ORMSchema = el.InnerText;
                }

                XmlNodeList LocationCurrentConfFile = xmlDoc.GetElementsByTagName("LocationCurrentConfFile");
                if (LocationCurrentConfFile.Count > 0)
                {
                    XmlNode el = LocationCurrentConfFile[0];
                    obj._XMLSetting = el.InnerText;
                }

                XmlNodeList LocationDefaultConfFile = xmlDoc.GetElementsByTagName("LocationDefaultConfFile");
                if (LocationDefaultConfFile.Count > 0)
                {
                    XmlNode el = LocationDefaultConfFile[0];
                    obj._DefaultXMLSetting = el.InnerText;
                }

                XmlNodeList LocationLogFile = xmlDoc.GetElementsByTagName("LocationLogFile");
                if (LocationLogFile.Count > 0)
                {
                    XmlNode el = LocationLogFile[0];
                    obj._NameLogFile = el.InnerText;
                }

                XmlNodeList NamePlugin = xmlDoc.GetElementsByTagName("NamePlugin");
                if (NamePlugin.Count > 0)
                {
                    XmlNode el = NamePlugin[0];
                    obj._NamePlugin = el.InnerText;
                }

                XmlNodeList LocationPlugin = xmlDoc.GetElementsByTagName("LocationPlugin");
                if (LocationPlugin.Count > 0)
                {
                    XmlNode el = LocationPlugin[0];
                    obj._LocationPlugin = el.InnerText;
                }


                XmlNodeList StrUploadPath = xmlDoc.GetElementsByTagName("StrUploadPath");
                if (StrUploadPath.Count > 0)
                {
                    XmlNode el = StrUploadPath[0];
                    obj._StrUploadPath = el.InnerText;
                }

                XmlNodeList StrUploadServerPath = xmlDoc.GetElementsByTagName("StrUploadServerPath");
                if (StrUploadServerPath.Count > 0)
                {
                    XmlNode el = StrUploadServerPath[0];
                    obj._StrUploadServerPath = el.InnerText;
                }

                xml.Close();

                return(obj);
            }
        }