Example #1
0
 public XmlElement GetCotePowerXmlElement(XmlDocument xmlDocSource, string AuthorizeGroupID, Sys_Module objCoteModule, List<Sys_Module> objSys_ModuleList, List<Sys_Module> AddSys_ModuleList)
 {
     List<CoteInfo> allCoteInfoList = null;
     List<sys_authorizegrouppower> source = null;
     allCoteInfoList = this.GetAllCoteInfoList();
     if (AuthorizeGroupID.IsNull())
     {
         allCoteInfoList = this.GetAllCoteInfoList();
     }
     else
     {
         source = this.GetAuthorizeGroupCotePower(AuthorizeGroupID, objCoteModule.ModuleID);
         if (source.Count == 0)
         {
             return null;
         }
         if (source.Any<sys_authorizegrouppower>(s => s.IsCoteSupper))
         {
             allCoteInfoList = this.GetAllCoteInfoList();
             source = null;
             ModuleRule rule = new ModuleRule();
             string ModuleIDPath = rule.Sys_Module.FirstOrDefault<Sys_Module>(s => (s.ModuleID == objCoteModule.ModuleID)).ModuleIDPath;
             objSys_ModuleList.RemoveAll(s => s.ModuleIDPath.StartsWith(ModuleIDPath));
             objSys_ModuleList.AddRange(from s in rule.Sys_Module
                 where (s.ModuleIDPath.StartsWith(ModuleIDPath) && s.IsPower) && !s.IsSupperPower
                 select s);
         }
         else
         {
             allCoteInfoList = this.GetCoteInfoKeyList((from s in source select s.CoteID).Distinct<string>().ToList<string>().ConvertListToString<string>());
         }
     }
     XmlElement element = xmlDocSource.CreateElement("Module");
     element.SetAttribute("ModuleID", RolePowerKey.Create(objCoteModule.ModuleID).ToKey);
     element.SetAttribute("ModuleName", objCoteModule.ModuleName);
     if (AuthorizeGroupID.IsNull() || (source == null))
     {
         XmlElement newChild = xmlDocSource.CreateElement("Module");
         newChild.SetAttribute("ModuleID", RolePowerKey.Create(objCoteModule.ModuleID, objCoteModule.ModuleID, objCoteModule.ModuleID, false, true).ToKey);
         newChild.SetAttribute("ModuleName", "***" + objCoteModule.ModuleName + "***所有权限");
         element.AppendChild(newChild);
     }
     foreach (CoteInfo info in allCoteInfoList)
     {
         XmlElement element3 = xmlDocSource.CreateElement("Module");
         element3.SetAttribute("ModuleID", RolePowerKey.Create(objCoteModule.ModuleID, info.ID, objCoteModule.ModuleID, false).ToKey);
         element3.SetAttribute("ModuleName", info.Name);
         element.AppendChild(element3);
         this.CreateEachModeuleXmlElement(xmlDocSource, info.ID, objCoteModule.ModuleID, objCoteModule, element3, objSys_ModuleList, source, AddSys_ModuleList);
     }
     return element;
 }
Example #2
0
        public XmlElement GetCotePowerXmlElement(XmlDocument xmlDocSource, string AuthorizeGroupID, Sys_Module objCoteModule, List <Sys_Module> objSys_ModuleList, List <Sys_Module> AddSys_ModuleList)
        {
            this.CurrentAuthorizeGroupID = AuthorizeGroupID;
            List <CoteInfo> source = null;
            List <sys_authorizegrouppower> authorizeGroupCotePower = null;

            if (AuthorizeGroupID.IsNull())
            {
                source = this.GetAllCoteInfoList();
            }
            else
            {
                authorizeGroupCotePower = this.GetAuthorizeGroupCotePower(AuthorizeGroupID, objCoteModule.ModuleID);
                if (authorizeGroupCotePower.Count == 0)
                {
                    return(null);
                }
                if (authorizeGroupCotePower.Any <sys_authorizegrouppower>(s => s.IsCoteSupper))
                {
                    source = new List <CoteInfo>();
                    foreach (string str in (from s in authorizeGroupCotePower
                                            where s.IsCoteSupper
                                            select s.CoteID).Distinct <string>())
                    {
                        source.AddRange(this.GetAllCoteInfoList(str));
                    }
                    source.AddRange(this.GetCoteInfoKeyList((from s in authorizeGroupCotePower
                                                             where !s.IsCoteSupper
                                                             select s.CoteID).Distinct <string>().ToList <string>().ConvertListToString <string>()));
                    ModuleRule rule         = new ModuleRule();
                    string     ModuleIDPath = rule.Sys_Module.FirstOrDefault <Sys_Module>(s => (s.ModuleID == objCoteModule.ModuleID)).ModuleIDPath;
                    objSys_ModuleList.RemoveAll(s => s.ModuleIDPath.StartsWith(ModuleIDPath));
                    objSys_ModuleList.AddRange(from s in rule.Sys_Module
                                               where (s.ModuleIDPath.StartsWith(ModuleIDPath) && s.IsPower) && !s.IsSupperPower
                                               select s);
                }
                else
                {
                    source = this.GetCoteInfoKeyList((from s in authorizeGroupCotePower select s.CoteID).Distinct <string>().ToList <string>().ConvertListToString <string>());
                }
            }
            source = source.Distinct <CoteInfo>(new CoteInfoComparer()).ToList <CoteInfo>();
            CoteInfo objCoteInfo = source.FirstOrDefault <CoteInfo>(s => s.ID == this.RootIDValue);

            if (objCoteInfo == null)
            {
                return(null);
            }
            XmlElement objXmlElement = xmlDocSource.CreateElement("Module");

            objXmlElement.SetAttribute("ModuleID", RolePowerKey.Create(objCoteModule.ModuleID, objCoteInfo.ID, objCoteModule.ModuleID, false).ToKey);
            objXmlElement.SetAttribute("ModuleName", objCoteModule.ModuleName);
            bool isCoteSupper = false;

            if (AuthorizeGroupID.IsNull() || authorizeGroupCotePower.Any <sys_authorizegrouppower>(s => ((s.CoteID == objCoteInfo.ID) && s.IsCoteSupper)))
            {
                isCoteSupper = true;
                XmlElement newChild = xmlDocSource.CreateElement("Module");
                newChild.SetAttribute("ModuleID", RolePowerKey.Create(objCoteModule.ModuleID, objCoteInfo.ID, objCoteModule.ModuleID, false, true).ToKey);
                newChild.SetAttribute("ModuleName", "***" + objCoteModule.ModuleName + "***所有权限");
                objXmlElement.AppendChild(newChild);
            }
            if (source.Any <CoteInfo>(s => s.ParentID == objCoteInfo.ID))
            {
                if (this.IsParentUrl)
                {
                    this.CreateEachModeuleXmlElement(xmlDocSource, objCoteInfo.ID, objCoteModule.ModuleID, isCoteSupper, objCoteModule, objXmlElement, objSys_ModuleList, authorizeGroupCotePower, AddSys_ModuleList);
                }
            }
            else
            {
                this.CreateEachModeuleXmlElement(xmlDocSource, objCoteInfo.ID, objCoteModule.ModuleID, isCoteSupper, objCoteModule, objXmlElement, objSys_ModuleList, authorizeGroupCotePower, AddSys_ModuleList);
            }
            this.CreateCoteChildMenuPowerXmlElement(xmlDocSource, objCoteInfo.ID, objCoteModule, objXmlElement, source, objSys_ModuleList, authorizeGroupCotePower, AddSys_ModuleList);
            return(objXmlElement);
        }