コード例 #1
0
        private object GetMenuList()
        {
            List <resource> list = IocModule.GetEntity <IresourceEx>().getEntityList();

            //string str = ToMenuJson(list, "0");
            return(ToMenuJson(list, "0"));
        }
コード例 #2
0
        public void Details()//详情视图
        {
            List <propertymapping> pros  = IocModule.GetEntity <IpropertyMappingEx>().getEntityList();
            List <propertymapping> types = pros.Where(p => p.propertyName == "type" && p.parentId != 0).ToList();

            tp.Put("types", types);
            tp.Display(ctx, "/Html/layer/articledetail_layer.html");
        }
コード例 #3
0
ファイル: AccountsPrincipal.cs プロジェクト: xxzzjj222/Athena
 /// <summary>
 /// 设置当前角色数据列表
 /// </summary>
 /// <param name="username"></param>
 /// <param name="roleID"></param>
 public void SetList(string username, int roleID)
 {
     actionList  = IocModule.GetEntity <IroleActionEx>().getRoleAllAction(roleID);
     menuList    = IocModule.GetEntity <IroleResourceEx>().getRoleResource(roleID, 1);
     toolbarList = IocModule.GetEntity <IroleResourceEx>().getRoleResource(roleID, 2);
     buttonList  = IocModule.GetEntity <IroleResourceEx>().getRoleResource(roleID, 3);
     scriptList  = IocModule.GetEntity <IroleResourceEx>().getRoleResource(roleID, 4);
     fileList    = IocModule.GetEntity <IroleResourceEx>().getRoleResource(roleID, 5);
 }
コード例 #4
0
        /// <summary>
        /// 获取指定用户的特定类型和属主的资源列表
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="type"></param>
        /// <param name="owner"></param>
        /// <param name="currentrole"></param>
        /// <returns></returns>
        public static List <resource> getUserResource(string username, int type, role currentrole, string owner = "")
        {
            List <resource> rr = new List <resource>();
            IroleResourceEx _roleResourceEx = IocModule.GetEntity <IroleResourceEx>();

            rr.AddRange(_roleResourceEx.getRoleResource(currentrole.id, type, owner));
            rr = rr.Where((x, i) => rr.FindIndex(z => z.id == x.id) == i).ToList();//Lambda表达式去重
            return(rr);
        }
コード例 #5
0
ファイル: AccountsPrincipal.cs プロジェクト: xxzzjj222/Athena
        /// <summary>
        /// 根据用户名构造
        /// </summary>
        public AccountsPrincipal(string userName)
        {
            identity = new SiteIdentity(userName);
            user u = IocModule.GetEntity <IuserEx>().getUser(userName) as user;

            if (u != null)
            {
                SetList(userName);
                currentuser = u;
            }
        }
コード例 #6
0
ファイル: AccountsPrincipal.cs プロジェクト: xxzzjj222/Athena
 /// <summary>
 /// 验证方式1,传统的基于口令的验证登录信息
 /// </summary>
 public static AccountsPrincipal ValidateLogin(string username, string password)
 {
     if (IocModule.GetEntity <IuserEx>().checkPassword(username, password))
     {
         return(new AccountsPrincipal(username));
     }
     else
     {
         return(null);
     }
 }
コード例 #7
0
ファイル: AccountsPrincipal.cs プロジェクト: xxzzjj222/Athena
 /// <summary>
 /// 验证方式2,通过数字签名验证登录信息
 /// </summary>
 public static AccountsPrincipal ValidateLoginBySignature(string username, string msg, string sig)
 {
     if (IocModule.GetEntity <IuserEx>().verify(username, msg, sig))
     {
         return(new AccountsPrincipal(username));
     }
     else
     {
         return(null);
     }
 }
コード例 #8
0
ファイル: AccountsPrincipal.cs プロジェクト: xxzzjj222/Athena
        /// <summary>
        /// 根据用户编号构造
        /// </summary>
        public AccountsPrincipal(int userID)
        {
            identity = new SiteIdentity(userID);
            user u = IocModule.GetEntity <IuserEx>().getEntityById(userID) as user;

            if (u != null)
            {
                currentuser = u;
                string username = u.username;
                SetList(username);
            }
        }
コード例 #9
0
ファイル: AccountsPrincipal.cs プロジェクト: xxzzjj222/Diana
 /// <summary>
 /// 设置当前用户的当前角色的数据列表
 /// </summary>
 /// <param name="username"></param>
 public void SetList(string username)
 {
     roleList    = IocModule.GetEntity <IuserRoleEx>().getRole(username);
     actionList  = UserInfo.getUserAllAction(username, currentrole);
     menuList    = UserInfo.getUserResource(username, 1, currentrole);
     toolbarList = UserInfo.getUserResource(username, 2, currentrole);
     buttonList  = UserInfo.getUserResource(username, 3, currentrole);
     scriptList  = UserInfo.getUserResource(username, 4, currentrole);
     fileList    = UserInfo.getUserResource(username, 5, currentrole);
     //////////////////工作流新增/////////////////////////////////////
     //wfCtrlActionList = UserInfo.getUserWfCtrlActions(username);
     //wfActionList = UserInfo.getWfActions(username);
     ///////////////////////////////////////////////////////////////
 }
コード例 #10
0
        public override void view()
        {
            List <role>      roles      = new List <role>();
            List <user_role> user_roles = IocModule.GetEntity <IuserRoleEx>().getRole(accctx.currentuser.id);

            foreach (var item in user_roles)
            {
                role r = IocModule.GetEntity <IroleEx>().getRole(item.roleid);
                roles.Add(r);
            }
            tp.Put("username", accctx.currentuser.username);
            tp.Put("rolelist", roles);
            tp.Display(ctx, "../selectrole.html");
        }
コード例 #11
0
        public static List <resource> getUserAllResource(string username, string owner = "")//获取指定用户的特定类型和属主的资源列表
        {
            List <resource> rr       = new List <resource>();
            List <role>     rolelist = IocModule.GetEntity <IroleEx>().getUserRoles(username);

            if (rolelist.Count > 0)
            {
                IroleResourceEx _roleResourceEx = IocModule.GetEntity <IroleResourceEx>();
                foreach (var e in rolelist)
                {
                    rr.AddRange(_roleResourceEx.getRoleAllResource(e.id, owner));
                }
                rr = rr.Where((x, i) => rr.FindIndex(z => z.id == x.id) == i).ToList();//Lambda表达式去重
            }
            return(rr);
        }
コード例 #12
0
        public static List <action> getUserAction(string username, int type, string owner = "")//获取指定用户的特定类型和属主的动作列表,会含有重复项
        {
            List <action> rr       = new List <action>();
            List <role>   rolelist = IocModule.GetEntity <IuserRoleEx>().getRole(username);

            if (rolelist.Count > 0)
            {
                IroleActionEx _roleActionEx = IocModule.GetEntity <IroleActionEx>();
                foreach (var e in rolelist)
                {
                    rr.AddRange(_roleActionEx.getRoleAction(e.id, type, owner));
                }
                rr = rr.Where((x, i) => rr.FindIndex(z => z.id == x.id) == i).ToList();//Lambda表达式去重
            }
            return(rr);
        }
コード例 #13
0
        public void selectrole()
        {
            string msg = "";

            if (ctx.Request["roleid"] != null)
            {
                string roleid = ctx.Request["roleid"];
                accctx.currentrole = IocModule.GetEntity <IroleEx>().getRole(int.Parse(roleid));
                accctx.SetList(accctx.currentuser.username); //加载当前用户当前角色的所有权限资源
                msg = "角色选择成功,页面跳转中!";
                WriteBackHtml(msg, true);                    //在页面上可以以红字提醒,JS直接direct跳转到下一个链接
            }
            else
            {
                WriteBackHtml(msg, false);
            }
        }
コード例 #14
0
ファイル: AccountsPrincipal.cs プロジェクト: xxzzjj222/Athena
 /// <summary>
 /// 设置当前用户数据列表
 /// </summary>
 /// <param name="username"></param>
 private void SetList(string username)
 {
     try
     {
         actionList  = UserInfo.getUserAllAction(username);
         roleList    = IocModule.GetEntity <IuserRoleEx>().getRole(username);
         menuList    = UserInfo.getUserResource(username, 1);
         toolbarList = UserInfo.getUserResource(username, 2);
         buttonList  = UserInfo.getUserResource(username, 3);
         scriptList  = UserInfo.getUserResource(username, 4);
         fileList    = UserInfo.getUserResource(username, 5);
     }
     catch (Exception ex)
     {
         string m = ex.Message;
     }
 }
コード例 #15
0
        /// <summary>
        /// 无动作名时执行默认方法
        /// </summary>
        public override void DefaultAction()//默认动作
        {
            string state   = ctx.Request["state"];
            string pageUrl = string.Empty;
            var    data    = ctx.Request;  //获取回调响应参数
            var    code    = data["code"]; // 认证返回的code信息;

            if (!string.IsNullOrEmpty(code))
            {
                api                   = new LoginApiHelp(state); //存储用户信息
                threeloginInfo        = api.DealCode(code);      //据code向百度服务器进行交互获取长期的Access Token   并调用api获取数据
                accctx                = AccountsPrincipal.ValidateLogin(threeloginInfo.useName, threeloginInfo.uid);
                ctx.Session["accctx"] = accctx;
                if (string.IsNullOrEmpty(accctx.currentrole.rolename))
                {
                    accctx.currentrole = IocModule.GetEntity <IroleEx>().getAllRole().OrderByDescending(c => c.rolecode).FirstOrDefault();
                }
                ctx.Response.Redirect("/index.ashx?ctrl=index&action=view", false);
            }
        }
コード例 #16
0
ファイル: AcTree.cs プロジェクト: xxzzjj222/Athena
        //需要获取check值的初始化方法
        public AcTree(action action, List <action> roleresource)
        {
            this.action       = action;
            this.roleresource = roleresource;

            if (action != null)
            {
                IactionEx     IactionEx = IocModule.GetEntity <IactionEx>();
                List <action> rlist     = IactionEx.getEntityList().Where(p => p.actionowner == action.id.ToString()).ToList();//获取属于这个节点的子节点
                foreach (action r in rlist)
                {
                    AcTree tn = new AcTree(r, roleresource);
                    if (roleresource.Where(a => a.id == r.id).Count() > 0)
                    {
                        tn.@checked = true;
                    }
                    this.children.Add(tn);
                }
            }
        }
コード例 #17
0
ファイル: baseControler.cs プロジェクト: xxzzjj222/Diana
 public void  getbuttonresource(string controlername, int type)
 {
     if (ctx.Session["accctx"] != null && accctx.currentrole.rolename == "超级管理员")//如果是超级管理员,则不需要判断权限直接调用
     {
         List <resource> btns = IdalCommon.IresourceEx.getResourcesbycontrolername(controlername, 3);
         tp.Put("btns", btns);
     }
     else
     {
         var item = IocModule.GetEntity <IresourceEx>().getResourcebycontrolername(controlername, 2);
         if (item != null)
         {
             if (accctx.Buttons != null)
             {
                 List <resource> btns = accctx.Buttons.FindAll(t => t.resourceowner == Convert.ToString(item.id));
                 tp.Put("btns", btns);
             }
         }
     }
 }
コード例 #18
0
ファイル: LoginApiHelp.cs プロジェクト: xxzzjj222/Diana
        public threeloginInfo DealCode(string code)
        {
            threeloginInfo    tl    = null;
            ThreeLoginFactory three = new ThreeLoginFactory(GetThreeLoginType());
            var token = three.GetLoginHelp().AccessToken(code);

            if (token != null)
            {
                var userInfo = three.GetLoginHelp().UserInfo(token.access_token, token.uid);//调用API  获取用户数据
                if (userInfo != null)
                {
                    var item = IocModule.GetEntity <IthreeloginInfoEx>().getthreeloginInfobyuid(userInfo.userid);
                    tl             = new threeloginInfo();
                    tl.accessToken = token.access_token;
                    tl.code        = code;
                    tl.uid         = userInfo.userid;
                    tl.useImg      = portraiturl + userInfo.portrait;
                    tl.type        = (int)BlakTypeEnum.BAIDU;
                    tl.typeName    = BlakTypeEnum.BAIDU.ToString();
                    //tl.sex = Convert.ToInt32(userInfo.sex);
                    tl.useName = userInfo.username;
                    //tl.refreshToken = token.refresh_token;

                    if (item == null)
                    {
                        #region 第一次第三方登录
                        //存储数据库
                        IocModule.GetEntity <IthreeloginInfoEx>().insert(tl);
                        IocModule.GetEntity <IthreeloginInfoEx>().InsertthreeloginInfo(tl);
                        #endregion
                    }
                    else
                    {
                        tl.id = item.id;
                        IocModule.GetEntity <IthreeloginInfoEx>().update(tl);
                    }
                }
            }
            return(tl);
        }
コード例 #19
0
        /// <summary>
        /// 根据用户id获取用户角色列表
        /// </summary>
        public void GetPermissionTree()
        {
            string userId        = ctx.Request["userId"];
            var    rolelist      = IdalCommon.IroleEx.getEntityList();
            var    authorityRole = new List <role>();

            if (!string.IsNullOrEmpty(userId))
            {
                try
                {
                    int  id = Convert.ToInt32(userId);
                    user u  = IdalCommon.IuserEx.getEntityById(id);
                    //authorityRole = IdalCommon.IuserRoleEx.getRole(u.username);
                    authorityRole = IocModule.GetEntity <IuserRoleEx>().getRole(u.username);
                }
                catch (Exception ex)
                {
                    string message = ex.Message;
                }
            }
            var treeList = new List <TreeViewModel>();

            foreach (role item in rolelist)
            {
                TreeViewModel tree = new TreeViewModel();
                tree.id          = item.id.ToString();
                tree.text        = item.rolename;
                tree.value       = item.id.ToString();
                tree.parentId    = "0";
                tree.isexpand    = true;
                tree.complete    = true;
                tree.showcheck   = true;
                tree.checkstate  = authorityRole.Count(t => t.id == item.id);
                tree.hasChildren = false;
                treeList.Add(tree);
            }
            string jsontree = treeList.TreeViewJson();

            writeJsonBack(jsontree);
        }
コード例 #20
0
        /// <summary>
        /// 根据用户id获取用户角色列表
        /// </summary>
        /// <returns></returns>
        public ActionResult getRolelist(string userId)
        {
            var rolelist      = IdalCommon.IroleEx.getEntityList();
            var authorityRole = new List <role>();

            if (!string.IsNullOrEmpty(userId))
            {
                try
                {
                    int id = Convert.ToInt32(userId);
                    //user u = IdalCommon.IuserEx.getEntityById(id);
                    //authorityRole = IdalCommon.IuserRoleEx.getRole(u.username);
                    authorityRole = IocModule.GetEntity <IuserRoleEx>().getRoleList(id);
                }
                catch (Exception ex)
                {
                    string message = ex.Message;
                }
            }

            var treeList = new List <TreeViewModel>();

            foreach (role item in rolelist)
            {
                TreeViewModel tree = new TreeViewModel();
                tree.id          = item.id.ToString();
                tree.text        = item.rolename;
                tree.value       = item.id.ToString();
                tree.parentId    = null;
                tree.isexpand    = true;
                tree.complete    = true;
                tree.showcheck   = true;
                tree.checkstate  = authorityRole.Count(t => t.id == item.id);
                tree.hasChildren = false;
                treeList.Add(tree);
            }
            return(Content(treeList.TreeViewJson()));
        }
コード例 #21
0
        private object GetMenuList()
        {
            List <resource> list;

            accctx = (AccountsPrincipal)ctx.Session["accctx"];    //获取当前用户信息上下文
            if (accctx.currentrole.rolename == "超级管理员")
            {
                list = IocModule.GetEntity <IresourceEx>().getEntityList();
            }
            else
            {
                if (accctx.Menus != null)
                {
                    list = accctx.Menus;
                }
                else
                {
                    list = IdalCommon.IroleResourceEx.getRoleAllResource(accctx.currentrole.id);
                    list = list.Where((x, i) => list.FindIndex(z => z.id == x.id) == i).ToList();//Lambda表达式去重
                    return(ToMenuJson(list, "0"));
                }
            }
            return(ToMenuJson(list, "0"));
        }
コード例 #22
0
        /// <summary>
        /// 获取指定用户的特定类型和属主的动作列表,会含有重复项
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="type">动作类型</param>
        /// <param name="owner">上级</param>
        /// <returns></returns>
        public static List <action> getUserAction(string username, int type, role currentrole, string owner = "")
        {
            List <action> rr            = new List <action>();
            IroleActionEx _roleActionEx = IocModule.GetEntity <IroleActionEx>();

            if (currentrole != null)
            {
                rr.AddRange(_roleActionEx.getRoleAllAction(currentrole.id, owner));
            }
            else
            {
                List <role> rolelist = IocModule.GetEntity <IuserRoleEx>().getRole(username);
                if (rolelist.Count > 0)
                {
                    foreach (var e in rolelist)
                    {
                        rr.AddRange(_roleActionEx.getRoleAction(e.id, type, owner));
                    }
                }
            }

            rr = rr.Where((x, i) => rr.FindIndex(z => z.id == x.id) == i).ToList();//Lambda表达式去重
            return(rr);
        }