Beispiel #1
0
        public async Task <IHttpActionResult> GetUserRoles()
        {
            var rolesResponse = await UserRoleService.GetUserRoles();

            if (rolesResponse == null)
            {
                return(BadRequest("Error In Getting User Roles!"));
            }
            else
            {
                return(Ok(rolesResponse));
            }
        }
Beispiel #2
0
 public IHttpActionResult GetUserRoles()
 {
     try
     {
         string accessToken = Request.Headers.Authorization == null ? null : Request.Headers.Authorization.Parameter;
         var    lstUsrRole  = _service.GetUserRoles(accessToken);
         if (lstUsrRole.Count > 0)
         {
             return(Content(HttpStatusCode.OK, lstUsrRole));
         }
         else
         {
             return(Content(HttpStatusCode.OK, "Content not found"));
         }
     }
     catch (Exception ex)
     {
         Logger.WriteException("GetUserRoles : ", ex);
         return(Content(HttpStatusCode.BadRequest, ex.Message));
     }
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            // Initializer initializer = new Initializer();
            //initializer.Seed();
            AutoMapperConfig.Config();
            string filePath = System.AppDomain.CurrentDomain.BaseDirectory + "Excle\\新建工作表.xlsx";
            List <PointTxnDetailImport> excelList             = ImportExcelHelper.GetListFromExcel <PointTxnDetailImport>(filePath);
            PointTxnDetailService       pointTxnDetailService = new PointTxnDetailService();
            var list1 = Mapper.Map <List <PointTxnDetailImport>, List <PointTxnDetail> >(excelList);

            list1.ForEach(p =>
            {
                p.CreateUser  = "******";
                p.CredateTime = DateTime.Now;
            });
            pointTxnDetailService.Add(list1);


            UserService        userService        = new UserService();
            SysFunctionService sysFunctionService = new SysFunctionService();
            RoleService        roleService        = new RoleService();
            UserRightsService  userRightsService  = new UserRightsService();
            SysButtonService   sysButtonService   = new SysButtonService();
            SysMenuService     sysMenuService     = new SysMenuService();
            UserRoleService    userRoleService    = new UserRoleService();
            SystemService      systemService      = new SystemService();
            StoreReportService storeReportService = new StoreReportService();



            storeReportService.test();
            var             user = userService.Find(1);
            List <UserRole> list = userRoleService.GetUserRoles();

            foreach (var item in list)
            {
                Console.WriteLine("角色名称:" + item.Role.RoleName);
            }
            try
            {
                string jsonString = list.ToJsonString();
                Console.WriteLine("Json数据:" + jsonString);
                var userRoles = userRoleService.GetUserRole();

                string jsonString2 = userRoles.ToJsonString();
                Console.WriteLine("Json2数据:" + jsonString2);
            }
            catch (Exception ex)
            {
                string errorMsg = ex.Message;
            }

            List <UserRights> userRights = userRightsService.GetUserRights(user.Id);

//<<<<<<< .mine
//            //List<SysMenu> SysMenuList = new List<SysMenu>();
//            //try
//            //{
//            //    SysMenuList = userRights.Where(p => p.SysFunction.SysButtonId == 3).Select(p => p.SysFunction.SysMenu).ToList();
//            //}
//            //catch (Exception ex)
//            //{
//            //    string msg = ex.Message;
//            //}
//            //List<SysButton> SysButtonList = userRights.Select(p => p.SysFunction.SysButton).ToList();
//            //foreach (var item in SysMenuList)
//            //{
//            //    Console.WriteLine("菜单名称:" + item.MenuName);
//            //}
//            //foreach (var item in SysButtonList)
//            //{
//            //    Console.WriteLine("按钮名称:" + item.ButtonName);
//            //}
//||||||| .r59
//            List<SysMenu> SysMenuList = new List<SysMenu>();
//            try
//            {
//                SysMenuList = userRights.Where(p => p.SysFunction.SysButtonId == 3).Select(p => p.SysFunction.SysMenu).ToList();
//            }
//            catch (Exception ex)
//            {
//                string msg = ex.Message;
//            }
//            List<SysButton> SysButtonList = userRights.Select(p => p.SysFunction.SysButton).ToList();
//            foreach (var item in SysMenuList)
//            {
//                Console.WriteLine("菜单名称:" + item.MenuName);
//            }
//            foreach (var item in SysButtonList)
//            {
//                Console.WriteLine("按钮名称:" + item.ButtonName);
//            }
//=======
//            List<SysMenu> SysMenuList = new List<SysMenu>();
//            //try
//            //{
//            //    SysMenuList = userRights.Where(p => p.SysFunction.SysButtonId == 3).Select(p => p.SysFunction.SysMenu).ToList();
//            //}
//            //catch (Exception ex)
//            //{
//            //    string msg = ex.Message;
//            //}
//            //List<SysButton> SysButtonList = userRights.Select(p => p.SysFunction.SysButton).ToList();
//            //foreach (var item in SysMenuList)
//            //{
//            //    Console.WriteLine("菜单名称:" + item.MenuName);
//            //}
//            //foreach (var item in SysButtonList)
//            //{
//            //    Console.WriteLine("按钮名称:" + item.ButtonName);
//            //}
//>>>>>>> .r71
            Console.WriteLine("按钮名称:");
            Retry.Execute(Test, new TimeSpan(2000));
        }