示例#1
0
        /// <summary>
        /// 添加权限定义  -2已存在对应的定义
        /// </summary>
        /// <param name="PermissionID"></param>
        /// <param name="PermissionKey">权限KEY 如:VIEW,UPDATE,ADD,DELETE</param>
        /// <param name="PermissionName"></param>
        /// <param name="TabID"></param>
        /// <returns></returns>
        public static int addPermission(int PermissionID, string PermissionKey, string PermissionName, int TabID)
        {
            PermissionInfo info;
            int            result = 0;

            info   = new PermissionInfo(PermissionID, "SYSTEM_TAB", PermissionKey, PermissionName, TabID);
            result = PermissionBLL.Insert(info, ReturnTypes.EffectRow);
            return(result);
        }
示例#2
0
        public static string GetMenuJSON(int UserID)
        {
            string UserType = "";

            Model.UserInfo userinfo = BLL.UsersBLL.GetModel(UserID);
            if (userinfo == null || userinfo.UserID != UserID)
            {
                return("");
            }
            UserType = userinfo.UserType;
            List <TabsInfo> list   = BLL.TabsBLL.GetList(-1, "ParentId=0 and DisPlay='True'", "");
            string          result = "[";

            if (list != null && list.Count > 0)
            {
                foreach (TabsInfo info in list)
                {
                    if (PermissionBLL.GetPermission(info.TabKey, UserID, "VIEW"))
                    {
                        string TabUrl = "javascript:void(0);";
                        if (info.TabUrl.Length > 0)
                        {
                            //if (i == 1)
                            //    TabUrl = "Main.aspx?menuid=" + info.TabID;
                            //else
                            TabUrl = info.TabUrl;
                        }

                        result += "{\"url\":\"" + TabUrl + "\",\"id\":\"" + info.TabID + "\",\"name\":\"" + info.TabName + "\",\"submenu\":[]},";
                    }
                }
            }
            if (UserType == Common.enumUserType.host.ToString())
            {
                result += "{\"url\":\"javascript:void(0);\",\"id\":\"admin\",\"name\":\"admin\",\"submenu\":[]},";
                result += "{\"url\":\"javascript:void(0);\",\"id\":\"host\",\"name\":\"Host\",\"submenu\":[]},";
            }
            if (UserType == Common.enumUserType.admin.ToString())
            {
                result += "{\"url\":\"javascript:void(0);\",\"id\":\"admin\",\"name\":\"admin\",\"submenu\":[]},";
            }
            if (result.EndsWith(","))
            {
                result = result.Remove(result.Length - 1);
            }
            result += "]";
            return(result);
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="ParentId"></param>
        /// <param name="Level">级别 0为到所有级 1为到一级 2为到二级 ...</param>
        /// <param name="addto0"></param>
        /// <param name="addto2"></param>
        /// <returns></returns>
        private static string menuXML(int UserID, int ParentId, int Level, string addto0, string addto1)
        {
            i++;
            if (Level > 0 && i > Level)
            {
                return("");
            }

            string          result = "";
            List <TabsInfo> list   = BLL.TabsBLL.GetList(-1, "ParentId=" + ParentId + " and DisPlay='True'", "");

            if (list != null && list.Count > 0)
            {
                result += "{0}";
                foreach (TabsInfo info in list)
                {
                    if (PermissionBLL.GetPermission(info.TabKey, UserID, "VIEW"))
                    {
                        string TabUrl = "javascript:void(0);";
                        if (info.TabUrl.Length > 0)
                        {
                            //if (i == 1)
                            //    TabUrl = "Main.aspx?menuid=" + info.TabID;
                            //else
                            TabUrl = info.TabUrl;
                        }
                        result += "<Tab ID=\"" + info.TabID + "\" NavigateUrl=\"" + TabUrl + "\" Text=\"" + info.TabName + "\">";
                        //result += "<Tab ID=\"" + info.TabID + "\" NavigateUrl=\"/admin/Main.aspx?menuid=" + info.TabID + "\" Text=\"" + info.TabName + "\">";
                        result += menuXML(UserID, info.TabID, Level, "", "");
                        result += "</Tab>";
                    }
                }
                result += "{1}";
            }
            else
            {
                if (i > 0)
                {
                    result += "{0}{1}";
                }
            }

            result = string.Format(result, addto0, addto1);

            i--;
            return(result);
        }
示例#4
0
        private static string menuJSON(int UserID, int ParentId, int Level)
        {
            i++;
            if (Level > 0 && i > Level)
            {
                return("");
            }

            string          result = "";
            List <TabsInfo> list   = BLL.TabsBLL.GetList(-1, "ParentId=" + ParentId + " and DisPlay='True'", ""); //TabsController.GetListInfoTabs(0, "ParentId=" + ParentId + " and DisPlay='True'");

            if (list != null && list.Count > 0)
            {
                foreach (TabsInfo info in list)
                {
                    if (PermissionBLL.GetPermission(info.TabKey, UserID, "VIEW"))
                    {
                        string TabUrl = "javascript:void(0);";
                        if (info.TabUrl.Length > 0)
                        {
                            //if (i == 1)
                            //    TabUrl = "Main.aspx?menuid=" + info.TabID;
                            //else
                            TabUrl = info.TabUrl;
                        }

                        result += "{\"url\":\"" + TabUrl + "\",\"id\":\"" + info.TabID + "\",\"name\":\"" + info.TabName + "\",\"submenu\":[";

                        result += menuJSON(UserID, info.TabID, Level);

                        result += "]},";
                    }
                }
            }
            if (result.Trim().Length > 0 && result.EndsWith(","))
            {
                result = result.Remove(result.Length - 1);
            }
            i--;
            return(result);
        }
示例#5
0
        /// <summary>
        /// 系统升级 更新菜单
        /// </summary>
        /// <returns></returns>
        public static int updateSystem_updatetabs()
        {
            //PermissionController.DeleteAllPermission();
            new TabsDAL().Delete("");
            PermissionBLL.Delete("");
            PermissionBLL.addPermission(1, enum_userpermission.VIEW.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.VIEW), 0);
            TabsInfo info;
            int      result = 0;

            #region 内容发布 1
            info = new TabsInfo(1, "内容发布", "Main.aspx?menuid=1", 0, "", true, "content", 1);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
            });
            info = new TabsInfo(11, "文章", "DesktopModules/article/article.aspx", 1, "", true, "article", 11);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
            });
            info = new TabsInfo(111, "文章", "DesktopModules/article/article.aspx", 11, "", true, "article", 111);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
                { enum_userpermission.ADD.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.ADD) },
                { enum_userpermission.UPDATE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.UPDATE) },
                { enum_userpermission.DELETE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.DELETE) },
            });
            info = new TabsInfo(112, "文章分类", "DesktopModules/article/article_category.aspx", 11, "", true, "article", 112);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
                { enum_userpermission.ADD.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.ADD) },
                { enum_userpermission.UPDATE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.UPDATE) },
                { enum_userpermission.DELETE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.DELETE) },
            });

            info = new TabsInfo(12, "广告", "DesktopModules/ad/ad.aspx", 1, "", true, "ad", 12);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
            });
            info = new TabsInfo(121, "广告位", "DesktopModules/ad/AdPosition.aspx", 12, "", true, "adposition", 121);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
                { enum_userpermission.ADD.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.ADD) },
                { enum_userpermission.UPDATE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.UPDATE) },
                { enum_userpermission.DELETE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.DELETE) },
            });
            info = new TabsInfo(122, "广告", "DesktopModules/ad/ad.aspx", 12, "", true, "ad", 122);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
                { enum_userpermission.ADD.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.ADD) },
                { enum_userpermission.UPDATE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.UPDATE) },
                { enum_userpermission.DELETE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.DELETE) },
            });

            #endregion

            #region 会员
            info = new TabsInfo(2, "会员", "Main.aspx?menuid=2", 0, "", true, "member", 2);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
            });
            info = new TabsInfo(21, "会员列表", "DesktopModules/member/member.aspx", 2, "", true, "article", 21);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
            });
            #endregion

            #region 商家
            info = new TabsInfo(3, "商家", "Main.aspx?menuid=2", 0, "", true, "member", 3);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
            });
            info = new TabsInfo(31, "商家列表", "DesktopModules/seller/seller.aspx", 3, "", true, "article", 31);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
            });
            #endregion

            #region 管理 4

            info = new TabsInfo(4, "管理", "Main.aspx?menuid=4", 0, "", true, "users", 4);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
            });
            info = new TabsInfo(41, "URL", "", 4, "", true, "companys", 41);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
            });
            info = new TabsInfo(411, "系统URL", "DesktopModules/resource/sysurl.aspx", 41, "", true, "url", 411);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
                { enum_userpermission.UPDATE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.UPDATE) },
                { enum_userpermission.DELETE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.DELETE) },
            });
            info = new TabsInfo(412, "自定义URL", "DesktopModules/resource/url.aspx", 41, "", true, "url", 412);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
                { enum_userpermission.ADD.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.ADD) },
                { enum_userpermission.UPDATE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.UPDATE) },
                { enum_userpermission.DELETE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.DELETE) },
            });
            info = new TabsInfo(42, "设置", "", 4, "", true, "config", 42);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
            });
            info = new TabsInfo(421, "参数设置", "DesktopModules/config/edit_config.aspx", 42, "", true, "url", 421);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
                { enum_userpermission.UPDATE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.UPDATE) },
                { enum_userpermission.DELETE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.DELETE) },
            });
            #endregion

            //===========================================

            #region 微信 5
            info = new TabsInfo(5, "微信", "Main.aspx?menuid=5", 0, "", true, "wx", 5);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
            });
            info = new TabsInfo(51, "微信", "", 5, "", true, "wx", 51);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
            });
            info = new TabsInfo(511, "素材", "DesktopModules/wx/wx_Material.aspx", 51, "", true, "wx_material", 511);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
                { enum_userpermission.UPDATE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.UPDATE) },
                { enum_userpermission.DELETE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.DELETE) },
            });
            info = new TabsInfo(512, "自动回复", "DesktopModules/wx/wx_ReplyMesage.aspx", 51, "", true, "wx_replymesage", 512);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
                { enum_userpermission.UPDATE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.UPDATE) },
                { enum_userpermission.DELETE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.DELETE) },
            });
            info = new TabsInfo(513, "自定义菜单", "DesktopModules/wx/wx_diymenu.aspx", 51, "", true, "wx_diymenu", 513);
            PermissionBLL.edittabs(info, new Dictionary <string, string>()
            {
                { enum_userpermission.UPDATE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.UPDATE) },
                { enum_userpermission.DELETE.ToString(), EnumHelper.GetEnumDescription(enum_userpermission.DELETE) },
            });
            #endregion

            return(result);
        }
示例#6
0
文件: RolesBLL.cs 项目: ben889/myb2b
        public static void init()
        {
            int        roleid_company = (int)Common.enumUserType.company;
            int        roleid_person  = (int)Common.enumUserType.person;
            List <int> listid         = new List <int>();

            listid.Add(roleid_company);
            listid.Add(roleid_person);
            //BLL.UserRolesBLL.Delete("");
            //Delete("");
            for (int i = 0; i < listid.Count; i++)
            {
                int    roleid     = listid[i];
                string RoleName   = Common.EnumHelper.GetEnumDescription(typeof(Common.enumUserType), roleid);
                string tabs_where = "";
                if (roleid == (int)Common.enumUserType.company)
                {
                    tabs_where = "TabKey not in('withdraw_cash')";
                }
                else if (roleid == (int)Common.enumUserType.person)
                {
                    tabs_where = "TabKey not in('withdraw_cash')";
                }
                Model.RoleInfo roleinfo = BLL.RolesBLL.GetModel(roleid);
                if (roleinfo == null || roleinfo.RoleID != roleid)
                {
                    roleinfo             = new Model.RoleInfo();
                    roleinfo.RoleID      = roleid;
                    roleinfo.RoleName    = RoleName;
                    roleinfo.Description = "";
                    roleinfo.IconFile    = "";
                    int addroleresult = BLL.RolesBLL.Add(roleinfo);
                }
                if (roleinfo.RoleID == roleid)
                {
                    //重新删除后再添加对应的权限
                    TabPermissionBLL.Delete("roleid=" + roleid);// .DeleteTabPermissionByRoleID(roleid);
                    List <TabsInfo> tabslist = TabsBLL.GetList(-1, tabs_where, "");
                    if (tabslist != null)
                    {
                        foreach (TabsInfo tabsInfo in tabslist)
                        {
                            if (tabsInfo == null || tabsInfo.TabID <= 0)
                            {
                                continue;
                            }
                            List <PermissionInfo> list = PermissionBLL.GetList(-1, "PermissionCode='SYSTEM_TAB' AND (TabID=0 OR TabID is NULL or TabID=" + tabsInfo.TabID + ")", "");
                            if (list == null || list.Count == 0)
                            {
                                continue;
                            }
                            foreach (PermissionInfo info in list)
                            {
                                //PermissionBLL.UpdateTabPermissionByRoleID(tabsInfo.TabID, info.PermissionID, roleid, 0, 0, 0);
                                TabPermissionInfo tabpinfo = new TabPermissionInfo();
                                tabpinfo.TabID        = tabsInfo.TabID;
                                tabpinfo.RoleID       = roleid;
                                tabpinfo.PermissionID = info.PermissionID;
                                TabPermissionBLL.Save(tabpinfo);
                            }
                        }
                    }
                }
            }
        }