Example #1
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            ChannelInfo nodeInfo;

            try
            {
                nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
                if (!nodeInfo.IndexName.Equals(TbNodeIndexName.Text) && TbNodeIndexName.Text.Length != 0)
                {
                    var nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
                    if (nodeIndexNameList.IndexOf(TbNodeIndexName.Text) != -1)
                    {
                        FailMessage("栏目属性修改失败,栏目索引已存在!");
                        return;
                    }
                }

                if (nodeInfo.ContentModelPluginId != DdlContentModelPluginId.SelectedValue)
                {
                    nodeInfo.ContentModelPluginId = DdlContentModelPluginId.SelectedValue;
                }

                nodeInfo.ContentRelatedPluginIds = ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds);

                TbFilePath.Text = TbFilePath.Text.Trim();
                if (!nodeInfo.FilePath.Equals(TbFilePath.Text) && TbFilePath.Text.Length != 0)
                {
                    if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
                    {
                        FailMessage("栏目页面路径不符合系统要求!");
                        return;
                    }

                    if (PathUtils.IsDirectoryPath(TbFilePath.Text))
                    {
                        TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
                    }

                    var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
                    if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
                    {
                        FailMessage("栏目修改失败,栏目页面路径已存在!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text))
                {
                    var filePathRule = TbChannelFilePathRule.Text.Replace("|", string.Empty);
                    if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
                    {
                        FailMessage("栏目页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(filePathRule))
                    {
                        FailMessage("栏目页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(TbContentFilePathRule.Text))
                {
                    var filePathRule = TbContentFilePathRule.Text.Replace("|", string.Empty);
                    if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
                    {
                        FailMessage("内容页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(filePathRule))
                    {
                        FailMessage("内容页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                var styleInfoList      = TableStyleManager.GetChannelStyleInfoList(nodeInfo);
                var extendedAttributes = BackgroundInputTypeParser.SaveAttributes(SiteInfo, styleInfoList, Request.Form, null);
                nodeInfo.Additional.Load(extendedAttributes);

                nodeInfo.ChannelName         = TbNodeName.Text;
                nodeInfo.IndexName           = TbNodeIndexName.Text;
                nodeInfo.FilePath            = TbFilePath.Text;
                nodeInfo.ChannelFilePathRule = TbChannelFilePathRule.Text;
                nodeInfo.ContentFilePathRule = TbContentFilePathRule.Text;

                var list = new ArrayList();
                foreach (ListItem item in CblNodeGroupNameCollection.Items)
                {
                    if (item.Selected)
                    {
                        list.Add(item.Value);
                    }
                }
                nodeInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
                nodeInfo.ImageUrl            = TbImageUrl.Text;
                nodeInfo.Content             = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]);

                nodeInfo.Keywords    = TbKeywords.Text;
                nodeInfo.Description = TbDescription.Text;

                nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(RblIsChannelAddable.SelectedValue);
                nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(RblIsContentAddable.SelectedValue);

                nodeInfo.LinkUrl  = TbLinkUrl.Text;
                nodeInfo.LinkType = DdlLinkType.SelectedValue;
                nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue));
                nodeInfo.ChannelTemplateId           = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0;
                nodeInfo.ContentTemplateId           = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0;

                DataProvider.ChannelDao.Update(nodeInfo);
            }
            catch (Exception ex)
            {
                FailMessage(ex, $"栏目修改失败:{ex.Message}");
                LogUtils.AddErrorLog(ex);
                return;
            }

            CreateManager.CreateChannel(SiteId, nodeInfo.Id);

            AuthRequest.AddSiteLog(SiteId, "修改栏目", $"栏目:{TbNodeName.Text}");

            SuccessMessage("栏目修改成功!");
            PageUtils.Redirect(ReturnUrl);
        }
Example #2
0
        private void TranslateChannelAndContent(List <NodeInfo> nodeInfoList, int targetPublishmentSystemID, int parentID, ETranslateType translateType, bool isChecked, int checkedLevel, List <string> nodeIndexNameList, List <string> filePathList)
        {
            if (nodeInfoList == null || nodeInfoList.Count == 0)
            {
                return;
            }

            if (nodeIndexNameList == null)
            {
                nodeIndexNameList = DataProvider.NodeDao.GetNodeIndexNameList(targetPublishmentSystemID);
            }

            if (filePathList == null)
            {
                filePathList = DataProvider.NodeDao.GetAllFilePathByPublishmentSystemId(targetPublishmentSystemID);
            }

            var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetPublishmentSystemID);

            foreach (NodeInfo oldNodeInfo in nodeInfoList)
            {
                var nodeInfo = new NodeInfo(oldNodeInfo);
                nodeInfo.PublishmentSystemId = targetPublishmentSystemID;
                nodeInfo.ParentId            = parentID;
                nodeInfo.ContentNum          = 0;
                nodeInfo.ChildrenCount       = 0;

                nodeInfo.AddDate = DateTime.Now;
                if (IsDeleteAfterTranslate.Visible && EBooleanUtils.Equals(IsDeleteAfterTranslate.SelectedValue, EBoolean.True))
                {
                    nodeIndexNameList.Add(nodeInfo.NodeIndexName);
                }

                else if (!string.IsNullOrEmpty(nodeInfo.NodeIndexName) && nodeIndexNameList.IndexOf(nodeInfo.NodeIndexName) == -1)
                {
                    nodeIndexNameList.Add(nodeInfo.NodeIndexName);
                }
                else
                {
                    nodeInfo.NodeIndexName = string.Empty;
                }

                if (!string.IsNullOrEmpty(nodeInfo.FilePath) && filePathList.IndexOf(nodeInfo.FilePath) == -1)
                {
                    filePathList.Add(nodeInfo.FilePath);
                }
                else
                {
                    nodeInfo.FilePath = string.Empty;
                }

                var insertedNodeID = DataProvider.NodeDao.InsertNodeInfo(nodeInfo);

                if (translateType == ETranslateType.All)
                {
                    TranslateContent(targetPublishmentSystemInfo, oldNodeInfo.NodeId, insertedNodeID, isChecked, checkedLevel);
                }

                if (insertedNodeID != 0)
                {
                    var orderByString        = ETaxisTypeUtils.GetChannelOrderByString(ETaxisType.OrderByTaxis);
                    var childrenNodeInfoList = DataProvider.NodeDao.GetNodeInfoList(oldNodeInfo, 0, "", EScopeType.Children, orderByString);
                    if (childrenNodeInfoList != null && childrenNodeInfoList.Count > 0)
                    {
                        TranslateChannelAndContent(childrenNodeInfoList, targetPublishmentSystemID, insertedNodeID, translateType, isChecked, checkedLevel, nodeIndexNameList, filePathList);
                    }

                    if (isChecked)
                    {
                        CreateManager.CreateChannel(targetPublishmentSystemInfo.PublishmentSystemId, insertedNodeID);
                    }
                }
            }
        }
Example #3
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var isChanged = false;

            try
            {
                var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);

                if (!nodeInfo.IndexName.Equals(TbNodeIndexName.Text) && TbNodeIndexName.Text.Length != 0)
                {
                    var nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
                    if (nodeIndexNameList.IndexOf(TbNodeIndexName.Text) != -1)
                    {
                        FailMessage("栏目修改失败,栏目索引已存在!");
                        return;
                    }
                }

                if (PhFilePath.Visible)
                {
                    TbFilePath.Text = TbFilePath.Text.Trim();
                    if (!nodeInfo.FilePath.Equals(TbFilePath.Text) && TbFilePath.Text.Length != 0)
                    {
                        if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
                        {
                            FailMessage("栏目页面路径不符合系统要求!");
                            return;
                        }

                        if (PathUtils.IsDirectoryPath(TbFilePath.Text))
                        {
                            TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
                        }

                        var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
                        if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
                        {
                            FailMessage("栏目修改失败,栏目页面路径已存在!");
                            return;
                        }
                    }
                }

                var extendedAttributes = new ExtendedAttributes();
                var relatedIdentities  = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
                var styleInfoList      = TableStyleManager.GetTableStyleInfoList(DataProvider.ChannelDao.TableName,
                                                                                 relatedIdentities);
                BackgroundInputTypeParser.SaveAttributes(extendedAttributes, SiteInfo, styleInfoList, Request.Form, null);
                if (extendedAttributes.Count > 0)
                {
                    nodeInfo.Additional.Load(extendedAttributes.ToDictionary());
                }

                nodeInfo.ChannelName = TbNodeName.Text;
                nodeInfo.IndexName   = TbNodeIndexName.Text;
                if (PhFilePath.Visible)
                {
                    nodeInfo.FilePath = TbFilePath.Text;
                }

                var list = new ArrayList();
                foreach (ListItem item in CblNodeGroupNameCollection.Items)
                {
                    if (item.Selected)
                    {
                        list.Add(item.Value);
                    }
                }
                nodeInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
                nodeInfo.ImageUrl            = TbImageUrl.Text;
                nodeInfo.Content             = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]);
                if (TbKeywords.Visible)
                {
                    nodeInfo.Keywords = TbKeywords.Text;
                }
                if (TbDescription.Visible)
                {
                    nodeInfo.Description = TbDescription.Text;
                }

                if (PhLinkUrl.Visible)
                {
                    nodeInfo.LinkUrl = TbLinkUrl.Text;
                }
                if (PhLinkType.Visible)
                {
                    nodeInfo.LinkType = DdlLinkType.SelectedValue;
                }
                nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue));
                if (PhChannelTemplateId.Visible)
                {
                    nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0;
                }
                nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0;

                DataProvider.ChannelDao.Update(nodeInfo);

                AuthRequest.AddSiteLog(SiteId, _channelId, 0, "修改栏目", $"栏目:{nodeInfo.ChannelName}");

                isChanged = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, $"栏目修改失败:{ex.Message}");
                LogUtils.AddErrorLog(ex);
            }

            if (isChanged)
            {
                CreateManager.CreateChannel(SiteId, _channelId);

                if (string.IsNullOrEmpty(_returnUrl))
                {
                    LayerUtils.Close(Page);
                }
                else
                {
                    LayerUtils.CloseAndRedirect(Page, _returnUrl);
                }
            }
        }
Example #4
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            int insertChannelId;

            try
            {
                var channelId = AuthRequest.GetQueryInt("ChannelId");
                var nodeInfo  = new ChannelInfo
                {
                    SiteId                  = SiteId,
                    ParentId                = channelId,
                    ContentModelPluginId    = DdlContentModelPluginId.SelectedValue,
                    ContentRelatedPluginIds =
                        ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds)
                };

                if (TbNodeIndexName.Text.Length != 0)
                {
                    var nodeIndexNameArrayList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
                    if (nodeIndexNameArrayList.IndexOf(TbNodeIndexName.Text) != -1)
                    {
                        FailMessage("栏目添加失败,栏目索引已存在!");
                        return;
                    }
                }

                if (TbFilePath.Text.Length != 0)
                {
                    if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
                    {
                        FailMessage("栏目页面路径不符合系统要求!");
                        return;
                    }

                    if (PathUtils.IsDirectoryPath(TbFilePath.Text))
                    {
                        TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
                    }

                    var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
                    if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
                    {
                        FailMessage("栏目添加失败,栏目页面路径已存在!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text))
                {
                    if (!DirectoryUtils.IsDirectoryNameCompliant(TbChannelFilePathRule.Text))
                    {
                        FailMessage("栏目页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(TbChannelFilePathRule.Text))
                    {
                        FailMessage("栏目页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(TbContentFilePathRule.Text))
                {
                    if (!DirectoryUtils.IsDirectoryNameCompliant(TbContentFilePathRule.Text))
                    {
                        FailMessage("内容页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(TbContentFilePathRule.Text))
                    {
                        FailMessage("内容页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                var parentNodeInfo     = ChannelManager.GetChannelInfo(SiteId, _channelId);
                var styleInfoList      = TableStyleManager.GetChannelStyleInfoList(parentNodeInfo);
                var extendedAttributes = BackgroundInputTypeParser.SaveAttributes(SiteInfo, styleInfoList, Request.Form, null);
                nodeInfo.Additional.Load(extendedAttributes);
                //foreach (string key in attributes)
                //{
                //    nodeInfo.Additional.SetExtendedAttribute(key, attributes[key]);
                //}

                nodeInfo.ChannelName         = TbNodeName.Text;
                nodeInfo.IndexName           = TbNodeIndexName.Text;
                nodeInfo.FilePath            = TbFilePath.Text;
                nodeInfo.ChannelFilePathRule = TbChannelFilePathRule.Text;
                nodeInfo.ContentFilePathRule = TbContentFilePathRule.Text;

                var list = new ArrayList();
                foreach (ListItem item in CblNodeGroupNameCollection.Items)
                {
                    if (item.Selected)
                    {
                        list.Add(item.Value);
                    }
                }
                nodeInfo.GroupNameCollection         = TranslateUtils.ObjectCollectionToString(list);
                nodeInfo.ImageUrl                    = TbImageUrl.Text;
                nodeInfo.Content                     = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]);
                nodeInfo.Keywords                    = TbKeywords.Text;
                nodeInfo.Description                 = TbDescription.Text;
                nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(RblIsChannelAddable.SelectedValue);
                nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(RblIsContentAddable.SelectedValue);

                nodeInfo.LinkUrl  = TbLinkUrl.Text;
                nodeInfo.LinkType = DdlLinkType.SelectedValue;

                nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue));

                nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0;
                nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0;

                nodeInfo.AddDate = DateTime.Now;
                insertChannelId  = DataProvider.ChannelDao.Insert(nodeInfo);
                //栏目选择投票样式后,内容
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                FailMessage(ex, $"栏目添加失败:{ex.Message}");
                return;
            }

            CreateManager.CreateChannel(SiteId, insertChannelId);

            AuthRequest.AddSiteLog(SiteId, "添加栏目", $"栏目:{TbNodeName.Text}");

            SuccessMessage("栏目添加成功!");
            AddWaitAndRedirectScript(ReturnUrl);
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isSuccess = false;

            try
            {
                var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, _nodeId);

                var filePath = nodeInfo.FilePath;

                if (phFilePath.Visible)
                {
                    tbFilePath.Text = tbFilePath.Text.Trim();
                    if (!string.IsNullOrEmpty(tbFilePath.Text) && !StringUtils.EqualsIgnoreCase(filePath, tbFilePath.Text))
                    {
                        if (!DirectoryUtils.IsDirectoryNameCompliant(tbFilePath.Text))
                        {
                            FailMessage("栏目页面路径不符合系统要求!");
                            return;
                        }

                        if (PathUtils.IsDirectoryPath(tbFilePath.Text))
                        {
                            tbFilePath.Text = PageUtils.Combine(tbFilePath.Text, "index.html");
                        }

                        var filePathArrayList = DataProvider.NodeDao.GetAllFilePathByPublishmentSystemId(PublishmentSystemId);
                        filePathArrayList.AddRange(DataProvider.TemplateMatchDao.GetAllFilePathByPublishmentSystemId(PublishmentSystemId));
                        if (filePathArrayList.IndexOf(tbFilePath.Text) != -1)
                        {
                            FailMessage("栏目修改失败,栏目页面路径已存在!");
                            return;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(tbChannelFilePathRule.Text))
                {
                    var filePathRule = tbChannelFilePathRule.Text.Replace("|", string.Empty);
                    if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
                    {
                        FailMessage("栏目页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(filePathRule))
                    {
                        FailMessage("栏目页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(tbContentFilePathRule.Text))
                {
                    var filePathRule = tbContentFilePathRule.Text.Replace("|", string.Empty);
                    if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
                    {
                        FailMessage("内容页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(filePathRule))
                    {
                        FailMessage("内容页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                if (tbFilePath.Text != PageUtility.GetInputChannelUrl(PublishmentSystemInfo, nodeInfo))
                {
                    nodeInfo.FilePath = tbFilePath.Text;
                }
                if (tbChannelFilePathRule.Text != PathUtility.GetChannelFilePathRule(PublishmentSystemInfo, _nodeId))
                {
                    nodeInfo.ChannelFilePathRule = tbChannelFilePathRule.Text;
                }
                if (tbContentFilePathRule.Text != PathUtility.GetContentFilePathRule(PublishmentSystemInfo, _nodeId))
                {
                    nodeInfo.ContentFilePathRule = tbContentFilePathRule.Text;
                }

                DataProvider.NodeDao.UpdateNodeInfo(nodeInfo);

                CreateManager.CreateChannel(PublishmentSystemId, _nodeId);

                Body.AddSiteLog(PublishmentSystemId, _nodeId, 0, "设置页面命名规则", $"栏目:{nodeInfo.NodeName}");

                isSuccess = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, ex.Message);
            }

            if (isSuccess)
            {
                PageUtils.CloseModalPageAndRedirect(Page, PageTemplateFilePathRule.GetRedirectUrl(PublishmentSystemId, _nodeId));
            }
        }
Example #6
0
        public void Create_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var channelIdList = new List <int>();
            var selectedChannelIdArrayList = ControlUtils.GetSelectedListControlValueArrayList(LbChannelIdList);

            var tableName = SiteInfo.TableName;

            if (DdlScope.SelectedValue == "Month")
            {
                var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, SiteId, 720);
                foreach (var channelId in lastEditList)
                {
                    if (selectedChannelIdArrayList.Contains(channelId.ToString()))
                    {
                        channelIdList.Add(channelId);
                    }
                }
            }
            else if (DdlScope.SelectedValue == "Day")
            {
                var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, SiteId, 24);
                foreach (var channelId in lastEditList)
                {
                    if (selectedChannelIdArrayList.Contains(channelId.ToString()))
                    {
                        channelIdList.Add(channelId);
                    }
                }
            }
            else if (DdlScope.SelectedValue == "2Hour")
            {
                var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, SiteId, 2);
                foreach (var channelId in lastEditList)
                {
                    if (selectedChannelIdArrayList.Contains(channelId.ToString()))
                    {
                        channelIdList.Add(channelId);
                    }
                }
            }
            else
            {
                channelIdList = TranslateUtils.StringCollectionToIntList(TranslateUtils.ObjectCollectionToString(selectedChannelIdArrayList));
            }

            if (channelIdList.Count == 0)
            {
                FailMessage("请首先选中希望生成页面的栏目!");
                return;
            }

            foreach (var channelId in channelIdList)
            {
                CreateManager.CreateChannel(SiteId, channelId);
            }

            PageCreateStatus.Redirect(SiteId);
        }
Example #7
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                int insertNodeId;
                try
                {
                    var nodeId   = Body.GetQueryInt("NodeID");
                    var nodeInfo = new NodeInfo
                    {
                        ParentId       = nodeId,
                        ContentModelId = ContentModelID.SelectedValue
                    };

                    if (NodeIndexName.Text.Length != 0)
                    {
                        var nodeIndexNameArrayList = DataProvider.NodeDao.GetNodeIndexNameList(PublishmentSystemId);
                        if (nodeIndexNameArrayList.IndexOf(NodeIndexName.Text) != -1)
                        {
                            FailMessage("栏目添加失败,栏目索引已存在!");
                            return;
                        }
                    }

                    if (FilePath.Text.Length != 0)
                    {
                        if (!DirectoryUtils.IsDirectoryNameCompliant(FilePath.Text))
                        {
                            FailMessage("栏目页面路径不符合系统要求!");
                            return;
                        }

                        if (PathUtils.IsDirectoryPath(FilePath.Text))
                        {
                            FilePath.Text = PageUtils.Combine(FilePath.Text, "index.html");
                        }

                        var filePathArrayList = DataProvider.NodeDao.GetAllFilePathByPublishmentSystemId(PublishmentSystemId);
                        if (filePathArrayList.IndexOf(FilePath.Text) != -1)
                        {
                            FailMessage("栏目添加失败,栏目页面路径已存在!");
                            return;
                        }
                    }

                    if (!string.IsNullOrEmpty(ChannelFilePathRule.Text))
                    {
                        if (!DirectoryUtils.IsDirectoryNameCompliant(ChannelFilePathRule.Text))
                        {
                            FailMessage("栏目页面命名规则不符合系统要求!");
                            return;
                        }
                        if (PathUtils.IsDirectoryPath(ChannelFilePathRule.Text))
                        {
                            FailMessage("栏目页面命名规则必须包含生成文件的后缀!");
                            return;
                        }
                    }

                    if (!string.IsNullOrEmpty(ContentFilePathRule.Text))
                    {
                        if (!DirectoryUtils.IsDirectoryNameCompliant(ContentFilePathRule.Text))
                        {
                            FailMessage("内容页面命名规则不符合系统要求!");
                            return;
                        }
                        if (PathUtils.IsDirectoryPath(ContentFilePathRule.Text))
                        {
                            FailMessage("内容页面命名规则必须包含生成文件的后缀!");
                            return;
                        }
                    }

                    var extendedAttributes = new ExtendedAttributes();
                    var relatedIdentities  = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, _nodeId);
                    InputTypeParser.AddValuesToAttributes(ETableStyle.Channel, DataProvider.NodeDao.TableName, PublishmentSystemInfo, relatedIdentities, Request.Form, extendedAttributes.Attributes);
                    var attributes = extendedAttributes.Attributes;
                    foreach (string key in attributes)
                    {
                        nodeInfo.Additional.SetExtendedAttribute(key, attributes[key]);
                    }

                    nodeInfo.NodeName            = NodeName.Text;
                    nodeInfo.NodeIndexName       = NodeIndexName.Text;
                    nodeInfo.FilePath            = FilePath.Text;
                    nodeInfo.ChannelFilePathRule = ChannelFilePathRule.Text;
                    nodeInfo.ContentFilePathRule = ContentFilePathRule.Text;

                    var list = new ArrayList();
                    foreach (ListItem item in NodeGroupNameCollection.Items)
                    {
                        if (item.Selected)
                        {
                            list.Add(item.Value);
                        }
                    }
                    nodeInfo.NodeGroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
                    nodeInfo.ImageUrl    = NavigationPicPath.Text;
                    nodeInfo.Content     = StringUtility.TextEditorContentEncode(Request.Form[NodeAttribute.Content], PublishmentSystemInfo, PublishmentSystemInfo.Additional.IsSaveImageInTextEditor);
                    nodeInfo.Keywords    = Keywords.Text;
                    nodeInfo.Description = Description.Text;
                    nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(IsChannelAddable.SelectedValue);
                    nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(IsContentAddable.SelectedValue);

                    nodeInfo.LinkUrl           = LinkURL.Text;
                    nodeInfo.LinkType          = ELinkTypeUtils.GetEnumType(LinkType.SelectedValue);
                    nodeInfo.ChannelTemplateId = (ChannelTemplateID.Items.Count > 0) ? int.Parse(ChannelTemplateID.SelectedValue) : 0;
                    nodeInfo.ContentTemplateId = (ContentTemplateID.Items.Count > 0) ? int.Parse(ContentTemplateID.SelectedValue) : 0;

                    nodeInfo.AddDate       = DateTime.Now;
                    nodeInfo.NodeModelType = Convert.ToInt32((ChannelModal.SelectedValue));
                    insertNodeId           = DataProvider.NodeDao.InsertNodeInfo(nodeInfo);
                    //栏目选择投票样式后,内容
                }
                catch (Exception ex)
                {
                    FailMessage(ex, $"栏目添加失败:{ex.Message}");
                    LogUtils.AddErrorLog(ex);
                    return;
                }

                CreateManager.CreateChannel(PublishmentSystemId, insertNodeId);

                Body.AddSiteLog(PublishmentSystemId, "添加栏目", $"栏目:{NodeName.Text}");

                SuccessMessage("栏目添加成功!");
                AddWaitAndRedirectScript(_returnUrl);
            }
        }
Example #8
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);

            if (Body.IsQueryExists("CreateChannelsOneByOne") && Body.IsQueryExists("ChannelIDCollection"))
            {
                foreach (var channelId in TranslateUtils.StringCollectionToIntList(Body.GetQueryString("ChannelIDCollection")))
                {
                    CreateManager.CreateChannel(SiteId, channelId);
                }

                LayerUtils.CloseAndOpenPageCreateStatus(Page);
                //PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString(SiteId, "已成功将栏目放入生成队列"));
            }
            else if (Body.IsQueryExists("CreateContentsOneByOne") && Body.IsQueryExists("channelId") &&
                     Body.IsQueryExists("contentIdCollection"))
            {
                foreach (var contentId in TranslateUtils.StringCollectionToIntList(Body.GetQueryString("contentIdCollection")))
                {
                    CreateManager.CreateContent(SiteId, Body.GetQueryInt("channelId"),
                                                contentId);
                }

                LayerUtils.CloseAndOpenPageCreateStatus(Page);
                //PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString(SiteId, "已成功将内容放入生成队列"));
            }
            else if (Body.IsQueryExists("CreateByTemplate") && Body.IsQueryExists("templateID"))
            {
                CreateManager.CreateFile(SiteId, Body.GetQueryInt("templateID"));

                PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString(SiteId, "已成功将文件放入生成队列"));
            }
            else if (Body.IsQueryExists("CreateByIDsCollection") && Body.IsQueryExists("IDsCollection"))
            {
                foreach (var channelIdContentId in
                         TranslateUtils.StringCollectionToStringCollection(Body.GetQueryString("IDsCollection")))
                {
                    var pair = channelIdContentId.Split('_');
                    CreateManager.CreateContent(SiteId, TranslateUtils.ToInt(pair[0]),
                                                TranslateUtils.ToInt(pair[1]));
                }

                LayerUtils.CloseAndOpenPageCreateStatus(Page);
                //PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString(SiteId, "已成功将文件放入生成队列"));
            }
            //---------------------------------------------------------------------------------------//
            else if (Body.IsQueryExists("SiteTemplateDownload"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var downloadUrl   = TranslateUtils.DecryptStringBySecretKey(Body.GetQueryString("DownloadUrl"));
                var directoryName = PathUtils.GetFileNameWithoutExtension(downloadUrl);

                var parameters = AjaxOtherService.GetSiteTemplateDownloadParameters(downloadUrl, directoryName, userKeyPrefix);
                LtlScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateDownloadUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
            else if (Body.IsQueryExists("SiteTemplateZip"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var parameters = AjaxOtherService.GetSiteTemplateZipParameters(Body.GetQueryString("DirectoryName"), userKeyPrefix);
                LtlScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateZipUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
            else if (Body.IsQueryExists("SiteTemplateUnZip"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var parameters = AjaxOtherService.GetSiteTemplateUnZipParameters(Body.GetQueryString("FileName"), userKeyPrefix);
                LtlScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateUnZipUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
            //---------------------------------------------------------------------------------------//
            else if (Body.IsQueryExists("PluginDownload"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var parameters = AjaxOtherService.GetPluginDownloadParameters(Body.GetQueryString("DownloadUrl"), userKeyPrefix);
                LtlScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetPluginDownloadUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
        }
Example #9
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            bool isChanged;
            var  parentChannelId = TranslateUtils.ToInt(Request.Form["channelId"]);

            if (parentChannelId == 0)
            {
                parentChannelId = SiteId;
            }

            try
            {
                if (string.IsNullOrEmpty(TbNodeNames.Text))
                {
                    FailMessage("请填写需要添加的栏目名称");
                    return;
                }

                var insertedChannelIdHashtable = new Hashtable {
                    [1] = parentChannelId
                };                                                                      //key为栏目的级别,1为第一级栏目

                var           nodeNameArray     = TbNodeNames.Text.Split('\n');
                List <string> nodeIndexNameList = null;
                foreach (var item in nodeNameArray)
                {
                    if (string.IsNullOrEmpty(item))
                    {
                        continue;
                    }

                    //count为栏目的级别
                    var count     = (StringUtils.GetStartCount('-', item) == 0) ? StringUtils.GetStartCount('-', item) : StringUtils.GetStartCount('-', item);
                    var nodeName  = item.Substring(count, item.Length - count);
                    var nodeIndex = string.Empty;
                    count++;

                    if (!string.IsNullOrEmpty(nodeName) && insertedChannelIdHashtable.Contains(count))
                    {
                        if (CbIsNameToIndex.Checked)
                        {
                            nodeIndex = nodeName.Trim();
                        }

                        if (StringUtils.Contains(nodeName, "(") && StringUtils.Contains(nodeName, ")"))
                        {
                            var length = nodeName.IndexOf(')') - nodeName.IndexOf('(');
                            if (length > 0)
                            {
                                nodeIndex = nodeName.Substring(nodeName.IndexOf('(') + 1, length);
                                nodeName  = nodeName.Substring(0, nodeName.IndexOf('('));
                            }
                        }
                        nodeName  = nodeName.Trim();
                        nodeIndex = nodeIndex.Trim(' ', '(', ')');
                        if (!string.IsNullOrEmpty(nodeIndex))
                        {
                            if (nodeIndexNameList == null)
                            {
                                nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
                            }
                            if (nodeIndexNameList.IndexOf(nodeIndex) != -1)
                            {
                                nodeIndex = string.Empty;
                            }
                            else
                            {
                                nodeIndexNameList.Add(nodeIndex);
                            }
                        }

                        var parentId             = (int)insertedChannelIdHashtable[count];
                        var contentModelPluginId = DdlContentModelPluginId.SelectedValue;
                        if (string.IsNullOrEmpty(contentModelPluginId))
                        {
                            var parentNodeInfo = ChannelManager.GetChannelInfo(SiteId, parentId);
                            contentModelPluginId = parentNodeInfo.ContentModelPluginId;
                        }

                        var channelTemplateId = TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue);
                        var contentTemplateId = TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue);

                        var insertedChannelId = DataProvider.ChannelDao.Insert(SiteId, parentId, nodeName, nodeIndex, contentModelPluginId, ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds), channelTemplateId, contentTemplateId);
                        insertedChannelIdHashtable[count + 1] = insertedChannelId;

                        CreateManager.CreateChannel(SiteId, insertedChannelId);
                    }
                }

                Body.AddSiteLog(SiteId, parentChannelId, 0, "快速添加栏目", $"父栏目:{ChannelManager.GetChannelName(SiteId, parentChannelId)},栏目:{TbNodeNames.Text.Replace('\n', ',')}");

                isChanged = true;
            }
            catch (Exception ex)
            {
                isChanged = false;
                FailMessage(ex, ex.Message);
            }

            if (isChanged)
            {
                LayerUtils.CloseAndRedirect(Page, _returnUrl);
            }
        }
Example #10
0
        private void TranslateChannelAndContent(List <ChannelInfo> nodeInfoList, int targetSiteId, int parentId, ETranslateType translateType, List <string> nodeIndexNameList, List <string> filePathList)
        {
            if (nodeInfoList == null || nodeInfoList.Count == 0)
            {
                return;
            }

            if (nodeIndexNameList == null)
            {
                nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(targetSiteId);
            }

            if (filePathList == null)
            {
                filePathList = DataProvider.ChannelDao.GetAllFilePathBySiteId(targetSiteId);
            }

            foreach (var oldNodeInfo in nodeInfoList)
            {
                var nodeInfo = new ChannelInfo(oldNodeInfo)
                {
                    SiteId        = targetSiteId,
                    ParentId      = parentId,
                    ChildrenCount = 0,
                    AddDate       = DateTime.Now
                };

                if (RblIsDeleteAfterTranslate.Visible && EBooleanUtils.Equals(RblIsDeleteAfterTranslate.SelectedValue, EBoolean.True))
                {
                    nodeIndexNameList.Add(nodeInfo.IndexName);
                }

                else if (!string.IsNullOrEmpty(nodeInfo.IndexName) && nodeIndexNameList.IndexOf(nodeInfo.IndexName) == -1)
                {
                    nodeIndexNameList.Add(nodeInfo.IndexName);
                }
                else
                {
                    nodeInfo.IndexName = string.Empty;
                }

                if (!string.IsNullOrEmpty(nodeInfo.FilePath) && filePathList.IndexOf(nodeInfo.FilePath) == -1)
                {
                    filePathList.Add(nodeInfo.FilePath);
                }
                else
                {
                    nodeInfo.FilePath = string.Empty;
                }

                var targetChannelId = DataProvider.ChannelDao.Insert(nodeInfo);

                if (translateType == ETranslateType.All)
                {
                    TranslateContent(oldNodeInfo.Id, targetSiteId, targetChannelId);
                }

                if (targetChannelId != 0)
                {
                    //var orderByString = ETaxisTypeUtils.GetChannelOrderByString(ETaxisType.OrderByTaxis);
                    //var childrenNodeInfoList = DataProvider.ChannelDao.GetChannelInfoList(oldNodeInfo, 0, "", EScopeType.Children, orderByString);

                    var channelIdList        = ChannelManager.GetChannelIdList(oldNodeInfo, EScopeType.Children, string.Empty, string.Empty, string.Empty);
                    var childrenNodeInfoList = new List <ChannelInfo>();
                    foreach (var channelId in channelIdList)
                    {
                        childrenNodeInfoList.Add(ChannelManager.GetChannelInfo(oldNodeInfo.SiteId, channelId));
                    }

                    if (channelIdList.Count > 0)
                    {
                        TranslateChannelAndContent(childrenNodeInfoList, targetSiteId, targetChannelId, translateType, nodeIndexNameList, filePathList);
                    }

                    CreateManager.CreateChannel(targetSiteId, targetChannelId);
                }
            }
        }
Example #11
0
        public IHttpActionResult Create([FromBody] CreateParameter parameter)
        {
            try
            {
                var request = new RequestImpl();
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSitePermissions(parameter.SiteId, ConfigManager.WebSitePermissions.Create))
                {
                    return(Unauthorized());
                }

                var selectedChannelIdList = new List <int>();

                if (parameter.IsAllChecked)
                {
                    selectedChannelIdList = ChannelManager.GetChannelIdList(parameter.SiteId);
                }
                else if (parameter.IsDescendent)
                {
                    foreach (var channelId in parameter.ChannelIdList)
                    {
                        selectedChannelIdList.Add(channelId);

                        var channelInfo = ChannelManager.GetChannelInfo(parameter.SiteId, channelId);
                        if (channelInfo.ChildrenCount > 0)
                        {
                            var descendentIdList = ChannelManager.GetChannelIdList(channelInfo, EScopeType.Descendant);
                            foreach (var descendentId in descendentIdList)
                            {
                                if (selectedChannelIdList.Contains(descendentId))
                                {
                                    continue;
                                }

                                selectedChannelIdList.Add(descendentId);
                            }
                        }
                    }
                }
                else
                {
                    selectedChannelIdList.AddRange(parameter.ChannelIdList);
                }

                var channelIdList = new List <int>();

                if (parameter.Scope == "1month" || parameter.Scope == "1day" || parameter.Scope == "2hours")
                {
                    var siteInfo  = SiteManager.GetSiteInfo(parameter.SiteId);
                    var tableName = siteInfo.TableName;

                    if (parameter.Scope == "1month")
                    {
                        var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, parameter.SiteId, 720);
                        foreach (var channelId in lastEditList)
                        {
                            if (selectedChannelIdList.Contains(channelId))
                            {
                                channelIdList.Add(channelId);
                            }
                        }
                    }
                    else if (parameter.Scope == "1day")
                    {
                        var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, parameter.SiteId, 24);
                        foreach (var channelId in lastEditList)
                        {
                            if (selectedChannelIdList.Contains(channelId))
                            {
                                channelIdList.Add(channelId);
                            }
                        }
                    }
                    else if (parameter.Scope == "2hours")
                    {
                        var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, parameter.SiteId, 2);
                        foreach (var channelId in lastEditList)
                        {
                            if (selectedChannelIdList.Contains(channelId))
                            {
                                channelIdList.Add(channelId);
                            }
                        }
                    }
                }
                else
                {
                    channelIdList = selectedChannelIdList;
                }

                foreach (var channelId in channelIdList)
                {
                    if (parameter.IsChannelPage)
                    {
                        CreateManager.CreateChannel(parameter.SiteId, channelId);
                    }
                    if (parameter.IsContentPage)
                    {
                        CreateManager.CreateAllContent(parameter.SiteId, channelId);
                    }
                }

                return(Ok(new { }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isSuccess = false;

            try
            {
                var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);

                if (PhChannel.Visible)
                {
                    channelInfo.LinkUrl  = TbLinkUrl.Text;
                    channelInfo.LinkType = DdlLinkType.SelectedValue;

                    var filePath = channelInfo.FilePath;
                    TbFilePath.Text = TbFilePath.Text.Trim();
                    if (!string.IsNullOrEmpty(TbFilePath.Text) && !StringUtils.EqualsIgnoreCase(filePath, TbFilePath.Text))
                    {
                        if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
                        {
                            FailMessage("栏目页面路径不符合系统要求!");
                            return;
                        }

                        if (PathUtils.IsDirectoryPath(TbFilePath.Text))
                        {
                            TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
                        }

                        var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
                        filePathArrayList.AddRange(DataProvider.TemplateMatchDao.GetAllFilePathBySiteId(SiteId));
                        if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
                        {
                            FailMessage("栏目修改失败,栏目页面路径已存在!");
                            return;
                        }
                    }

                    if (TbFilePath.Text != PageUtility.GetInputChannelUrl(SiteInfo, channelInfo, false))
                    {
                        channelInfo.FilePath = TbFilePath.Text;
                    }
                }

                if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text))
                {
                    var filePathRule = TbChannelFilePathRule.Text.Replace("|", string.Empty);
                    if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
                    {
                        FailMessage("栏目页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(filePathRule))
                    {
                        FailMessage("栏目页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(TbContentFilePathRule.Text))
                {
                    var filePathRule = TbContentFilePathRule.Text.Replace("|", string.Empty);
                    if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
                    {
                        FailMessage("内容页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(filePathRule))
                    {
                        FailMessage("内容页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                if (TbChannelFilePathRule.Text != PathUtility.GetChannelFilePathRule(SiteInfo, _channelId))
                {
                    channelInfo.ChannelFilePathRule = TbChannelFilePathRule.Text;
                }
                if (TbContentFilePathRule.Text != PathUtility.GetContentFilePathRule(SiteInfo, _channelId))
                {
                    channelInfo.ContentFilePathRule = TbContentFilePathRule.Text;
                }

                channelInfo.Additional.IsChannelCreatable = TranslateUtils.ToBool(RblIsChannelCreatable.SelectedValue);
                channelInfo.Additional.IsContentCreatable = TranslateUtils.ToBool(RblIsContentCreatable.SelectedValue);

                DataProvider.ChannelDao.Update(channelInfo);

                CreateManager.CreateChannel(SiteId, _channelId);

                AuthRequest.AddSiteLog(SiteId, _channelId, 0, "设置页面生成规则", $"栏目:{channelInfo.ChannelName}");

                isSuccess = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, ex.Message);
            }

            if (isSuccess)
            {
                LayerUtils.CloseAndRedirect(Page, PageConfigurationCreateRule.GetRedirectUrl(SiteId, _channelId));
            }
        }
Example #13
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);

            if (Body.IsQueryExists("Gather") && Body.IsQueryExists("GatherRuleNameCollection"))
            {
                var userKeyPrefix = StringUtils.Guid();
                var parameters    = AjaxGatherService.GetGatherParameters(PublishmentSystemId, Body.GetQueryString("GatherRuleNameCollection"), userKeyPrefix);
                RegisterScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxGatherService.GetGatherUrl(), parameters, userKeyPrefix, AjaxGatherService.GetCountArrayUrl());
            }
            else if (Body.IsQueryExists("GatherDatabase") && Body.IsQueryExists("GatherRuleNameCollection"))
            {
                var userKeyPrefix = StringUtils.Guid();
                var parameters    = AjaxGatherService.GetGatherDatabaseParameters(PublishmentSystemId,
                                                                                  Body.GetQueryString("GatherRuleNameCollection"), userKeyPrefix);
                RegisterScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxGatherService.GetGatherDatabaseUrl(), parameters, userKeyPrefix, AjaxGatherService.GetCountArrayUrl());
            }
            else if (Body.IsQueryExists("GatherFile") && Body.IsQueryExists("GatherRuleNameCollection"))
            {
                var userKeyPrefix = StringUtils.Guid();
                var parameters    = AjaxGatherService.GetGatherFileParameters(PublishmentSystemId,
                                                                              Body.GetQueryString("GatherRuleNameCollection"), userKeyPrefix);
                RegisterScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxGatherService.GetGatherFileUrl(), parameters,
                                                           userKeyPrefix, AjaxGatherService.GetCountArrayUrl());
            }
            //----------------------------------------------------------------------------------------//
            else if (Body.IsQueryExists("CreateChannelsOneByOne") && Body.IsQueryExists("ChannelIDCollection"))
            {
                foreach (var channelId in TranslateUtils.StringCollectionToIntList(Body.GetQueryString("ChannelIDCollection")))
                {
                    CreateManager.CreateChannel(PublishmentSystemId, channelId);
                }

                PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString("已成功将栏目放入生成队列"));
            }
            else if (Body.IsQueryExists("CreateContentsOneByOne") && Body.IsQueryExists("NodeID") &&
                     Body.IsQueryExists("ContentIDCollection"))
            {
                foreach (var contentId in TranslateUtils.StringCollectionToIntList(Body.GetQueryString("ContentIDCollection")))
                {
                    CreateManager.CreateContent(PublishmentSystemId, Body.GetQueryInt("NodeID"),
                                                contentId);
                }

                PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString("已成功将内容放入生成队列"));
            }
            else if (Body.IsQueryExists("CreateByTemplate") && Body.IsQueryExists("templateID"))
            {
                CreateManager.CreateFile(PublishmentSystemId, Body.GetQueryInt("templateID"));

                PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString("已成功将文件放入生成队列"));
            }
            else if (Body.IsQueryExists("CreateByIDsCollection") && Body.IsQueryExists("IDsCollection"))
            {
                foreach (var nodeIdContentId in
                         TranslateUtils.StringCollectionToStringCollection(Body.GetQueryString("IDsCollection")))
                {
                    var pair = nodeIdContentId.Split('_');
                    CreateManager.CreateContent(PublishmentSystemId, TranslateUtils.ToInt(pair[0]),
                                                TranslateUtils.ToInt(pair[1]));
                }

                PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString("已成功将文件放入生成队列"));
            }
            //---------------------------------------------------------------------------------------//
            else if (Body.IsQueryExists("SiteTemplateDownload"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var parameters = AjaxOtherService.GetSiteTemplateDownloadParameters(Body.GetQueryString("DownloadUrl"),
                                                                                    Body.GetQueryString("DirectoryName"), userKeyPrefix);
                RegisterScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateDownloadUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
            else if (Body.IsQueryExists("SiteTemplateZip"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var parameters = AjaxOtherService.GetSiteTemplateZipParameters(Body.GetQueryString("DirectoryName"), userKeyPrefix);
                RegisterScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateZipUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
            else if (Body.IsQueryExists("SiteTemplateUnZip"))
            {
                var userKeyPrefix = StringUtils.Guid();

                var parameters = AjaxOtherService.GetSiteTemplateUnZipParameters(Body.GetQueryString("FileName"), userKeyPrefix);
                RegisterScripts.Text =
                    AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateUnZipUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl());
            }
        }
Example #14
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                var isChanged = false;

                try
                {
                    var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, _nodeId);

                    if (NodeIndexNameRow.Visible)
                    {
                        if (!nodeInfo.NodeIndexName.Equals(NodeIndexName.Text) && NodeIndexName.Text.Length != 0)
                        {
                            var nodeIndexNameList = DataProvider.NodeDao.GetNodeIndexNameList(PublishmentSystemId);
                            if (nodeIndexNameList.IndexOf(NodeIndexName.Text) != -1)
                            {
                                FailMessage("栏目修改失败,栏目索引已存在!");
                                return;
                            }
                        }
                    }

                    if (FilePathRow.Visible)
                    {
                        FilePath.Text = FilePath.Text.Trim();
                        if (!nodeInfo.FilePath.Equals(FilePath.Text) && FilePath.Text.Length != 0)
                        {
                            if (!DirectoryUtils.IsDirectoryNameCompliant(FilePath.Text))
                            {
                                FailMessage("栏目页面路径不符合系统要求!");
                                return;
                            }

                            if (PathUtils.IsDirectoryPath(FilePath.Text))
                            {
                                FilePath.Text = PageUtils.Combine(FilePath.Text, "index.html");
                            }

                            var filePathArrayList = DataProvider.NodeDao.GetAllFilePathByPublishmentSystemId(PublishmentSystemId);
                            if (filePathArrayList.IndexOf(FilePath.Text) != -1)
                            {
                                FailMessage("栏目修改失败,栏目页面路径已存在!");
                                return;
                            }
                        }
                    }

                    if (channelControl.Visible)
                    {
                        var extendedAttributes = new ExtendedAttributes();
                        var relatedIdentities  = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, _nodeId);
                        BackgroundInputTypeParser.AddValuesToAttributes(ETableStyle.Channel, DataProvider.NodeDao.TableName, PublishmentSystemInfo, relatedIdentities, Request.Form, extendedAttributes.Attributes);
                        if (extendedAttributes.Attributes.Count > 0)
                        {
                            nodeInfo.Additional.SetExtendedAttribute(extendedAttributes.Attributes);
                        }
                    }

                    if (NodeNameRow.Visible)
                    {
                        nodeInfo.NodeName = NodeName.Text;
                    }
                    if (NodeIndexNameRow.Visible)
                    {
                        nodeInfo.NodeIndexName = NodeIndexName.Text;
                    }
                    if (FilePathRow.Visible)
                    {
                        nodeInfo.FilePath = FilePath.Text;
                    }

                    if (NodeGroupNameCollectionRow.Visible)
                    {
                        var list = new ArrayList();
                        foreach (ListItem item in NodeGroupNameCollection.Items)
                        {
                            if (item.Selected)
                            {
                                list.Add(item.Value);
                            }
                        }
                        nodeInfo.NodeGroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
                    }
                    if (ImageUrlRow.Visible)
                    {
                        nodeInfo.ImageUrl = tbImageUrl.Text;
                    }
                    if (ContentRow.Visible)
                    {
                        nodeInfo.Content = StringUtility.TextEditorContentEncode(Request.Form[NodeAttribute.Content], PublishmentSystemInfo, PublishmentSystemInfo.Additional.IsSaveImageInTextEditor);
                    }
                    if (Keywords.Visible)
                    {
                        nodeInfo.Keywords = Keywords.Text;
                    }
                    if (Description.Visible)
                    {
                        nodeInfo.Description = Description.Text;
                    }



                    if (LinkUrlRow.Visible)
                    {
                        nodeInfo.LinkUrl = LinkUrl.Text;
                    }
                    if (LinkTypeRow.Visible)
                    {
                        nodeInfo.LinkType = ELinkTypeUtils.GetEnumType(LinkType.SelectedValue);
                    }
                    if (ChannelTemplateIDRow.Visible)
                    {
                        nodeInfo.ChannelTemplateId = (ChannelTemplateID.Items.Count > 0) ? int.Parse(ChannelTemplateID.SelectedValue) : 0;
                    }
                    if (ContentTemplateIDRow.Visible)
                    {
                        nodeInfo.ContentTemplateId = (ContentTemplateID.Items.Count > 0) ? int.Parse(ContentTemplateID.SelectedValue) : 0;
                    }

                    DataProvider.NodeDao.UpdateNodeInfo(nodeInfo);

                    Body.AddSiteLog(PublishmentSystemId, _nodeId, 0, "修改栏目", $"栏目:{nodeInfo.NodeName}");

                    isChanged = true;
                }
                catch (Exception ex)
                {
                    FailMessage(ex, $"栏目修改失败:{ex.Message}");
                    LogUtils.AddErrorLog(ex);
                }

                if (isChanged)
                {
                    CreateManager.CreateChannel(PublishmentSystemId, _nodeId);

                    if (string.IsNullOrEmpty(_returnUrl))
                    {
                        PageUtils.CloseModalPage(Page);
                    }
                    else
                    {
                        PageUtils.CloseModalPageAndRedirect(Page, _returnUrl);
                    }
                }
            }
        }