Ejemplo n.º 1
0
        public ActionResult Sort(FormCollection collection)
        {
            Business.Platform.RoleApp broleApp    = new Business.Platform.RoleApp();
            List <Data.Model.RoleApp> roleAppList = new List <Data.Model.RoleApp>();
            string id      = Request.QueryString["id"];
            var    roleApp = broleApp.Get(id.ToGuid());

            roleAppList = broleApp.GetChild(roleApp.ParentID);

            if (collection != null)
            {
                string srots = Request.Form["sortapp"];
                if (srots.IsNullOrEmpty())
                {
                    return(View(roleAppList));
                }
                string[] sortArray = srots.Split(new char[] { ',' });
                for (int i = 0; i < sortArray.Length; i++)
                {
                    Guid guid;
                    if (!sortArray[i].IsGuid(out guid))
                    {
                        continue;
                    }
                    broleApp.UpdateSort(guid, i + 1);
                }
                broleApp.ClearAllDataTableCache();
                string rid = roleApp.ParentID.ToString();
                ViewBag.Script = "parent.frames[0].reLoad('" + rid + "');";
                roleAppList    = broleApp.GetChild(roleApp.ParentID);
            }
            return(View(roleAppList));
        }
Ejemplo n.º 2
0
        public string TreeRefresh()
        {
            string id     = Request["refreshid"];
            string userID = Request.QueryString["userid"];
            Guid   rid;

            if (!id.IsGuid(out rid))
            {
                return("[]");
            }
            Business.Platform.RoleApp  BRoleApp  = new Business.Platform.RoleApp();
            Business.Platform.UsersApp BUsersApp = new Business.Platform.UsersApp();
            var childs = BRoleApp.GetChild(rid);

            //加载个人应用
            if (userID.IsGuid())
            {
                BUsersApp.AppendUserApps(userID.ToGuid(), rid, childs);
            }

            System.Text.StringBuilder json = new System.Text.StringBuilder("[", childs.Count * 50);
            int count = childs.Count;
            int i     = 0;

            foreach (var child in childs.OrderBy(p => p.Sort))
            {
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", child.ID.ToString());
                json.AppendFormat("\"title\":\"{0}\",", child.Title);
                json.AppendFormat("\"ico\":\"{0}\",", child.Ico);
                json.AppendFormat("\"link\":\"{0}\",", "");
                json.AppendFormat("\"type\":\"{0}\",", child.Type);
                json.AppendFormat("\"model\":\"{0}\",", "");
                json.AppendFormat("\"width\":\"{0}\",", "");
                json.AppendFormat("\"height\":\"{0}\",", "");
                json.AppendFormat("\"hasChilds\":\"{0}\",", BRoleApp.HasChild(child.ID) || BUsersApp.HasChild(child.ID) ? "1" : "0");
                json.AppendFormat("\"childs\":[");
                json.Append("]");
                json.Append("}");
                if (i++ < count - 1)
                {
                    json.Append(",");
                }
            }
            json.Append("]");
            return(json.ToString());
        }
Ejemplo n.º 3
0
        public string TreeRefresh()
        {
            string id = Request["refreshid"];

            if (!id.IsGuid())
            {
                return("[]");
            }
            Business.Platform.RoleApp BRoleApp = new Business.Platform.RoleApp();
            var childs = BRoleApp.GetChild(id.ToGuid());

            System.Text.StringBuilder json = new System.Text.StringBuilder("[", childs.Count * 50);
            int count = childs.Count;
            int i     = 0;

            foreach (var child in childs)
            {
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", child.ID);
                json.AppendFormat("\"title\":\"{0}\",", child.Title);
                json.AppendFormat("\"ico\":\"{0}\",", child.Ico.IsNullOrEmpty() ? "" : Url.Content("~/" + child.Ico));
                json.AppendFormat("\"link\":\"{0}\",", "");
                json.AppendFormat("\"type\":\"{0}\",", "0");
                json.AppendFormat("\"model\":\"{0}\",", "");
                json.AppendFormat("\"width\":\"{0}\",", "");
                json.AppendFormat("\"height\":\"{0}\",", "");
                json.AppendFormat("\"hasChilds\":\"{0}\",", BRoleApp.HasChild(child.ID) ? "1" : "0");
                json.AppendFormat("\"childs\":[");
                json.Append("]");
                json.Append("}");
                if (i++ < count - 1)
                {
                    json.Append(",");
                }
            }
            json.Append("]");
            return(json.ToString());
        }