Exemplo n.º 1
0
        public void ExportTableStyles(int publishmentSystemId, string tableName)
        {
            var allRelatedIdentities = DataProvider.NodeDao.GetNodeIdListByPublishmentSystemId(publishmentSystemId);

            allRelatedIdentities.Insert(0, 0);
            var tableStyleInfoWithItemsDict = TableStyleManager.GetTableStyleInfoWithItemsDictinary(tableName, allRelatedIdentities);

            if (tableStyleInfoWithItemsDict == null || tableStyleInfoWithItemsDict.Count <= 0)
            {
                return;
            }

            var styleDirectoryPath = PathUtils.Combine(_directoryPath, tableName);

            DirectoryUtils.CreateDirectoryIfNotExists(styleDirectoryPath);

            foreach (var attributeName in tableStyleInfoWithItemsDict.Keys)
            {
                var tableStyleInfoWithItemList = tableStyleInfoWithItemsDict[attributeName];
                if (tableStyleInfoWithItemList == null || tableStyleInfoWithItemList.Count <= 0)
                {
                    continue;
                }

                var attributeNameDirectoryPath = PathUtils.Combine(styleDirectoryPath, attributeName);
                DirectoryUtils.CreateDirectoryIfNotExists(attributeNameDirectoryPath);

                foreach (var tableStyleInfo in tableStyleInfoWithItemList)
                {
                    //仅导出当前系统内的表样式
                    if (tableStyleInfo.RelatedIdentity != 0)
                    {
                        if (!ChannelUtility.IsAncestorOrSelf(publishmentSystemId, publishmentSystemId, tableStyleInfo.RelatedIdentity))
                        {
                            continue;
                        }
                    }
                    var filePath = attributeNameDirectoryPath + PathUtils.SeparatorChar + tableStyleInfo.TableStyleId + ".xml";
                    var feed     = ExportTableStyleInfo(tableStyleInfo);
                    if (tableStyleInfo.StyleItems != null && tableStyleInfo.StyleItems.Count > 0)
                    {
                        foreach (var styleItemInfo in tableStyleInfo.StyleItems)
                        {
                            var entry = ExportTableStyleItemInfo(styleItemInfo);
                            feed.Entries.Add(entry);
                        }
                    }
                    feed.Save(filePath);
                }
            }
        }
Exemplo n.º 2
0
        private static bool TestTypeUpChannel(PageInfo pageInfo, ContextInfo contextInfo, string testOperate, string testValue)
        {
            var isSuccess = false;

            if (StringUtils.EqualsIgnoreCase(testOperate, OperateNotIn))
            {
                var channelIndexes = TranslateUtils.StringCollectionToStringList(testValue);
                var isIn           = false;
                foreach (var channelIndex in channelIndexes)
                {
                    var parentId = DataProvider.NodeDao.GetNodeIdByNodeIndexName(pageInfo.PublishmentSystemId, channelIndex);
                    if (parentId != pageInfo.PageNodeId &&
                        ChannelUtility.IsAncestorOrSelf(pageInfo.PublishmentSystemId, parentId, pageInfo.PageNodeId))
                    {
                        isIn = true;
                        break;
                    }
                }
                if (!isIn)
                {
                    isSuccess = true;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(testValue))
                {
                    if (contextInfo.ChannelID != pageInfo.PageNodeId &&
                        ChannelUtility.IsAncestorOrSelf(pageInfo.PublishmentSystemId, contextInfo.ChannelID, pageInfo.PageNodeId))
                    {
                        isSuccess = true;
                    }
                }
                else
                {
                    var channelIndexes = TranslateUtils.StringCollectionToStringList(testValue);
                    foreach (string channelIndex in channelIndexes)
                    {
                        var parentId = DataProvider.NodeDao.GetNodeIdByNodeIndexName(pageInfo.PublishmentSystemId, channelIndex);
                        if (parentId != pageInfo.PageNodeId &&
                            ChannelUtility.IsAncestorOrSelf(pageInfo.PublishmentSystemId, parentId, pageInfo.PageNodeId))
                        {
                            isSuccess = true;
                            break;
                        }
                    }
                }
            }
            return(isSuccess);
        }
Exemplo n.º 3
0
 private static bool IsShowPublishmentSystem(int publishmentSystemId, ICollection publishmentSystemIdCollection, ICollection nodeIdCollection)
 {
     foreach (int psId in publishmentSystemIdCollection)
     {
         if (psId == publishmentSystemId)
         {
             return(true);
         }
     }
     foreach (int nodeId in nodeIdCollection)
     {
         if (ChannelUtility.IsAncestorOrSelf(publishmentSystemId, publishmentSystemId, nodeId))
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 4
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;

                //站点要判断是否存在,是否有权限,update by sessionliang 20160104
                if (publishmentSystemId == 0 || !PublishmentSystemManager.IsExists(publishmentSystemId) || !publishmentSystemIdList.Contains(publishmentSystemId))
                {
                    //ArrayList publishmentSystemIDArrayList = PublishmentSystemManager.GetPublishmentSystemIDArrayListOrderByLevel();
                    // List<int> publishmentSystemIDList = ProductPermissionsManager.Current.PublishmentSystemIDList;
                    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 (ChannelUtility.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;
                    }

                    var appId = EPublishmentSystemTypeUtils.GetValue(_publishmentSystemInfo.PublishmentSystemType);

                    NtLeftMenuSite.FileName            = $"~/SiteFiles/Configuration/Menus/{appId}/Management.config";
                    NtLeftMenuSite.PublishmentSystemId = _publishmentSystemInfo.PublishmentSystemId;
                    NtLeftMenuSite.PermissionList      = permissionList;

                    ClientScriptRegisterClientScriptBlock("NodeTreeScript", NodeNaviTreeItem.GetNavigationBarScript());
                }
                else
                {
                    if (_permissions.IsSystemAdministrator)
                    {
                        PageUtils.Redirect(PageAppAdd.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);
                NtLeftMenuSystem.FileName       = $"~/SiteFiles/Configuration/Menus/{_menuId}.config";
                NtLeftMenuSystem.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();

            //update at 20141106,避免空引用异常
            if (_publishmentSystemInfo != null && _publishmentSystemInfo.PublishmentSystemId > 0)
            {
                BaiRongDataProvider.AdministratorDao.UpdatePublishmentSystemId(Body.AdministratorName, _publishmentSystemInfo.PublishmentSystemId);
            }
        }
Exemplo n.º 5
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                var targetNodeID = int.Parse(NodeIDTo.SelectedValue);

                var targetPublishmentSystemID   = int.Parse(PublishmentSystemIDDropDownList.SelectedValue);
                var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetPublishmentSystemID);
                var isChecked    = false;
                var checkedLevel = 0;
                if (targetPublishmentSystemInfo.CheckContentLevel == 0 || AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentAdd, AppManager.Cms.Permission.Channel.ContentCheck))
                {
                    isChecked    = true;
                    checkedLevel = 0;
                }
                else
                {
                    var UserCheckLevel  = 0;
                    var OwnHighestLevel = false;

                    if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel1))
                    {
                        UserCheckLevel = 1;
                        if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel2))
                        {
                            UserCheckLevel = 2;
                            if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel3))
                            {
                                UserCheckLevel = 3;
                                if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel4))
                                {
                                    UserCheckLevel = 4;
                                    if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel5))
                                    {
                                        UserCheckLevel = 5;
                                    }
                                }
                            }
                        }
                    }

                    if (UserCheckLevel >= targetPublishmentSystemInfo.CheckContentLevel)
                    {
                        OwnHighestLevel = true;
                    }
                    if (OwnHighestLevel)
                    {
                        isChecked    = true;
                        checkedLevel = 0;
                    }
                    else
                    {
                        isChecked    = false;
                        checkedLevel = UserCheckLevel;
                    }
                }

                try
                {
                    var translateType = ETranslateTypeUtils.GetEnumType(TranslateType.SelectedValue);

                    var nodeIDStrArrayList = ControlUtils.GetSelectedListControlValueArrayList(NodeIDFrom);

                    var nodeIDArrayList = new ArrayList();//需要转移的栏目ID
                    foreach (string nodeIDStr in nodeIDStrArrayList)
                    {
                        var nodeID = int.Parse(nodeIDStr);
                        if (translateType != ETranslateType.Content)//需要转移栏目
                        {
                            if (!ChannelUtility.IsAncestorOrSelf(PublishmentSystemId, nodeID, targetNodeID))
                            {
                                nodeIDArrayList.Add(nodeID);
                            }
                        }

                        if (translateType == ETranslateType.Content)//转移内容
                        {
                            TranslateContent(targetPublishmentSystemInfo, nodeID, targetNodeID, isChecked, checkedLevel);
                        }
                    }

                    if (translateType != ETranslateType.Content)//需要转移栏目
                    {
                        var nodeIDArrayListToTranslate = new ArrayList(nodeIDArrayList);
                        foreach (int nodeID in nodeIDArrayList)
                        {
                            var subNodeIDArrayList = DataProvider.NodeDao.GetNodeIdListForDescendant(nodeID);
                            if (subNodeIDArrayList != null && subNodeIDArrayList.Count > 0)
                            {
                                foreach (int nodeIDToDelete in subNodeIDArrayList)
                                {
                                    if (nodeIDArrayListToTranslate.Contains(nodeIDToDelete))
                                    {
                                        nodeIDArrayListToTranslate.Remove(nodeIDToDelete);
                                    }
                                }
                            }
                        }

                        var nodeInfoList = new List <NodeInfo>();
                        foreach (int nodeID in nodeIDArrayListToTranslate)
                        {
                            var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, nodeID);
                            nodeInfoList.Add(nodeInfo);
                        }

                        TranslateChannelAndContent(nodeInfoList, targetPublishmentSystemID, targetNodeID, translateType, isChecked, checkedLevel, null, null);

                        if (IsDeleteAfterTranslate.Visible && EBooleanUtils.Equals(IsDeleteAfterTranslate.SelectedValue, EBoolean.True))
                        {
                            foreach (int nodeID in nodeIDArrayListToTranslate)
                            {
                                try
                                {
                                    DataProvider.NodeDao.Delete(nodeID);
                                }
                                catch { }
                            }
                        }
                    }
                    Submit.Enabled = false;

                    var builder = new StringBuilder();
                    foreach (ListItem listItem in NodeIDFrom.Items)
                    {
                        if (listItem.Selected)
                        {
                            builder.Append(listItem.Text).Append(",");
                        }
                    }
                    if (builder.Length > 0)
                    {
                        builder.Length = builder.Length - 1;
                    }
                    Body.AddSiteLog(PublishmentSystemId, "批量转移", $"栏目:{builder},转移后删除:{IsDeleteAfterTranslate.SelectedValue}");

                    SuccessMessage("批量转移成功!");
                    if (Body.IsQueryExists("ChannelIDCollection"))
                    {
                        PageUtils.Redirect(returnUrl);
                    }
                    else
                    {
                        PageUtils.Redirect(GetRedirectUrl(PublishmentSystemId));
                    }
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "批量转移失败!");
                    LogUtils.AddErrorLog(ex);
                }
            }
        }