public ActionResult Sort(FormCollection collection) { MyCreek.Platform.Dictionary BDict = new MyCreek.Platform.Dictionary(); string id = Request.QueryString["id"]; string refreshID = ""; Guid dictid; List <MyCreek.Data.Model.Dictionary> dicts = new List <MyCreek.Data.Model.Dictionary>(); if (id.IsGuid(out dictid)) { var dict = BDict.Get(dictid); if (dict != null) { dicts = BDict.GetChilds(dict.ParentID); refreshID = dict.ParentID.ToString(); } } if (collection != null) { string sortdict = Request.Form["sort"]; if (sortdict.IsNullOrEmpty()) { return(View(dicts)); } string[] sortArray = sortdict.Split(','); int i = 1; foreach (string id1 in sortArray) { Guid gid; if (id1.IsGuid(out gid)) { BDict.UpdateSort(gid, i++); } } BDict.RefreshCache(); MyCreek.Platform.Log.Add("保存了数据字典排序", "保存了ID为:" + id + "的同级排序", MyCreek.Platform.Log.Types.数据字典); ViewBag.Script = "parent.frames[0].reLoad('" + refreshID + "');"; dicts = BDict.GetChilds(refreshID.ToGuid()); } return(View(dicts)); }
protected void Page_Load(object sender, EventArgs e) { MyCreek.Platform.Dictionary BDict = new MyCreek.Platform.Dictionary(); string id = Request.QueryString["id"]; string refreshID = ""; Guid dictid; if (id.IsGuid(out dictid)) { var dict = BDict.Get(dictid); if (dict != null) { DictList = BDict.GetChilds(dict.ParentID); refreshID = dict.ParentID.ToString(); } } if (IsPostBack) { string sortdict = Request.Form["sort"]; if (sortdict.IsNullOrEmpty()) { return; } string[] sortArray = sortdict.Split(','); int i = 1; foreach (string id1 in sortArray) { Guid gid; if (id1.IsGuid(out gid)) { BDict.UpdateSort(gid, i++); } } BDict.RefreshCache(); MyCreek.Platform.Log.Add("保存了数据字典排序", "保存了ID为:" + id + "的同级排序", MyCreek.Platform.Log.Types.数据字典); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "parent.frames[0].reLoad('" + refreshID + "');", true); DictList = BDict.GetChilds(refreshID.ToGuid()); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string id = context.Request.QueryString["refreshid"]; Guid gid; if (!id.IsGuid(out gid)) { context.Response.Write("[]"); return; } System.Text.StringBuilder json = new System.Text.StringBuilder("[", 1000); MyCreek.Platform.Dictionary BDict = new MyCreek.Platform.Dictionary(); var childs = BDict.GetChilds(gid).OrderBy(p => p.Sort); int i = 0; int count = childs.Count(); foreach (var child in childs) { var hasChilds = BDict.HasChilds(child.ID); json.Append("{"); json.AppendFormat("\"id\":\"{0}\",", child.ID); json.AppendFormat("\"parentID\":\"{0}\",", child.ParentID); json.AppendFormat("\"title\":\"{0}\",", child.Title); json.AppendFormat("\"type\":\"{0}\",", hasChilds ? "1" : "2"); json.AppendFormat("\"ico\":\"{0}\",", ""); json.AppendFormat("\"hasChilds\":\"{0}\",", hasChilds ? "1" : "0"); json.Append("\"childs\":["); json.Append("]"); json.Append("}"); if (i++ < count - 1) { json.Append(","); } } json.Append("]"); context.Response.Write(json.ToString()); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; MyCreek.Platform.Dictionary BDict = new MyCreek.Platform.Dictionary(); string rootid = context.Request.QueryString["root"]; bool ischild = "1" == context.Request.QueryString["ischild"];//是否要加载下级节点 Guid rootID = Guid.Empty; if (!rootid.IsGuid(out rootID)) { if (!rootid.IsGuid(out rootID)) { var dict = BDict.GetByCode(rootid); if (dict != null) { rootID = dict.ID; } } } var root = rootID != Guid.Empty ? BDict.Get(rootID) : BDict.GetRoot(); var rootHasChild = BDict.HasChilds(root.ID); System.Text.StringBuilder json = new System.Text.StringBuilder("[", 1000); json.Append("{"); json.AppendFormat("\"id\":\"{0}\",", root.ID); json.AppendFormat("\"parentID\":\"{0}\",", root.ParentID); json.AppendFormat("\"title\":\"{0}\",", root.Title); json.AppendFormat("\"type\":\"{0}\",", rootHasChild ? "0" : "2"); //类型:0根 1父 2子 json.AppendFormat("\"ico\":\"{0}\",", Common.Tools.BaseUrl + "/images/ico/role.gif"); json.AppendFormat("\"hasChilds\":\"{0}\",", rootHasChild ? "1" : "0"); json.Append("\"childs\":["); var childs = BDict.GetChilds(root.ID); int i = 0; int count = childs.Count; foreach (var child in childs) { var hasChild = ischild && BDict.HasChilds(child.ID); json.Append("{"); json.AppendFormat("\"id\":\"{0}\",", child.ID); json.AppendFormat("\"parentID\":\"{0}\",", child.ParentID); json.AppendFormat("\"title\":\"{0}\",", child.Title); json.AppendFormat("\"type\":\"{0}\",", hasChild ? "1" : "2"); json.AppendFormat("\"ico\":\"{0}\",", ""); json.AppendFormat("\"hasChilds\":\"{0}\",", hasChild ? "1" : "0"); json.Append("\"childs\":["); json.Append("]"); json.Append("}"); if (i++ < count - 1) { json.Append(","); } } json.Append("]"); json.Append("}"); json.Append("]"); context.Response.Write(json.ToString()); }
public string Tree1() { MyCreek.Platform.Dictionary BDict = new MyCreek.Platform.Dictionary(); string rootid = Request.QueryString["root"]; bool ischild = "1" == Request.QueryString["ischild"];//是否要加载下级节点 Guid rootID = Guid.Empty; if (!rootid.IsNullOrEmpty()) { if (!rootid.IsGuid(out rootID)) { var dict = BDict.GetByCode(rootid); if (dict != null) { rootID = dict.ID; } } } var root = rootID != Guid.Empty ? BDict.Get(rootID) : BDict.GetRoot(); var rootHasChild = BDict.HasChilds(root.ID); System.Text.StringBuilder json = new System.Text.StringBuilder("[", 1000); json.Append("{"); json.AppendFormat("\"id\":\"{0}\",", root.ID); json.AppendFormat("\"parentID\":\"{0}\",", root.ParentID); json.AppendFormat("\"title\":\"{0}\",", root.Title); json.AppendFormat("\"type\":\"{0}\",", rootHasChild ? "0" : "2"); //类型:0根 1父 2子 json.AppendFormat("\"ico\":\"{0}\",", Url.Content("~/images/ico/role.gif")); json.AppendFormat("\"hasChilds\":\"{0}\",", rootHasChild ? "1" : "0"); json.Append("\"childs\":["); var childs = BDict.GetChilds(root.ID); int i = 0; int count = childs.Count; foreach (var child in childs) { var hasChild = ischild && BDict.HasChilds(child.ID); json.Append("{"); json.AppendFormat("\"id\":\"{0}\",", child.ID); json.AppendFormat("\"parentID\":\"{0}\",", child.ParentID); json.AppendFormat("\"title\":\"{0}\",", child.Title); json.AppendFormat("\"type\":\"{0}\",", hasChild ? "1" : "2"); json.AppendFormat("\"ico\":\"{0}\",", ""); json.AppendFormat("\"hasChilds\":\"{0}\",", hasChild ? "1" : "0"); json.Append("\"childs\":["); json.Append("]"); json.Append("}"); if (i++ < count - 1) { json.Append(","); } } json.Append("]"); json.Append("}"); json.Append("]"); return(json.ToString()); }