public void CreateIdentifier(PublishmentSystemInfo publishmentSystemInfo, int parentNodeId, bool isAll) { var nodeIdList = DataProvider.NodeDao.GetNodeIdListForDescendant(parentNodeId); nodeIdList.Add(parentNodeId); foreach (int nodeId in nodeIdList) { var contentIdList = BaiRongDataProvider.ContentDao.GetContentIdList(publishmentSystemInfo.AuxiliaryTableForGovPublic, nodeId); foreach (int contentId in contentIdList) { var contentInfo = GetContentInfo(publishmentSystemInfo, contentId); if (isAll || string.IsNullOrEmpty(contentInfo.Identifier)) { var identifier = GovPublicManager.GetIdentifier(publishmentSystemInfo, contentInfo.NodeId, contentInfo.DepartmentId, contentInfo); contentInfo.Identifier = identifier; DataProvider.ContentDao.Update(publishmentSystemInfo.AuxiliaryTableForGovPublic, publishmentSystemInfo, contentInfo); } } } }
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 { InputTypeParser.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; InputTypeParser.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); } }