Ejemplo n.º 1
0
        public ConfigObj readConfig()
        {
            ConfigObj config = new ConfigObj();
            try
            {
                StringBuilder output = new StringBuilder();

                String xmlString = getTextFromFile(getConfPath(Constants.CONF_PATH));
                if (xmlString != null)
                {
                    config = parseConfig(xmlString);
                }

            }
            catch (Exception e)
            {
                throw e;
            }

            return config;
        }
Ejemplo n.º 2
0
        public void writeConfig(ConfigObj config, String configPath)
        {
            StringBuilder sb = null;
            try
            {

                sb = new StringBuilder();

                sb.Append("<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\n");
                sb.Append(" <openaudit>\n");
                sb.Append("     <config strId='"+config.strId+"' remoteServer='"+config.remoteServer+"' remoteTarget='"+config.remoteTarget+"' version='"+config.version+"' uploadUrl='"+config.uploadUrl+"' downloadUrl='"+config.downloadUrl+"' >\n");
                sb.Append("     </config>\n");
                sb.Append(" </openaudit>\n");

                if (File.Exists(configPath)) File.Delete(configPath);
                using (StreamWriter outfile = new StreamWriter(configPath))
                {
                    outfile.Write(sb.ToString());
                    outfile.Close();
                }
            }
            catch (Exception e)
            {

                throw e;
            }
            finally
            {
                if (sb != null) sb = null;
            }
        }
Ejemplo n.º 3
0
        public ConfigObj parseConfig(String configXml)
        {
            ConfigObj config = new ConfigObj();
            try
            {
                using (XmlReader reader = XmlReader.Create(new StringReader(configXml)))
                {
                    reader.ReadToFollowing("config");
                    config.strId = reader.GetAttribute("strId");
                    config.remoteServer = reader.GetAttribute("remoteServer");
                    config.remoteTarget = reader.GetAttribute("remoteTarget");
                    config.downloadUrl = reader.GetAttribute("downloadUrl");
                    config.uploadUrl = reader.GetAttribute("uploadUrl");
                    config.version = reader.GetAttribute("version");
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return config;
        }