Esempio n. 1
0
    public static void ApplayRecordPermision(BPMConnection cn, JsonItemCollection items, string rsid, string tableName, string jsonitemKeyAttrName)
    {
        //获得资源上的记录级权限种类
        UserResourcePermisionCollection resourcePerms = UserResourceSecurityManager.GetResourcePermisions(cn, rsid);
        BPMObjectNameCollection         permNames     = new BPMObjectNameCollection();

        foreach (UserResourcePermision resourcePerm in resourcePerms)
        {
            if (resourcePerm.PermType == UserResourcePermisionType.Record)
            {
                permNames.Add(resourcePerm.PermName);
            }
        }

        //应用权限
        foreach (JsonItem item in items)
        {
            string key = Convert.ToString(item.Attributes[jsonitemKeyAttrName]);
            bool[] rv  = RecordSecurityManager.CheckPermision(cn, tableName, key, permNames);

            JsonItem jsonPerm = new JsonItem();
            item.Attributes["perm"] = jsonPerm;
            for (int i = 0; i < permNames.Count; i++)
            {
                jsonPerm.Attributes[permNames[i]] = rv[i];
            }
        }
    }
Esempio n. 2
0
    public static void ApplayPermision(BPMConnection cn, JsonItemCollection items)
    {
        for (int moduleIndex = 0; moduleIndex < items.Count; moduleIndex++)
        {
            JsonItem item          = items[moduleIndex];
            bool     moduleExecute = true;

            if (item.Attributes.ContainsKey("modulePerm"))
            {
                YZModulePermision perm = item.Attributes["modulePerm"] as YZModulePermision;
                item.Attributes.Remove("modulePerm");

                //检查模块权限
                moduleExecute = UserResourceSecurityManager.CheckPermision(cn, perm.RSID, "Execute");

                if (moduleExecute)
                {
                    //获得模块config配置项
                    JsonItem config = null;
                    if (item.Attributes.ContainsKey("config"))
                    {
                        config = item.Attributes["config"] as JsonItem;
                    }
                    else
                    {
                        config = new JsonItem();
                        item.Attributes["config"] = config;
                    }

                    //在config配置项下建perm配置
                    JsonItem jsonPerm = new JsonItem();
                    config.Attributes["perm"] = jsonPerm;

                    //记录模块rsid
                    jsonPerm.Attributes["rsid"] = perm.RSID;

                    //生成工具条上的访问权限
                    if (perm.GenToolbarPermision)
                    {
                        //获得工具条上的模块级权限种类
                        UserResourcePermisionCollection resourcePerms = UserResourceSecurityManager.GetResourcePermisions(cn, perm.RSID);
                        BPMObjectNameCollection         permNames     = new BPMObjectNameCollection();
                        foreach (UserResourcePermision resourcePerm in resourcePerms)
                        {
                            if (resourcePerm.PermType == UserResourcePermisionType.Module)
                            {
                                permNames.Add(resourcePerm.PermName);
                            }
                        }

                        //记录工具条上的模块级权限许可情况
                        bool[] rv = UserResourceSecurityManager.CheckPermision(cn, perm.RSID, permNames);
                        for (int i = 0; i < permNames.Count; i++)
                        {
                            jsonPerm.Attributes[permNames[i]] = rv[i];
                        }
                    }
                }
                else
                {
                    items.RemoveAt(moduleIndex);
                    moduleIndex--;
                }
            }

            //此模块可见则检查子级
            if (moduleExecute)
            {
                if (item.Attributes.ContainsKey("children"))
                {
                    JsonItemCollection children = item.Attributes["children"] as JsonItemCollection;
                    if (children != null)
                    {
                        int allCount = children.Count;
                        ApplayPermision(cn, children);

                        if (allCount != 0 && children.Count == 0)
                        {
                            //item.Attributes["empty"] = true;
                            items.RemoveAt(moduleIndex);
                            moduleIndex--;
                            continue;
                        }
                    }
                }

                if (item.Attributes.ContainsKey("tabs"))
                {
                    JsonItemCollection tabs = item.Attributes["tabs"] as JsonItemCollection;
                    if (tabs != null)
                    {
                        int allCount = tabs.Count;
                        ApplayPermision(cn, tabs);

                        if (allCount != 0 && tabs.Count == 0)
                        {
                            //item.Attributes["empty"] = true;
                            items.RemoveAt(moduleIndex);
                            moduleIndex--;
                            continue;
                        }
                    }
                }
            }
        }
    }
Esempio n. 3
0
 public static bool CheckModulePermision(BPMConnection cn, string rsid, string permName)
 {
     return(UserResourceSecurityManager.CheckPermision(cn, rsid, permName));
 }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Charset = "UTF-8";
        Response.AddHeader("P3P", "CP=CAO PSA OUR"); //无此行当在ie的iframe中打开应用(default.aspx.cs)时设置cookie后,ajax request时cookie没了
        this.Response.Cache.SetCacheability(HttpCacheability.NoCache);

        if (!YZAuthHelper.IsAuthenticated)
        {
            FormsAuthentication.RedirectToLoginPage();
            return;
        }

        //设置页标题
        this.Page.Title = System.Web.Configuration.WebConfigurationManager.AppSettings["CompanyInfoDefaultPageTitle"];
        if (String.IsNullOrEmpty(this.Page.Title))
        {
            this.Page.Title = Resources.YZStrings.Aspx_DefaultPage_Title;
        }

        //设置HTML标准
        if (String.Compare(this.Request.Browser.Browser, "IE", true) == 0 && this.Request.Browser.MajorVersion == 6)
        {
        }
        else
        {
            this._litTop.Text = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
        }

        //没有site参数,或site参数不正确
        int factoryId = 0;

        Int32.TryParse(this.Request.QueryString["site"], out factoryId);

        //获得帐号信息
        User user = new User();
        int  taskCount;
        int  userLevel = 10;
        bool permSys   = false;
        bool leave     = false;

        using (BPMConnection cn = new BPMConnection())
        {
            cn.WebOpen();

            //获得当前用户
            user.Open(cn, YZAuthHelper.LoginUserAccount);
            taskCount = cn.GetMyTaskCount(null);
            UserCommonInfo userCommonInfo = UserCommonInfo.FromAccount(cn, YZAuthHelper.LoginUserAccount);

            MemberCollection positions = OrgSvr.GetUserPositions(cn, YZAuthHelper.LoginUserAccount);
            foreach (Member member in positions)
            {
                if (member.Level > userLevel)
                {
                    userLevel = (int)member.Level;
                }
            }

            //检查对系统管理模块的权限
            permSys = UserResourceSecurityManager.CheckPermision(cn, YZWellKnowRSID.SYS, "Execute");
            leave   = userCommonInfo.OutOfOfficeState == OutOfOfficeState.InOffice ? false:true;
        }

        JsonItem rv = new JsonItem();

        rv.Attributes["LCID"]               = YZLangHelper.CurrentCulture.LCID;
        rv.Attributes["CompanyName"]        = System.Web.Configuration.WebConfigurationManager.AppSettings["CompanyInfoCompanyName"];
        rv.Attributes["Account"]            = YZAuthHelper.LoginUserAccount;
        rv.Attributes["DisplayName"]        = user.DisplayName;
        rv.Attributes["TaskCount"]          = taskCount;
        rv.Attributes["UserLevel"]          = userLevel;
        rv.Attributes["PermSys"]            = permSys;
        rv.Attributes["Leave"]              = leave;
        rv.Attributes["Link1"]              = System.Web.Configuration.WebConfigurationManager.AppSettings["CompanyInfoLink1"];
        rv.Attributes["DBType"]             = QueryManager.DBProviderName != "SQL Server" ? QueryManager.DBProviderName : "";
        rv.Attributes["UnreadMessageCount"] = 0;

        //获得rootUrl
        string url         = this.Request.Url.GetLeftPart(UriPartial.Authority);
        string virtualPath = HttpRuntime.AppDomainAppVirtualPath;

        if (virtualPath == "/")
        {
            virtualPath = String.Empty;
        }

        url = url + virtualPath + "/";

        //在页面中包含JS
        string             jscode = String.Format("var rootUrl='{0}';\nvar userInfo = {1}", url, rv.ToString());
        HtmlGenericControl js     = new HtmlGenericControl("script");

        js.Attributes["type"] = "text/javascript";
        js.InnerHtml          = jscode;
        this.Page.Header.Controls.AddAt(1, js);

        //设置Cookie
        HttpCookie cookie;

        cookie = new HttpCookie("UserDisplayName", HttpUtility.UrlEncode(Convert.ToString(rv.Attributes["DisplayName"]), System.Text.Encoding.UTF8));
        this.Response.SetCookie(cookie);
        cookie = new HttpCookie("UserLevel", userLevel.ToString());
        this.Response.SetCookie(cookie);

        string startApp = this.Request.QueryString["StartApp"];

        if (String.IsNullOrEmpty(startApp))
        {
            startApp = System.Web.Configuration.WebConfigurationManager.AppSettings["StartApp"];
        }
        if (String.IsNullOrEmpty(startApp))
        {
            startApp = "YZApp";
        }

        this._litStartApp.Text    = String.Format("<script src=\"{0}/MainWindow.js\" type=\"text/javascript\"></script>", startApp);
        this._litStartAppCss.Text = String.Format("<link href=\"{0}/Styles/main.css\" rel=\"stylesheet\" type=\"text/css\" />", startApp);
    }