using System; using System.Collections; using System.Collections.Generic; 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 SysController : BaseController { ValidationErrors errors = new ValidationErrors(); #region 缓存 /// ///缓存列表 /// /// [AuthorizeRedirect(Roles = InitRights.CONST_清除缓存)] public ActionResult CacheIndex() { ToolBar tool = new ToolBar(); // tool.AllowButton("Other1"); string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.清除缓存, userRightId); tool.AllowButton(toolbtn); tool.AddOtherButton("Other1", "清除缓存", "icon-remove", "DeleteCache_Click", true); tool.AddOtherButton("Other2", "刷新", "icon-reload", "Reload_Click", true); ViewBag.ToolBar = tool; string tableId = "tablist"; Table tab = new Table(tableId); tab.isCheckbox = true; tab.AddHeadCol("CacheKey", "20%", "名称"); tab.AddHeadCol("Content", "", "描述"); tab.AddHeadRow(); ViewBag.gridTable = tab.GetHead(); return View(); } #region 列表 [HttpPost] /// /// 按照条件获取数据 /// /// /// /// [AuthorizeRedirect(Roles = InitRights.CONST_清除缓存)] public JsonResult GetCaheHtmlList(string columns) { Table table = new Table(columns, true); XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("~/Xml/CacheConfig.xml")); XmlNode node = doc.DocumentElement; string cacheKey = Request.Params["cacheKey"]; cacheKey = string.IsNullOrEmpty(cacheKey) ? "" : cacheKey; IDictionaryEnumerator dicCache = HttpRuntime.Cache.GetEnumerator(); List cacheList = new List(); while (dicCache.MoveNext()) { if (dicCache.Key.ToString().IndexOf("Cache_UserInfo_") == -1) cacheList.Add(dicCache.Key.ToString()); } Dictionary dicXml = new Dictionary(); foreach (XmlNode childNode in node.ChildNodes) { dicXml.Add(childNode.Attributes["key"].Value, childNode.InnerText); } table.isCheckbox = true; string cacheName = string.Empty; string cacheDes = string.Empty; foreach (XmlNode childNode in node.ChildNodes) { cacheName = string.IsNullOrEmpty(cacheKey) ? childNode.Attributes["key"].Value : childNode.Attributes["key"].Value.Replace(cacheKey, "" + cacheKey + ""); table.AddCol("text-align:left;padding-left:10px;", "", cacheName); cacheDes = string.IsNullOrEmpty(cacheKey) ? childNode.InnerText : childNode.InnerText.Replace(cacheKey, "" + cacheKey + ""); table.AddCol("text-align:left;padding-left:10px;", "", cacheDes); table.AddRow(); } //foreach (string cache in cacheList) //{ // if (dicXml.Keys.Contains(cache)) // continue; // cacheName = string.IsNullOrEmpty(cacheKey) ? cache : cache.Replace(cacheKey, "" + cacheKey + ""); // table.AddCol("text-align:left;padding-left:10px;", "", cacheName); // if (dicXml.Keys.Contains(cache)) // { // cacheDes = string.IsNullOrEmpty(cacheKey) ? dicXml[cache] : dicXml[cache].Replace(cacheKey, "" + cacheKey + ""); // table.AddCol("text-align:left;padding-left:10px;", "", cacheDes); // } // else // table.AddCol(""); // table.AddRow(); //} var json = new { rowsList = table.GetRows() }; return Json(json, JsonRequestBehavior.AllowGet); } #endregion [AuthorizeToolBar(InitRights.CONST_清除缓存, InitToolBar.CONST_Other1)] public JsonResult DeleteChache(string CacheKey) { if (string.IsNullOrWhiteSpace(CacheKey)) { return JsonHandler.ManageMessage("参数不能为空!", false); } bool result = true; try { string[] cacheKyes = CacheKey.Split(','); foreach (string chache in cacheKyes) { CacheHelper.Remove(chache); } } catch (Exception ex) { result = false; errors.Add(ex.ToString()); } return JsonHandler.DeleteMessage(errors, result); } #endregion #region 读取样式 #endregion } }