Пример #1
0
        public string Tree1()
        {
            string msg;

            if (!Tools.CheckLogin(out msg) && !RoadFlow.Platform.WeiXin.Organize.CheckLogin())
            {
                return("");
            }
            RoadFlow.Platform.Dictionary dictionary = new RoadFlow.Platform.Dictionary();
            string text  = base.Request.QueryString["root"];
            bool   flag2 = "1" == base.Request.QueryString["ischild"];
            Guid   test  = Guid.Empty;

            if (!text.IsNullOrEmpty() && !text.IsGuid(out test))
            {
                RoadFlow.Data.Model.Dictionary byCode = dictionary.GetByCode(text);
                if (byCode != null)
                {
                    test = byCode.ID;
                }
            }
            RoadFlow.Data.Model.Dictionary dictionary2 = (test != Guid.Empty) ? dictionary.Get(test) : dictionary.GetRoot();
            bool          flag          = dictionary.HasChilds(dictionary2.ID);
            StringBuilder stringBuilder = new StringBuilder("[", 1000);

            stringBuilder.Append("{");
            stringBuilder.AppendFormat("\"id\":\"{0}\",", dictionary2.ID);
            stringBuilder.AppendFormat("\"parentID\":\"{0}\",", dictionary2.ParentID);
            stringBuilder.AppendFormat("\"title\":\"{0}\",", dictionary2.Title);
            stringBuilder.AppendFormat("\"type\":\"{0}\",", flag ? "0" : "2");
            stringBuilder.AppendFormat("\"ico\":\"{0}\",", base.Url.Content("~/images/ico/role.gif"));
            stringBuilder.AppendFormat("\"hasChilds\":\"{0}\",", flag ? "1" : "0");
            stringBuilder.Append("\"childs\":[");
            List <RoadFlow.Data.Model.Dictionary> childs = dictionary.GetChilds(dictionary2.ID);
            int num   = 0;
            int count = childs.Count;

            foreach (RoadFlow.Data.Model.Dictionary item in childs)
            {
                stringBuilder.Append("{");
                stringBuilder.AppendFormat("\"id\":\"{0}\",", item.ID);
                stringBuilder.AppendFormat("\"parentID\":\"{0}\",", item.ParentID);
                stringBuilder.AppendFormat("\"title\":\"{0}\",", item.Title);
                stringBuilder.AppendFormat("\"ico\":\"{0}\",", "");
                stringBuilder.AppendFormat("\"hasChilds\":\"{0}\",", dictionary.HasChilds(item.ID) ? "1" : "0");
                stringBuilder.Append("\"childs\":[");
                stringBuilder.Append("]");
                stringBuilder.Append("}");
                if (num++ < count - 1)
                {
                    stringBuilder.Append(",");
                }
            }
            stringBuilder.Append("]");
            stringBuilder.Append("}");
            stringBuilder.Append("]");
            return(stringBuilder.ToString());
        }
Пример #2
0
        public string TreeRefresh()
        {
            string msg;

            if (!Tools.CheckLogin(out msg) && !RoadFlow.Platform.WeiXin.Organize.CheckLogin())
            {
                return("");
            }
            Guid test;

            if (!base.Request.QueryString["refreshid"].IsGuid(out test))
            {
                base.Response.Write("[]");
            }
            StringBuilder stringBuilder = new StringBuilder("[", 1000);

            RoadFlow.Platform.Dictionary dictionary = new RoadFlow.Platform.Dictionary();
            IOrderedEnumerable <RoadFlow.Data.Model.Dictionary> orderedEnumerable = from p in dictionary.GetChilds(test)
                                                                                    orderby p.Sort
                                                                                    select p;
            int num  = 0;
            int num2 = orderedEnumerable.Count();

            foreach (RoadFlow.Data.Model.Dictionary item in orderedEnumerable)
            {
                bool flag = dictionary.HasChilds(item.ID);
                stringBuilder.Append("{");
                stringBuilder.AppendFormat("\"id\":\"{0}\",", item.ID);
                stringBuilder.AppendFormat("\"parentID\":\"{0}\",", item.ParentID);
                stringBuilder.AppendFormat("\"title\":\"{0}\",", item.Title);
                stringBuilder.AppendFormat("\"type\":\"{0}\",", flag ? "1" : "2");
                stringBuilder.AppendFormat("\"ico\":\"{0}\",", "");
                stringBuilder.AppendFormat("\"hasChilds\":\"{0}\",", flag ? "1" : "0");
                stringBuilder.Append("\"childs\":[");
                stringBuilder.Append("]");
                stringBuilder.Append("}");
                if (num++ < num2 - 1)
                {
                    stringBuilder.Append(",");
                }
            }
            stringBuilder.Append("]");
            return(stringBuilder.ToString());
        }