public ActionResult GetAccessResource() { int accessid = DoRequest.GetFormInt("id"); string[] item = { }; var resrole = QueryAccessResource.Do(accessid); if (resrole != null && resrole.Body != null) { item = resrole.Body.res_ids; return(Json(new { error = false, access = item, message = "操作成功!" })); } return(Json(new { error = true, message = "操作失败" })); }
public ActionResult PostAccessResourceData() { string xmlString = DoRequest.GetFormString("xml", false); xmlString = HttpUtility.UrlDecode(xmlString); int accessid = DoRequest.GetFormInt("id"); string ids = ""; int _count = 0; List <int> idsi = new List <int>(); try { XmlDataDocument xmlDoc = new XmlDataDocument(); xmlDoc.LoadXml(xmlString); XmlNodeList nodes = xmlDoc.SelectNodes("items/item"); if (nodes != null) { foreach (XmlNode item in nodes) { int resid = Utils.StrToInt(item.Attributes["resid"].Value.Trim(), 0); int issel = Utils.StrToInt(item.Attributes["isselect"].Value.Trim(), 0); if (issel == 1) { if (_count == 0) { ids = resid.ToString(); } else { ids = ids + "," + resid.ToString(); } _count++; idsi.Add(resid); } } } } catch (Exception) { return(Json(new { error = true, input = "message", message = "Xml解析失败..." })); } _count = 0; string delids = ""; string[] oldlist = { }; var resrole = QueryAccessResource.Do(accessid); if (resrole != null && resrole.Body != null) { oldlist = resrole.Body.res_ids; } foreach (string item in oldlist) { if (!idsi.Contains(Utils.StrToInt(item, 0))) { if (_count == 0) { delids = item; } else { delids = delids + "," + item; } _count++; } } if (delids.Equals("")) { delids = "0"; } var returnValue = -1; var res = OpAccessResource.Do(accessid, ids, delids); if (res != null && res.Header != null && res.Header.Result != null && res.Header.Result.Code != null) { returnValue = Utils.StrToInt(res.Header.Result.Code, -1); } if (returnValue == 0) { return(Json(new { error = false, message = "操作成功!" })); } return(Json(new { error = true, message = "操作失败!" })); }