public async Task <ActionResult <GetResult> > Get() { var siteIds = await _authManager.GetSiteIdsAsync(); if (siteIds.Count == 0) { return(new GetResult { Unauthorized = true }); } var sites = new List <Select <int> >(); foreach (var siteId in siteIds) { var permissionSite = await _siteRepository.GetAsync(siteId); sites.Add(new Select <int> { Value = permissionSite.Id, Label = permissionSite.SiteName }); } var site = await _siteRepository.GetAsync(siteIds[0]); var channel = await _channelRepository.GetAsync(site.Id); var enabledChannelIds = await _authManager.GetChannelIdsAsync(site.Id); var visibleChannelIds = await _authManager.GetVisibleChannelIdsAsync(enabledChannelIds); var root = await _channelRepository.GetCascadeAsync(site, channel, async summary => { var visible = visibleChannelIds.Contains(summary.Id); var disabled = !enabledChannelIds.Contains(summary.Id); var current = await _contentRepository.GetSummariesAsync(site, summary); if (!visible) { return(null); } return(new { current.Count, Disabled = disabled }); }); var siteUrl = await _pathManager.GetSiteUrlAsync(site, true); var groupNames = await _contentGroupRepository.GetGroupNamesAsync(site.Id); var tagNames = await _contentTagRepository.GetTagNamesAsync(site.Id); var checkedLevels = ElementUtils.GetCheckBoxes(CheckManager.GetCheckedLevels(site, true, site.CheckContentLevel, true)); var columnsManager = new ColumnsManager(_databaseManager, _pathManager); var columns = await columnsManager.GetContentListColumnsAsync(site, channel, ColumnsManager.PageType.SearchContents); var titleColumn = columns.FirstOrDefault(x => StringUtils.EqualsIgnoreCase(x.AttributeName, nameof(Models.Content.Title))); columns.Remove(titleColumn); return(new GetResult { Unauthorized = false, Sites = sites, SiteId = site.Id, SiteName = site.SiteName, SiteUrl = siteUrl, Root = root, GroupNames = groupNames, TagNames = tagNames, CheckedLevels = checkedLevels, TitleColumn = titleColumn, Columns = columns }); }
public IHttpActionResult GetConfig() { try { var request = new AuthenticatedRequest(); var siteId = request.GetQueryInt("siteId"); var channelId = request.GetQueryInt("channelId"); var channelContentIds = MinContentInfo.ParseMinContentInfoList(request.GetQueryString("channelContentIds")); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentTranslate)) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } var retVal = new List <Dictionary <string, object> >(); foreach (var channelContentId in channelContentIds) { var contentChannelInfo = ChannelManager.GetChannelInfo(siteId, channelContentId.ChannelId); var contentInfo = ContentManager.GetContentInfo(siteInfo, contentChannelInfo, channelContentId.Id); if (contentInfo == null) { continue; } var dict = contentInfo.ToDictionary(); dict["checkState"] = CheckManager.GetCheckState(siteInfo, contentInfo); retVal.Add(dict); } var sites = new List <object>(); var channels = new List <object>(); var siteIdList = request.AdminPermissionsImpl.GetSiteIdList(); foreach (var permissionSiteId in siteIdList) { var permissionSiteInfo = SiteManager.GetSiteInfo(permissionSiteId); sites.Add(new { permissionSiteInfo.Id, permissionSiteInfo.SiteName }); } var channelIdList = request.AdminPermissionsImpl.GetChannelIdList(siteInfo.Id, ConfigManager.ChannelPermissions.ContentAdd); foreach (var permissionChannelId in channelIdList) { var permissionChannelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, permissionChannelId); channels.Add(new { permissionChannelInfo.Id, ChannelName = ChannelManager.GetChannelNameNavigation(siteInfo.Id, permissionChannelId) }); } return(Ok(new { Value = retVal, Sites = sites, Channels = channels, Site = siteInfo })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
public IHttpActionResult GetConfig() { try { var request = new AuthenticatedRequest(); var siteId = request.GetQueryInt("siteId"); var channelId = request.GetQueryInt("channelId"); var contentIdList = TranslateUtils.StringCollectionToIntList(request.GetQueryString("contentIds")); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentCheck)) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } var retval = new List <Dictionary <string, object> >(); foreach (var contentId in contentIdList) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); if (contentInfo == null) { continue; } var dict = contentInfo.ToDictionary(); dict["title"] = WebUtils.GetContentTitle(siteInfo, contentInfo, string.Empty); dict["checkState"] = CheckManager.GetCheckState(siteInfo, contentInfo); retval.Add(dict); } var isChecked = CheckManager.GetUserCheckLevel(request.AdminPermissionsImpl, siteInfo, siteId, out var checkedLevel); var checkedLevels = CheckManager.GetCheckedLevels(siteInfo, isChecked, checkedLevel, true); var allChannels = ChannelManager.GetChannels(siteId, request.AdminPermissionsImpl, ConfigManager.ChannelPermissions.ContentAdd); return(Ok(new { Value = retval, CheckedLevels = checkedLevels, CheckedLevel = checkedLevel, AllChannels = allChannels })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
public ActionResult Check(FormCollection collection) { try { CheckManager checkManager = new CheckManager(User.Identity.Name); List <string> filesToCheck = new List <string>(); if (String.IsNullOrEmpty(collection["filesToCheck"])) { Infrastructure.Logger.Error("Null to check files"); return(View()); } filesToCheck.AddRange(((string)collection["filesToCheck"]).Split(',')); List <string> reqFiles = new List <string>(); if (String.IsNullOrEmpty(collection["reqFiles"])) { Infrastructure.Logger.Error("Null req files"); return(View()); } reqFiles.AddRange(((string)collection["reqFiles"]).Split(',')); reqFiles = reqFiles .Select(x => checkManager.GetFilePath(x)) .ToList(); filesToCheck = filesToCheck .Select(x => checkManager.GetFilePath(x)) .ToList(); Infrastructure.Logger.Info("to check:" + String.Join(",", filesToCheck)); //!!! check collection values and add them if (ModelState.IsValid) { if (Request.Files.Count > 0) { foreach (HttpPostedFile file in Request.Files) { // add this file to current user string fileName = Path.Combine(Infrastructure.GetUsersDirectory(User.Identity.Name), file.FileName); //!!!check extension file.SaveAs(fileName); } } List <ReqFile> rqfiles = reqFiles.Select(f => new ReqFile(f)).ToList(); DocumentMatcher dm = new DocumentMatcher(rqfiles); List <CheckResult> results = new List <CheckResult>(); foreach (string fileName in filesToCheck) { FileToCheck fcheck = new FileToCheck(fileName); results.AddRange(dm.Check(fcheck)); Infrastructure.Logger.Info("After {0}: count is {1}", fileName, results.Count); } Infrastructure.Logger.Info("Message: " + results[0].ToString()); var model = new CheckResultModel() { Message = results[0].ToString().Split('\n').ToList(), ReqFile = Path.GetFileName(reqFiles[0]), DocxFile = Path.GetFileName(filesToCheck[0]) }; return(View("CheckResultView", model)); } } catch (Exception e) { Infrastructure.Logger.Error(e.ToString()); return(View()); } return(View()); }
public override void Submit_OnClick(object sender, EventArgs e) { var checkedLevel = TranslateUtils.ToIntWithNagetive(DdlCheckType.SelectedValue); var isChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel; var contentInfoListToCheck = new List <ContentInfo>(); var idsDictionaryToCheck = new Dictionary <int, List <int> >(); foreach (var channelId in _idsDictionary.Keys) { var tableName = ChannelManager.GetTableName(SiteInfo, channelId); var contentIdList = _idsDictionary[channelId]; var contentIdListToCheck = new List <int>(); int checkedLevelOfUser; var isCheckedOfUser = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissions, SiteInfo, channelId, out checkedLevelOfUser); foreach (var contentId in contentIdList) { var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId); if (contentInfo != null) { if (CheckManager.IsCheckable(SiteInfo, contentInfo.ChannelId, contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser)) { contentInfoListToCheck.Add(contentInfo); contentIdListToCheck.Add(contentId); } DataProvider.ContentDao.Update(tableName, SiteInfo, contentInfo); CreateManager.CreateContentAndTrigger(SiteId, contentInfo.ChannelId, contentId); } } if (contentIdListToCheck.Count > 0) { idsDictionaryToCheck[channelId] = contentIdListToCheck; } } if (contentInfoListToCheck.Count == 0) { LayerUtils.CloseWithoutRefresh(Page, "alert('您的审核权限不足,无法审核所选内容!');"); return; } var translateChannelId = TranslateUtils.ToInt(DdlTranslateChannelId.SelectedValue); foreach (var channelId in idsDictionaryToCheck.Keys) { var tableName = ChannelManager.GetTableName(SiteInfo, channelId); var contentIdList = idsDictionaryToCheck[channelId]; DataProvider.ContentDao.UpdateIsChecked(tableName, SiteId, channelId, contentIdList, translateChannelId, true, AuthRequest.AdminName, isChecked, checkedLevel, TbCheckReasons.Text); DataProvider.ChannelDao.UpdateContentNum(SiteInfo, channelId, true); } if (translateChannelId > 0) { DataProvider.ChannelDao.UpdateContentNum(SiteInfo, translateChannelId, true); } AuthRequest.AddSiteLog(SiteId, SiteId, 0, "设置内容状态为" + DdlCheckType.SelectedItem.Text, TbCheckReasons.Text); foreach (var channelId in idsDictionaryToCheck.Keys) { var contentIdList = _idsDictionary[channelId]; if (contentIdList != null) { foreach (var contentId in contentIdList) { CreateManager.CreateContentAndTrigger(SiteId, channelId, contentId); } } } LayerUtils.CloseAndRedirect(Page, _returnUrl); }
private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } var contentInfo = new ContentInfo(e.Item.DataItem); var ltlTitle = (Literal)e.Item.FindControl("ltlTitle"); var ltlChannel = (Literal)e.Item.FindControl("ltlChannel"); var ltlColumns = (Literal)e.Item.FindControl("ltlColumns"); var ltlStatus = (Literal)e.Item.FindControl("ltlStatus"); var ltlCommands = (Literal)e.Item.FindControl("ltlCommands"); var ltlSelect = (Literal)e.Item.FindControl("ltlSelect"); ltlTitle.Text = WebUtils.GetContentTitle(SiteInfo, contentInfo, PageUrl); ltlColumns.Text = TextUtility.GetColumnsHtml(_nameValueCacheDict, SiteInfo, contentInfo, _attributesOfDisplay, _attributesOfDisplayStyleInfoList); string nodeName; if (!_nameValueCacheDict.TryGetValue(contentInfo.ChannelId.ToString(), out nodeName)) { nodeName = ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId); _nameValueCacheDict[contentInfo.ChannelId.ToString()] = nodeName; } ltlChannel.Text = nodeName; ltlStatus.Text = $@"<a href=""javascript:;"" title=""设置内容状态"" onclick=""{ModalCheckState.GetOpenWindowString(SiteId, contentInfo, PageUrl)}"">{CheckManager.GetCheckState(SiteInfo, contentInfo.IsChecked, contentInfo.CheckedLevel)}</a>"; ltlCommands.Text = TextUtility.GetCommandsHtml(SiteInfo, _pluginLinks, contentInfo, PageUrl, Body.AdminName, _isEdit); ltlSelect.Text = $@"<input type=""checkbox"" name=""IDsCollection"" value=""{contentInfo.ChannelId}_{contentInfo.Id}"" />"; }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId", "channelId"); var channelId = AuthRequest.GetQueryInt("channelId"); var contentId = AuthRequest.GetQueryInt("id"); ReturnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("returnUrl")); if (string.IsNullOrEmpty(ReturnUrl)) { ReturnUrl = PageContent.GetRedirectUrl(SiteId, channelId); } _nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId); var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, channelId); _tableName = ChannelManager.GetTableName(SiteInfo, _nodeInfo); ContentInfo contentInfo = null; _styleInfoList = TableStyleManager.GetTableStyleInfoList(_tableName, relatedIdentities); if (!IsPermissions(contentId)) { return; } if (contentId > 0) { contentInfo = DataProvider.ContentDao.GetContentInfo(_tableName, contentId); } var titleFormat = IsPostBack ? Request.Form[ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title)] : contentInfo?.GetString(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title)); LtlTitleHtml.Text = ContentUtility.GetTitleHtml(titleFormat, AjaxCmsService.GetTitlesUrl(SiteId, _nodeInfo.Id)); AcAttributes.SiteInfo = SiteInfo; AcAttributes.ChannelId = _nodeInfo.Id; AcAttributes.StyleInfoList = _styleInfoList; if (!IsPostBack) { var pageTitle = contentId == 0 ? "添加内容" : "编辑内容"; LtlPageTitle.Text = pageTitle; if (HasChannelPermissions(_nodeInfo.Id, ConfigManager.ChannelPermissions.ContentTranslate)) { PhTranslate.Visible = true; BtnTranslate.Attributes.Add("onclick", ModalChannelMultipleSelect.GetOpenWindowString(SiteId, true)); ETranslateContentTypeUtils.AddListItems(DdlTranslateType, true); ControlUtils.SelectSingleItem(DdlTranslateType, ETranslateContentTypeUtils.GetValue(ETranslateContentType.Copy)); } else { PhTranslate.Visible = false; } CblContentAttributes.Items.Add(new ListItem("置顶", ContentAttribute.IsTop)); CblContentAttributes.Items.Add(new ListItem("推荐", ContentAttribute.IsRecommend)); CblContentAttributes.Items.Add(new ListItem("热点", ContentAttribute.IsHot)); CblContentAttributes.Items.Add(new ListItem("醒目", ContentAttribute.IsColor)); TbAddDate.DateTime = DateTime.Now; TbAddDate.Now = true; var contentGroupNameList = DataProvider.ContentGroupDao.GetGroupNameList(SiteId); foreach (var groupName in contentGroupNameList) { var item = new ListItem(groupName, groupName); CblContentGroups.Items.Add(item); } BtnContentGroupAdd.Attributes.Add("onclick", ModalContentGroupAdd.GetOpenWindowString(SiteId)); LtlTags.Text = ContentUtility.GetTagsHtml(AjaxCmsService.GetTagsUrl(SiteId)); if (HasChannelPermissions(_nodeInfo.Id, ConfigManager.ChannelPermissions.ContentCheck)) { PhStatus.Visible = true; int checkedLevel; var isChecked = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissions, SiteInfo, _nodeInfo.Id, out checkedLevel); if (AuthRequest.IsQueryExists("contentLevel")) { checkedLevel = TranslateUtils.ToIntWithNagetive(AuthRequest.GetQueryString("contentLevel")); if (checkedLevel != CheckManager.LevelInt.NotChange) { isChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel; } } CheckManager.LoadContentLevelToEdit(DdlContentLevel, SiteInfo, _nodeInfo.Id, contentInfo, isChecked, checkedLevel); } else { PhStatus.Visible = false; } BtnSubmit.Attributes.Add("onclick", InputParserUtils.GetValidateSubmitOnClickScript("myForm", true, "autoCheckKeywords()")); //自动检测敏感词 ClientScriptRegisterStartupScript("autoCheckKeywords", WebUtils.GetAutoCheckKeywordsScript(SiteInfo)); if (contentId == 0) { var attributes = TableStyleManager.GetDefaultAttributes(_styleInfoList); if (AuthRequest.IsQueryExists("isUploadWord")) { var isFirstLineTitle = AuthRequest.GetQueryBool("isFirstLineTitle"); var isFirstLineRemove = AuthRequest.GetQueryBool("isFirstLineRemove"); var isClearFormat = AuthRequest.GetQueryBool("isClearFormat"); var isFirstLineIndent = AuthRequest.GetQueryBool("isFirstLineIndent"); var isClearFontSize = AuthRequest.GetQueryBool("isClearFontSize"); var isClearFontFamily = AuthRequest.GetQueryBool("isClearFontFamily"); var isClearImages = AuthRequest.GetQueryBool("isClearImages"); var contentLevel = AuthRequest.GetQueryInt("contentLevel"); var fileName = AuthRequest.GetQueryString("fileName"); var formCollection = WordUtils.GetWordNameValueCollection(SiteId, isFirstLineTitle, isFirstLineRemove, isClearFormat, isFirstLineIndent, isClearFontSize, isClearFontFamily, isClearImages, contentLevel, fileName); attributes.Load(formCollection); TbTitle.Text = formCollection[ContentAttribute.Title]; } AcAttributes.Attributes = attributes; } else if (contentInfo != null) { TbTitle.Text = contentInfo.Title; TbTags.Text = contentInfo.Tags; var list = new List <string>(); if (contentInfo.IsTop) { list.Add(ContentAttribute.IsTop); } if (contentInfo.IsRecommend) { list.Add(ContentAttribute.IsRecommend); } if (contentInfo.IsHot) { list.Add(ContentAttribute.IsHot); } if (contentInfo.IsColor) { list.Add(ContentAttribute.IsColor); } ControlUtils.SelectMultiItems(CblContentAttributes, list); TbLinkUrl.Text = contentInfo.LinkUrl; TbAddDate.DateTime = contentInfo.AddDate; ControlUtils.SelectMultiItems(CblContentGroups, TranslateUtils.StringCollectionToStringList(contentInfo.GroupNameCollection)); AcAttributes.Attributes = contentInfo; } } else { AcAttributes.Attributes = new ExtendedAttributes(Request.Form); } //DataBind(); }
public async Task <ActionResult <TreeResult> > Tree([FromBody] TreeRequest request) { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, MenuUtils.SitePermissions.ContentsSearch)) { return(Unauthorized()); } var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(NotFound()); } var channel = await _channelRepository.GetAsync(request.SiteId); var root = await _channelRepository.GetCascadeAsync(site, channel, async summary => { var count = await _contentRepository.GetCountAsync(site, summary); return(new { Count = count }); }); if (!request.Reload) { var siteUrl = await _pathManager.GetSiteUrlAsync(site, true); var groupNames = await _contentGroupRepository.GetGroupNamesAsync(request.SiteId); var tagNames = await _contentTagRepository.GetTagNamesAsync(request.SiteId); var checkedLevels = ElementUtils.GetCheckBoxes(CheckManager.GetCheckedLevels(site, true, site.CheckContentLevel, true)); var columnsManager = new ColumnsManager(_databaseManager, _pathManager); var columns = await columnsManager.GetContentListColumnsAsync(site, channel, ColumnsManager.PageType.SearchContents); var permissions = new Permissions { IsAdd = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, MenuUtils.ContentPermissions.Add), IsDelete = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, MenuUtils.ContentPermissions.Delete), IsEdit = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, MenuUtils.ContentPermissions.Edit), IsArrange = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, MenuUtils.ContentPermissions.Arrange), IsTranslate = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, MenuUtils.ContentPermissions.Translate), IsCheck = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, MenuUtils.ContentPermissions.CheckLevel1), IsCreate = await _authManager.HasSitePermissionsAsync(site.Id, MenuUtils.SitePermissions.CreateContents) || await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, MenuUtils.ContentPermissions.Create), IsChannelEdit = await _authManager.HasChannelPermissionsAsync(site.Id, channel.Id, MenuUtils.ChannelPermissions.Edit) }; var titleColumn = columns.FirstOrDefault(x => StringUtils.EqualsIgnoreCase(x.AttributeName, nameof(Models.Content.Title))); columns.Remove(titleColumn); return(new TreeResult { Root = root, SiteUrl = siteUrl, GroupNames = groupNames, TagNames = tagNames, CheckedLevels = checkedLevels, TitleColumn = titleColumn, Columns = columns, Permissions = permissions }); } return(new TreeResult { Root = root }); }
public object GetContentAdd(RequestImpl request) { var requestSiteId = request.SiteId; var requestChannelId = request.ChannelId; var requestContentId = request.ContentId; var sites = new List <object>(); var channels = new List <object>(); object site = null; object channel = null; List <string> groupNames = null; List <string> tagNames = null; ContentInfo contentInfo = null; List <TableStyleInfo> styles = null; List <KeyValuePair <int, string> > checkedLevels = null; var checkedLevel = 0; if (request.IsUserLoggin) { SiteInfo siteInfo = null; ChannelInfo channelInfo = null; var siteIdList = request.UserPermissionsImpl.GetSiteIdList(); foreach (var siteId in siteIdList) { var permissionSiteInfo = SiteManager.GetSiteInfo(siteId); if (requestSiteId == siteId) { siteInfo = permissionSiteInfo; } sites.Add(new { permissionSiteInfo.Id, permissionSiteInfo.SiteName }); } if (siteInfo == null && siteIdList.Count > 0) { siteInfo = SiteManager.GetSiteInfo(siteIdList[0]); } if (siteInfo != null) { var channelIdList = request.UserPermissionsImpl.GetChannelIdList(siteInfo.Id, ConfigManager.ChannelPermissions.ContentAdd); foreach (var permissionChannelId in channelIdList) { var permissionChannelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, permissionChannelId); if (channelInfo == null || permissionChannelInfo.Id == requestChannelId) { channelInfo = permissionChannelInfo; } channels.Add(new { permissionChannelInfo.Id, ChannelName = ChannelManager.GetChannelNameNavigation(siteInfo.Id, permissionChannelId) }); } site = new { siteInfo.Id, siteInfo.SiteName, SiteUrl = PageUtility.GetSiteUrl(siteInfo, false) }; groupNames = ContentGroupManager.GetGroupNameList(siteInfo.Id); tagNames = ContentTagManager.GetTagNameList(siteInfo.Id); } if (channelInfo != null) { channel = new { channelInfo.Id, ChannelName = ChannelManager.GetChannelNameNavigation(siteInfo.Id, channelInfo.Id) }; styles = TableStyleManager.GetContentStyleInfoList(siteInfo, channelInfo); var checkKeyValuePair = CheckManager.GetUserCheckLevel(request.AdminPermissionsImpl, siteInfo, siteInfo.Id); checkedLevels = CheckManager.GetCheckedLevels(siteInfo, checkKeyValuePair.Key, checkedLevel, true); if (requestContentId != 0) { checkedLevels.Insert(0, new KeyValuePair <int, string>(CheckManager.LevelInt.NotChange, CheckManager.Level.NotChange)); checkedLevel = CheckManager.LevelInt.NotChange; contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, requestContentId); if (contentInfo != null && (contentInfo.SiteId != siteInfo.Id || contentInfo.ChannelId != channelInfo.Id)) { contentInfo = null; } } else { contentInfo = new ContentInfo(new { Id = 0, SiteId = siteInfo.Id, ChannelId = channelInfo.Id, AddDate = DateTime.Now }); } } } return(new { Value = request.UserInfo, Config = ConfigManager.Instance.SystemConfigInfo, Sites = sites, Channels = channels, Site = site, Channel = channel, AllGroupNames = groupNames, AllTagNames = tagNames, Styles = styles, CheckedLevels = checkedLevels, CheckedLevel = checkedLevel, Content = contentInfo, }); }
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 void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("PublishmentSystemID", "NodeID", "ReturnUrl"); var nodeId = Body.GetQueryInt("NodeID"); var contentId = Body.GetQueryInt("ID"); ReturnUrl = StringUtils.ValueFromUrl(Body.GetQueryString("ReturnUrl")); _nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, nodeId); _tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, _nodeInfo); _tableName = NodeManager.GetTableName(PublishmentSystemInfo, _nodeInfo); _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, nodeId); ContentInfo contentInfo = null; if (contentId == 0) { if (_nodeInfo != null && _nodeInfo.Additional.IsContentAddable == false) { PageUtils.RedirectToErrorPage("此栏目不能添加内容!"); return; } if (!HasChannelPermissions(nodeId, AppManager.Cms.Permission.Channel.ContentAdd)) { if (!Body.IsAdministratorLoggin) { PageUtils.RedirectToLoginPage(); return; } else { PageUtils.RedirectToErrorPage("您无此栏目的添加内容权限!"); return; } } } else { contentInfo = DataProvider.ContentDao.GetContentInfo(_tableStyle, _tableName, contentId); if (!HasChannelPermissions(nodeId, AppManager.Cms.Permission.Channel.ContentEdit)) { if (!Body.IsAdministratorLoggin) { PageUtils.RedirectToLoginPage(); return; } PageUtils.RedirectToErrorPage("您无此栏目的修改内容权限!"); return; } } if (!IsPostBack) { var nodeNames = NodeManager.GetNodeNameNavigation(PublishmentSystemId, _nodeInfo.NodeId); var pageTitle = (contentId == 0) ? $"添加{ContentModelManager.GetContentModelInfo(PublishmentSystemInfo, _nodeInfo.ContentModelId).ModelName}" : $"编辑{ContentModelManager.GetContentModelInfo(PublishmentSystemInfo, _nodeInfo.ContentModelId).ModelName}"; BreadCrumbWithItemTitle(AppManager.Cms.LeftMenu.IdContent, pageTitle, nodeNames, string.Empty); LtlPageTitle.Text = pageTitle; LtlPageTitle.Text += $@" <script language=""javascript"" type=""text/javascript""> var previewUrl = '{PagePreview.GetRedirectUrl(PublishmentSystemId, _nodeInfo.NodeId, contentId, 0, 0)}'; </script> "; //转移 if (AdminUtility.HasChannelPermissions(Body.AdministratorName, PublishmentSystemId, _nodeInfo.NodeId, AppManager.Cms.Permission.Channel.ContentTranslate)) { PhTranslate.Visible = PublishmentSystemInfo.Additional.IsTranslate; DivTranslateAdd.Attributes.Add("onclick", ModalChannelMultipleSelect.GetOpenWindowString(PublishmentSystemId, true)); ETranslateContentTypeUtils.AddListItems(DdlTranslateType, true); ControlUtils.SelectListItems(DdlTranslateType, ETranslateContentTypeUtils.GetValue(ETranslateContentType.Copy)); } else { PhTranslate.Visible = false; } //内容属性 var excludeAttributeNames = TableManager.GetExcludeAttributeNames(_tableStyle); AcAttributes.AddExcludeAttributeNames(excludeAttributeNames); if (excludeAttributeNames.Count == 0) { PhContentAttributes.Visible = false; } else { PhContentAttributes.Visible = true; foreach (var attributeName in excludeAttributeNames) { var styleInfo = TableStyleManager.GetTableStyleInfo(_tableStyle, _tableName, attributeName, _relatedIdentities); if (styleInfo.IsVisible) { var listItem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName); if (contentId > 0) { listItem.Selected = TranslateUtils.ToBool(contentInfo?.GetExtendedAttribute(styleInfo.AttributeName)); } else { if (TranslateUtils.ToBool(styleInfo.DefaultValue)) { listItem.Selected = true; } } CblContentAttributes.Items.Add(listItem); } } } //内容组 var contentGroupNameList = DataProvider.ContentGroupDao.GetContentGroupNameList(PublishmentSystemId); if (!PublishmentSystemInfo.Additional.IsGroupContent || contentGroupNameList.Count == 0) { PhContentGroup.Visible = false; } else { foreach (var groupName in contentGroupNameList) { var item = new ListItem(groupName, groupName); if (contentId > 0) { item.Selected = StringUtils.In(contentInfo?.ContentGroupNameCollection, groupName); } CblContentGroupNameCollection.Items.Add(item); } } //标签 if (!PublishmentSystemInfo.Additional.IsRelatedByTags) { PhTags.Visible = false; } else { var tagScript = @" <script type=""text/javascript""> function getTags(tag){ $.get('[url]&tag=' + encodeURIComponent(tag) + '&r=' + Math.random(), function(data) { if(data !=''){ var arr = data.split('|'); var temp=''; for(i=0;i<arr.length;i++) { temp += '<li><a>'+arr[i].replace(tag,'<b>' + tag + '</b>') + '</a></li>'; } var myli='<ul>'+temp+'</ul>'; $('#tagTips').html(myli); $('#tagTips').show(); }else{ $('#tagTips').hide(); } $('#tagTips li').click(function () { var tag = $('#TbTags').val(); var i = tag.lastIndexOf(' '); if (i > 0) { tag = tag.substring(0, i) + ' ' + $(this).text(); }else{ tag = $(this).text(); } $('#TbTags').val(tag); $('#tagTips').hide(); }) }); } $(document).ready(function () { $('#TbTags').keyup(function (e) { if (e.keyCode != 40 && e.keyCode != 38) { var tag = $('#TbTags').val(); var i = tag.lastIndexOf(' '); if (i > 0){ tag = tag.substring(i + 1);} if (tag != '' && tag != ' '){ window.setTimeout(""getTags('"" + tag + ""');"", 200); }else{ $('#tagTips').hide(); } } }).blur(function () { window.setTimeout(""$('#tagTips').hide();"", 200); })}); </script> <div id=""tagTips"" class=""inputTips""></div> "; LtlTags.Text = tagScript.Replace("[url]", AjaxCmsService.GetTagsUrl(PublishmentSystemId)); } if (contentId == 0) { var formCollection = new NameValueCollection(); if (Body.IsQueryExists("isUploadWord")) { var isFirstLineTitle = Body.GetQueryBool("isFirstLineTitle"); var isFirstLineRemove = Body.GetQueryBool("isFirstLineRemove"); var isClearFormat = Body.GetQueryBool("isClearFormat"); var isFirstLineIndent = Body.GetQueryBool("isFirstLineIndent"); var isClearFontSize = Body.GetQueryBool("isClearFontSize"); var isClearFontFamily = Body.GetQueryBool("isClearFontFamily"); var isClearImages = Body.GetQueryBool("isClearImages"); var contentLevel = Body.GetQueryInt("contentLevel"); var fileName = Body.GetQueryString("fileName"); formCollection = WordUtils.GetWordNameValueCollection(PublishmentSystemId, _nodeInfo.ContentModelId, isFirstLineTitle, isFirstLineRemove, isClearFormat, isFirstLineIndent, isClearFontSize, isClearFontFamily, isClearImages, contentLevel, fileName); } AcAttributes.SetParameters(formCollection, PublishmentSystemInfo, _nodeInfo.NodeId, _relatedIdentities, _tableStyle, _tableName, false, IsPostBack); } else { AcAttributes.SetParameters(contentInfo?.Attributes, PublishmentSystemInfo, _nodeInfo.NodeId, _relatedIdentities, _tableStyle, _tableName, true, IsPostBack); TbTags.Text = contentInfo?.Tags; } if (HasChannelPermissions(nodeId, AppManager.Cms.Permission.Channel.ContentCheck)) { PhStatus.Visible = true; int checkedLevel; var isChecked = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, _nodeInfo.NodeId, out checkedLevel); if (Body.IsQueryExists("contentLevel")) { checkedLevel = TranslateUtils.ToIntWithNagetive(Body.GetQueryString("contentLevel")); if (checkedLevel != LevelManager.LevelInt.NotChange) { isChecked = checkedLevel >= PublishmentSystemInfo.CheckContentLevel; } } LevelManager.LoadContentLevelToEdit(RblContentLevel, PublishmentSystemInfo, nodeId, contentInfo, isChecked, checkedLevel); } else { PhStatus.Visible = false; } BtnSubmit.Attributes.Add("onclick", InputParserUtils.GetValidateSubmitOnClickScript("myForm", true, "autoCheckKeywords()")); //自动检测敏感词 ClientScriptRegisterStartupScript("autoCheckKeywords", WebUtils.GetAutoCheckKeywordsScript(PublishmentSystemInfo)); } else { AcAttributes.SetParameters(Request.Form, PublishmentSystemInfo, _nodeInfo.NodeId, _relatedIdentities, _tableStyle, _tableName, contentId != 0, IsPostBack); } DataBind(); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("PublishmentSystemID"); var permissions = PermissionsManager.GetPermissions(Body.AdministratorName); var nodeId = PublishmentSystemId; _isGovPublic = Body.GetQueryBool("IsGovPublic"); if (_isGovPublic) { nodeId = PublishmentSystemInfo.Additional.GovPublicNodeId; if (nodeId == 0) { nodeId = PublishmentSystemId; } } _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, nodeId); _nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, nodeId); _tableName = NodeManager.GetTableName(PublishmentSystemInfo, _nodeInfo); _tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, _nodeInfo); _tableStyleInfoList = TableStyleManager.GetTableStyleInfoList(_tableStyle, _tableName, _relatedIdentities); _attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(NodeManager.GetContentAttributesOfDisplay(PublishmentSystemId, nodeId)); if (!IsPostBack) { BreadCrumb(AppManager.Cms.LeftMenu.IdContent, "内容审核", string.Empty); var checkedLevel = 5; var isChecked = true; foreach (var owningNodeId in ProductPermissionsManager.Current.OwningNodeIdList) { int checkedLevelByNodeId; var isCheckedByNodeId = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, owningNodeId, out checkedLevelByNodeId); if (checkedLevel > checkedLevelByNodeId) { checkedLevel = checkedLevelByNodeId; } if (!isCheckedByNodeId) { isChecked = false; } } LevelManager.LoadContentLevelToList(State, PublishmentSystemInfo, PublishmentSystemId, isChecked, checkedLevel); if (_isGovPublic) { PhContentModel.Visible = false; } else { PhContentModel.Visible = true; var contentModelInfoList = ContentModelManager.GetContentModelInfoList(PublishmentSystemInfo); foreach (var modelInfo in contentModelInfoList) { DdlContentModelId.Items.Add(new ListItem(modelInfo.ModelName, modelInfo.ModelId)); } ControlUtils.SelectListItems(DdlContentModelId, _nodeInfo.ContentModelId); //EContentModelTypeUtils.AddListItemsForContentCheck(this.ContentModelID); } if (!string.IsNullOrEmpty(Body.GetQueryString("State"))) { ControlUtils.SelectListItems(State, Body.GetQueryString("State")); } if (!string.IsNullOrEmpty(Body.GetQueryString("ModelID"))) { ControlUtils.SelectListItems(DdlContentModelId, Body.GetQueryString("ModelID")); } SpContents.ControlToPaginate = RptContents; SpContents.ItemsPerPage = PublishmentSystemInfo.Additional.PageSize; var checkLevelArrayList = new ArrayList(); if (!string.IsNullOrEmpty(Body.GetQueryString("State"))) { checkLevelArrayList.Add(Body.GetQueryString("State")); } else { checkLevelArrayList = LevelManager.LevelInt.GetCheckLevelArrayList(PublishmentSystemInfo, isChecked, checkedLevel); } var tableName = NodeManager.GetTableName(PublishmentSystemInfo, DdlContentModelId.SelectedValue); if (_isGovPublic) { tableName = PublishmentSystemInfo.AuxiliaryTableForGovPublic; } var owningNodeIdList = new List <int>(); if (!permissions.IsSystemAdministrator) { foreach (var owningNodeId in ProductPermissionsManager.Current.OwningNodeIdList) { if (AdminUtility.HasChannelPermissions(Body.AdministratorName, PublishmentSystemId, owningNodeId, AppManager.Cms.Permission.Channel.ContentCheck)) { owningNodeIdList.Add(owningNodeId); } } } SpContents.SelectCommand = BaiRongDataProvider.ContentDao.GetSelectedCommendByCheck(tableName, PublishmentSystemId, permissions.IsSystemAdministrator, owningNodeIdList, checkLevelArrayList); SpContents.SortField = ContentAttribute.LastEditDate; SpContents.SortMode = SortMode.DESC; RptContents.ItemDataBound += rptContents_ItemDataBound; SpContents.DataBind(); var showPopWinString = ModalContentCheck.GetOpenWindowStringForMultiChannels(PublishmentSystemId, PageUrl); BtnCheck.Attributes.Add("onclick", showPopWinString); LtlColumnHeadRows.Text = ContentUtility.GetColumnHeadRowsHtml(_tableStyleInfoList, _attributesOfDisplay, _tableStyle, PublishmentSystemInfo); LtlCommandHeadRows.Text = ContentUtility.GetCommandHeadRowsHtml(Body.AdministratorName, _tableStyle, PublishmentSystemInfo, _nodeInfo); } if (!HasChannelPermissions(PublishmentSystemId, AppManager.Cms.Permission.Channel.ContentDelete)) { BtnDelete.Visible = false; } else { BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(PublishmentSystemId, false, PageUrl)); } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId"); _channelId = AuthRequest.IsQueryExists("ChannelId") ? AuthRequest.GetQueryInt("ChannelId") : SiteId; _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId); _nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); _tableName = ChannelManager.GetTableName(SiteInfo, _nodeInfo); _styleInfoList = TableStyleManager.GetTableStyleInfoList(_tableName, _relatedIdentities); _attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(ChannelManager.GetContentAttributesOfDisplay(SiteId, _channelId)); _attributesOfDisplayStyleInfoList = ContentUtility.GetAllTableStyleInfoList(_styleInfoList); _pluginLinks = PluginContentManager.GetContentLinks(_nodeInfo); _isEdit = TextUtility.IsEdit(SiteInfo, _channelId, AuthRequest.AdminPermissions); if (IsPostBack) { return; } var checkedLevel = 5; var isChecked = true; foreach (var owningChannelId in AuthRequest.AdminPermissions.OwningChannelIdList) { int checkedLevelByChannelId; var isCheckedByChannelId = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissions, SiteInfo, owningChannelId, out checkedLevelByChannelId); if (checkedLevel > checkedLevelByChannelId) { checkedLevel = checkedLevelByChannelId; } if (!isCheckedByChannelId) { isChecked = false; } } ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, true, true, AuthRequest.AdminPermissions); CheckManager.LoadContentLevelToList(DdlState, SiteInfo, SiteId, isChecked, checkedLevel); var checkLevelList = new List <int>(); if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("channelId"))) { ControlUtils.SelectSingleItem(DdlChannelId, AuthRequest.GetQueryString("channelId")); } if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("state"))) { ControlUtils.SelectSingleItem(DdlState, AuthRequest.GetQueryString("state")); checkLevelList.Add(AuthRequest.GetQueryInt("state")); } else { checkLevelList = CheckManager.LevelInt.GetCheckLevelList(SiteInfo, isChecked, checkedLevel); } SpContents.ControlToPaginate = RptContents; SpContents.ItemsPerPage = SiteInfo.Additional.PageSize; var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); var tableName = ChannelManager.GetTableName(SiteInfo, nodeInfo); var channelIdList = ChannelManager.GetChannelIdList(nodeInfo, EScopeType.All, string.Empty, string.Empty, nodeInfo.ContentModelPluginId); var list = new List <int>(); if (AuthRequest.AdminPermissions.IsSystemAdministrator) { list = channelIdList; } else { var owningChannelIdList = new List <int>(); foreach (var owningChannelId in AuthRequest.AdminPermissions.OwningChannelIdList) { if (HasChannelPermissions(owningChannelId, ConfigManager.ChannelPermissions.ContentCheck)) { owningChannelIdList.Add(owningChannelId); } } foreach (var theChannelId in channelIdList) { if (owningChannelIdList.Contains(theChannelId)) { list.Add(theChannelId); } } } SpContents.SelectCommand = DataProvider.ContentDao.GetSelectedCommendByCheck(tableName, SiteId, list, checkLevelList); SpContents.SortField = ContentAttribute.LastEditDate; SpContents.SortMode = SortMode.DESC; RptContents.ItemDataBound += RptContents_ItemDataBound; SpContents.DataBind(); var showPopWinString = ModalContentCheck.GetOpenWindowStringForMultiChannels(SiteId, PageUrl); BtnCheck.Attributes.Add("onclick", showPopWinString); LtlColumnsHead.Text = TextUtility.GetColumnsHeadHtml(_styleInfoList, _attributesOfDisplay, SiteInfo); if (!HasChannelPermissions(SiteId, ConfigManager.ChannelPermissions.ContentDelete)) { BtnDelete.Visible = false; } else { BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(SiteId, false, PageUrl)); } }
public async Task <ActionResult <GetResult> > Get([FromQuery] GetRequest request) { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, MenuUtils.SitePermissions.Contents) || !await _authManager.HasContentPermissionsAsync(request.SiteId, request.ChannelId, MenuUtils.ContentPermissions.View)) { return(Unauthorized()); } var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(NotFound()); } var channel = await _channelRepository.GetAsync(request.ChannelId); var content = await _contentRepository.GetAsync(site, channel, request.ContentId); if (content == null) { return(NotFound()); } var channelName = await _channelRepository.GetChannelNameNavigationAsync(request.SiteId, request.ChannelId); var columnsManager = new ColumnsManager(_databaseManager, _pathManager); var columns = await columnsManager.GetContentListColumnsAsync(site, channel, ColumnsManager.PageType.Contents); var calculatedContent = await columnsManager.CalculateContentListAsync(1, site, request.ChannelId, content, columns); calculatedContent.Body = content.Body; var siteUrl = await _pathManager.GetSiteUrlAsync(site, true); var groupNames = await _contentGroupRepository.GetGroupNamesAsync(request.SiteId); var tagNames = await _contentTagRepository.GetTagNamesAsync(request.SiteId); var editorColumns = new List <ContentColumn>(); var styles = await _tableStyleRepository.GetContentStylesAsync(site, channel); foreach (var tableStyle in styles) { if (tableStyle.InputType != InputType.TextEditor) { continue; } editorColumns.Add(new ContentColumn { AttributeName = tableStyle.AttributeName, DisplayName = tableStyle.DisplayName }); } return(new GetResult { Content = calculatedContent, ChannelName = channelName, State = CheckManager.GetCheckState(site, content), Columns = columns, SiteUrl = siteUrl, GroupNames = groupNames, TagNames = tagNames, EditorColumns = editorColumns }); }
public IEnumerator PowerUp_UseOnePowerUp_Review(PowerUpTypesEnum powerUpTypeEnum) { #region Create Managers IMasterManager masterManager; ICellRegistrator cellRegistrator; IBoard board = ObjectsCreator.CreateBoard(9, 9, out masterManager, out cellRegistrator); IUpdateManager updateManager = masterManager.UpdateManager; IGameplayLogicManager gameplayLogicManager = ObjectsCreator.CreateGameplayLogicManager(); INotifier gameplayNotifier = masterManager.GameplayNotifier; ISpawnManager spawnManager = masterManager.SpawnManager; IInputManager inputManager = new InputManager(gameplayNotifier); ICheckManager checkManager = new CheckManager(); #endregion #region Create And SetUp Cell with PowerUp ICell cellWithPowerUp = new NormalCell(4, 4); Vector3 cellPosition = new Vector2(4, 4); cellWithPowerUp.CurrentGameObject = spawnManager.SpawnPowerPrefab(powerUpTypeEnum, cellPosition); cellRegistrator.RegistrateNormalCell(cellWithPowerUp as NormalCell); board.Cells[cellWithPowerUp.TargetX, cellWithPowerUp.TargetY] = cellWithPowerUp; #endregion yield return(new WaitForSeconds(0.1f)); #region SetUp Board and Managers board.Initial(); checkManager.Board = board; gameplayLogicManager.Board = board; gameplayLogicManager.CheckManager = checkManager; gameplayLogicManager.SpawnManager = spawnManager; gameplayLogicManager.Notifier = new Notifier(); inputManager.AddSubscriber(gameplayLogicManager); updateManager.AddUpdatable(inputManager as IUpdatable); updateManager.IsUpdate = true; #endregion yield return(new WaitForSeconds(0.3f)); #region Try Use PowerUp int swipeCount = 2; gameplayLogicManager.TryCheckSwipedCells(cellWithPowerUp, swipeCount); #endregion #region Remove From Scene yield return(new WaitForSeconds(2f)); updateManager.IsUpdate = false; foreach (var cell in board.Cells) { GameObject.Destroy(cell.CurrentGameObject); } #endregion }
public IHttpActionResult GetConfig() { try { var request = new AuthenticatedRequest(); var siteId = request.GetQueryInt("siteId"); var channelId = request.GetQueryInt("channelId"); var contentIdList = TranslateUtils.StringCollectionToIntList(request.GetQueryString("contentIds")); var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } var sites = new List <object>(); var channels = new List <object>(); if (channelInfo.Additional.TransType == ECrossSiteTransType.SelfSite || channelInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite || channelInfo.Additional.TransType == ECrossSiteTransType.ParentSite) { int theSiteId; if (channelInfo.Additional.TransType == ECrossSiteTransType.SelfSite) { theSiteId = siteInfo.Id; } else if (channelInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite) { theSiteId = channelInfo.Additional.TransSiteId; } else { theSiteId = SiteManager.GetParentSiteId(siteInfo.Id); } if (theSiteId > 0) { var theSiteInfo = SiteManager.GetSiteInfo(theSiteId); if (theSiteInfo != null) { sites.Add(new { theSiteInfo.Id, theSiteInfo.SiteName }); } } } else if (channelInfo.Additional.TransType == ECrossSiteTransType.AllParentSite) { var siteIdList = SiteManager.GetSiteIdList(); var allParentSiteIdList = new List <int>(); SiteManager.GetAllParentSiteIdList(allParentSiteIdList, siteIdList, siteInfo.Id); foreach (var psId in siteIdList) { if (psId == siteInfo.Id) { continue; } var psInfo = SiteManager.GetSiteInfo(psId); var show = psInfo.IsRoot || allParentSiteIdList.Contains(psInfo.Id); if (show) { sites.Add(new { psInfo.Id, psInfo.SiteName }); } } } else if (channelInfo.Additional.TransType == ECrossSiteTransType.AllSite) { var siteIdList = SiteManager.GetSiteIdList(); foreach (var psId in siteIdList) { var psInfo = SiteManager.GetSiteInfo(psId); sites.Add(new { psInfo.Id, psInfo.SiteName }); } } var retval = new List <Dictionary <string, object> >(); foreach (var contentId in contentIdList) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); if (contentInfo == null) { continue; } var dict = contentInfo.ToDictionary(); dict["checkState"] = CheckManager.GetCheckState(siteInfo, contentInfo); retval.Add(dict); } var channelIdList = ChannelManager.GetChannelIdList(siteInfo.Id); foreach (var permissionChannelId in channelIdList) { var permissionChannelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, permissionChannelId); channels.Add(new { permissionChannelInfo.Id, ChannelName = ChannelManager.GetChannelNameNavigation(siteInfo.Id, permissionChannelId) }); } return(Ok(new { Value = retval, Sites = sites, Channels = channels, Site = siteInfo })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
public IEnumerator PowerUp_UseTwoPowerUp_Review(PowerUpTypesEnum powerUpTypeEnumA, PowerUpTypesEnum powerUpTypeEnumB) { #region Create Managers IMasterManager masterManager; ICellRegistrator cellRegistrator; IBoard board = ObjectsCreator.CreateBoard(9, 9, out masterManager, out cellRegistrator); IUpdateManager updateManager = masterManager.UpdateManager; IGameplayLogicManager gameplayLogicManager = ObjectsCreator.CreateGameplayLogicManager(); INotifier gameplayNotifier = masterManager.GameplayNotifier; ISpawnManager spawnManager = masterManager.SpawnManager; IInputManager inputManager = new InputManager(gameplayNotifier); ICheckManager checkManager = new CheckManager(); #endregion #region Create And SetUp Cells with PowerUp IList <ICell> cellsWithPowerUp = new List <ICell>(); IList <Vector3> positions = new List <Vector3>(); switch (powerUpTypeEnumA) { case PowerUpTypesEnum.Bomb: positions.Add(new Vector2(4, 4)); positions.Add(new Vector2(2, 4)); break; case PowerUpTypesEnum.Vertical: positions.Add(new Vector2(3, 3)); positions.Add(new Vector2(3, 6)); break; case PowerUpTypesEnum.Horizontal: positions.Add(new Vector2(3, 3)); positions.Add(new Vector2(6, 3)); break; } for (int i = 0; i < 2; i++) { ICell cell = new NormalCell((int)positions[i].x, (int)positions[i].y); Vector3 cellPosition = new Vector2((int)positions[i].x, (int)positions[i].y); cell.CurrentGameObject = spawnManager.SpawnPowerPrefab(i == 0 ? powerUpTypeEnumA : powerUpTypeEnumB, positions[i]); cellRegistrator.RegistrateNormalCell(cell as NormalCell); board.Cells[cell.TargetX, cell.TargetY] = cell; cellsWithPowerUp.Add(cell); } #endregion yield return(new WaitForSeconds(0.1f)); #region SetUp Board and Managers board.Initial(); checkManager.Board = board; gameplayLogicManager.Board = board; gameplayLogicManager.CheckManager = checkManager; gameplayLogicManager.SpawnManager = spawnManager; gameplayLogicManager.Notifier = new Notifier(); inputManager.AddSubscriber(gameplayLogicManager); updateManager.AddUpdatable(inputManager as IUpdatable); updateManager.IsUpdate = true; #endregion yield return(new WaitForSeconds(0.3f)); #region Try Use PowerUp int swipeCount = 2; gameplayLogicManager.TryCheckSwipedCells(cellsWithPowerUp[0], swipeCount); #endregion #region Remove From Scene yield return(new WaitForSeconds(2f)); updateManager.IsUpdate = false; foreach (var cell in board.Cells) { GameObject.Destroy(cell.CurrentGameObject); } #endregion }
public ActionResult DeleteResearchChecksForYear(FileViewModel model) { CheckManager.DeleteResearchChecksForYear(Convert.ToInt32(model.Year)); ViewData["DeletedAncientChecks"] = string.Format("Deleted checks for year {0}", model.Year); return(View("RecentChecks")); }
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, true, 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 ActionResult DeleteResearchTable() { CheckManager.DeleteResearchTable(); return(View("RecentChecks")); }
public async Task <ActionResult <GetResult> > Get([FromQuery] GetRequest request) { if (!await _authManager.HasContentPermissionsAsync(request.SiteId, request.ChannelId, MenuUtils.ContentPermissions.Translate)) { return(Unauthorized()); } var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(NotFound()); } var channel = await _channelRepository.GetAsync(request.ChannelId); if (channel == null) { return(NotFound()); } var retVal = new List <IDictionary <string, object> >(); foreach (var contentId in request.ContentIds) { var contentInfo = await _contentRepository.GetAsync(site, channel, contentId); if (contentInfo == null) { continue; } var dict = contentInfo.ToDictionary(); dict["checkState"] = CheckManager.GetCheckState(site, contentInfo); retVal.Add(dict); } var sites = new List <object>(); var channels = new List <object>(); var siteIdList = await _authManager.GetSiteIdsAsync(); foreach (var permissionSiteId in siteIdList) { var permissionSite = await _siteRepository.GetAsync(permissionSiteId); sites.Add(new { permissionSite.Id, permissionSite.SiteName }); } var channelIdList = await _authManager.GetChannelIdsAsync(site.Id, MenuUtils.ContentPermissions.Add); foreach (var permissionChannelId in channelIdList) { var permissionChannelInfo = await _channelRepository.GetAsync(permissionChannelId); channels.Add(new { permissionChannelInfo.Id, ChannelName = await _channelRepository.GetChannelNameNavigationAsync(site.Id, permissionChannelId) }); } return(new GetResult { Value = retVal, Sites = sites, Channels = channels, Site = site }); }
public async Task <ActionResult <GetResult> > Get([FromQuery] GetRequest request) { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, MenuUtils.SitePermissions.Contents) || !await _authManager.HasContentPermissionsAsync(request.SiteId, request.ChannelId, MenuUtils.ContentPermissions.Add, MenuUtils.ContentPermissions.Edit)) { return(Unauthorized()); } var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(NotFound()); } var channel = await _channelRepository.GetAsync(request.ChannelId); if (channel == null) { return(NotFound()); } var groupNames = await _contentGroupRepository.GetGroupNamesAsync(site.Id); var tagNames = await _contentTagRepository.GetTagNamesAsync(site.Id); var allStyles = await _tableStyleRepository.GetContentStylesAsync(site, channel); var styles = allStyles .Where(style => !string.IsNullOrEmpty(style.DisplayName) && !ListUtils.ContainsIgnoreCase(ColumnsManager.MetadataAttributes.Value, style.AttributeName)).ToList(); var templates = await _templateRepository.GetTemplatesByTypeAsync(request.SiteId, TemplateType.ContentTemplate); var(userIsChecked, userCheckedLevel) = await CheckManager.GetUserCheckLevelAsync(_authManager, site, request.ChannelId); var checkedLevels = CheckManager.GetCheckedLevelOptions(site, userIsChecked, userCheckedLevel, true); Content content; if (request.ContentId > 0) { content = await _pathManager.DecodeContentAsync(site, channel, request.ContentId); } else { content = new Content { Id = 0, SiteId = site.Id, ChannelId = channel.Id, AddDate = DateTime.Now, CheckedLevel = site.CheckContentDefaultLevel }; } foreach (var style in styles) { if (style.InputType == InputType.CheckBox || style.InputType == InputType.SelectMultiple) { if (request.ContentId == 0) { var value = style.Items != null ? style.Items.Where(x => x.Selected).Select(x => x.Value).ToList() : new List <string>(); content.Set(style.AttributeName, value); } else { var value = content.Get(style.AttributeName); content.Set(style.AttributeName, ListUtils.ToList(value)); } } else if (style.InputType == InputType.Radio || style.InputType == InputType.SelectOne) { if (request.ContentId == 0) { var item = style.Items?.FirstOrDefault(x => x.Selected); var value = item != null ? item.Value : string.Empty; content.Set(style.AttributeName, value); } else { var value = content.Get(style.AttributeName); content.Set(style.AttributeName, StringUtils.ToString(value)); } } else if (style.InputType == InputType.Text || style.InputType == InputType.TextArea || style.InputType == InputType.TextEditor) { content.Set(style.AttributeName, string.Empty); } } var siteUrl = await _pathManager.GetSiteUrlAsync(site, true); var isCensorTextEnabled = await _censorManager.IsTextEnabledAsync(); return(new GetResult { Content = content, Site = site, SiteUrl = StringUtils.TrimEndSlash(siteUrl), Channel = channel, GroupNames = groupNames, TagNames = tagNames, Styles = styles, Templates = templates, CheckedLevels = checkedLevels, CheckedLevel = userCheckedLevel, IsCensorTextEnabled = isCensorTextEnabled }); }
public async Task <ActionResult <TreeResult> > Tree([FromBody] TreeRequest request) { var siteIdList = await _authManager.GetSiteIdsAsync(); if (siteIdList == null || siteIdList.Count == 0) { return(Unauthorized()); } var sites = new List <Select <int> >(); Site site = null; foreach (var siteId in siteIdList) { var permissionSite = await _siteRepository.GetAsync(siteId); if (request.SiteId == siteId) { site = permissionSite; } sites.Add(new Select <int> { Value = permissionSite.Id, Label = permissionSite.SiteName }); } if (site == null && siteIdList.Count > 0) { site = await _siteRepository.GetAsync(siteIdList[0]); } if (site == null) { return(Unauthorized()); } var channel = await _channelRepository.GetAsync(site.Id); var root = await _channelRepository.GetCascadeAsync(site, channel, async summary => { var count = await _contentRepository.GetCountAsync(site, summary); return(new { Count = count }); }); if (!request.Reload) { var siteUrl = await _pathManager.GetSiteUrlAsync(site, true); var groupNames = await _contentGroupRepository.GetGroupNamesAsync(site.Id); var tagNames = await _contentTagRepository.GetTagNamesAsync(site.Id); var checkedLevels = ElementUtils.GetCheckBoxes(CheckManager.GetCheckedLevels(site, true, site.CheckContentLevel, true)); var columnsManager = new ColumnsManager(_databaseManager, _pathManager); var columns = await columnsManager.GetContentListColumnsAsync(site, channel, ColumnsManager.PageType.SearchContents); var permissions = new TreePermissions { IsAdd = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, Types.ContentPermissions.Add), IsDelete = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, Types.ContentPermissions.Delete), IsEdit = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, Types.ContentPermissions.Edit), IsArrange = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, Types.ContentPermissions.Arrange), IsTranslate = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, Types.ContentPermissions.Translate), IsCheck = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, Types.ContentPermissions.CheckLevel1), IsCreate = await _authManager.HasSitePermissionsAsync(site.Id, Types.SitePermissions.CreateContents) || await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, Types.ContentPermissions.Create), IsChannelEdit = await _authManager.HasChannelPermissionsAsync(site.Id, channel.Id, Types.ChannelPermissions.Edit) }; return(new TreeResult { Sites = sites, SiteId = site.Id, SiteName = site.SiteName, SiteUrl = siteUrl, Root = root, GroupNames = groupNames, TagNames = tagNames, CheckedLevels = checkedLevels, Columns = columns, Permissions = permissions }); } return(new TreeResult { Root = root }); }
private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } var contentInfo = new ContentInfo((IDataRecord)e.Item.DataItem); var ltlTitle = (Literal)e.Item.FindControl("ltlTitle"); var ltlColumns = (Literal)e.Item.FindControl("ltlColumns"); var ltlStatus = (Literal)e.Item.FindControl("ltlStatus"); var ltlCommands = (Literal)e.Item.FindControl("ltlCommands"); var ltlSelect = (Literal)e.Item.FindControl("ltlSelect"); ltlTitle.Text = WebUtils.GetContentTitle(SiteInfo, contentInfo, PageUrl); ltlColumns.Text = TextUtility.GetColumnsHtml(_nameValueCacheDict, SiteInfo, contentInfo, _attributesOfDisplay, _allStyleInfoList, _pluginColumns); ltlStatus.Text = $@"<a href=""javascript:;"" title=""设置内容状态"" onclick=""{ModalCheckState.GetOpenWindowString(SiteId, contentInfo, PageUrl)}"">{CheckManager.GetCheckState(SiteInfo, contentInfo)}</a>"; var pluginMenus = PluginMenuManager.GetContentMenus(_pluginIds, contentInfo); ltlCommands.Text = TextUtility.GetCommandsHtml(SiteInfo, pluginMenus, contentInfo, PageUrl, AuthRequest.AdminName, _isEdit); ltlSelect.Text = $@"<input type=""checkbox"" name=""contentIdCollection"" value=""{contentInfo.Id}"" />"; }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId", "ReturnUrl"); _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("ReturnUrl")); _idsDictionary = ContentUtility.GetIDsDictionary(Request.QueryString); if (IsPostBack) { return; } var titles = new StringBuilder(); foreach (var channelId in _idsDictionary.Keys) { var tableName = ChannelManager.GetTableName(SiteInfo, channelId); var contentIdList = _idsDictionary[channelId]; foreach (var contentId in contentIdList) { var title = DataProvider.ContentDao.GetValue(tableName, contentId, ContentAttribute.Title); titles.Append(title + "<br />"); } } if (!string.IsNullOrEmpty(LtlTitles.Text)) { titles.Length -= 6; } LtlTitles.Text = titles.ToString(); var checkedLevel = 5; var isChecked = true; foreach (var channelId in _idsDictionary.Keys) { int checkedLevelByChannelId; var isCheckedByChannelId = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissions, SiteInfo, channelId, out checkedLevelByChannelId); if (checkedLevel > checkedLevelByChannelId) { checkedLevel = checkedLevelByChannelId; } if (!isCheckedByChannelId) { isChecked = false; } } CheckManager.LoadContentLevelToCheck(DdlCheckType, SiteInfo, isChecked, checkedLevel); var listItem = new ListItem("<保持原栏目不变>", "0"); DdlTranslateChannelId.Items.Add(listItem); ChannelManager.AddListItemsForAddContent(DdlTranslateChannelId.Items, SiteInfo, true, AuthRequest.AdminPermissions); }
public static List <ImportRow> GetImportRows() { List <Check> researchChecks = CheckManager.GetResearchChecks(); List <ImportRow> importRows = new List <ImportRow>(); // Each resolved check creates a new import row or updates an existing one. foreach (CheckViewModel resolvedCheck in CheckManager.GetResolvedChecksAsList()) { string disposition = resolvedCheck.Disposition; //GetDispositionFromCheck(resolvedCheck); if (disposition != null && !disposition.Equals("Unknown")) { List <ImportRow> irows = (from irow in importRows where irow.LBVDCheckNum == resolvedCheck.Num || irow.LBVDCheckNum2 == resolvedCheck.Num || irow.LBVDCheckNum3 == resolvedCheck.Num || irow.TIDCheckNum == resolvedCheck.Num || irow.TIDCheckNum2 == resolvedCheck.Num || irow.TIDCheckNum3 == resolvedCheck.Num || irow.TDLCheckNum == resolvedCheck.Num || irow.TDLCheckNum2 == resolvedCheck.Num || irow.TDLCheckNum3 == resolvedCheck.Num || irow.MBVDCheckNum == resolvedCheck.Num || irow.MBVDCheckNum2 == resolvedCheck.Num || irow.MBVDCheckNum3 == resolvedCheck.Num // Supporting document checks /* || irow.SDCheckNum1 == resolvedCheck.Num || irow.SDCheckNum2 == resolvedCheck.Num || irow.SDCheckNum3 == resolvedCheck.Num || || irow.SDCheckNum12 == resolvedCheck.Num || irow.SDCheckNum22 == resolvedCheck.Num || irow.SDCheckNum32 == resolvedCheck.Num || || irow.SDCheckNum13 == resolvedCheck.Num || irow.SDCheckNum23 == resolvedCheck.Num || irow.SDCheckNum33 == resolvedCheck.Num */ // Does resolvedCheck match an existing importRow by ID? // This is the case where there is more than one check on an import row, IR, // and resolvedCheck will be used to update row IR. || (resolvedCheck.InterviewRecordID != 0 && irow.InterviewRecordID == resolvedCheck.InterviewRecordID) || (resolvedCheck.RecordID != 0 && irow.RecordID == resolvedCheck.RecordID) select irow).ToList(); if (irows.Count() == 0) { // There is no import row representing this resolved check. // Create one. importRows.Add(NewImportRow(researchChecks, resolvedCheck, disposition)); } else { bool added = false; foreach (ImportRow irow in irows) { if ((resolvedCheck.Service == "LBVD" || resolvedCheck.Service == "LBVD2" || resolvedCheck.Service == "LBVD3" || resolvedCheck.Service == "TID" || resolvedCheck.Service == "TID2" || resolvedCheck.Service == "TID3" || resolvedCheck.Service == "TDL" || resolvedCheck.Service == "TDL2" || resolvedCheck.Service == "TDL3" || resolvedCheck.Service == "MBVD" || resolvedCheck.Service == "MBVD2" || resolvedCheck.Service == "MBVD3") && ((resolvedCheck.InterviewRecordID != 0 && resolvedCheck.InterviewRecordID != irow.InterviewRecordID) || (resolvedCheck.RecordID != 0 && resolvedCheck.RecordID != irow.RecordID))) { // Case of same check number being used for multiple // birth certificates. if (!added) { // Log.Debug(string.Format("resolvedCheck: RecordID {0}, InterviewRecordID {1}, Num: {2}, Name: {3}", resolvedCheck.RecordID, resolvedCheck.InterviewRecordID, resolvedCheck.Num, resolvedCheck.Name)); importRows.Add(NewImportRow(researchChecks, resolvedCheck, disposition)); // Prevent the same resolved check from being added twice. added = true; } } else { // Found row among existing import rows. There is more than one check // number on this row. In other words, the client had more than // one check written for the visit this row corresponds to. UpdateExistingImportRow(resolvedCheck, disposition, irow); } } } } } return(importRows); }
public async Task <ActionResult <TreeResult> > Tree([FromBody] TreeRequest request) { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, MenuUtils.SitePermissions.Contents)) { return(Unauthorized()); } var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(NotFound()); } var channel = await _channelRepository.GetAsync(request.SiteId); var enabledChannelIds = await _authManager.GetContentPermissionsChannelIdsAsync(site.Id); var visibleChannelIds = await _authManager.GetVisibleChannelIdsAsync(enabledChannelIds); var root = await _channelRepository.GetCascadeAsync(site, channel, async summary => { var visible = visibleChannelIds.Contains(summary.Id); var disabled = !enabledChannelIds.Contains(summary.Id); var current = await _contentRepository.GetSummariesAsync(site, summary); if (!visible) { return(null); } return(new { current.Count, Disabled = disabled }); }); if (!request.Reload) { var siteUrl = await _pathManager.GetSiteUrlAsync(site, true); var groupNames = await _contentGroupRepository.GetGroupNamesAsync(request.SiteId); var tagNames = await _contentTagRepository.GetTagNamesAsync(request.SiteId); var checkedLevels = ElementUtils.GetCheckBoxes(CheckManager.GetCheckedLevels(site, true, site.CheckContentLevel, true)); return(new TreeResult { Root = root, SiteUrl = siteUrl, GroupNames = groupNames, TagNames = tagNames, CheckedLevels = checkedLevels }); } return(new TreeResult { Root = root }); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId"); _channelId = AuthRequest.IsQueryExists("channelId") ? AuthRequest.GetQueryInt("channelId") : SiteId; _isCheckOnly = AuthRequest.GetQueryBool("isCheckOnly"); _isTrashOnly = AuthRequest.GetQueryBool("isTrashOnly"); _isWritingOnly = AuthRequest.GetQueryBool("isWritingOnly"); _isAdminOnly = AuthRequest.GetQueryBool("isAdminOnly"); _channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); var tableName = ChannelManager.GetTableName(SiteInfo, _channelInfo); _styleInfoList = TableStyleManager.GetContentStyleInfoList(SiteInfo, _channelInfo); _attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(ChannelManager.GetContentAttributesOfDisplay(SiteId, _channelId)); _allStyleInfoList = ContentUtility.GetAllTableStyleInfoList(_styleInfoList); _pluginIds = PluginContentManager.GetContentPluginIds(_channelInfo); _pluginColumns = PluginContentManager.GetContentColumns(_pluginIds); _isEdit = TextUtility.IsEdit(SiteInfo, _channelId, AuthRequest.AdminPermissionsImpl); var state = AuthRequest.IsQueryExists("state") ? AuthRequest.GetQueryInt("state") : CheckManager.LevelInt.All; var searchType = AuthRequest.IsQueryExists("searchType") ? AuthRequest.GetQueryString("searchType") : ContentAttribute.Title; var dateFrom = AuthRequest.IsQueryExists("dateFrom") ? AuthRequest.GetQueryString("dateFrom") : string.Empty; var dateTo = AuthRequest.IsQueryExists("dateTo") ? AuthRequest.GetQueryString("dateTo") : string.Empty; var keyword = AuthRequest.IsQueryExists("keyword") ? AuthRequest.GetQueryString("keyword") : string.Empty; var checkedLevel = 5; var isChecked = true; foreach (var owningChannelId in AuthRequest.AdminPermissionsImpl.ChannelIdList) { int checkedLevelByChannelId; var isCheckedByChannelId = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissionsImpl, SiteInfo, owningChannelId, out checkedLevelByChannelId); if (checkedLevel > checkedLevelByChannelId) { checkedLevel = checkedLevelByChannelId; } if (!isCheckedByChannelId) { isChecked = false; } } RptContents.ItemDataBound += RptContents_ItemDataBound; var allAttributeNameList = TableColumnManager.GetTableColumnNameList(tableName, DataType.Text); var adminId = _isAdminOnly ? AuthRequest.AdminId : AuthRequest.AdminPermissionsImpl.GetAdminId(SiteInfo.Id, _channelInfo.Id); var whereString = DataProvider.ContentDao.GetPagerWhereSqlString(SiteInfo, _channelInfo, searchType, keyword, dateFrom, dateTo, state, _isCheckOnly, false, _isTrashOnly, _isWritingOnly, adminId, AuthRequest.AdminPermissionsImpl, allAttributeNameList); PgContents.Param = new PagerParam { ControlToPaginate = RptContents, TableName = tableName, PageSize = SiteInfo.Additional.PageSize, Page = AuthRequest.GetQueryInt(Pager.QueryNamePage, 1), OrderSqlString = ETaxisTypeUtils.GetContentOrderByString(ETaxisType.OrderByIdDesc), ReturnColumnNames = TranslateUtils.ObjectCollectionToString(allAttributeNameList), WhereSqlString = whereString, TotalCount = DataProvider.DatabaseDao.GetPageTotalCount(tableName, whereString) }; if (IsPostBack) { return; } if (_isTrashOnly) { if (AuthRequest.IsQueryExists("IsDeleteAll")) { //DataProvider.ContentDao.DeleteContentsByTrash(SiteId, _channelId, tableName); var list = DataProvider.ContentDao.GetContentIdListByTrash(SiteId, tableName); foreach (var(contentChannelId, contentId) in list) { ContentUtility.Delete(tableName, SiteInfo, contentChannelId, contentId); } AuthRequest.AddSiteLog(SiteId, "清空回收站"); SuccessMessage("成功清空回收站!"); } else if (AuthRequest.IsQueryExists("IsRestore")) { var idsDictionary = ContentUtility.GetIDsDictionary(Request.QueryString); foreach (var channelId in idsDictionary.Keys) { var contentIdList = idsDictionary[channelId]; DataProvider.ContentDao.UpdateTrashContents(SiteId, channelId, ChannelManager.GetTableName(SiteInfo, channelId), contentIdList); } AuthRequest.AddSiteLog(SiteId, "从回收站还原内容"); SuccessMessage("成功还原内容!"); } else if (AuthRequest.IsQueryExists("IsRestoreAll")) { DataProvider.ContentDao.UpdateRestoreContentsByTrash(SiteId, _channelId, tableName); AuthRequest.AddSiteLog(SiteId, "从回收站还原所有内容"); SuccessMessage("成功还原所有内容!"); } } ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, true, true, AuthRequest.AdminPermissionsImpl); if (_isCheckOnly) { CheckManager.LoadContentLevelToCheck(DdlState, SiteInfo, isChecked, checkedLevel); } else { CheckManager.LoadContentLevelToList(DdlState, SiteInfo, _isCheckOnly, isChecked, checkedLevel); } ControlUtils.SelectSingleItem(DdlState, state.ToString()); foreach (var styleInfo in _allStyleInfoList) { if (styleInfo.InputType == InputType.TextEditor) { continue; } var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName); DdlSearchType.Items.Add(listitem); } //ETriStateUtils.AddListItems(DdlState, "全部", "已审核", "待审核"); if (SiteId != _channelId) { ControlUtils.SelectSingleItem(DdlChannelId, _channelId.ToString()); } //ControlUtils.SelectSingleItem(DdlState, AuthRequest.GetQueryString("State")); ControlUtils.SelectSingleItem(DdlSearchType, searchType); TbKeyword.Text = keyword; TbDateFrom.Text = dateFrom; TbDateTo.Text = dateTo; PgContents.DataBind(); LtlColumnsHead.Text += TextUtility.GetColumnsHeadHtml(_styleInfoList, _pluginColumns, _attributesOfDisplay); BtnSelect.Attributes.Add("onclick", ModalSelectColumns.GetOpenWindowString(SiteId, _channelId)); if (_isTrashOnly) { LtlColumnsHead.Text += @"<th class=""text-center text-nowrap"" width=""150"">删除时间</th>"; BtnAddToGroup.Visible = BtnTranslate.Visible = BtnCheck.Visible = false; PhTrash.Visible = true; if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentDelete)) { BtnDelete.Visible = false; BtnDeleteAll.Visible = false; } else { BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(SiteId, true, PageUrl)); BtnDeleteAll.Attributes.Add("onclick", PageUtils.GetRedirectStringWithConfirm(PageUtils.AddQueryString(PageUrl, "IsDeleteAll", "True"), "确实要清空回收站吗?")); } BtnRestore.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValue(PageUtils.AddQueryString(PageUrl, "IsRestore", "True"), "IDsCollection", "IDsCollection", "请选择需要还原的内容!")); BtnRestoreAll.Attributes.Add("onclick", PageUtils.GetRedirectStringWithConfirm(PageUtils.AddQueryString(PageUrl, "IsRestoreAll", "True"), "确实要还原所有内容吗?")); } else { LtlColumnsHead.Text += @"<th class=""text-center text-nowrap"" width=""100"">操作</th>"; BtnAddToGroup.Attributes.Add("onclick", ModalAddToGroup.GetOpenWindowStringToContentForMultiChannels(SiteId)); if (HasChannelPermissions(SiteId, ConfigManager.ChannelPermissions.ContentCheck)) { BtnCheck.Attributes.Add("onclick", ModalContentCheck.GetOpenWindowStringForMultiChannels(SiteId, PageUrl)); if (_isCheckOnly) { BtnCheck.CssClass = "btn m-r-5 btn-success"; } } else { PhCheck.Visible = false; } if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentTranslate)) { BtnTranslate.Visible = false; } else { BtnTranslate.Attributes.Add("onclick", PageContentTranslate.GetRedirectClickStringForMultiChannels(SiteId, PageUrl)); } if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentDelete)) { BtnDelete.Visible = false; } else { BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(SiteId, false, PageUrl)); } } }
public async Task <ActionResult <ListResult> > List([FromBody] ListRequest request) { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, MenuUtils.SitePermissions.Contents) || !await _authManager.HasContentPermissionsAsync(request.SiteId, request.ChannelId, MenuUtils.ContentPermissions.View, MenuUtils.ContentPermissions.Add, MenuUtils.ContentPermissions.Edit, MenuUtils.ContentPermissions.Delete, MenuUtils.ContentPermissions.Translate, MenuUtils.ContentPermissions.Arrange, MenuUtils.ContentPermissions.CheckLevel1, MenuUtils.ContentPermissions.CheckLevel2, MenuUtils.ContentPermissions.CheckLevel3, MenuUtils.ContentPermissions.CheckLevel4, MenuUtils.ContentPermissions.CheckLevel5)) { return(Unauthorized()); } var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(NotFound()); } var channel = await _channelRepository.GetAsync(request.ChannelId); if (channel == null) { return(this.Error("无法确定内容对应的栏目")); } if (channel.IsPreviewContentsExists) { await _contentRepository.DeletePreviewAsync(site, channel); } var columnsManager = new ColumnsManager(_databaseManager, _pathManager); var columns = await columnsManager.GetContentListColumnsAsync(site, channel, ColumnsManager.PageType.Contents); var pageContents = new List <Content>(); List <ContentSummary> summaries; if (!string.IsNullOrEmpty(request.SearchType) && !string.IsNullOrEmpty(request.SearchText) || request.IsAdvanced) { summaries = await _contentRepository.SearchAsync(site, channel, channel.IsAllContents, request.SearchType, request.SearchText, request.IsAdvanced, request.CheckedLevels, request.IsTop, request.IsRecommend, request.IsHot, request.IsColor, request.GroupNames, request.TagNames); } else { summaries = await _contentRepository.GetSummariesAsync(site, channel, channel.IsAllContents); } var total = summaries.Count; var channelPlugins = _pluginManager.GetPlugins(request.SiteId, request.ChannelId); var contentMenus = new List <Menu>(); foreach (var plugin in channelPlugins) { var pluginMenus = plugin.GetMenus() .Where(x => ListUtils.ContainsIgnoreCase(x.Type, Types.Resources.Content)).ToList(); if (pluginMenus.Count == 0) { continue; } contentMenus.AddRange(pluginMenus); } if (total > 0) { var offset = site.PageSize * (request.Page - 1); var pageSummaries = summaries.Skip(offset).Take(site.PageSize).ToList(); var sequence = offset + 1; foreach (var summary in pageSummaries) { var content = await _contentRepository.GetAsync(site, summary.ChannelId, summary.Id); if (content == null) { continue; } var pageContent = await columnsManager.CalculateContentListAsync(sequence ++, site, request.ChannelId, content, columns); pageContents.Add(pageContent); } } var(isChecked, checkedLevel) = await CheckManager.GetUserCheckLevelAsync(_authManager, site, request.ChannelId); var checkedLevels = ElementUtils.GetCheckBoxes(CheckManager.GetCheckedLevels(site, isChecked, checkedLevel, true)); var permissions = new Permissions { IsAdd = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, MenuUtils.ContentPermissions.Add), IsDelete = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, MenuUtils.ContentPermissions.Delete), IsEdit = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, MenuUtils.ContentPermissions.Edit), IsArrange = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, MenuUtils.ContentPermissions.Arrange), IsTranslate = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, MenuUtils.ContentPermissions.Translate), IsCheck = await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, MenuUtils.ContentPermissions.CheckLevel1), IsCreate = await _authManager.HasSitePermissionsAsync(site.Id, MenuUtils.SitePermissions.CreateContents) || await _authManager.HasContentPermissionsAsync(site.Id, channel.Id, MenuUtils.ContentPermissions.Create), IsChannelEdit = await _authManager.HasChannelPermissionsAsync(site.Id, channel.Id, MenuUtils.ChannelPermissions.Edit) }; var titleColumn = columns.FirstOrDefault(x => StringUtils.EqualsIgnoreCase(x.AttributeName, nameof(Models.Content.Title))); columns.Remove(titleColumn); return(new ListResult { PageContents = pageContents, Total = total, PageSize = site.PageSize, TitleColumn = titleColumn, Columns = columns, IsAllContents = channel.IsAllContents, CheckedLevels = checkedLevels, Permissions = permissions, Menus = contentMenus }); }
public void CheckManager_Create_NotNull() { ICheckManager checkManager = new CheckManager(); Assert.IsNotNull(checkManager); }