public ActionResult AddApp(FormCollection collection)
        {
            BizProcess.Platform.AppLibrary bappLibrary = new BizProcess.Platform.AppLibrary();
            BizProcess.Platform.UsersApp   busersApp   = new BizProcess.Platform.UsersApp();
            BizProcess.Platform.RoleApp    broleApp    = new BizProcess.Platform.RoleApp();
            BizProcess.Data.Model.UsersApp usersApp    = null;

            string id     = Request.QueryString["id"];
            string userID = Request.QueryString["userid"];
            string roleID = Request.QueryString["roleid"];

            if (collection != null && id.IsGuid() && userID.IsGuid())
            {
                usersApp = busersApp.Get(id.ToGuid());
                if (!Request.Form["Save"].IsNullOrEmpty())
                {
                    string name    = Request.Form["Name"];
                    string type    = Request.Form["Type"];
                    string appid   = Request.Form["AppID"];
                    string params1 = Request.Form["Params"];
                    string ico     = Request.Form["Ico"];

                    BizProcess.Data.Model.UsersApp usersApp1 = new BizProcess.Data.Model.UsersApp();

                    usersApp1.ID       = Guid.NewGuid();
                    usersApp1.ParentID = id.ToGuid();
                    usersApp1.Title    = name.Trim();
                    usersApp1.Sort     = broleApp.GetMaxSort(id.ToGuid());
                    usersApp1.UserID   = userID.ToGuid();
                    usersApp1.RoleID   = roleID.IsGuid() ? roleID.ToGuid() : Guid.Empty;
                    if (appid.IsGuid())
                    {
                        usersApp1.AppID = appid.ToGuid();
                    }
                    else
                    {
                        usersApp1.AppID = null;
                    }
                    usersApp1.Params = params1.IsNullOrEmpty() ? null : params1.Trim();
                    if (!ico.IsNullOrEmpty())
                    {
                        usersApp1.Ico = ico;
                    }

                    busersApp.Add(usersApp1);
                    busersApp.ClearCache();
                    BizProcess.Platform.Log.Add("添加了个人应用", busersApp.Serialize(), BizProcess.Platform.Log.Types.角色应用);
                    string refreshID = id;
                    ViewBag.Script = "alert('添加成功!'); parent.frames[0].reLoad('" + refreshID + "')";
                }
            }

            ViewBag.AppTypesOptions = bappLibrary.GetTypeOptions();
            return(View());
        }
        public string TreeRefresh()
        {
            string id     = Request["refreshid"];
            string userID = Request.QueryString["userid"];
            Guid   rid;

            if (!id.IsGuid(out rid))
            {
                return("[]");
            }
            BizProcess.Platform.RoleApp  BRoleApp  = new BizProcess.Platform.RoleApp();
            BizProcess.Platform.UsersApp BUsersApp = new BizProcess.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());
        }
示例#3
0
        /// <summary>
        /// 检查应用程序权限
        /// </summary>
        /// <param name="appid"></param>
        /// <returns></returns>
        public static bool CheckApp(out string msg, string appid = "")
        {
            msg   = "";
            appid = appid.IsNullOrEmpty() ? System.Web.HttpContext.Current.Request.QueryString["appid"] : appid;
            Guid appGuid;

            if (!appid.IsGuid(out appGuid))
            {
                return(false);
            }
            var app = new BizProcess.Platform.RoleApp().GetFromCache(appid);

            if (app != null)
            {
                var roles = BizProcess.Platform.Users.CurrentUserRoles;
                if (roles.Contains(app["RoleID"].ToString().ToGuid()))
                {
                    return(true);
                }
                else
                {
                    msg = "<script>top.login();</script>";
                }
            }
            else
            {
                var userID = BizProcess.Platform.Users.CurrentUserID;
                if (userID.IsEmptyGuid())
                {
                    msg = "<script>top.login();</script>";
                    return(false);
                }
                var userApp = new BizProcess.Platform.UsersApp().GetUserDataRows(userID);
                foreach (System.Data.DataRow dr in userApp)
                {
                    if (dr["ID"].ToString().ToGuid() == appGuid)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        public ActionResult Body1(FormCollection collection)
        {
            BizProcess.Platform.AppLibrary bappLibrary = new BizProcess.Platform.AppLibrary();
            BizProcess.Platform.RoleApp    broleApp    = new BizProcess.Platform.RoleApp();
            BizProcess.Platform.UsersApp   buserApp    = new BizProcess.Platform.UsersApp();
            BizProcess.Data.Model.UsersApp usersApp    = null;

            string id = Request.QueryString["id"];

            string name    = string.Empty;
            string type    = string.Empty;
            string appid   = string.Empty;
            string params1 = string.Empty;
            string ico     = string.Empty;

            Guid appID;

            if (id.IsGuid(out appID))
            {
                usersApp = buserApp.Get(appID);
                if (usersApp != null)
                {
                    name    = usersApp.Title;
                    type    = usersApp.AppID.HasValue ? bappLibrary.GetTypeByID(usersApp.AppID.Value) : "";
                    appid   = usersApp.AppID.ToString();
                    params1 = usersApp.Params;
                    ico     = usersApp.Ico;
                }
            }


            if (collection != null && usersApp != null)
            {
                if (!Request.Form["Save"].IsNullOrEmpty())
                {
                    name    = Request.Form["Name"];
                    type    = Request.Form["Type"];
                    appid   = Request.Form["AppID"];
                    params1 = Request.Form["Params"];
                    ico     = Request.Form["Ico"];

                    string oldXML = usersApp.Serialize();
                    usersApp.Title = name.Trim();
                    if (appid.IsGuid())
                    {
                        usersApp.AppID = appid.ToGuid();
                    }
                    else
                    {
                        usersApp.AppID = null;
                    }
                    usersApp.Params = params1.IsNullOrEmpty() ? null : params1.Trim();
                    if (!ico.IsNullOrEmpty())
                    {
                        usersApp.Ico = ico;
                    }
                    else
                    {
                        usersApp.Ico = null;
                    }

                    buserApp.Update(usersApp);
                    buserApp.ClearCache();
                    BizProcess.Platform.Log.Add("修改了个人应用", "", BizProcess.Platform.Log.Types.角色应用, oldXML, usersApp.Serialize());
                    string refreshID = usersApp.ParentID.ToString();
                    ViewBag.Script = "alert('保存成功!'); parent.frames[0].reLoad('" + refreshID + "')";
                }

                if (!Request.Form["Delete"].IsNullOrEmpty())
                {
                    int i = buserApp.DeleteAndAllChilds(usersApp.ID);
                    buserApp.ClearCache();
                    BizProcess.Platform.Log.Add("删除了个人应用", usersApp.Serialize(), BizProcess.Platform.Log.Types.角色应用);
                    string refreshID = usersApp.ParentID.ToString();
                    var    parent    = buserApp.Get(usersApp.ParentID);
                    string page      = parent == null ? "Body" : "Body1";
                    ViewBag.Script = "parent.frames[0].reLoad('" + refreshID + "');window.location='" + page + "?id=" + refreshID + "&appid=" + Request.QueryString["appid"] + "&tabid=" + Request.QueryString["tabid"] + "&userid=" + Request.QueryString["userid"] + "';";
                }
            }
            ViewBag.AppID           = appid;
            ViewBag.AppTypesOptions = bappLibrary.GetTypeOptions(type);
            return(View(usersApp == null ? new BizProcess.Data.Model.UsersApp() : usersApp));
        }