コード例 #1
0
        /// <summary>
        /// 执行保存已经修改的ConfigInfo
        /// </summary>
        /// <param name="configInfo">传入configInfo实例对象</param>
        /// <param name="xmlConfigPath">修改的xml文件</param>
        /// <returns></returns>
        public string SaveConfig(ConfigInfo configInfo, string xmlConfigPath)
        {
            string modifyPath = "preferences";
            string result     = "";
            var    value      = new Dictionary <string, string>();

            value.Add("SvnPath", configInfo.Svnpath);
            value.Add("UpdateInterval", configInfo.Updateinterval);
            value.Add("StandarOutput", configInfo.StandarOutput);
            value.Add("ServiceSwitch", configInfo.ServiceSwitch);
            value.Add("ReportFrom", configInfo.ReportFrom);
            value.Add("Password", configInfo.Password);
            value.Add("MailHost", configInfo.SmtpServer);
            value.Add("ReportTo", configInfo.ReportTo);
            try
            {
                XmlDao   xmlDao   = new XmlDao();
                XElement xElement = xmlDao.SelectOneXElement(null, xmlConfigPath, modifyPath);
                result = xmlDao.ModifyXNode(value, xElement, xmlConfigPath);
                return(result);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                result = "failed";
                return(result);
            }
        }
コード例 #2
0
        /// <summary>
        /// 执行修改项目动态内容的操作(现有的,只修改不增加)
        /// </summary>
        /// <param name="projects">需要修改的项目的键值对</param>
        /// <param name="property">需要筛选的属性值的键值对</param>
        /// <param name="xmlPath">xml文件的路径</param>
        /// <param name="nodePath">节点的路径</param>
        /// <returns></returns>
        public string ModifyProject(Dictionary <string, string> projects, Dictionary <string, string> property,
                                    string xmlPath, string nodePath)
        {
            string   result   = "";
            XElement xElement = dao.SelectOneXElement(property, xmlPath, nodePath);

            result = dao.ModifyXNode(projects, xElement, xmlPath);
            return(result);
        }