public static bool Import(AtomEntry entry, int siteId) { var isNodeGroup = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, "IsContentGroup")); if (!isNodeGroup) { return(false); } var groupName = AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(ContentGroupInfo.GroupName), "ContentGroupName" }); if (string.IsNullOrEmpty(groupName)) { return(true); } if (ContentGroupManager.IsExists(siteId, groupName)) { return(true); } var taxis = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(ContentGroupInfo.Taxis))); var description = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(ContentGroupInfo.Description)); DataProvider.ContentGroupDao.Insert(new ContentGroupInfo(groupName, siteId, taxis, description)); return(true); }
public override void Submit_OnClick(object sender, EventArgs e) { var isChanged = false; var contentGroupInfo = new ContentGroupInfo { GroupName = AttackUtils.FilterXss(TbContentGroupName.Text), SiteId = SiteId, Description = TbDescription.Text }; if (AuthRequest.IsQueryExists("GroupName")) { try { DataProvider.ContentGroupDao.Update(contentGroupInfo); AuthRequest.AddSiteLog(SiteId, "修改内容组", $"内容组:{contentGroupInfo.GroupName}"); isChanged = true; } catch (Exception ex) { FailMessage(ex, "内容组修改失败!"); } } else { if (ContentGroupManager.IsExists(SiteId, TbContentGroupName.Text)) { FailMessage("内容组添加失败,内容组名称已存在!"); } else { try { DataProvider.ContentGroupDao.Insert(contentGroupInfo); AuthRequest.AddSiteLog(SiteId, "添加内容组", $"内容组:{contentGroupInfo.GroupName}"); isChanged = true; } catch (Exception ex) { FailMessage(ex, "内容组添加失败!"); } } } if (isChanged) { LayerUtils.Close(Page); } }
public IHttpActionResult Submit() { try { var request = new RequestImpl(); var siteId = request.GetPostInt("siteId"); var channelId = request.GetPostInt("channelId"); var contentIdList = TranslateUtils.StringCollectionToIntList(request.GetPostString("contentIds")); var pageType = request.GetPostString("pageType"); var groupNames = TranslateUtils.StringCollectionToStringList(request.GetPostString("groupNames")); var groupName = request.GetPostString("groupName"); var description = request.GetPostString("description"); if (!request.IsUserLoggin || !request.UserPermissionsImpl.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentEdit)) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } if (pageType == "setGroup") { foreach (var contentId in contentIdList) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); if (contentInfo == null) { continue; } var list = TranslateUtils.StringCollectionToStringList(contentInfo.GroupNameCollection); foreach (var name in groupNames) { if (!list.Contains(name)) { list.Add(name); } } contentInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list); DataProvider.ContentDao.Update(siteInfo, channelInfo, contentInfo); } request.AddSiteLog(siteId, "批量设置内容组", $"内容组:{TranslateUtils.ObjectCollectionToString(groupNames)}"); } else if (pageType == "cancelGroup") { foreach (var contentId in contentIdList) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); if (contentInfo == null) { continue; } var list = TranslateUtils.StringCollectionToStringList(contentInfo.GroupNameCollection); foreach (var name in groupNames) { if (list.Contains(name)) { list.Remove(name); } } contentInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list); DataProvider.ContentDao.Update(siteInfo, channelInfo, contentInfo); } request.AddSiteLog(siteId, "批量取消内容组", $"内容组:{TranslateUtils.ObjectCollectionToString(groupNames)}"); } else if (pageType == "addGroup") { var groupInfo = new ContentGroupInfo { GroupName = AttackUtils.FilterXss(groupName), SiteId = siteId, Description = AttackUtils.FilterXss(description) }; if (ContentGroupManager.IsExists(siteId, groupInfo.GroupName)) { DataProvider.ContentGroupDao.Update(groupInfo); request.AddSiteLog(siteId, "修改内容组", $"内容组:{groupInfo.GroupName}"); } else { DataProvider.ContentGroupDao.Insert(groupInfo); request.AddSiteLog(siteId, "添加内容组", $"内容组:{groupInfo.GroupName}"); } foreach (var contentId in contentIdList) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); if (contentInfo == null) { continue; } var list = TranslateUtils.StringCollectionToStringList(contentInfo.GroupNameCollection); if (!list.Contains(groupInfo.GroupName)) { list.Add(groupInfo.GroupName); } contentInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list); DataProvider.ContentDao.Update(siteInfo, channelInfo, contentInfo); } request.AddSiteLog(siteId, "批量设置内容组", $"内容组:{groupInfo.GroupName}"); } return(Ok(new { Value = contentIdList })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }