public static LoginInfo ToLoginInfo(this Employee employee)
        {
            LoginInfo result = new LoginInfo()
            {
                ID          = employee.ID,
                IsAdmin     = employee.IsAdmin.GetValueOrDefault(false),
                UserName    = employee.UserName,
                MenuIDs     = new List <string>(),
                Permissions = new Dictionary <string, int>(),
            };

            if (!result.IsAdmin)
            {
                //var rids = (employee.RoleIDs + "").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.ToInt()).ToList();
                var menus = MvcBase.Unity.Get <IMenuService>().ListCache();
                //var roles = MvcCore.Unity.Get<ISysRoleService>().ListCache().Where(s => rids.Contains(s.ID));

                //#region 绑定角色

                //foreach (var role in roles)
                //{
                //    foreach (var detail in role.Details)
                //    {
                //        if (result.Roles.ContainsKey(detail.MenuID.GetValueOrDefault(0)))
                //        {
                //            //取合集
                //            List<int> newValue = new List<int>();
                //            newValue.AddRange(System.Web.Mvc.RoleHelper.SplitRole(result.Roles[detail.MenuID.GetValueOrDefault(0)]));
                //            newValue.AddRange(System.Web.Mvc.RoleHelper.SplitRole(detail.Roles));
                //            newValue = newValue.Distinct().ToList();
                //            result.Roles[detail.MenuID.GetValueOrDefault(0)] = newValue.Sum(s => s);
                //        }
                //        else result.Roles.Add(detail.MenuID.GetValueOrDefault(0), detail.Roles.GetValueOrDefault(0));
                //    }
                //}

                //#endregion

                #region 权限
                var permissions     = MvcBase.Unity.Get <IPermissionService>().List().Where(m => m.UserID == employee.ID).ToList();
                var list_permission = new List <string>();
                foreach (var item in permissions)
                {
                    //取合集
                    list_permission.Add(item.MenuID);
                    list_permission = list_permission.Distinct().ToList();
                    result.Permissions[item.MenuID] = item.Permissions.GetValueOrDefault(0);
                }

                #endregion

                #region 绑定菜单

                foreach (var root in menus)
                {
                    bool hasChecked = false;
                    foreach (var item in root.Children.Where(s => list_permission.Contains(s.ID)))
                    {
                        result.MenuIDs.Add(item.ID);
                        hasChecked = true;
                    }
                    if (hasChecked)
                    {
                        result.MenuIDs.Add(root.ID);
                    }
                }

                #endregion
            }
            return(result);
        }
 private static void SetCache(this LoginInfo loginInfo)
 {
     CacheExtensions.SetCache(LoginCacheName + loginInfo.ID, loginInfo, CacheTimeType.ByMinutes, 10);
 }