Example #1
0
 private List<CoteInfo> ConvertCoteInfo(MySqlDataReader reader)
 {
     List<CoteInfo> list = new List<CoteInfo>();
     try
     {
         while (reader.Read())
         {
             CoteInfo item = new CoteInfo {
                 ParentID = ""
             };
             if (reader[this.IDName] != DBNull.Value)
             {
                 item.ID = Convert.ToString(reader[this.IDName]);
             }
             if (reader[this.Name] != DBNull.Value)
             {
                 item.Name = Convert.ToString(reader[this.Name]);
             }
             list.Add(item);
         }
     }
     catch (Exception exception)
     {
         LogHelper<LogModuleType>.Write(LogModuleType.ModuleLog, exception, "");
         return list;
     }
     finally
     {
         reader.Close();
     }
     return list;
 }
Example #2
0
        public XmlElement GetCotePowerMenuXmlElement(XmlDocument xmlDocSource, UserInfo objUserInfo, Sys_Module objModule)
        {
            List <CoteInfo>      source = null;
            List <Sys_RolePower> list2  = null;

            this.CurrentIsSuper = objUserInfo.IsSuper;
            if (objUserInfo.IsSuper)
            {
                source = this.GetAllCoteInfoList();
            }
            else
            {
                list2 = this.GetUserCoteRolePower(objUserInfo.UserID, objModule.ModuleID).ToList <Sys_RolePower>();
                if (list2.Count == 0)
                {
                    return(null);
                }
                if (list2.Any <Sys_RolePower>(s => s.IsCoteSupper))
                {
                    source = new List <CoteInfo>();
                    foreach (string str in (from s in list2
                                            where s.IsCoteSupper
                                            select s.CoteID).Distinct <string>())
                    {
                        source.AddRange(this.GetAllCoteInfoList(str));
                    }
                    source.AddRange(this.GetCoteInfoKeyList((from s in list2
                                                             where !s.IsCoteSupper
                                                             select s.CoteID).Distinct <string>().ToList <string>().ConvertListToString <string>()));
                }
                else
                {
                    source = this.GetCoteInfoKeyList((from s in list2 select s.CoteID).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);
            }
            string     format        = "javascript:opentreemodule('{0}','{1}','{2}','{3}');";
            string     str3          = objModule.CommandArgument + ((objModule.CommandArgument.IndexOf("?") >= 0) ? "&" : "?") + this.IDName + "={0}&" + this.ParentIDName + "={1}&CoteIsParent={2}&CoteID={0}&CoteModuleID=" + objModule.ModuleID + "&PowerName={3}";
            XmlElement objXmlElement = xmlDocSource.CreateElement("Module");

            objXmlElement.SetAttribute("ModuleID", objCoteInfo.ID.ToString());
            objXmlElement.SetAttribute("ModuleName", objModule.ModuleName);
            objXmlElement.SetAttribute("ToolTip", objModule.ToolTip);
            objXmlElement.SetAttribute("ImageUrl", objModule.ImageUrl);
            objXmlElement.SetAttribute("ModuleLevel", objModule.ModuleLevel.ToString());
            objXmlElement.SetAttribute("NavigateUrl", string.Format(format, new object[] { objModule.ModuleID.ToString() + objCoteInfo.ID, objModule.ImageUrl, string.Format(str3, new object[] { objCoteInfo.ID, objCoteInfo.ParentID, source.Any <CoteInfo>(s => (s.ParentID == objCoteInfo.ID)) ? "1" : "0", objCoteInfo.Name }).EncryptModuleQuery(), objModule.ModuleName }));
            bool isCoteSuper = this.ParentIsCoteSupper(objCoteInfo, source, list2);

            this.CreateCoteChildMenuPowerXmlElement(xmlDocSource, isCoteSuper, list2, objCoteInfo.ID, objXmlElement, source, str3, objModule.ModuleLevel, objModule);
            return(objXmlElement);
        }
Example #3
0
        public bool ParentIsCoteSupper(CoteInfo objCoteInfo, List <CoteInfo> objCoteInfoList, List <Sys_RolePower> objCoteRolePowerList)
        {
            if (this.CurrentIsSuper)
            {
                return(true);
            }
            if (objCoteRolePowerList.Any <Sys_RolePower>(s => (s.CoteID == objCoteInfo.ID) && s.IsCoteSupper))
            {
                return(true);
            }
            CoteInfo info = objCoteInfoList.FirstOrDefault <CoteInfo>(s => s.ID == objCoteInfo.ParentID);

            if (info == null)
            {
                return(false);
            }
            return(this.ParentIsCoteSupper(info, objCoteInfoList, objCoteRolePowerList));
        }
Example #4
0
 private void CreateCoteChildMenuPowerXmlElement(XmlDocument xmlDocSource, string ParentID, Sys_Module objCoteModule, XmlElement objXmlElement, List <CoteInfo> objCoteInfoList, List <Sys_Module> objSys_ModuleList, List <sys_authorizegrouppower> objCoteRolePowerList, List <Sys_Module> AddSys_ModuleList)
 {
     using (IEnumerator <CoteInfo> enumerator = (from s in objCoteInfoList
                                                 where s.ParentID == ParentID
                                                 select s).GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             Func <CoteInfo, bool> predicate = null;
             CoteInfo   objCoteInfo          = enumerator.Current;
             XmlElement newChild             = xmlDocSource.CreateElement("Module");
             newChild.SetAttribute("ModuleID", RolePowerKey.Create(objCoteModule.ModuleID, objCoteInfo.ID, objCoteModule.ModuleID, false).ToKey);
             newChild.SetAttribute("ModuleName", objCoteInfo.Name);
             objXmlElement.AppendChild(newChild);
             bool isCoteSupper = this.ParentIsCoteSupper(objCoteInfo, objCoteInfoList, objCoteRolePowerList);
             if (predicate == null)
             {
                 predicate = s => s.ParentID == objCoteInfo.ID;
             }
             if (objCoteInfoList.Any <CoteInfo>(predicate))
             {
                 if (this.CurrentAuthorizeGroupID.IsNull() || isCoteSupper)
                 {
                     XmlElement element2 = xmlDocSource.CreateElement("Module");
                     element2.SetAttribute("ModuleID", RolePowerKey.Create(objCoteModule.ModuleID, objCoteInfo.ID, objCoteModule.ModuleID, false, true).ToKey);
                     element2.SetAttribute("ModuleName", "***" + objCoteInfo.Name + "***所有权限");
                     newChild.AppendChild(element2);
                 }
                 if (this.IsParentUrl)
                 {
                     this.CreateEachModeuleXmlElement(xmlDocSource, objCoteInfo.ID, objCoteModule.ModuleID, isCoteSupper, objCoteModule, newChild, objSys_ModuleList, objCoteRolePowerList, AddSys_ModuleList);
                 }
             }
             else
             {
                 this.CreateEachModeuleXmlElement(xmlDocSource, objCoteInfo.ID, objCoteModule.ModuleID, isCoteSupper, objCoteModule, newChild, objSys_ModuleList, objCoteRolePowerList, AddSys_ModuleList);
             }
             this.CreateCoteChildMenuPowerXmlElement(xmlDocSource, objCoteInfo.ID, objCoteModule, newChild, objCoteInfoList, objSys_ModuleList, objCoteRolePowerList, AddSys_ModuleList);
         }
     }
 }
Example #5
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);
        }
Example #6
0
        private void CreateCoteChildMenuPowerXmlElement(XmlDocument xmlDocSource, bool isCoteSuper, List <Sys_RolePower> objCotePowerList, string ParentID, XmlElement objXmlElement, List <CoteInfo> objCoteInfoList, string coteUrl, int ModuleLevel, Sys_Module objModule)
        {
            Func <Sys_RolePower, bool> predicate = null;
            bool   flag   = true;
            string format = "javascript:opentreemodule('{0}','{1}','{2}','{3}');";

            using (IEnumerator <CoteInfo> enumerator = (from s in objCoteInfoList
                                                        where s.ParentID == ParentID
                                                        select s).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Func <CoteInfo, bool> func = null;
                    CoteInfo objCoteInfo       = enumerator.Current;
                    if (flag)
                    {
                        if (!this.IsParentUrl)
                        {
                            objXmlElement.SetNodeAttribute("NavigateUrl", "");
                        }
                        else if (!isCoteSuper)
                        {
                            if (predicate == null)
                            {
                                predicate = s => s.CoteID == ParentID;
                            }
                            if (objCotePowerList.Where <Sys_RolePower>(predicate).Count <Sys_RolePower>() < 2)
                            {
                                objXmlElement.SetNodeAttribute("NavigateUrl", "");
                            }
                        }
                        ModuleLevel++;
                        flag = false;
                    }
                    XmlElement newChild = xmlDocSource.CreateElement("Module");
                    newChild.SetAttribute("ModuleID", objCoteInfo.ID.ToString());
                    newChild.SetAttribute("ModuleName", objCoteInfo.Name);
                    newChild.SetAttribute("ToolTip", objCoteInfo.Name);
                    newChild.SetAttribute("ImageUrl", objModule.ImageUrl);
                    newChild.SetAttribute("ModuleLevel", ModuleLevel.ToString());
                    object[] args = new object[4];
                    args[0] = objModule.ModuleID.ToString() + objCoteInfo.ID;
                    args[1] = objModule.ImageUrl;
                    object[] objArray2 = new object[4];
                    objArray2[0] = objCoteInfo.ID;
                    objArray2[1] = objCoteInfo.ParentID;
                    if (func == null)
                    {
                        func = s => s.ParentID == objCoteInfo.ID;
                    }
                    objArray2[2] = objCoteInfoList.Any <CoteInfo>(func) ? "1" : "0";
                    objArray2[3] = objCoteInfo.Name;
                    args[2]      = string.Format(coteUrl, objArray2).EncryptModuleQuery();
                    args[3]      = objCoteInfo.Name;
                    newChild.SetAttribute("NavigateUrl", string.Format(format, args));
                    objXmlElement.AppendChild(newChild);
                    isCoteSuper = this.ParentIsCoteSupper(objCoteInfo, objCoteInfoList, objCotePowerList);
                    this.CreateCoteChildMenuPowerXmlElement(xmlDocSource, isCoteSuper, objCotePowerList, objCoteInfo.ID, newChild, objCoteInfoList, coteUrl, ModuleLevel, objModule);
                }
            }
        }