public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { var fileCount = TranslateUtils.ToInt(Request.Form["File_Count"]); if (fileCount == 1) { var fileName = Request.Form["fileName_1"]; var redirectUrl = WebUtils.GetContentAddUploadWordUrl(PublishmentSystemId, _nodeInfo, cbIsFirstLineTitle.Checked, cbIsFirstLineRemove.Checked, cbIsClearFormat.Checked, cbIsFirstLineIndent.Checked, cbIsClearFontSize.Checked, cbIsClearFontFamily.Checked, cbIsClearImages.Checked, TranslateUtils.ToIntWithNagetive(rblContentLevel.SelectedValue), fileName, _returnUrl); PageUtils.CloseModalPageAndRedirect(Page, redirectUrl); return; } if (fileCount > 1) { var tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, _nodeInfo); var tableName = NodeManager.GetTableName(PublishmentSystemInfo, _nodeInfo); var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, _nodeInfo.NodeId); for (var index = 1; index <= fileCount; index++) { var fileName = Request.Form["fileName_" + index]; if (!string.IsNullOrEmpty(fileName)) { var formCollection = WordUtils.GetWordNameValueCollection(PublishmentSystemId, _nodeInfo.ContentModelId, cbIsFirstLineTitle.Checked, cbIsFirstLineRemove.Checked, cbIsClearFormat.Checked, cbIsFirstLineIndent.Checked, cbIsClearFontSize.Checked, cbIsClearFontFamily.Checked, cbIsClearImages.Checked, TranslateUtils.ToInt(rblContentLevel.SelectedValue), fileName); if (!string.IsNullOrEmpty(formCollection[ContentAttribute.Title])) { var contentInfo = ContentUtility.GetContentInfo(tableStyle); BackgroundInputTypeParser.AddValuesToAttributes(tableStyle, tableName, PublishmentSystemInfo, relatedIdentities, formCollection, contentInfo.Attributes, ContentAttribute.HiddenAttributes); contentInfo.NodeId = _nodeInfo.NodeId; contentInfo.PublishmentSystemId = PublishmentSystemId; contentInfo.AddUserName = Body.AdministratorName; contentInfo.AddDate = DateTime.Now; contentInfo.LastEditUserName = contentInfo.AddUserName; contentInfo.LastEditDate = contentInfo.AddDate; contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(rblContentLevel.SelectedValue); contentInfo.IsChecked = contentInfo.CheckedLevel >= PublishmentSystemInfo.CheckContentLevel; contentInfo.Id = DataProvider.ContentDao.Insert(tableName, PublishmentSystemInfo, contentInfo); if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id); } } } } } PageUtils.CloseModalPage(Page); } }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { PublishmentSystemInfo.PublishmentSystemName = TbPublishmentSystemName.Text; try { BackgroundInputTypeParser.AddValuesToAttributes(ETableStyle.Site, DataProvider.PublishmentSystemDao.TableName, PublishmentSystemInfo, _relatedIdentities, Page.Request.Form, PublishmentSystemInfo.Additional.Attributes); DataProvider.PublishmentSystemDao.Update(PublishmentSystemInfo); Body.AddSiteLog(PublishmentSystemId, "修改站点设置"); SuccessMessage("站点设置修改成功!"); } catch (Exception ex) { FailMessage(ex, "站点设置修改失败!"); } } }
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); BackgroundInputTypeParser.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; 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); } }
private int SaveContentInfo(bool isPreview, out string errorMessage) { int savedContentId; errorMessage = string.Empty; var contentId = 0; if (!isPreview) { contentId = Body.GetQueryInt("ID"); } if (contentId == 0) { var contentInfo = ContentUtility.GetContentInfo(_tableStyle); try { contentInfo.NodeId = _nodeInfo.NodeId; contentInfo.PublishmentSystemId = PublishmentSystemId; contentInfo.AddUserName = Body.AdministratorName; if (contentInfo.AddDate.Year == DateUtils.SqlMinValue.Year) { errorMessage = $"内容添加失败:系统时间不能为{DateUtils.SqlMinValue.Year}年"; return(0); } contentInfo.LastEditUserName = contentInfo.AddUserName; contentInfo.LastEditDate = DateTime.Now; //自动保存的时候,不保存编辑器的图片 BackgroundInputTypeParser.AddValuesToAttributes(_tableStyle, _tableName, PublishmentSystemInfo, _relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes, true); contentInfo.ContentGroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroupNameCollection.Items); var tagCollection = TagUtils.ParseTagsString(TbTags.Text); if (PhContentAttributes.Visible) { foreach (ListItem listItem in CblContentAttributes.Items) { var value = listItem.Selected.ToString(); var attributeName = listItem.Value; contentInfo.SetExtendedAttribute(attributeName, value); } } contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(RblContentLevel.SelectedValue); contentInfo.IsChecked = contentInfo.CheckedLevel >= PublishmentSystemInfo.CheckContentLevel; contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " "); if (isPreview) { savedContentId = DataProvider.ContentDao.InsertPreview(_tableName, PublishmentSystemInfo, _nodeInfo, contentInfo); } else { savedContentId = DataProvider.ContentDao.Insert(_tableName, PublishmentSystemInfo, contentInfo); //判断是不是有审核权限 int checkedLevelOfUser; var isCheckedOfUser = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, contentInfo.NodeId, out checkedLevelOfUser); if (LevelManager.IsCheckable(PublishmentSystemInfo, contentInfo.NodeId, contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser)) { //添加审核记录 BaiRongDataProvider.ContentDao.UpdateIsChecked(_tableName, PublishmentSystemId, contentInfo.NodeId, new List <int> { savedContentId }, 0, true, Body.AdministratorName, contentInfo.IsChecked, contentInfo.CheckedLevel, ""); } if (PhTags.Visible) { TagUtils.AddTags(tagCollection, PublishmentSystemId, savedContentId); } } contentInfo.Id = savedContentId; } catch (Exception ex) { LogUtils.AddErrorLog(ex); errorMessage = $"内容添加失败:{ex.Message}"; return(0); } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id); } Body.AddSiteLog(PublishmentSystemId, _nodeInfo.NodeId, 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(EContentModelTypeUtils.Equals(_nodeInfo.ContentModelId, EContentModelType.Photo) ? PageContentPhotoUpload.GetRedirectUrl(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id, Body.GetQueryString("ReturnUrl")) : PageContentAddAfter.GetRedirectUrl(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id, ReturnUrl)); } else { var contentInfo = DataProvider.ContentDao.GetContentInfo(_tableStyle, _tableName, contentId); try { var tagsLast = contentInfo.Tags; contentInfo.LastEditUserName = Body.AdministratorName; contentInfo.LastEditDate = DateTime.Now; //自动保存的时候,不保存编辑器的图片 BackgroundInputTypeParser.AddValuesToAttributes(_tableStyle, _tableName, PublishmentSystemInfo, _relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes, true); contentInfo.ContentGroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroupNameCollection.Items); var tagCollection = TagUtils.ParseTagsString(TbTags.Text); if (PhContentAttributes.Visible) { foreach (ListItem listItem in CblContentAttributes.Items) { var value = listItem.Selected.ToString(); var attributeName = listItem.Value; contentInfo.SetExtendedAttribute(attributeName, value); } } var checkedLevel = TranslateUtils.ToIntWithNagetive(RblContentLevel.SelectedValue); if (checkedLevel != LevelManager.LevelInt.NotChange) { contentInfo.IsChecked = checkedLevel >= PublishmentSystemInfo.CheckContentLevel; contentInfo.CheckedLevel = checkedLevel; } contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " "); 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); if (EContentModelTypeUtils.Equals(_nodeInfo.ContentModelId, EContentModelType.Photo)) { PageUtils.Redirect(PageContentPhotoUpload.GetRedirectUrl(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id, Body.GetQueryString("ReturnUrl"))); } //更新引用该内容的信息 //如果不是异步自动保存,那么需要将引用此内容的content修改 var sourceContentIdList = new List <int> { contentInfo.Id }; var tableList = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableListCreatedInDbByAuxiliaryTableType(EAuxiliaryTableType.BackgroundContent, EAuxiliaryTableType.JobContent, EAuxiliaryTableType.VoteContent); foreach (var table in tableList) { var targetContentIdList = BaiRongDataProvider.ContentDao.GetReferenceIdList(table.TableEnName, sourceContentIdList); foreach (int targetContentId in targetContentIdList) { var targetContentInfo = DataProvider.ContentDao.GetContentInfo(ETableStyleUtils.GetEnumType(table.AuxiliaryTableType.ToString()), table.TableEnName, targetContentId); if (targetContentInfo != null && targetContentInfo.GetExtendedAttribute(ContentAttribute.TranslateContentType) == ETranslateContentType.ReferenceContent.ToString()) { contentInfo.Id = targetContentId; contentInfo.PublishmentSystemId = targetContentInfo.PublishmentSystemId; contentInfo.NodeId = targetContentInfo.NodeId; contentInfo.SourceId = targetContentInfo.SourceId; contentInfo.ReferenceId = targetContentInfo.ReferenceId; contentInfo.Taxis = targetContentInfo.Taxis; contentInfo.SetExtendedAttribute(ContentAttribute.TranslateContentType, targetContentInfo.GetExtendedAttribute(ContentAttribute.TranslateContentType)); BaiRongDataProvider.ContentDao.Update(table.TableEnName, contentInfo); //资源:图片,文件,视频 var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetContentInfo.PublishmentSystemId); var bgContentInfo = contentInfo as BackgroundContentInfo; var bgTargetContentInfo = targetContentInfo as BackgroundContentInfo; if (bgTargetContentInfo != null && bgContentInfo != null) { if (bgContentInfo.ImageUrl != bgTargetContentInfo.ImageUrl) { //修改图片 var sourceImageUrl = PathUtility.MapPath(PublishmentSystemInfo, bgContentInfo.ImageUrl); CopyReferenceFiles(targetPublishmentSystemInfo, sourceImageUrl); } else if (bgContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)) != bgTargetContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl))) { var sourceImageUrls = TranslateUtils.StringCollectionToStringList(bgContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl))); foreach (string imageUrl in sourceImageUrls) { var sourceImageUrl = PathUtility.MapPath(PublishmentSystemInfo, imageUrl); CopyReferenceFiles(targetPublishmentSystemInfo, sourceImageUrl); } } if (bgContentInfo.FileUrl != bgTargetContentInfo.FileUrl) { //修改附件 var sourceFileUrl = PathUtility.MapPath(PublishmentSystemInfo, bgContentInfo.FileUrl); CopyReferenceFiles(targetPublishmentSystemInfo, sourceFileUrl); } else if (bgContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)) != bgTargetContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl))) { var sourceFileUrls = TranslateUtils.StringCollectionToStringList(bgContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl))); foreach (string fileUrl in sourceFileUrls) { var sourceFileUrl = PathUtility.MapPath(PublishmentSystemInfo, fileUrl); CopyReferenceFiles(targetPublishmentSystemInfo, sourceFileUrl); } } } } } } } catch (Exception ex) { LogUtils.AddErrorLog(ex); errorMessage = $"内容修改失败:{ex.Message}"; return(0); } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(PublishmentSystemId, _nodeInfo.NodeId, contentId); } Body.AddSiteLog(PublishmentSystemId, _nodeInfo.NodeId, contentId, "修改内容", $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},内容标题:{contentInfo.Title}"); PageUtils.Redirect(ReturnUrl); savedContentId = contentId; } return(savedContentId); }
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) { 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); } } }
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); } } } }