public void ContentFormSubmited(int siteId, int channelId, IContentInfo contentInfo, IDictionary <string, object> form) { var categoryChannelId = TranslateUtils.Get <int>(form, "categoryChannelId"); var categoryDepartmentId = TranslateUtils.Get <int>(form, "categoryDepartmentId"); if (categoryChannelId == 0) { throw new Exception("请选择正确的主题分类"); } contentInfo.ChannelId = categoryChannelId; if (categoryDepartmentId == 0) { throw new Exception("请选择正确的机构分类"); } contentInfo.Set(ContentAttribute.DepartmentId, categoryDepartmentId.ToString()); var classInfoList = Main.CategoryClassRepository.GetCategoryClassInfoList(siteId); foreach (var classInfo in classInfoList) { if (classInfo.IsSystem || !classInfo.IsEnabled) { continue; } var attributeName = PublicManager.GetCategoryContentAttributeName(classInfo.ClassCode); var attributeValue = TranslateUtils.Get <int>(form, attributeName); contentInfo.Set(attributeName, attributeValue.ToString()); //if (attributeValue > 0) //{ // CategoryDao.UpdateContentNum(PublishmentSystemInfo, categoryClassInfo.ContentAttributeName, categoryId); //} } if (contentInfo.Id == 0) { var identifier = PublicManager.GetIdentifier(siteId, categoryChannelId, categoryDepartmentId, contentInfo); contentInfo.Set(nameof(ContentAttribute.Identifier), identifier); } else { var effectDate = contentInfo.Get <DateTime>(ContentAttribute.EffectDate); if (string.IsNullOrEmpty(contentInfo.Get <string>(ContentAttribute.Identifier)) || PublicManager.IsIdentifierChanged(siteId, categoryChannelId, categoryDepartmentId, effectDate, contentInfo)) { var identifier = PublicManager.GetIdentifier(siteId, categoryChannelId, categoryDepartmentId, contentInfo); contentInfo.Set(nameof(ContentAttribute.Identifier), identifier); } } }
public void CreateIdentifier(int siteId, int parentChannelId, bool isAll) { var channelIdList = Context.ChannelApi.GetChannelIdList(siteId, parentChannelId); channelIdList.Add(parentChannelId); foreach (var channelId in channelIdList) { var contentIdList = Context.ContentApi.GetContentIdList(siteId, channelId); foreach (var contentId in contentIdList) { var contentInfo = Context.ContentApi.GetContentInfo(siteId, channelId, contentId); if (isAll || string.IsNullOrEmpty(contentInfo.Get <string>(ContentAttribute.Identifier))) { var identifier = PublicManager.GetIdentifier(siteId, contentInfo.ChannelId, contentInfo.Get <int>(ContentAttribute.DepartmentId), contentInfo); contentInfo.Set(ContentAttribute.Identifier, identifier); Context.ContentApi.Update(siteId, channelId, contentInfo); } } } }