Esempio n. 1
0
        public void Update(SystemPermissionsInfo info)
        {
            var updateParms = new IDataParameter[]
            {
                GetParameter(ParmRoleRoleName, EDataType.NVarChar, 255, info.RoleName),
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, info.PublishmentSystemId),
                GetParameter(ParmNodeIdCollection, EDataType.Text, info.NodeIdCollection),
                GetParameter(ParmChannelPermissions, EDataType.Text, info.ChannelPermissions),
                GetParameter(ParmWebsitePermissions, EDataType.Text, info.WebsitePermissions)
            };

            ExecuteNonQuery(_sqlUpdate, updateParms);
        }
Esempio n. 2
0
        public void InsertWithTransNew(SystemPermissionsInfo info, IDbTransaction trans)
        {
            //if (IsExists(info.RoleName, info.PublishmentSystemId, trans))
            //{
            //    DeleteWithTrans(info.RoleName, info.PublishmentSystemId, trans);
            //}

            var insertParms = new IDataParameter[]
            {
                GetParameter(ParmRoleRoleName, EDataType.NVarChar, 255, info.RoleName),
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, info.PublishmentSystemId),
                GetParameter(ParmNodeIdCollection, EDataType.Text, info.NodeIdCollection),
                GetParameter(ParmChannelPermissions, EDataType.Text, info.ChannelPermissions),
                GetParameter(ParmWebsitePermissions, EDataType.Text, info.WebsitePermissions)
            };

            ExecuteNonQuery(trans, SqlInsert, insertParms);
        }
Esempio n. 3
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var systemPermissionsInfoList = Session[PageRoleAdd.SystemPermissionsInfoListKey] as List <SystemPermissionsInfo>;

            if (systemPermissionsInfoList != null)
            {
                var systemPermissionlist = new List <SystemPermissionsInfo>();
                foreach (var systemPermissionsInfo in systemPermissionsInfoList)
                {
                    if (systemPermissionsInfo.PublishmentSystemId == PublishmentSystemId)
                    {
                        continue;
                    }
                    systemPermissionlist.Add(systemPermissionsInfo);
                }

                var nodeIdList = TranslateUtils.StringCollectionToStringList(Request.Form["NodeIDCollection"]);
                if (nodeIdList.Count > 0 && CblChannelPermissions.SelectedItem != null || CblWebsitePermissions.SelectedItem != null)
                {
                    var systemPermissionsInfo = new SystemPermissionsInfo
                    {
                        PublishmentSystemId = PublishmentSystemId,
                        NodeIdCollection    = TranslateUtils.ObjectCollectionToString(nodeIdList),
                        ChannelPermissions  =
                            ControlUtils.SelectedItemsValueToStringCollection(CblChannelPermissions.Items),
                        WebsitePermissions =
                            ControlUtils.SelectedItemsValueToStringCollection(CblWebsitePermissions.Items)
                    };

                    systemPermissionlist.Add(systemPermissionsInfo);
                }

                Session[PageRoleAdd.SystemPermissionsInfoListKey] = systemPermissionlist;
            }

            PageUtils.Redirect(PageRoleAdd.GetReturnRedirectUrl(Body.GetQueryString("RoleName")));
        }
Esempio n. 4
0
        /// <summary>
        /// 根据角色名和站点ID获取角色权限信息
        /// </summary>
        /// <param name="roleName"></param>
        /// <param name="publishmentSystemId"></param>
        /// <returns></returns>
        public SystemPermissionsInfo GetSystemPermissionsInfoByRp(string roleName, int publishmentSystemId)
        {
            SystemPermissionsInfo info = null;

            var parms = new IDataParameter[]
            {
                GetParameter(ParmRoleRoleName, EDataType.NVarChar, 255, roleName),
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId)
            };

            using (var rdr = ExecuteReader(SqlSelectAllByRp, parms))
            {
                if (rdr.Read())
                {
                    var i = 0;
                    info = new SystemPermissionsInfo(GetString(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i));
                }
                rdr.Close();
            }

            return(info);
        }
Esempio n. 5
0
        public List <SystemPermissionsInfo> GetSystemPermissionsInfoList(string roleName)
        {
            var list = new List <SystemPermissionsInfo>();

            var parms = new IDataParameter[]
            {
                GetParameter(ParmRoleRoleName, EDataType.NVarChar, 255, roleName)
            };

            using (var rdr = ExecuteReader(SqlSelectAllByRoleName, parms))
            {
                while (rdr.Read())
                {
                    var i    = 0;
                    var info = new SystemPermissionsInfo(GetString(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i));
                    list.Add(info);
                }
                rdr.Close();
            }

            return(list);
        }
Esempio n. 6
0
        public List <SystemPermissionsInfo> GetSystemPermissionsInfoListByPublishmentSystemId(int publishmentSystemId, string whereStr)
        {
            var list = new List <SystemPermissionsInfo>();

            var parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId)
            };

            using (var rdr = ExecuteReader(
                       $"SELECT RoleName, PublishmentSystemID, NodeIDCollection, ChannelPermissions, WebsitePermissions FROM siteserver_SystemPermissions WHERE PublishmentSystemID = @PublishmentSystemID {whereStr} ", parms))
            {
                while (rdr.Read())
                {
                    var i    = 0;
                    var info = new SystemPermissionsInfo(GetString(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i));
                    list.Add(info);
                }
                rdr.Close();
            }

            return(list);
        }
Esempio n. 7
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            var permissioins = PermissionsManager.GetPermissions(Body.AdministratorName);

            LtlNodeTree.Text = GetNodeTreeHtml();

            if (IsPostBack)
            {
                return;
            }

            PermissionsManager.VerifyAdministratorPermissions(Body.AdministratorName, AppManager.Admin.Permission.AdminManagement);

            if (permissioins.IsSystemAdministrator)
            {
                var channelPermissions = PermissionConfigManager.Instance.ChannelPermissions;
                foreach (var permission in channelPermissions)
                {
                    if (permission.Name == AppManager.Cms.Permission.Channel.ContentCheckLevel1)
                    {
                        if (PublishmentSystemInfo.IsCheckContentUseLevel)
                        {
                            if (PublishmentSystemInfo.CheckContentLevel < 1)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (permission.Name == AppManager.Cms.Permission.Channel.ContentCheckLevel2)
                    {
                        if (PublishmentSystemInfo.IsCheckContentUseLevel)
                        {
                            if (PublishmentSystemInfo.CheckContentLevel < 2)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (permission.Name == AppManager.Cms.Permission.Channel.ContentCheckLevel3)
                    {
                        if (PublishmentSystemInfo.IsCheckContentUseLevel)
                        {
                            if (PublishmentSystemInfo.CheckContentLevel < 3)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (permission.Name == AppManager.Cms.Permission.Channel.ContentCheckLevel4)
                    {
                        if (PublishmentSystemInfo.IsCheckContentUseLevel)
                        {
                            if (PublishmentSystemInfo.CheckContentLevel < 4)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (permission.Name == AppManager.Cms.Permission.Channel.ContentCheckLevel5)
                    {
                        if (PublishmentSystemInfo.IsCheckContentUseLevel)
                        {
                            if (PublishmentSystemInfo.CheckContentLevel < 5)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    var listItem = new ListItem(permission.Text, permission.Name);
                    CblChannelPermissions.Items.Add(listItem);
                }
            }
            else
            {
                PhChannelPermissions.Visible = false;
                if (ProductPermissionsManager.Current.ChannelPermissionDict.ContainsKey(PublishmentSystemId))
                {
                    var channelPermissions = ProductPermissionsManager.Current.ChannelPermissionDict[PublishmentSystemId];
                    foreach (var channelPermission in channelPermissions)
                    {
                        foreach (var permission in PermissionConfigManager.Instance.ChannelPermissions)
                        {
                            if (permission.Name == channelPermission)
                            {
                                if (channelPermission == AppManager.Cms.Permission.Channel.ContentCheck)
                                {
                                    if (PublishmentSystemInfo.IsCheckContentUseLevel)
                                    {
                                        continue;
                                    }
                                }
                                else if (channelPermission == AppManager.Cms.Permission.Channel.ContentCheckLevel1)
                                {
                                    if (PublishmentSystemInfo.IsCheckContentUseLevel == false || PublishmentSystemInfo.CheckContentLevel < 1)
                                    {
                                        continue;
                                    }
                                }
                                else if (channelPermission == AppManager.Cms.Permission.Channel.ContentCheckLevel2)
                                {
                                    if (PublishmentSystemInfo.IsCheckContentUseLevel == false || PublishmentSystemInfo.CheckContentLevel < 2)
                                    {
                                        continue;
                                    }
                                }
                                else if (channelPermission == AppManager.Cms.Permission.Channel.ContentCheckLevel3)
                                {
                                    if (PublishmentSystemInfo.IsCheckContentUseLevel == false || PublishmentSystemInfo.CheckContentLevel < 3)
                                    {
                                        continue;
                                    }
                                }
                                else if (channelPermission == AppManager.Cms.Permission.Channel.ContentCheckLevel4)
                                {
                                    if (PublishmentSystemInfo.IsCheckContentUseLevel == false || PublishmentSystemInfo.CheckContentLevel < 4)
                                    {
                                        continue;
                                    }
                                }
                                else if (channelPermission == AppManager.Cms.Permission.Channel.ContentCheckLevel5)
                                {
                                    if (PublishmentSystemInfo.IsCheckContentUseLevel == false || PublishmentSystemInfo.CheckContentLevel < 5)
                                    {
                                        continue;
                                    }
                                }

                                PhChannelPermissions.Visible = true;
                                var listItem = new ListItem(permission.Text, permission.Name);
                                CblChannelPermissions.Items.Add(listItem);
                            }
                        }
                    }
                }
            }

            if (permissioins.IsSystemAdministrator)
            {
                var websitePermissions = PermissionConfigManager.Instance.WebsitePermissions;
                foreach (var permission in websitePermissions)
                {
                    var listItem = new ListItem(permission.Text, permission.Name);
                    CblWebsitePermissions.Items.Add(listItem);
                }
            }
            else
            {
                PhWebsitePermissions.Visible = false;
                if (ProductPermissionsManager.Current.WebsitePermissionDict.ContainsKey(PublishmentSystemId))
                {
                    var websitePermissionList = ProductPermissionsManager.Current.WebsitePermissionDict[PublishmentSystemId];
                    foreach (var websitePermission in websitePermissionList)
                    {
                        foreach (var permission in PermissionConfigManager.Instance.WebsitePermissions)
                        {
                            if (permission.Name == websitePermission)
                            {
                                PhWebsitePermissions.Visible = true;
                                var listItem = new ListItem(permission.Text, permission.Name);
                                CblWebsitePermissions.Items.Add(listItem);
                            }
                        }
                    }
                }
            }

            var systemPermissionsInfoList = Session[PageRoleAdd.SystemPermissionsInfoListKey] as List <SystemPermissionsInfo>;

            if (systemPermissionsInfoList != null)
            {
                SystemPermissionsInfo systemPermissionsInfo = null;
                foreach (var publishmentSystemPermissionsInfo in systemPermissionsInfoList)
                {
                    if (publishmentSystemPermissionsInfo.PublishmentSystemId == PublishmentSystemId)
                    {
                        systemPermissionsInfo = publishmentSystemPermissionsInfo;
                        break;
                    }
                }
                if (systemPermissionsInfo == null)
                {
                    return;
                }

                foreach (ListItem item in CblChannelPermissions.Items)
                {
                    item.Selected = CompareUtils.Contains(systemPermissionsInfo.ChannelPermissions, item.Value);
                }
                foreach (ListItem item in CblWebsitePermissions.Items)
                {
                    item.Selected = CompareUtils.Contains(systemPermissionsInfo.WebsitePermissions, item.Value);
                }
            }
        }