Ejemplo n.º 1
0
        private string GetOpenMode()
        {
            var q1 = (from p in ((AuthorizationMdl)HttpContext.Session[Constant.SESSION_AUTHORIZATION]).Applications
                      select p.Roles).ToList();

            string         openMode = string.Empty;
            StSystemConfig sysCfg   = (StSystemConfig)Parameter.CURRENT_SYSTEM_CONFIG;

            if (sysCfg.PsASTESPI == "N")
            {
                openMode = "A";
            }
            else
            {
                for (int i = 0; i < q1.Count; i++)
                {
                    for (int j = 0; j < q1[i].Count; j++)
                    {
                        RoleMdl roleMdl = (RoleMdl)q1[i][j];
                        if (roleMdl.alep == "Y")
                        {
                            openMode = "B";
                        }

                        switch (roleMdl.roty)
                        {
                        case "HR Admin":
                            openMode = "A";
                            break;

                        case "HR Staff":
                            openMode = "A";
                            break;

                        case "General Staff":
                            if (openMode != "A")
                            {
                                openMode = "B";
                            }
                            break;
                        }
                    }
                }
            }

            return(openMode);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Purpose: 将Authorization Xml String转换成Authorization对象
        /// </summary>
        /// <param name="_AuthXmlText"></param>
        /// <returns></returns>
        public AuthorizationMdl ParseAuthorizationXml(string _AuthXmlText)
        {
            AuthorizationMdl result = new AuthorizationMdl();

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(_AuthXmlText);
                XmlNodeList nodes;
                result.Action = doc.SelectSingleNode("/Authorization/Action").InnerText.ToString();

                //result.User = doc.SelectSingleNode("/Authorization/User").InnerText.ToString();
                XmlNode userNode = doc.SelectSingleNode("/Authorization/User");
                UserMdl user     = new UserMdl();
                user.urid   = userNode.Attributes["urid"].Value.ToString();
                user.urnm   = userNode.Attributes["urnm"].Value.ToString();
                user.sfid   = userNode.Attributes["sfid"].Value.ToString();
                result.User = user;

                XmlNodeList   AppNodes     = doc.SelectNodes("/Authorization/Application");
                List <AppMdl> applications = new List <AppMdl>();
                for (int i = 0; i < AppNodes.Count; i++)
                {
                    AppMdl appMdl = new AppMdl();
                    appMdl.apnm    = AppNodes[i].Attributes["name"].Value;
                    appMdl.Web_Url = AppNodes[i].Attributes["url"].Value;
                    nodes          = AppNodes[i].SelectNodes("Roles/Role");
                    List <RoleMdl> roles = new List <RoleMdl>();
                    for (int j = 0; j < nodes.Count; j++)
                    {
                        RoleMdl roleMdl = new RoleMdl();
                        roleMdl.roty           = nodes[j].Attributes["roty"].Value;
                        roleMdl.Is_System_Role = (Public_Flag)Enum.Parse(typeof(Public_Flag), nodes[j].Attributes["issr"].Value);
                        roleMdl.Role_Id        = nodes[j].Attributes["roid"].Value;
                        roleMdl.Role_Name      = nodes[j].Attributes["ronm"].Value;
                        roleMdl.alep           = nodes[j].Attributes["alep"].Value;
                        roles.Add(roleMdl);
                    }
                    appMdl.Roles = roles;
                    nodes        = AppNodes[i].SelectNodes("Modules/Module");
                    List <ModuleMdl> modules = new List <ModuleMdl>();
                    for (int j = 0; j < nodes.Count; j++)
                    {
                        ModuleMdl module = new ModuleMdl();
                        module.Name = nodes[j].Attributes["name"].Value;
                        XmlNodeList        fNodes    = nodes[j].SelectNodes("Functions/Function");
                        List <FunctionMdl> functions = new List <FunctionMdl>();
                        for (int k = 0; k < fNodes.Count; k++)
                        {
                            FunctionMdl funtion = new FunctionMdl();
                            funtion.Id         = fNodes[k].Attributes["id"].Value;
                            funtion.Name       = fNodes[k].Attributes["name"].Value;
                            funtion.Url        = fNodes[k].Attributes["url"].Value;
                            funtion.Permission = (Security_Permission_Type)Enum.Parse(typeof(Security_Permission_Type), fNodes[k].InnerText.ToString());
                            functions.Add(funtion);
                        }
                        module.Functions = functions;
                        modules.Add(module);
                    }
                    appMdl.Modules = modules;

                    applications.Add(appMdl);
                }
                result.Applications = applications;

                return(result);
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }