TG.WXCRM.V4/WEB/Controllers/Base/CacheController.cs

43 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml;
using WX.CRM.Common;
using WX.CRM.WebHelper;
namespace WX.CRM.WEB.Controllers.Base
{
public class CacheController : Controller
{
ValidationErrors errors = new ValidationErrors();
//
// GET: /Cache/
public JsonResult DeleteCache()
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("~/Xml/CacheConfig.xml"));
XmlNode node = doc.DocumentElement;
List<string> cacheKey = new List<string>();
foreach (XmlNode childNode in node.ChildNodes)
{
var cacheName = childNode.Attributes["key"].Value;
cacheKey.Add(cacheName);
}
bool result = true;
try
{
foreach (string chache in cacheKey)
{
CacheHelper.Remove(chache);
}
}
catch (Exception ex) { result = false; errors.Add(ex.ToString()); }
return JsonHandler.DeleteMessage(errors, result);
}
}
}