Exemplo n.º 1
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");
            returnUrl = StringUtils.ValueFromUrl(Body.GetQueryString("ReturnUrl"));

            if (!HasChannelPermissions(PublishmentSystemId, AppManager.Cms.Permission.Channel.ContentDelete))
            {
                IsDeleteAfterTranslate.Visible = false;
            }

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.Cms.LeftMenu.IdContent, "批量转移", string.Empty);

                phReturn.Visible = !string.IsNullOrEmpty(returnUrl);
                ETranslateTypeUtils.AddListItems(TranslateType);
                if (Body.IsQueryExists("ChannelIDCollection"))
                {
                    ControlUtils.SelectListItems(TranslateType, ETranslateTypeUtils.GetValue(ETranslateType.All));
                }
                else
                {
                    ControlUtils.SelectListItems(TranslateType, ETranslateTypeUtils.GetValue(ETranslateType.Content));
                }

                IsDeleteAfterTranslate.Items[0].Value = true.ToString();
                IsDeleteAfterTranslate.Items[1].Value = false.ToString();

                var publishmentSystemIDList = ProductPermissionsManager.Current.PublishmentSystemIdList;
                foreach (var psID in publishmentSystemIDList)
                {
                    var psInfo   = PublishmentSystemManager.GetPublishmentSystemInfo(psID);
                    var listitem = new ListItem(psInfo.PublishmentSystemName, psID.ToString());
                    if (psID == PublishmentSystemId)
                    {
                        listitem.Selected = true;
                    }
                    PublishmentSystemIDDropDownList.Items.Add(listitem);
                }

                var nodeIDStrArrayList = new List <string>();
                if (Body.IsQueryExists("ChannelIDCollection"))
                {
                    nodeIDStrArrayList = TranslateUtils.StringCollectionToStringList(Body.GetQueryString("ChannelIDCollection"));
                }

                var nodeIdList = DataProvider.NodeDao.GetNodeIdListByPublishmentSystemId(PublishmentSystemId);
                var nodeCount  = nodeIdList.Count;
                isLastNodeArray = new bool[nodeCount];
                foreach (int theNodeID in nodeIdList)
                {
                    var enabled = IsOwningNodeId(theNodeID);
                    if (!enabled)
                    {
                        if (!IsHasChildOwningNodeId(theNodeID))
                        {
                            continue;
                        }
                    }
                    var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, theNodeID);

                    var value = enabled ? nodeInfo.NodeId.ToString() : string.Empty;
                    value = (nodeInfo.Additional.IsContentAddable) ? value : string.Empty;

                    var text     = GetTitle(nodeInfo);
                    var listItem = new ListItem(text, value);
                    if (nodeIDStrArrayList.Contains(value))
                    {
                        listItem.Selected = true;
                    }
                    NodeIDFrom.Items.Add(listItem);
                    listItem = new ListItem(text, value);
                    NodeIDTo.Items.Add(listItem);
                }
            }
        }
Exemplo n.º 2
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);
                }
            }
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                return;
            }

            var targetChannelId = TranslateUtils.ToInt(DdlChannelIdTo.SelectedValue);

            var targetSiteId = TranslateUtils.ToInt(DdlSiteId.SelectedValue);

            var translateType = ETranslateTypeUtils.GetEnumType(DdlTranslateType.SelectedValue);

            var channelIdStrArrayList = ControlUtils.GetSelectedListControlValueArrayList(LbChannelIdFrom);

            var channelIdList = new List <int>();//需要转移的栏目ID

            foreach (string channelIdStr in channelIdStrArrayList)
            {
                var channelId = int.Parse(channelIdStr);
                if (translateType != ETranslateType.Content)//需要转移栏目
                {
                    if (!ChannelManager.IsAncestorOrSelf(SiteId, channelId, targetChannelId))
                    {
                        channelIdList.Add(channelId);
                    }
                }

                if (translateType == ETranslateType.Content)//转移内容
                {
                    TranslateContent(channelId, targetSiteId, targetChannelId);
                }
            }

            if (translateType != ETranslateType.Content)//需要转移栏目
            {
                var channelIdListToTranslate = new List <int>(channelIdList);
                foreach (var channelId in channelIdList)
                {
                    var channelInfo      = ChannelManager.GetChannelInfo(SiteId, channelId);
                    var subChannelIdList = ChannelManager.GetChannelIdList(channelInfo, EScopeType.Descendant, string.Empty, string.Empty, string.Empty);

                    if (subChannelIdList != null && subChannelIdList.Count > 0)
                    {
                        foreach (var channelIdToDelete in subChannelIdList)
                        {
                            if (channelIdListToTranslate.Contains(channelIdToDelete))
                            {
                                channelIdListToTranslate.Remove(channelIdToDelete);
                            }
                        }
                    }
                }

                var nodeInfoList = new List <ChannelInfo>();
                foreach (int channelId in channelIdListToTranslate)
                {
                    var nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
                    nodeInfoList.Add(nodeInfo);
                }

                TranslateChannelAndContent(nodeInfoList, targetSiteId, targetChannelId, translateType, null, null);

                if (RblIsDeleteAfterTranslate.Visible && EBooleanUtils.Equals(RblIsDeleteAfterTranslate.SelectedValue, EBoolean.True))
                {
                    foreach (var channelId in channelIdListToTranslate)
                    {
                        try
                        {
                            DataProvider.ChannelDao.Delete(SiteId, channelId);
                        }
                        catch
                        {
                            // ignored
                        }
                    }
                }
            }

            var builder = new StringBuilder();

            foreach (ListItem listItem in LbChannelIdFrom.Items)
            {
                if (listItem.Selected)
                {
                    builder.Append(listItem.Text).Append(",");
                }
            }
            if (builder.Length > 0)
            {
                builder.Length = builder.Length - 1;
            }
            AuthRequest.AddSiteLog(SiteId, "批量转移", $"栏目:{builder},转移后删除:{RblIsDeleteAfterTranslate.SelectedValue}");

            SuccessMessage("批量转移成功!");

            if (!string.IsNullOrEmpty(ReturnUrl))
            {
                PageUtils.Redirect(ReturnUrl);
            }
        }
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId");
            ReturnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("ReturnUrl"));

            if (!HasChannelPermissions(SiteId, ConfigManager.ChannelPermissions.ContentDelete))
            {
                RblIsDeleteAfterTranslate.Visible = false;
            }

            if (IsPostBack)
            {
                return;
            }

            PhReturn.Visible = !string.IsNullOrEmpty(ReturnUrl);
            ETranslateTypeUtils.AddListItems(DdlTranslateType);
            ControlUtils.SelectSingleItem(DdlTranslateType,
                                          AuthRequest.IsQueryExists("ChannelIDCollection")
                    ? ETranslateTypeUtils.GetValue(ETranslateType.All)
                    : ETranslateTypeUtils.GetValue(ETranslateType.Content));

            var siteIdList = AuthRequest.AdminPermissionsImpl.GetSiteIdList();

            foreach (var psId in siteIdList)
            {
                var psInfo   = SiteManager.GetSiteInfo(psId);
                var listitem = new ListItem(psInfo.SiteName, psId.ToString());
                if (psId == SiteId)
                {
                    listitem.Selected = true;
                }
                DdlSiteId.Items.Add(listitem);
            }

            var channelIdStrList = new List <string>();

            if (AuthRequest.IsQueryExists("ChannelIDCollection"))
            {
                channelIdStrList = TranslateUtils.StringCollectionToStringList(AuthRequest.GetQueryString("ChannelIDCollection"));
            }

            var channelIdList = ChannelManager.GetChannelIdList(SiteId);
            var nodeCount     = channelIdList.Count;

            _isLastNodeArray = new bool[nodeCount];
            foreach (var theChannelId in channelIdList)
            {
                var enabled = IsOwningChannelId(theChannelId);
                if (!enabled)
                {
                    if (!IsDescendantOwningChannelId(theChannelId))
                    {
                        continue;
                    }
                }
                var nodeInfo = ChannelManager.GetChannelInfo(SiteId, theChannelId);

                var value = enabled ? nodeInfo.Id.ToString() : string.Empty;
                value = nodeInfo.Additional.IsContentAddable ? value : string.Empty;

                var text     = GetTitle(nodeInfo);
                var listItem = new ListItem(text, value);
                if (channelIdStrList.Contains(value))
                {
                    listItem.Selected = true;
                }
                LbChannelIdFrom.Items.Add(listItem);
                listItem = new ListItem(text, value);
                DdlChannelIdTo.Items.Add(listItem);
            }
        }
Exemplo n.º 5
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                return;
            }

            var targetChannelId = TranslateUtils.ToInt(DdlChannelIdTo.SelectedValue);

            var  targetSiteId   = TranslateUtils.ToInt(DdlSiteId.SelectedValue);
            var  targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId);
            bool isChecked;
            int  checkedLevel;

            if (targetSiteInfo.Additional.CheckContentLevel == 0 || AdminUtility.HasChannelPermissions(Body.AdminName, targetSiteId, targetChannelId, ConfigManager.Permissions.Channel.ContentAdd, ConfigManager.Permissions.Channel.ContentCheck))
            {
                isChecked    = true;
                checkedLevel = 0;
            }
            else
            {
                var userCheckLevel  = 0;
                var ownHighestLevel = false;

                if (AdminUtility.HasChannelPermissions(Body.AdminName, targetSiteId, targetChannelId, ConfigManager.Permissions.Channel.ContentCheckLevel1))
                {
                    userCheckLevel = 1;
                    if (AdminUtility.HasChannelPermissions(Body.AdminName, targetSiteId, targetChannelId, ConfigManager.Permissions.Channel.ContentCheckLevel2))
                    {
                        userCheckLevel = 2;
                        if (AdminUtility.HasChannelPermissions(Body.AdminName, targetSiteId, targetChannelId, ConfigManager.Permissions.Channel.ContentCheckLevel3))
                        {
                            userCheckLevel = 3;
                            if (AdminUtility.HasChannelPermissions(Body.AdminName, targetSiteId, targetChannelId, ConfigManager.Permissions.Channel.ContentCheckLevel4))
                            {
                                userCheckLevel = 4;
                                if (AdminUtility.HasChannelPermissions(Body.AdminName, targetSiteId, targetChannelId, ConfigManager.Permissions.Channel.ContentCheckLevel5))
                                {
                                    userCheckLevel = 5;
                                }
                            }
                        }
                    }
                }

                if (userCheckLevel >= targetSiteInfo.Additional.CheckContentLevel)
                {
                    ownHighestLevel = true;
                }
                if (ownHighestLevel)
                {
                    isChecked    = true;
                    checkedLevel = 0;
                }
                else
                {
                    isChecked    = false;
                    checkedLevel = userCheckLevel;
                }
            }

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

                var channelIdStrArrayList = ControlUtils.GetSelectedListControlValueArrayList(LbChannelIdFrom);

                var channelIdList = new List <int>();       //需要转移的栏目ID
                foreach (string channelIdStr in channelIdStrArrayList)
                {
                    var channelId = int.Parse(channelIdStr);
                    if (translateType != ETranslateType.Content)        //需要转移栏目
                    {
                        if (!ChannelManager.IsAncestorOrSelf(SiteId, channelId, targetChannelId))
                        {
                            channelIdList.Add(channelId);
                        }
                    }

                    if (translateType == ETranslateType.Content)        //转移内容
                    {
                        TranslateContent(targetSiteInfo, channelId, targetChannelId, isChecked, checkedLevel);
                    }
                }

                if (translateType != ETranslateType.Content)        //需要转移栏目
                {
                    var channelIdListToTranslate = new List <int>(channelIdList);
                    foreach (var channelId in channelIdList)
                    {
                        var subChannelIdArrayList = DataProvider.ChannelDao.GetIdListForDescendant(channelId);
                        if (subChannelIdArrayList != null && subChannelIdArrayList.Count > 0)
                        {
                            foreach (int channelIdToDelete in subChannelIdArrayList)
                            {
                                if (channelIdListToTranslate.Contains(channelIdToDelete))
                                {
                                    channelIdListToTranslate.Remove(channelIdToDelete);
                                }
                            }
                        }
                    }

                    var nodeInfoList = new List <ChannelInfo>();
                    foreach (int channelId in channelIdListToTranslate)
                    {
                        var nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
                        nodeInfoList.Add(nodeInfo);
                    }

                    TranslateChannelAndContent(nodeInfoList, targetSiteId, targetChannelId, translateType, isChecked, checkedLevel, null, null);

                    if (RblIsDeleteAfterTranslate.Visible && EBooleanUtils.Equals(RblIsDeleteAfterTranslate.SelectedValue, EBoolean.True))
                    {
                        foreach (int channelId in channelIdListToTranslate)
                        {
                            try
                            {
                                DataProvider.ChannelDao.Delete(SiteId, channelId);
                            }
                            catch
                            {
                                // ignored
                            }
                        }
                    }
                }
                BtnSubmit.Enabled = false;

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

                SuccessMessage("批量转移成功!");
                PageUtils.Redirect(Body.IsQueryExists("ChannelIDCollection") ? ReturnUrl : GetRedirectUrl(SiteId));
            }
            catch (Exception ex)
            {
                FailMessage(ex, "批量转移失败!");
                LogUtils.AddSystemErrorLog(ex);
            }
        }