Beispiel #1
0
        public ActionResult Users(int id)
        {
            var systemDB = _systemRepository.Get(id);
            var userDB   = _userRepository.GetAll();
            var userList = new List <UserDTO>();

            foreach (var user in userDB)
            {
                var systemContains = false;
                foreach (var system in user.Systems)
                {
                    if (system.Id == systemDB.Id)
                    {
                        systemContains = true;
                        break;
                    }
                }

                user.IsSelected = systemContains;
                userList.Add(user);
            }

            var systemDTO = new SystemDTO()
            {
                Id       = systemDB.Id,
                Name     = systemDB.Name,
                IsActive = systemDB.IsActive,
                Users    = userList
            };

            return(PartialView("_ListUsers", systemDTO));
        }
Beispiel #2
0
        public HttpResponseMessage Edit(SystemDTO system)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            _systemRepository.Update(system);
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Beispiel #3
0
        public HttpResponseMessage Delete(SystemDTO system)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            system.IsActive = false;
            _systemRepository.Update(system);
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Beispiel #4
0
        public HttpResponseMessage Create(SystemDTO system)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            system.IsActive = true;
            _systemRepository.Add(system);
            return(new HttpResponseMessage(HttpStatusCode.Created));
        }
Beispiel #5
0
        public HttpResponseMessage Users(SystemDTO systemDTO)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }
            var system = _systemRepository.Get(systemDTO.Id);

            system.Users.Clear();
            var userList = new List <UserDTO>();

            foreach (var user in systemDTO.Users.Where(s => s.IsSelected == true).ToList())
            {
                userList.Add(user);
            }

            system.Users = userList;
            _systemRepository.Update(system);
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Beispiel #6
0
        // GET: User/Create
        public ActionResult Create()
        {
            var system = new SystemDTO();

            return(PartialView("_Create", system));
        }
Beispiel #7
0
        /// <summary>
        /// 获得用户菜单
        /// </summary>
        /// <returns></returns>
        private MenuDTO GetMenuImp()
        {
            MenuDTO result = new MenuDTO();
            //1.当前user的所有function_id_list
            List <Guid> function_id_list = CubeDb.From <Mc_User_Function>()
                                           .Where(Mc_User_Function._.User_Id == User.Id)
                                           .Select(Mc_User_Function._.Function_Id)
                                           .ToList <Guid>();
            List <FunctionDTO> functionList = functionList = new List <FunctionDTO>();

            if (function_id_list != null)
            {
                functionList = CubeDb.From <Mc_Function>()
                               .Where(Mc_Function._.Id.In(function_id_list))
                               .Select(Mc_Function._.All)
                               .OrderBy(Mc_Function._.Code.Asc)
                               .ToList <FunctionDTO>();
            }

            //应对子功能有权限而父功能没有权限的情况
            List <FunctionDTO> parentFunctionList = new List <FunctionDTO>();

            foreach (FunctionDTO function in functionList)
            {
                if (function.Parent_Function_Id != null && function.Parent_Function_Id != Guid.Empty &&
                    !functionList.Exists(f => f.Id == function.Parent_Function_Id))
                {
                    FoundParentFunctionWithoutRight(function, parentFunctionList, functionList);
                }
            }
            functionList.AddRange(parentFunctionList);

            List <string>    system_id_list = functionList.Where(f => f.System_Id != null).Select(f => f.System_Id).ToList();
            List <SystemDTO> systemList     = CubeDb.From <Mc_System>()
                                              .Where(Mc_System._.Id.In(system_id_list))
                                              .Select(Mc_System._.All)
                                              .ToList <SystemDTO>();

            List <Guid>      domain_id_list = systemList.Where(s => s.Domain_Id != null).Select(s => s.Domain_Id).ToList();
            List <DomainDTO> domainList     = CubeDb.From <Mc_Domain>()
                                              .Where(Mc_Domain._.Id.In(domain_id_list))
                                              .Select(Mc_Domain._.All)
                                              .ToList <DomainDTO>();

            List <Guid>       product_id_list_from_system = systemList.Where(s => s.Product_Id != null).Select(s => s.Product_Id).ToList();
            List <Guid>       product_id_list_from_domain = domainList.Where(d => d.Product_Id != null).Select(d => d.Product_Id).ToList();
            List <Guid>       product_id_list             = product_id_list_from_system.Union(product_id_list_from_domain).ToList();
            List <ProductDTO> productList = CubeDb.From <Mc_Product>()
                                            .Where(Mc_Product._.Id.In(product_id_list))
                                            .Select(Mc_Product._.All)
                                            .ToList <ProductDTO>();

            //2.组装function
            foreach (FunctionDTO function in functionList)
            {
                function.SubFunctionList = functionList.FindAll(f => f.Parent_Function_Id != null && f.Parent_Function_Id.ToString().Equals(function.Id.ToString(), StringComparison.CurrentCultureIgnoreCase));

                if (function.Language_Key != null && !result.LanguageList.Exists(l => l.Language_Key == function.Language_Key))
                {
                    Mc_Language l = CubeDb.From <Mc_Language>()
                                    .Where(Mc_Language._.Language_Key == function.Language_Key)
                                    .Select(Mc_Language._.All)
                                    .ToList().FirstOrDefault();
                    if (l != null)
                    {
                        result.LanguageList.Add(l);
                    }
                }
            }

            //3.组装system
            foreach (SystemDTO system in systemList)
            {
                system.FunctionList = functionList.FindAll(f => (f.Parent_Function_Id == null || f.Parent_Function_Id == Guid.Empty) &&
                                                           f.System_Id != null && f.System_Id.ToString().Equals(system.Id.ToString(), StringComparison.CurrentCultureIgnoreCase));

                if (system.Language_Key != null && !result.LanguageList.Exists(l => l.Language_Key == system.Language_Key))
                {
                    Mc_Language l = CubeDb.From <Mc_Language>()
                                    .Where(Mc_Language._.Language_Key == system.Language_Key)
                                    .Select(Mc_Language._.All)
                                    .ToList().FirstOrDefault();
                    if (l != null)
                    {
                        result.LanguageList.Add(l);
                    }
                }
            }
            //System排序
            systemList = systemList.OrderBy(x => x.Code).ToList();

            //4.组装domain
            foreach (DomainDTO domain in domainList)
            {
                domain.SystemList = systemList.FindAll(s => s.Domain_Id != null &&
                                                       s.Domain_Id.ToString().Equals(domain.Id.ToString(), StringComparison.CurrentCultureIgnoreCase));
                if (domain.Language_Key != null && !result.LanguageList.Exists(l => l.Language_Key == domain.Language_Key))
                {
                    Mc_Language l = CubeDb.From <Mc_Language>()
                                    .Where(Mc_Language._.Language_Key == domain.Language_Key)
                                    .Select(Mc_Language._.All)
                                    .ToList().FirstOrDefault();
                    if (l != null)
                    {
                        result.LanguageList.Add(l);
                    }
                }
            }
            //domain排序
            domainList = domainList.OrderBy(d => d.Code).ToList();

            //5.组装product
            foreach (ProductDTO product in productList)
            {
                product.DomainList = domainList.FindAll(d => d.Product_Id != null &&
                                                        d.Product_Id.ToString().Equals(product.Id.ToString(), StringComparison.CurrentCultureIgnoreCase));
                product.SystemList = systemList.FindAll(s => (s.Domain_Id == null || s.Domain_Id == Guid.Empty) && s.Product_Id != null &&
                                                        s.Product_Id.ToString().Equals(product.Id.ToString(), StringComparison.CurrentCultureIgnoreCase));
            }

            //去除多余的Others
            ProductDTO othersProduct = new ProductDTO()
            {
                Id   = Guid.Empty,
                Name = "Others"
            };

            othersProduct.SystemList = systemList.FindAll(s => (s.Product_Id == null || s.Product_Id == Guid.Empty) &&
                                                          (s.Domain_Id == null || s.Domain_Id == Guid.Empty));
            othersProduct.DomainList = domainList.FindAll(sg => sg.Product_Id == null || sg.Product_Id == Guid.Empty);
            if (othersProduct.SystemList.Count() > 0 || othersProduct.DomainList.Count() > 0)
            {
                productList.Add(othersProduct);
            }

            if (SSOContext.IsDebug)
            {
                string     debugUrl     = System.Web.HttpUtility.UrlDecode(SSOContext.LocalDebugUrl).Replace("http://", "").Replace("https://", "");
                ProductDTO debugProduct = new ProductDTO();
                debugProduct.Id   = Guid.NewGuid();
                debugProduct.Name = "Debug";

                SystemDTO debugSystem = new SystemDTO();
                debugSystem.Code = "DEBUG";
                debugSystem.Id   = Guid.NewGuid();

                FunctionDTO debugFunction = new FunctionDTO();
                debugFunction.Code         = "DEBUG";
                debugFunction.Id           = Guid.NewGuid();
                debugFunction.Language_Key = "lang_debug";
                debugFunction.Url          = debugUrl;

                debugSystem.FunctionList.Add(debugFunction);
                debugProduct.SystemList.Add(debugSystem);
                productList.Add(debugProduct);
            }
            result.ProductList = productList;

            List <Guid> BookmarkIdList = CubeDb.From <Mc_Bookmark>()
                                         .Where(Mc_Bookmark._.User_Id == User.Id)
                                         .Select(Mc_Bookmark._.Function_Id).ToList <Guid>();
            List <FunctionDTO> bookmarkFunctionList = CubeDb.From <Mc_Function>()
                                                      .Where(Mc_Function._.Id.In(BookmarkIdList))
                                                      .Select(Mc_Function._.All)
                                                      .OrderBy(Mc_Function._.Code.Asc)
                                                      .ToList <FunctionDTO>();

            bookmarkFunctionList.RemoveAll(f => !function_id_list.Contains(f.Id));
            result.BookmarkList = bookmarkFunctionList;

            return(result);
        }
Beispiel #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (CubeConfig.SystemMode == Base.Enums.CubeSystemModeEnum.Single)
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "SwitchToSingleMode", @"SystemMode = 'S'; $('#ddlProduct').parents('tr').hide();
$('#ddlOrg').parents('tr').hide();", true);
//$('#ddlDomain').parents('tr').hide();", true);

                    string            systemId          = CubeConfig.CubeSystemId;
                    PermissionService permissionService = new PermissionService();
                    permissionService.Url = Config.Global.PermissionServiceUrl;
                    SystemDTO systemInfo = permissionService.GetSystemInfo(Guid.Parse(systemId));
                    DomainDTO domain     = permissionService.GetDomainInfo(systemInfo.Domain_Id);
                    Page.ClientScript.RegisterStartupScript(GetType(), "SetSingleModeInfo", @"SingleModeProductId = '" + systemInfo.Product_Id
                                                            + "'; SingleModeOrgId = '" + systemInfo.Org_Id + "'; SingleModeDomain = '" + domain.Name + "';", true);
                }

                InitializeSSORequest();

                if (_SSORequest != null)
                {
                    if (_SSORequest.LoginType == LoginTypeEnum.Debug)
                    {
                        string[] datas = _SSORequest.Data.Split(',');
                        if (datas.Length >= 5)
                        {
                            if (!string.IsNullOrWhiteSpace(datas[2]) && !string.IsNullOrWhiteSpace(datas[3]))
                            {
                                string       productName = datas[2];
                                string       orgName     = datas[3];
                                string       userName    = datas[4];
                                LoginService service     = new LoginService();

                                List <SimpleProductOrgDTO> productOrgList = (List <SimpleProductOrgDTO>)service.getProductOrgList().data;
                                SimpleProductOrgDTO        product        = productOrgList.FirstOrDefault(p => p.Name.Equals(productName, StringComparison.CurrentCultureIgnoreCase));
                                if (product != null)
                                {
                                    OrgDTO org = product.OrgList.FirstOrDefault(o => o.Name.Equals(orgName, StringComparison.CurrentCultureIgnoreCase));
                                    if (org != null)
                                    {
                                        LogonInfo logonInfo = new LogonInfo();
                                        logonInfo.SSORequest  = _SSORequest;
                                        logonInfo.IsNT        = true;
                                        logonInfo.OrgID       = org.Id;
                                        logonInfo.OrgName     = orgName;
                                        logonInfo.ProductID   = product.Id;
                                        logonInfo.ProductName = productName;
                                        logonInfo.UserName    = userName;
                                        logonInfo.Language    = "zh-CN";
                                        service.wfkLoginForDebug(logonInfo);
                                    }
                                }
                            }
                        }
                    }
                    else if (_SSORequest.LoginType == LoginTypeEnum.AdminSimulate)
                    {
                        Page.ClientScript.RegisterStartupScript(GetType(), "HidePassword", @"$('#tbxPassword').parents('tr').hide();
$('#ddlProduct').parents('tr').hide();
$('#ddlOrg').parents('tr').hide();
$('#ddlDomain').parents('tr').hide();", true);
                    }
                }

                if (CubeConfig.SystemMode == Base.Enums.CubeSystemModeEnum.Single)
                {
                    lblSystemName.Text = CubeConfig.CubeSystemName;
                    lblSystemName.Attributes["lang"] = "";
                }

                if (CubeConfig.CubeEnvironmentVisible)
                {
                    this.textEnvironmentInfo.Text = "(" + CubeConfig.CubeEnvironment + ")";
                }
            }
        }