Example #1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="addList">新增列表</param>
        /// <param name="updateList">修改列表</param>
        /// <param name="deleteList">删除列表</param>
        public override ActionResult Save(string addList, string updateList, string deleteList)
        {
            try
            {
                var listAdd = Util.Json.ToObject <List <ServerInfo> >(addList);
                foreach (var item in listAdd)
                {
                    item.Id = Guid.NewGuid().ToString();
                }
                var listUpdate = Util.Json.ToObject <List <ServerInfo> >(updateList);
                var listDelete = Util.Json.ToObject <List <ServerInfo> >(deleteList);

                XmlHelper.AddXmlNodes(ConfigPath, "ServerInfos", "ServerInfo", listAdd);
                XmlHelper.UpdateNodes(ConfigPath, "ServerInfos", "Id", listUpdate);
                XmlHelper.DeleteNodes(ConfigPath, "ServerInfos", "Id", listDelete);
            }
            catch (Exception ex)
            {
                return(Fail("保存失败," + ex.Message));
            }
            return(Ok(R.SaveSuccess));
        }