protected override void Render(HtmlTextWriter output) { if (StyleInfoList == null || StyleInfoList.Count == 0 || Attributes == null) { return; } var pageScripts = new NameValueCollection(); var builder = new StringBuilder(); foreach (var styleInfo in StyleInfoList) { if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.Title)) { continue; } string extra; var value = BackgroundInputTypeParser.Parse(SiteInfo, ChannelId, styleInfo, Attributes, pageScripts, out extra); if (string.IsNullOrEmpty(value) && string.IsNullOrEmpty(extra)) { continue; } //modify if (styleInfo.DisplayName == "ÊÓƵ") { continue; } if (styleInfo.DisplayName == "¸½¼þ") { continue; } if (styleInfo.InputType == InputType.TextEditor) { var commands = WebUtils.GetTextEditorCommands(SiteInfo, styleInfo.AttributeName); builder.Append($@" <div class=""form-group form-row""> <label class="" "">{styleInfo.DisplayName}</label> <div class=""col-sm-10""> {commands} <div class=""m-t-10""> {value} </div> </div> <div class=""col-sm-1""> {extra} </div> </div>"); } else { var html = $@" <div class=""form-group form-row""> <label class=""col-sm-1 col-form-label text-right"">{styleInfo.DisplayName}</label> <div class=""col-sm-6""> {value} </div> <div class=""col-sm-5""> {extra} </div> </div>"; if (styleInfo.InputType == InputType.Customize) { var eventArgs = new ContentFormLoadEventArgs(SiteInfo.Id, ChannelId, ContentId, Attributes, styleInfo.AttributeName, html); foreach (var service in PluginManager.Services) { try { html = service.OnContentFormLoad(eventArgs); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormLoad)); } } } builder.Append(html); } } output.Write(builder.ToString()); foreach (string key in pageScripts.Keys) { output.Write(pageScripts[key]); } }
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); }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } var contentId = AuthRequest.GetQueryInt("id"); string redirectUrl; if (contentId == 0) { var contentInfo = new ContentInfo(); try { contentInfo.ChannelId = _nodeInfo.Id; contentInfo.SiteId = SiteId; contentInfo.AddUserName = AuthRequest.AdminName; contentInfo.LastEditUserName = contentInfo.AddUserName; contentInfo.LastEditDate = DateTime.Now; BackgroundInputTypeParser.SaveAttributes(contentInfo, SiteInfo, _styleInfoList, Request.Form, ContentAttribute.AllAttributesLowercase); contentInfo.GroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroups.Items); var tagCollection = TagUtils.ParseTagsString(TbTags.Text); contentInfo.Title = TbTitle.Text; var formatString = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatStrong"]); var formatEm = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatEM"]); var formatU = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatU"]); var formatColor = Request.Form[ContentAttribute.Title + "_formatColor"]; var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor); contentInfo.Set(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title), theFormatString); foreach (ListItem listItem in CblContentAttributes.Items) { var value = listItem.Selected.ToString(); var attributeName = listItem.Value; contentInfo.Set(attributeName, value); } contentInfo.LinkUrl = TbLinkUrl.Text; contentInfo.AddDate = TbAddDate.DateTime; if (contentInfo.AddDate.Year <= DateUtils.SqlMinValue.Year) { contentInfo.AddDate = DateTime.Now; } contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue); contentInfo.IsChecked = contentInfo.CheckedLevel >= SiteInfo.Additional.CheckContentLevel; contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " "); foreach (var service in PluginManager.Services) { try { service.OnContentFormSubmit(new ContentFormSubmitEventArgs(SiteId, _nodeInfo.Id, contentInfo, new ExtendedAttributes(Request.Form))); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit)); } } contentInfo.Id = DataProvider.ContentDao.Insert(_tableName, SiteInfo, contentInfo); //判断是不是有审核权限 int checkedLevelOfUser; var isCheckedOfUser = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissions, SiteInfo, contentInfo.ChannelId, out checkedLevelOfUser); if (CheckManager.IsCheckable(SiteInfo, contentInfo.ChannelId, contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser)) { //添加审核记录 DataProvider.ContentDao.UpdateIsChecked(_tableName, SiteId, contentInfo.ChannelId, new List <int> { contentInfo.Id }, 0, AuthRequest.AdminName, contentInfo.IsChecked, contentInfo.CheckedLevel, ""); } TagUtils.AddTags(tagCollection, SiteId, contentInfo.Id); } catch (Exception ex) { LogUtils.AddErrorLog(ex); FailMessage($"内容添加失败:{ex.Message}"); } CreateManager.CreateContentAndTrigger(SiteId, _nodeInfo.Id, contentInfo.Id); AuthRequest.AddSiteLog(SiteId, _nodeInfo.Id, contentInfo.Id, "添加内容", $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId)},内容标题:{contentInfo.Title}"); ContentUtility.Translate(SiteInfo, _nodeInfo.Id, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(DdlTranslateType.SelectedValue), AuthRequest.AdminName); redirectUrl = PageContentAddAfter.GetRedirectUrl(SiteId, _nodeInfo.Id, contentInfo.Id, ReturnUrl); } else { var contentInfo = DataProvider.ContentDao.GetContentInfo(_tableName, contentId); try { var tagsLast = contentInfo.Tags; contentInfo.LastEditUserName = AuthRequest.AdminName; contentInfo.LastEditDate = DateTime.Now; BackgroundInputTypeParser.SaveAttributes(contentInfo, SiteInfo, _styleInfoList, Request.Form, ContentAttribute.AllAttributesLowercase); contentInfo.GroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroups.Items); var tagCollection = TagUtils.ParseTagsString(TbTags.Text); contentInfo.Title = TbTitle.Text; var formatString = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatStrong"]); var formatEm = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatEM"]); var formatU = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatU"]); var formatColor = Request.Form[ContentAttribute.Title + "_formatColor"]; var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor); contentInfo.Set(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title), theFormatString); foreach (ListItem listItem in CblContentAttributes.Items) { var value = listItem.Selected.ToString(); var attributeName = listItem.Value; contentInfo.Set(attributeName, value); } contentInfo.LinkUrl = TbLinkUrl.Text; contentInfo.AddDate = TbAddDate.DateTime; var checkedLevel = TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue); if (checkedLevel != CheckManager.LevelInt.NotChange) { contentInfo.IsChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel; contentInfo.CheckedLevel = checkedLevel; } contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " "); foreach (var service in PluginManager.Services) { try { service.OnContentFormSubmit(new ContentFormSubmitEventArgs(SiteId, _nodeInfo.Id, contentInfo, new ExtendedAttributes(Request.Form))); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit)); } } DataProvider.ContentDao.Update(_tableName, SiteInfo, contentInfo); TagUtils.UpdateTags(tagsLast, contentInfo.Tags, tagCollection, SiteId, contentId); ContentUtility.Translate(SiteInfo, _nodeInfo.Id, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(DdlTranslateType.SelectedValue), AuthRequest.AdminName); //更新引用该内容的信息 //如果不是异步自动保存,那么需要将引用此内容的content修改 //var sourceContentIdList = new List<int> //{ // contentInfo.Id //}; //var tableList = DataProvider.TableDao.GetTableCollectionInfoListCreatedInDb(); //foreach (var table in tableList) //{ // var targetContentIdList = DataProvider.ContentDao.GetReferenceIdList(table.TableName, sourceContentIdList); // foreach (var targetContentId in targetContentIdList) // { // var targetContentInfo = DataProvider.ContentDao.GetContentInfo(table.TableName, targetContentId); // if (targetContentInfo == null || targetContentInfo.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString()) continue; // contentInfo.Id = targetContentId; // contentInfo.SiteId = targetContentInfo.SiteId; // contentInfo.ChannelId = targetContentInfo.ChannelId; // contentInfo.SourceId = targetContentInfo.SourceId; // contentInfo.ReferenceId = targetContentInfo.ReferenceId; // contentInfo.Taxis = targetContentInfo.Taxis; // contentInfo.Set(ContentAttribute.TranslateContentType, targetContentInfo.GetString(ContentAttribute.TranslateContentType)); // DataProvider.ContentDao.Update(table.TableName, contentInfo); // //资源:图片,文件,视频 // var targetSiteInfo = SiteManager.GetSiteInfo(targetContentInfo.SiteId); // var bgContentInfo = contentInfo as BackgroundContentInfo; // var bgTargetContentInfo = targetContentInfo as BackgroundContentInfo; // if (bgTargetContentInfo != null && bgContentInfo != null) // { // if (bgContentInfo.ImageUrl != bgTargetContentInfo.ImageUrl) // { // //修改图片 // var sourceImageUrl = PathUtility.MapPath(SiteInfo, bgContentInfo.ImageUrl); // CopyReferenceFiles(targetSiteInfo, sourceImageUrl); // } // else if (bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)) != bgTargetContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl))) // { // var sourceImageUrls = TranslateUtils.StringCollectionToStringList(bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl))); // foreach (string imageUrl in sourceImageUrls) // { // var sourceImageUrl = PathUtility.MapPath(SiteInfo, imageUrl); // CopyReferenceFiles(targetSiteInfo, sourceImageUrl); // } // } // if (bgContentInfo.FileUrl != bgTargetContentInfo.FileUrl) // { // //修改附件 // var sourceFileUrl = PathUtility.MapPath(SiteInfo, bgContentInfo.FileUrl); // CopyReferenceFiles(targetSiteInfo, sourceFileUrl); // } // else if (bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)) != bgTargetContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl))) // { // var sourceFileUrls = TranslateUtils.StringCollectionToStringList(bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl))); // foreach (var fileUrl in sourceFileUrls) // { // var sourceFileUrl = PathUtility.MapPath(SiteInfo, fileUrl); // CopyReferenceFiles(targetSiteInfo, sourceFileUrl); // } // } // } // } //} } catch (Exception ex) { LogUtils.AddErrorLog(ex); FailMessage($"内容修改失败:{ex.Message}"); return; } CreateManager.CreateContentAndTrigger(SiteId, _nodeInfo.Id, contentId); AuthRequest.AddSiteLog(SiteId, _nodeInfo.Id, contentId, "修改内容", $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId)},内容标题:{contentInfo.Title}"); redirectUrl = ReturnUrl; } PageUtils.Redirect(redirectUrl); }
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); } } }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } var categoryChannelId = TranslateUtils.ToInt(Request["categoryChannelID"]); var categoryDepartmentId = TranslateUtils.ToInt(Request["categoryDepartmentID"]); if (categoryChannelId == 0) { FailMessage("信息采集失败,必须要选择一个主题分类"); return; } if (categoryDepartmentId == 0) { FailMessage("信息采集失败,必须要选择一个机构分类"); return; } var categoryClassInfoArrayList = DataProvider.GovPublicCategoryClassDao.GetCategoryClassInfoArrayList(PublishmentSystemId, ETriState.False, ETriState.True); if (_contentId == 0) { var contentInfo = new GovPublicContentInfo(); try { BackgroundInputTypeParser.AddValuesToAttributes(_tableStyle, _tableName, PublishmentSystemInfo, _relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes); contentInfo.NodeId = categoryChannelId; contentInfo.Description = tbDescription.Text; contentInfo.PublishDate = dtbPublishDate.DateTime; contentInfo.EffectDate = dtbEffectDate.DateTime; contentInfo.IsAbolition = TranslateUtils.ToBool(rblIsAbolition.SelectedValue); contentInfo.AbolitionDate = dtbAbolitionDate.DateTime; contentInfo.DocumentNo = tbDocumentNo.Text; contentInfo.Publisher = tbPublisher.Text; contentInfo.Keywords = tbKeywords.Text; contentInfo.DepartmentId = categoryDepartmentId; SetCategoryAttributes(contentInfo, categoryClassInfoArrayList); contentInfo.PublishmentSystemId = PublishmentSystemId; contentInfo.AddUserName = Body.AdministratorName; if (contentInfo.AddDate.Year == DateUtils.SqlMinValue.Year) { FailMessage($"内容添加失败:系统时间不能为{DateUtils.SqlMinValue.Year}年"); return; } contentInfo.LastEditUserName = contentInfo.AddUserName; contentInfo.LastEditDate = DateTime.Now; if (phContentAttributes.Visible) { foreach (ListItem listItem in ContentAttributes.Items) { var value = listItem.Selected.ToString(); var attributeName = listItem.Value; contentInfo.SetExtendedAttribute(attributeName, value); } } contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(ContentLevel.SelectedValue); contentInfo.IsChecked = contentInfo.CheckedLevel >= PublishmentSystemInfo.CheckContentLevel; contentInfo.ContentGroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(ContentGroupNameCollection.Items); var tagCollection = TagUtils.ParseTagsString(Tags.Text); contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " "); contentInfo.Identifier = GovPublicManager.GetIdentifier(PublishmentSystemInfo, categoryChannelId, categoryDepartmentId, contentInfo); var contentId = DataProvider.ContentDao.Insert(_tableName, PublishmentSystemInfo, contentInfo); //更新分类内容数 foreach (GovPublicCategoryClassInfo categoryClassInfo in categoryClassInfoArrayList) { var categoryId = TranslateUtils.ToInt(contentInfo.GetExtendedAttribute(categoryClassInfo.ContentAttributeName)); if (categoryId > 0) { DataProvider.GovPublicCategoryDao.UpdateContentNum(PublishmentSystemInfo, categoryClassInfo.ContentAttributeName, categoryId); } } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id); } contentInfo.Id = contentId; } catch (Exception ex) { FailMessage(ex, $"内容添加失败:{ex.Message}"); LogUtils.AddErrorLog(ex); return; } Body.AddSiteLog(PublishmentSystemId, categoryChannelId, contentInfo.Id, "添加内容", $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},内容标题:{contentInfo.Title}"); ContentUtility.Translate(PublishmentSystemInfo, _nodeInfo.NodeId, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(ddlTranslateType.SelectedValue), Body.AdministratorName); PageUtils.Redirect(PageGovPublicContentAddAfter.GetRedirectUrl(PublishmentSystemId, categoryChannelId, contentInfo.Id, Request.QueryString["ReturnUrl"])); } else { var contentInfo = DataProvider.GovPublicContentDao.GetContentInfo(PublishmentSystemInfo, _contentId); try { var oldNodeId = 0; if (contentInfo.NodeId != categoryChannelId) { oldNodeId = contentInfo.NodeId; contentInfo.NodeId = categoryChannelId; } var identifier = contentInfo.Identifier; BackgroundInputTypeParser.AddValuesToAttributes(_tableStyle, _tableName, PublishmentSystemInfo, _relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes); contentInfo.DepartmentId = categoryDepartmentId; SetCategoryAttributes(contentInfo, categoryClassInfoArrayList); contentInfo.Description = tbDescription.Text; contentInfo.PublishDate = dtbPublishDate.DateTime; contentInfo.EffectDate = dtbEffectDate.DateTime; contentInfo.IsAbolition = TranslateUtils.ToBool(rblIsAbolition.SelectedValue); contentInfo.AbolitionDate = dtbAbolitionDate.DateTime; contentInfo.DocumentNo = tbDocumentNo.Text; contentInfo.Publisher = tbPublisher.Text; contentInfo.Keywords = tbKeywords.Text; var contentAttributeNameWithCategoryId = SetCategoryAttributes(contentInfo, categoryClassInfoArrayList); contentInfo.LastEditUserName = Body.AdministratorName; contentInfo.LastEditDate = DateTime.Now; contentInfo.ContentGroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(ContentGroupNameCollection.Items); var tagsLast = contentInfo.Tags; var tagCollection = TagUtils.ParseTagsString(Tags.Text); contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " "); if (phContentAttributes.Visible) { foreach (ListItem listItem in ContentAttributes.Items) { var value = listItem.Selected.ToString(); var attributeName = listItem.Value; contentInfo.SetExtendedAttribute(attributeName, value); } } var checkedLevel = TranslateUtils.ToIntWithNagetive(ContentLevel.SelectedValue); if (checkedLevel != LevelManager.LevelInt.NotChange) { contentInfo.IsChecked = checkedLevel >= PublishmentSystemInfo.CheckContentLevel; contentInfo.CheckedLevel = checkedLevel; } if (string.IsNullOrEmpty(identifier)) { identifier = GovPublicManager.GetIdentifier(PublishmentSystemInfo, contentInfo.NodeId, contentInfo.DepartmentId, contentInfo); } else if (GovPublicManager.IsIdentifierChanged(categoryChannelId, categoryDepartmentId, dtbEffectDate.DateTime, contentInfo)) { identifier = GovPublicManager.GetIdentifier(PublishmentSystemInfo, contentInfo.NodeId, contentInfo.DepartmentId, contentInfo); } contentInfo.Identifier = identifier; DataProvider.ContentDao.Update(_tableName, PublishmentSystemInfo, contentInfo); if (phTags.Visible) { TagUtils.UpdateTags(tagsLast, contentInfo.Tags, tagCollection, PublishmentSystemId, _contentId); } ContentUtility.Translate(PublishmentSystemInfo, _nodeInfo.NodeId, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(ddlTranslateType.SelectedValue), Body.AdministratorName); //更新分类内容数 foreach (GovPublicCategoryClassInfo categoryClassInfo in categoryClassInfoArrayList) { if (!string.IsNullOrEmpty(contentAttributeNameWithCategoryId[categoryClassInfo.ContentAttributeName])) { var oldCategoryId = TranslateUtils.ToInt(contentAttributeNameWithCategoryId[categoryClassInfo.ContentAttributeName]); var newCategoryId = TranslateUtils.ToInt(contentInfo.GetExtendedAttribute(categoryClassInfo.ContentAttributeName)); if (oldCategoryId > 0) { DataProvider.GovPublicCategoryDao.UpdateContentNum(PublishmentSystemInfo, categoryClassInfo.ContentAttributeName, oldCategoryId); } if (newCategoryId > 0) { DataProvider.GovPublicCategoryDao.UpdateContentNum(PublishmentSystemInfo, categoryClassInfo.ContentAttributeName, newCategoryId); } } } if (oldNodeId > 0) { DataProvider.NodeDao.UpdateContentNum(PublishmentSystemInfo, oldNodeId, true); DataProvider.NodeDao.UpdateContentNum(PublishmentSystemInfo, categoryChannelId, true); } } catch (Exception ex) { FailMessage(ex, $"内容修改失败:{ex.Message}"); LogUtils.AddErrorLog(ex); return; } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(PublishmentSystemId, categoryChannelId, _contentId); } Body.AddSiteLog(PublishmentSystemId, categoryChannelId, _contentId, "修改内容", $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},内容标题:{contentInfo.Title}"); PageUtils.Redirect(ReturnUrl); } }
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); }
protected override void Render(HtmlTextWriter output) { if (formCollection == null) { if (HttpContext.Current.Request.Form != null && HttpContext.Current.Request.Form.Count > 0) { formCollection = HttpContext.Current.Request.Form; } else { formCollection = new NameValueCollection(); } } var styleInfo = TableStyleManager.GetTableStyleInfo(tableStyle, tableName, attributeName, relatedIdentities); if (!string.IsNullOrEmpty(DefaultValue)) { styleInfo.DefaultValue = DefaultValue; } if (styleInfo.IsVisible == false) { return; } var helpHtml = $"{styleInfo.DisplayName}:"; var pageScripts = new NameValueCollection(); if (string.IsNullOrEmpty(AdditionalAttributes)) { AdditionalAttributes = InputParserUtils.GetAdditionalAttributes(string.Empty, EInputTypeUtils.GetEnumType(styleInfo.InputType)); } styleInfo.Additional.IsValidate = TranslateUtils.ToBool(IsValidate); styleInfo.Additional.IsRequired = TranslateUtils.ToBool(IsRequire); var inputHtml = BackgroundInputTypeParser.Parse(publishmentSystemInfo, nodeID, styleInfo, tableStyle, attributeName, formCollection, isEdit, isPostBack, AdditionalAttributes, pageScripts, true); if (string.IsNullOrEmpty(FormatString)) { if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.TextEditor)) { output.Write(@" <tr><td colspan=""4"" align=""left"">{0}</td></tr> <tr><td colspan=""4"" align=""left"">{1}</td></tr> ", helpHtml, inputHtml); } else if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.Image)) { output.Write(@" <tr height=""80"" valign=""middle""><td>{0}</td><td colspan=""3"">{1}</td></tr> ", helpHtml, inputHtml); } else { output.Write(@" <tr><td>{0}</td><td colspan=""3"">{1}</td></tr> ", helpHtml, inputHtml); } } else { output.Write(FormatString, helpHtml, inputHtml); } foreach (string key in pageScripts.Keys) { output.Write(pageScripts[key]); } }
public IHttpActionResult Submit() { try { var request = new RequestImpl(); var siteId = request.GetPostInt("siteId"); var channelId = request.GetPostInt("channelId"); var isFirstLineTitle = request.GetPostBool("isFirstLineTitle"); var isFirstLineRemove = request.GetPostBool("isFirstLineRemove"); var isClearFormat = request.GetPostBool("isClearFormat"); var isFirstLineIndent = request.GetPostBool("isFirstLineIndent"); var isClearFontSize = request.GetPostBool("isClearFontSize"); var isClearFontFamily = request.GetPostBool("isClearFontFamily"); var isClearImages = request.GetPostBool("isClearImages"); var checkedLevel = request.GetPostInt("checkedLevel"); var fileNames = TranslateUtils.StringCollectionToStringList(request.GetPostString("fileNames")); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentAdd)) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var styleInfoList = TableStyleManager.GetContentStyleInfoList(siteInfo, channelInfo); var isChecked = checkedLevel >= siteInfo.Additional.CheckContentLevel; var contentIdList = new List <int>(); foreach (var fileName in fileNames) { if (string.IsNullOrEmpty(fileName)) { continue; } var formCollection = WordUtils.GetWordNameValueCollection(siteId, isFirstLineTitle, isFirstLineRemove, isClearFormat, isFirstLineIndent, isClearFontSize, isClearFontFamily, isClearImages, fileName); if (string.IsNullOrEmpty(formCollection[ContentAttribute.Title])) { continue; } var dict = BackgroundInputTypeParser.SaveAttributes(siteInfo, styleInfoList, formCollection, ContentAttribute.AllAttributes.Value); var contentInfo = new ContentInfo(dict) { ChannelId = channelInfo.Id, SiteId = siteId, AddUserName = request.AdminName, AddDate = DateTime.Now }; contentInfo.LastEditUserName = contentInfo.AddUserName; contentInfo.LastEditDate = contentInfo.AddDate; contentInfo.IsChecked = isChecked; contentInfo.CheckedLevel = checkedLevel; contentInfo.Title = formCollection[ContentAttribute.Title]; contentInfo.Id = DataProvider.ContentDao.Insert(tableName, siteInfo, channelInfo, contentInfo); contentIdList.Add(contentInfo.Id); } if (isChecked) { foreach (var contentId in contentIdList) { CreateManager.CreateContent(siteId, channelInfo.Id, contentId); } CreateManager.TriggerContentChangedEvent(siteId, channelInfo.Id); } return(Ok(new { Value = contentIdList })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { if (this.contentID == 0) { var contentInfo = new VoteContentInfo(); try { BackgroundInputTypeParser.AddValuesToAttributes(tableStyle, tableName, PublishmentSystemInfo, relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes); contentInfo.NodeId = nodeID; contentInfo.PublishmentSystemId = PublishmentSystemId; contentInfo.AddUserName = Body.AdministratorName; if (contentInfo.AddDate.Year == DateUtils.SqlMinValue.Year) { FailMessage($"投票添加失败:系统时间不能为{DateUtils.SqlMinValue.Year}年"); return; } contentInfo.LastEditUserName = contentInfo.AddUserName; contentInfo.LastEditDate = DateTime.Now; contentInfo.IsChecked = false; contentInfo.IsSummary = TranslateUtils.ToBool(Request.Form["IsSummary"]); contentInfo.Summary = tbSummary.Text; contentInfo.MaxSelectNum = TranslateUtils.ToInt(ddlMaxSelectNum.SelectedValue); contentInfo.AddDate = dtbAddDate.DateTime; if (string.IsNullOrEmpty(ddlEndDate.SelectedValue)) { contentInfo.EndDate = dtbEndDate.DateTime; } else { contentInfo.EndDate = TranslateUtils.ToDateTime(ddlEndDate.SelectedValue); } contentInfo.IsVotedView = TranslateUtils.ToBool(rblIsVotedView.SelectedValue); contentInfo.HiddenContent = tbHiddenContent.Text; var checkedLevel = 0; contentInfo.IsChecked = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, nodeID, out checkedLevel); contentInfo.CheckedLevel = checkedLevel; var contentID = DataProvider.ContentDao.Insert(tableName, PublishmentSystemInfo, contentInfo); var itemCount = TranslateUtils.ToInt(Request.Form["itemCount"]); var voteOptionInfoArrayList = new ArrayList(); for (var i = 0; i < itemCount; i++) { var title = Request.Form["options[" + i + "]"]; if (!string.IsNullOrEmpty(title)) { var optionInfo = new VoteOptionInfo(0, PublishmentSystemId, nodeID, contentID, title, string.Empty, string.Empty, 0); voteOptionInfoArrayList.Add(optionInfo); } } DataProvider.VoteOptionDao.Insert(voteOptionInfoArrayList); contentInfo.Id = contentID; } catch (Exception ex) { FailMessage(ex, $"投票添加失败:{ex.Message}"); LogUtils.AddErrorLog(ex); return; } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(PublishmentSystemId, nodeID, contentInfo.Id); } Body.AddSiteLog(PublishmentSystemId, nodeID, contentInfo.Id, "添加投票", $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},投票标题:{contentInfo.Title}"); PageUtils.Redirect(PageContentAddAfter.GetRedirectUrl(PublishmentSystemId, nodeID, contentInfo.Id, returnUrl)); } else { var contentInfo = DataProvider.VoteContentDao.GetContentInfo(PublishmentSystemInfo, contentID); try { BackgroundInputTypeParser.AddValuesToAttributes(tableStyle, tableName, PublishmentSystemInfo, relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes); contentInfo.LastEditUserName = Body.AdministratorName; contentInfo.LastEditDate = DateTime.Now; contentInfo.IsSummary = TranslateUtils.ToBool(Request.Form["IsSummary"]); contentInfo.Summary = tbSummary.Text; contentInfo.MaxSelectNum = TranslateUtils.ToInt(ddlMaxSelectNum.SelectedValue); contentInfo.AddDate = dtbAddDate.DateTime; contentInfo.EndDate = dtbEndDate.DateTime; contentInfo.IsVotedView = TranslateUtils.ToBool(rblIsVotedView.SelectedValue); contentInfo.HiddenContent = tbHiddenContent.Text; DataProvider.ContentDao.Update(tableName, PublishmentSystemInfo, contentInfo); var itemCount = TranslateUtils.ToInt(Request.Form["itemCount"]); var voteOptionInfoArrayList = new ArrayList(); for (var i = 0; i < itemCount; i++) { var title = Request.Form["options[" + i + "]"]; if (!string.IsNullOrEmpty(title)) { var optionInfo = new VoteOptionInfo(0, PublishmentSystemId, nodeID, contentID, title, string.Empty, string.Empty, 0); voteOptionInfoArrayList.Add(optionInfo); } } DataProvider.VoteOptionDao.UpdateVoteOptionInfoArrayList(PublishmentSystemId, nodeID, contentID, voteOptionInfoArrayList); } catch (Exception ex) { FailMessage(ex, $"投票修改失败:{ex.Message}"); LogUtils.AddErrorLog(ex); return; } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(PublishmentSystemId, nodeID, contentID); } Body.AddSiteLog(PublishmentSystemId, nodeID, contentID, "修改投票", $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},投票标题:{contentInfo.Title}"); PageUtils.Redirect(returnUrl); } } }
protected override object Process() { var siteId = AuthRequest.SiteId; var channelId = AuthRequest.ChannelId; var contentId = AuthRequest.ContentId; var siteInfo = SiteManager.GetSiteInfo(siteId); var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var styleInfoList = TableStyleManager.GetContentStyleInfoList(siteInfo, channelInfo); var form = AuthRequest.HttpRequest.Form; var dict = BackgroundInputTypeParser.SaveAttributes(siteInfo, styleInfoList, form, ContentAttribute.AllAttributes.Value); var contentInfo = new ContentInfo(dict) { ChannelId = channelId, SiteId = siteId, AddUserName = AuthRequest.AdminName, LastEditUserName = AuthRequest.AdminName, LastEditDate = DateTime.Now }; //contentInfo.GroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroups.Items); var tagCollection = TagUtils.ParseTagsString(form["TbTags"]); contentInfo.Title = form["TbTitle"]; var formatString = TranslateUtils.ToBool(form[ContentAttribute.Title + "_formatStrong"]); var formatEm = TranslateUtils.ToBool(form[ContentAttribute.Title + "_formatEM"]); var formatU = TranslateUtils.ToBool(form[ContentAttribute.Title + "_formatU"]); var formatColor = form[ContentAttribute.Title + "_formatColor"]; var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor); contentInfo.Set(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title), theFormatString); //foreach (ListItem listItem in CblContentAttributes.Items) //{ // var value = listItem.Selected.ToString(); // var attributeName = listItem.Value; // contentInfo.Set(attributeName, value); //} //contentInfo.LinkUrl = TbLinkUrl.Text; contentInfo.AddDate = TranslateUtils.ToDateTime(form["TbAddDate"]); contentInfo.IsChecked = false; contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " "); foreach (var service in PluginManager.Services) { try { service.OnContentFormSubmit(new ContentFormSubmitEventArgs(siteId, channelId, contentInfo.Id, TranslateUtils.ToDictionary(form), contentInfo)); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit)); } } contentInfo.Id = DataProvider.ContentDao.InsertPreview(tableName, siteInfo, channelInfo, contentInfo); return(new { previewUrl = ApiRoutePreview.GetContentPreviewUrl(siteId, channelId, contentId, contentInfo.Id) }); }
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); } } } }