Example #1
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;              // 检测是否允许访问本页面
            }
            if (PageUtils.DetermineRedirectToInstaller())
            {
                return;                          // 检测系统是否需要安装,如果需要转到安装页面。
            }
            if (!Body.IsAdministratorLoggin)     // 检测管理员是否登录
            {
                PageUtils.RedirectToLoginPage(); // 如果没有登录则跳到登录页面
                return;
            }

            if (Body.AdministratorInfo.IsLockedOut) // 检测管理员帐号是否被锁定
            {
                PageUtils.RedirectToLoginPage("对不起,您的账号已被锁定,无法进入系统!");
                return;
            }

            var redirectUrl = PageMain.GetRedirectUrl();                                             // 如果检测登录帐号一切正常,则准备转到框架主页 pagemain.aspx

            var permissions             = PermissionsManager.GetPermissions(Body.AdministratorName); // 获取登录管理员的权限
            var publishmentSystemIdList = ProductPermissionsManager.Current.PublishmentSystemIdList; // 获取当前站点ID

            if (publishmentSystemIdList == null || publishmentSystemIdList.Count == 0)               // 如果目前还没有创建站点
            {
                if (permissions.IsSystemAdministrator)                                               // 如果目前还没有创建站点并且当前登录管理员是系统管理员
                {
                    redirectUrl = PagePublishmentSystemAdd.GetRedirectUrl();                         // 则直接跳到站点创建页面
                }
            }

            LtlContent.Text = $@"
<script language=""javascript"">
function redirectUrl()
{{
   location.href = ""{redirectUrl}"";
}}
setTimeout(""redirectUrl()"", 2000);
</script>
";   // 通过输出js来实现2秒之后开始页面跳转
        }
Example #2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            LtlUserName.Text = AdminManager.GetDisplayName(Body.AdministratorName, true);

            _menuId      = Body.GetQueryString("menuID");
            _permissions = PermissionsManager.GetPermissions(Body.AdministratorName);

            if (string.IsNullOrEmpty(_menuId))
            {
                var publishmentSystemId = PublishmentSystemId;

                if (publishmentSystemId == 0)
                {
                    publishmentSystemId = Body.AdministratorInfo.PublishmentSystemId;
                }

                var publishmentSystemIdList = ProductPermissionsManager.Current.PublishmentSystemIdList;

                //站点要判断是否存在,是否有权限
                if (publishmentSystemId == 0 || !PublishmentSystemManager.IsExists(publishmentSystemId) || !publishmentSystemIdList.Contains(publishmentSystemId))
                {
                    if (publishmentSystemIdList != null && publishmentSystemIdList.Count > 0)
                    {
                        publishmentSystemId = publishmentSystemIdList[0];
                    }
                }

                _publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);

                if (_publishmentSystemInfo != null && _publishmentSystemInfo.PublishmentSystemId > 0)
                {
                    if (PublishmentSystemId == 0)
                    {
                        PageUtils.Redirect(GetRedirectUrl(_publishmentSystemInfo.PublishmentSystemId, string.Empty));
                        return;
                    }

                    var showPublishmentSystem = false;

                    var permissionList = new List <string>();
                    if (ProductPermissionsManager.Current.WebsitePermissionDict.ContainsKey(_publishmentSystemInfo.PublishmentSystemId))
                    {
                        var websitePermissionList = ProductPermissionsManager.Current.WebsitePermissionDict[_publishmentSystemInfo.PublishmentSystemId];
                        if (websitePermissionList != null)
                        {
                            showPublishmentSystem = true;
                            permissionList.AddRange(websitePermissionList);
                        }
                    }

                    ICollection nodeIdCollection = ProductPermissionsManager.Current.ChannelPermissionDict.Keys;
                    foreach (int nodeId in nodeIdCollection)
                    {
                        if (NodeManager.IsAncestorOrSelf(_publishmentSystemInfo.PublishmentSystemId, _publishmentSystemInfo.PublishmentSystemId, nodeId))
                        {
                            showPublishmentSystem = true;
                            var list = ProductPermissionsManager.Current.ChannelPermissionDict[nodeId];
                            permissionList.AddRange(list);
                        }
                    }

                    var publishmentSystemIdHashtable = new Hashtable();
                    if (publishmentSystemIdList != null)
                    {
                        foreach (var thePublishmentSystemId in publishmentSystemIdList)
                        {
                            publishmentSystemIdHashtable.Add(thePublishmentSystemId, thePublishmentSystemId);
                        }
                    }

                    if (!publishmentSystemIdHashtable.Contains(PublishmentSystemId))
                    {
                        showPublishmentSystem = false;
                    }

                    if (!showPublishmentSystem)
                    {
                        PageUtils.RedirectToErrorPage("您没有此发布系统的操作权限!");
                        return;
                    }

                    NtLeftMenu.TopId = AppManager.IdManagement;
                    NtLeftMenu.PublishmentSystemId = _publishmentSystemInfo.PublishmentSystemId;
                    NtLeftMenu.PermissionList      = permissionList;

                    ClientScriptRegisterClientScriptBlock("NodeTreeScript", NodeNaviTreeItem.GetNavigationBarScript());
                }
                else
                {
                    if (_permissions.IsSystemAdministrator)
                    {
                        PageUtils.Redirect(PagePublishmentSystemAdd.GetRedirectUrl());
                        return;
                    }
                }
            }
            else if (!string.IsNullOrEmpty(_menuId))
            {
                var permissionList = new List <string>();
                if (ProductPermissionsManager.Current.WebsitePermissionDict.ContainsKey(PublishmentSystemId))
                {
                    var websitePermissionList = ProductPermissionsManager.Current.WebsitePermissionDict[PublishmentSystemId];
                    if (websitePermissionList != null)
                    {
                        permissionList.AddRange(websitePermissionList);
                    }
                }

                permissionList.AddRange(_permissions.PermissionList);
                NtLeftMenu.TopId          = _menuId;
                NtLeftMenu.PermissionList = permissionList;

                ClientScriptRegisterClientScriptBlock("NodeTreeScript", NavigationTreeItem.GetNavigationBarScript());
            }

            var topMenuList = new List <int> {
                1, 2
            };

            //cms超管和有权限的管理员
            if (_permissions.IsConsoleAdministrator || _permissions.PermissionList.Count > 0)
            {
                topMenuList.Add(3);
            }
            RptTopMenu.DataSource     = topMenuList;
            RptTopMenu.ItemDataBound += RptTopMenu_ItemDataBound;
            RptTopMenu.DataBind();

            //避免空引用异常
            if (_publishmentSystemInfo != null && _publishmentSystemInfo.PublishmentSystemId > 0)
            {
                BaiRongDataProvider.AdministratorDao.UpdatePublishmentSystemId(Body.AdministratorName, _publishmentSystemInfo.PublishmentSystemId);
            }
        }
Example #3
0
        private bool GetPublishmentSystemListHtml(StringBuilder builder)
        {
            var publishmentSystemIdList = ProductPermissionsManager.Current.PublishmentSystemIdList;

            //操作者拥有的站点列表
            var mySystemInfoList = new List <PublishmentSystemInfo>();

            var parentWithChildren = new Dictionary <int, List <PublishmentSystemInfo> >();

            if (ProductPermissionsManager.Current.IsSystemAdministrator)
            {
                foreach (var publishmentSystemId in publishmentSystemIdList)
                {
                    AddToMySystemInfoList(mySystemInfoList, parentWithChildren, publishmentSystemId);
                }
            }
            else
            {
                ICollection nodeIdCollection = ProductPermissionsManager.Current.ChannelPermissionDict.Keys;
                ICollection publishmentSystemIdCollection = ProductPermissionsManager.Current.WebsitePermissionDict.Keys;
                foreach (var publishmentSystemId in publishmentSystemIdList)
                {
                    var showPublishmentSystem = IsShowPublishmentSystem(publishmentSystemId, publishmentSystemIdCollection, nodeIdCollection);
                    if (showPublishmentSystem)
                    {
                        AddToMySystemInfoList(mySystemInfoList, parentWithChildren, publishmentSystemId);
                    }
                }
            }

            if (_permissions.IsConsoleAdministrator)
            {
                var redirectUrl = PagePublishmentSystemAdd.GetRedirectUrl();
                builder.Append(
                    $@"<li style=""background:#eee;""><a href=""{PageUtils.GetLoadingUrl(redirectUrl)}""><i class=""icon-plus icon-large
""></i> 创建新站点</a></li>");

                builder.Append(@"<li class=""divider""></li>");
            }

            if (_hqPublishmentSystemInfo != null || mySystemInfoList.Count > 0)
            {
                if (_hqPublishmentSystemInfo != null)
                {
                    AddSite(builder, _hqPublishmentSystemInfo, parentWithChildren, 0);
                }

                if (mySystemInfoList.Count > 0)
                {
                    var count = 0;
                    foreach (var publishmentSystemInfo in mySystemInfoList)
                    {
                        if (publishmentSystemInfo.IsHeadquarters == false)
                        {
                            count++;
                            AddSite(builder, publishmentSystemInfo, parentWithChildren, 0);
                        }
                        if (count == 13)
                        {
                            builder.Append(@"<li class=""divider""></li>");
                            builder.Append(
                                $@"<li style=""background:#eee;""><a href=""javascript:;"" onclick=""{ModalPublishmentSystemSelect
                                    .GetOpenLayerString()}""><i class=""icon-search icon-large""></i> 列出全部站点...</a></li>");
                            break;
                        }
                    }
                }
            }

            //if (builder.Length > 0)
            //{
            //    builder.Append(@"<li class=""divider""></li>");
            //}

            return(_permissions.IsSystemAdministrator || publishmentSystemIdList.Count > 0);
        }