//
        // GET: /SysApplication/

        public ActionResult Index(SysApplicationSearchArgs arg, int pageIndex = 1)
        {
            PageItem pageItem = new PageItem {
                PageIndex = pageIndex, PageSize = 15
            };

            int appId = arg.AppId.ConvertTo <int>(-1);
            List <SysSubEntity>     subSystemList = subSystemLogic.GetSubSystemList().ToList <SysSubEntity>();
            List <SysAppTypeEntity> appTypeList   = appTypeLogic.GetAppTypeList().ToList <SysAppTypeEntity>();

            ViewBag.DictionaryAppType   = appTypeList.ToDictionary(k => k.AppTypeId, v => v);
            ViewBag.DictionarySubSystem = subSystemList.ToDictionary(k => k.SubSystemId, v => v);

            appTypeList.Insert(0, new SysAppTypeEntity()
            {
                AppTypeId = -1, TypeName = "全部"
            });
            subSystemList.Insert(0, new SysSubEntity()
            {
                SubSystemId = -1, SystemName = "全部"
            });
            ViewBag.AppTypeId   = new SelectList(appTypeList, "AppTypeId", "TypeName");
            ViewBag.SubSystemId = new SelectList(subSystemList, "SubSystemId", "SystemName");

            List <SysApplicationEntity> sysApplicationList = logic.GetSysApplicationList(appId, arg.SubSystemId, arg.AppName, arg.AppTypeId, arg.Status, pageItem).ToList <SysApplicationEntity>();

            ViewBag.SysApplicationList = new PagedList <SysApplicationEntity>(sysApplicationList, pageItem.PageIndex, pageItem.PageSize, pageItem.TotalCount);
            return(View(arg));
        }
Esempio n. 2
0
        // GET api/<controller>
        public HttpResponseMessage Get()
        {
            LocalCacheProvider cacheProvider = new LocalCacheProvider();
            string             cacheKey      = "Fx.Manage.AppController.ApplicationList";
            string             result        = cacheProvider.GetCache <string>(cacheKey);

            if (string.IsNullOrEmpty(result))
            {
                List <SysApplicationEntity> appList = logic.GetSysApplicationList().ToList <SysApplicationEntity>();
                List <AppReponseDTO>        list    = new List <AppReponseDTO>();
                foreach (SysApplicationEntity item in appList)
                {
                    list.Add(new AppReponseDTO()
                    {
                        AppId = item.AppId, AppEName = item.AppEName, AppName = item.AppName, AppTypeId = item.AppTypeId, Status = item.Status, SubSystemId = item.SubSystemId
                    });
                }
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                result = serializer.Serialize(list);
                if (!string.IsNullOrEmpty(result))
                {
                    cacheProvider.SetCache <string>(cacheKey, result, DateTime.Now.AddHours(1));
                }
            }
            return(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
Esempio n. 3
0
        //
        // GET: /SysApi/
        public ActionResult Index(SysApiSearchArgs arg, int pageIndex = 1)
        {
            int      appId    = arg.AppId.ConvertTo <int>(-1);
            PageItem pageItem = new PageItem {
                PageIndex = pageIndex, PageSize = 15
            };
            SysApplicationLogic         appLogic = new SysApplicationLogic();
            List <SysApplicationEntity> listApp  = appLogic.GetSysApplicationList().ToList <SysApplicationEntity>();

            ViewBag.DictionaryApplication = listApp.ToDictionary(k => k.AppId, v => v);
            List <SysApiEntity> sysApiList = logic.GetSysApiList(appId, arg.Status, arg.ApiName, pageItem).ToList <SysApiEntity>();

            ViewBag.SysApiList = new PagedList <SysApiEntity>(sysApiList, pageItem.PageIndex, pageItem.PageSize, pageItem.TotalCount);
            return(View(arg));
        }
        public ActionResult ConfigServiceRight(int roleId = -1, int userId = 0)
        {
            //具有国内/国际开发主管角色的登入用户进入该页后,角色下拉列表只列出国内/国际开发主管,
            //否则,列出国内开发主管和国际开发主管两角色:
            SysRoleLogic   roleLogic    = new SysRoleLogic();
            List <SysRole> roleList     = roleLogic.GetRoleList().ToList <SysRole>();
            LoginUserInfo  currentLogin = this.WorkContext.CurrentUser;

            //7表示国内开发主管角色,8表示国际开发主管角色
            if (currentLogin.RoleId == 7 || currentLogin.RoleId == 8)
            {
                roleList = roleList.Where(x => x.RoleId == currentLogin.RoleId).ToList <SysRole>();
            }
            else
            {
                roleList = roleList.Where(x => (x.RoleId == 7 || x.RoleId == 8)).ToList <SysRole>();
            }
            ViewBag.RoleId = new SelectList(roleList, "RoleId", "RoleName");
            if (roleId < 1)
            {
                if (currentLogin.RoleId == 7 || currentLogin.RoleId == 8)
                {
                    ViewBag.CurrentRoleId = currentLogin.RoleId;
                }
                else
                {
                    ViewBag.CurrentRoleId = 7;
                }
            }
            else
            {
                ViewBag.CurrentRoleId = roleId;
            }

            List <SysUser> userList = GetUserList(roleId);

            ViewBag.UserId        = new SelectList(userList, "UserId", "RealName");
            ViewBag.CurrentUserId = userId;

            List <SysRoleRight> roleRightList = new List <SysRoleRight>();

            if (roleId > 0)
            {
                SysApplicationLogic appIdMenuLogic = new SysApplicationLogic();

                //求配置中心权限管理模块的各菜单项:
                List <SysApplicationEntity> appIdMenuList = null;
                SysUserLogic sysUserLogic     = new SysUserLogic();
                SysUser      sysUser          = null;
                int?         selectedUserId   = -1;
                string       selectedUserName = string.Empty;
                switch (roleId)
                {
                case 7:    //国内开发主管角色,目前只求针对国内机票产品线的配置中心权限管理模块的各菜单项:
                    sysUser = sysUserLogic.GetUserInfo(userId);
                    if (sysUser != null)
                    {
                        selectedUserName        = sysUser.RealName;
                        ViewBag.CurrentUserName = selectedUserName;
                    }
                    appIdMenuList = appIdMenuLogic.GetSysApplicationList(-1, -1, "", -1, -1, null, new List <int> {
                        1
                    }, selectedUserName).ToList <SysApplicationEntity>();
                    break;

                case 8:     //国际开发主管角色,目前只求针对国际机票产品线的配置中心权限管理模块的各菜单项:
                    sysUser = sysUserLogic.GetUserInfo(userId);
                    if (sysUser != null)
                    {
                        selectedUserName        = sysUser.RealName;
                        ViewBag.CurrentUserName = selectedUserName;
                    }
                    appIdMenuList = appIdMenuLogic.GetSysApplicationList(-1, -1, "", -1, -1, null, new List <int> {
                        2
                    }, selectedUserName).ToList <SysApplicationEntity>();
                    break;

                default:
                    break;
                }
                ViewBag.AppIdMenuList = appIdMenuList;

                selectedUserId = ViewBag.CurrentUserId as int?;
                roleRightList  = logic.GetRoleRightList(roleId, true, (selectedUserId.HasValue ? Convert.ToInt32(selectedUserId) : -1)).ToList <SysRoleRight>();
            }

            return(View(roleRightList));
        }
        // GET api/<controller>/5
        public HttpResponseMessage Get([FromUri] ApplicationRequest request, string callback = "callback")
        {
            try
            {
                int applicationId             = request.AppId;
                AppDependentReponseDTO result = new AppDependentReponseDTO();

                result.AppType = appTypeLogic.GetAppTypeList().ToList <SysAppTypeEntity>();
                List <SysAppDependentEntity> dependentList = appDependentLogic.GetAppDependentList(applicationId).ToList <SysAppDependentEntity>();

                //所有应用信息
                List <SysApplicationEntity>      applicationList       = applicationLogic.GetSysApplicationList().ToList <SysApplicationEntity>();
                Dictionary <int, ApplicationDTO> applicationDictionary = applicationList.ToDictionary(k => k.AppId, v => new ApplicationDTO()
                {
                    AppId    = v.AppId,
                    AppType  = v.AppTypeId,
                    AppName  = v.AppName,
                    AppEName = v.AppEName
                });

                //依赖关系
                foreach (SysAppDependentEntity dependent in dependentList)
                {
                    if (applicationDictionary.ContainsKey(dependent.AppId) && applicationDictionary.ContainsKey(dependent.DependentAppId))
                    {
                        result.AppDependentInfo.Add(new AppDependentDTO()
                        {
                            Source = applicationDictionary[dependent.AppId], Target = applicationDictionary[dependent.DependentAppId]
                        });
                    }
                }
                if (applicationId < 0)
                {
                    //所有应用
                    result.Applications = applicationDictionary.Values.ToList <ApplicationDTO>();
                }
                else
                {
                    //只保留与当前APP有依赖、被依赖关系的应用信息
                    Dictionary <int, ApplicationDTO> appDic = new Dictionary <int, ApplicationDTO>();
                    if (applicationDictionary.ContainsKey(applicationId))
                    {
                        appDic.Add(applicationId, applicationDictionary[applicationId]);
                    }
                    foreach (AppDependentDTO appDependent in result.AppDependentInfo)
                    {
                        if (applicationDictionary.ContainsKey(appDependent.Source.AppId) && !appDic.ContainsKey(appDependent.Source.AppId))
                        {
                            appDic.Add(appDependent.Source.AppId, applicationDictionary[appDependent.Source.AppId]);
                        }
                        if (applicationDictionary.ContainsKey(appDependent.Target.AppId) && !appDic.ContainsKey(appDependent.Target.AppId))
                        {
                            appDic.Add(appDependent.Target.AppId, applicationDictionary[appDependent.Target.AppId]);
                        }
                    }
                    result.Applications = appDic.Values.ToList <ApplicationDTO>();
                }

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                string content = string.Format("{0}({1})", callback, serializer.Serialize(result));
                return(new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(content, System.Text.Encoding.UTF8, "text/javascript")
                });
            }
            catch (Exception ex)
            {
                //记录异常日志
                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
        }