public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } try { foreach (var channelId in _idsDictionary.Keys) { var tableName = ChannelManager.GetTableName(SiteInfo, channelId); var contentIdList = _idsDictionary[channelId]; if (!_isDeleteFromTrash) { if (bool.Parse(RblRetainFiles.SelectedValue) == false) { DeleteManager.DeleteContents(SiteInfo, channelId, contentIdList); SuccessMessage("成功删除内容以及生成页面!"); } else { SuccessMessage("成功删除内容,生成页面未被删除!"); } if (contentIdList.Count == 1) { var contentId = contentIdList[0]; var contentTitle = DataProvider.ContentDao.GetValue(tableName, contentId, ContentAttribute.Title); AuthRequest.AddSiteLog(SiteId, channelId, contentId, "删除内容", $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, channelId)},内容标题:{contentTitle}"); } else { AuthRequest.AddSiteLog(SiteId, "批量删除内容", $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, channelId)},内容条数:{contentIdList.Count}"); } DataProvider.ContentDao.UpdateTrashContents(SiteId, channelId, tableName, contentIdList); //引用内容,需要删除 //var siteTableNameList = SiteManager.GetTableNameList(); //foreach (var siteTableName in siteTableNameList) //{ // var targetContentIdList = DataProvider.ContentDao.GetReferenceIdList(siteTableName, contentIdList); // if (targetContentIdList.Count > 0) // { // var targetContentInfo = ContentManager.GetContentInfo(siteTableName, TranslateUtils.ToInt(targetContentIdList[0].ToString())); // DataProvider.ContentDao.DeleteContents(targetContentInfo.SiteId, siteTableName, targetContentIdList, targetContentInfo.ChannelId); // } //} CreateManager.TriggerContentChangedEvent(SiteId, channelId); } else { SuccessMessage("成功从回收站清空内容!"); DataProvider.ContentDao.DeleteContents(SiteId, tableName, contentIdList, channelId); AuthRequest.AddSiteLog(SiteId, "从回收站清空内容", $"内容条数:{contentIdList.Count}"); } } AddWaitAndRedirectScript(_returnUrl); } catch (Exception ex) { LogUtils.AddErrorLog(ex); FailMessage(ex, "删除内容失败!"); } }
public IHttpActionResult Submit() { try { var request = new AuthenticatedRequest(); var siteId = request.GetPostInt("siteId"); var channelId = request.GetPostInt("channelId"); var channelContentIds = MinContentInfo.ParseMinContentInfoList(request.GetPostString("channelContentIds")); var isUp = request.GetPostBool("isUp"); var taxis = request.GetPostInt("taxis"); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentEdit)) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } if (ETaxisTypeUtils.Equals(channelInfo.Additional.DefaultTaxisType, ETaxisType.OrderByTaxis)) { isUp = !isUp; } if (isUp == false) { channelContentIds.Reverse(); } foreach (var channelContentId in channelContentIds) { var contentChannelInfo = ChannelManager.GetChannelInfo(siteId, channelContentId.ChannelId); var tableName = ChannelManager.GetTableName(siteInfo, contentChannelInfo); var contentInfo = ContentManager.GetContentInfo(siteInfo, contentChannelInfo, channelContentId.Id); if (contentInfo == null) { continue; } var isTop = contentInfo.IsTop; for (var i = 1; i <= taxis; i++) { if (isUp) { if (DataProvider.ContentDao.SetTaxisToUp(siteId, tableName, channelContentId.ChannelId, channelContentId.Id, isTop) == false) { break; } } else { if (DataProvider.ContentDao.SetTaxisToDown(siteId, tableName, channelContentId.ChannelId, channelContentId.Id, isTop) == false) { break; } } } } foreach (var distinctChannelId in channelContentIds.Select(x => x.ChannelId).Distinct()) { CreateManager.TriggerContentChangedEvent(siteId, distinctChannelId); } request.AddSiteLog(siteId, channelId, 0, "对内容排序", string.Empty); return(Ok(new { Value = true })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
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 channelInfo = ChannelManager.GetChannelInfo(SiteInfo.Id, channelId); var contentIdList = _idsDictionary[channelId]; var contentIdListToCheck = new List <int>(); int checkedLevelOfUser; var isCheckedOfUser = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissionsImpl, SiteInfo, channelId, out checkedLevelOfUser); foreach (var contentId in contentIdList) { var contentInfo = ContentManager.GetContentInfo(SiteInfo, channelInfo, contentId); if (contentInfo != null) { if (CheckManager.IsCheckable(contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser)) { contentInfoListToCheck.Add(contentInfo); contentIdListToCheck.Add(contentId); } //DataProvider.ContentDao.Update(SiteInfo, channelInfo, contentInfo); //CreateManager.CreateContent(SiteId, contentInfo.ChannelId, contentId); //CreateManager.TriggerContentChangedEvent(SiteId, contentInfo.ChannelId); } } 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, AuthRequest.AdminName, isChecked, checkedLevel, TbCheckReasons.Text); } if (translateChannelId > 0) { var tableName = ChannelManager.GetTableName(SiteInfo, translateChannelId); ContentManager.RemoveCache(SiteInfo.Id, translateChannelId, tableName); } 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.CreateContent(SiteId, channelId, contentId); CreateManager.TriggerContentChangedEvent(SiteId, channelId); } } } LayerUtils.CloseAndRedirect(Page, _returnUrl); }
public static void Translate(SiteInfo siteInfo, int channelId, int contentId, int targetSiteId, int targetChannelId, ETranslateContentType translateType) { if (siteInfo == null || channelId <= 0 || contentId <= 0 || targetSiteId <= 0 || targetChannelId <= 0) { return; } var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId); var targetChannelInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId); var targetTableName = ChannelManager.GetTableName(targetSiteInfo, targetChannelInfo); var channelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId); var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); if (contentInfo == null) { return; } if (translateType == ETranslateContentType.Copy) { FileUtility.MoveFileByContentInfo(siteInfo, targetSiteInfo, contentInfo); contentInfo.SiteId = targetSiteId; contentInfo.SourceId = contentInfo.ChannelId; contentInfo.ChannelId = targetChannelId; contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.Copy.ToString()); //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Copy.ToString()); var theContentId = DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, targetChannelInfo, contentInfo); foreach (var service in PluginManager.Services) { try { service.OnContentTranslateCompleted(new ContentTranslateEventArgs(siteInfo.Id, channelInfo.Id, contentId, targetSiteId, targetChannelId, theContentId)); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentTranslateCompleted)); } } CreateManager.CreateContent(targetSiteInfo.Id, contentInfo.ChannelId, theContentId); CreateManager.TriggerContentChangedEvent(targetSiteInfo.Id, contentInfo.ChannelId); } else if (translateType == ETranslateContentType.Cut) { FileUtility.MoveFileByContentInfo(siteInfo, targetSiteInfo, contentInfo); contentInfo.SiteId = targetSiteId; contentInfo.SourceId = contentInfo.ChannelId; contentInfo.ChannelId = targetChannelId; contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.Cut.ToString()); //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Cut.ToString()); var newContentId = DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, targetChannelInfo, contentInfo); DataProvider.ContentDao.DeleteContents(siteInfo.Id, tableName, TranslateUtils.ToIntList(contentId), channelId); foreach (var service in PluginManager.Services) { try { service.OnContentTranslateCompleted(new ContentTranslateEventArgs(siteInfo.Id, channelInfo.Id, contentId, targetSiteId, targetChannelId, newContentId)); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentTranslateCompleted)); } try { service.OnContentDeleteCompleted(new ContentEventArgs(siteInfo.Id, channelInfo.Id, contentId)); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentDeleteCompleted)); } } CreateManager.CreateContent(targetSiteInfo.Id, contentInfo.ChannelId, newContentId); CreateManager.TriggerContentChangedEvent(targetSiteInfo.Id, contentInfo.ChannelId); } else if (translateType == ETranslateContentType.Reference) { if (contentInfo.ReferenceId != 0) { return; } contentInfo.SiteId = targetSiteId; contentInfo.SourceId = contentInfo.ChannelId; contentInfo.ChannelId = targetChannelId; contentInfo.ReferenceId = contentId; contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.Reference.ToString()); //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Reference.ToString()); int theContentId = DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, targetChannelInfo, contentInfo); CreateManager.CreateContent(targetSiteInfo.Id, contentInfo.ChannelId, theContentId); CreateManager.TriggerContentChangedEvent(targetSiteInfo.Id, contentInfo.ChannelId); } else if (translateType == ETranslateContentType.ReferenceContent) { if (contentInfo.ReferenceId != 0) { return; } FileUtility.MoveFileByContentInfo(siteInfo, targetSiteInfo, contentInfo); contentInfo.SiteId = targetSiteId; contentInfo.SourceId = contentInfo.ChannelId; contentInfo.ChannelId = targetChannelId; contentInfo.ReferenceId = contentId; contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.ReferenceContent.ToString()); var theContentId = DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, targetChannelInfo, contentInfo); foreach (var service in PluginManager.Services) { try { service.OnContentTranslateCompleted(new ContentTranslateEventArgs(siteInfo.Id, channelInfo.Id, contentId, targetSiteId, targetChannelId, theContentId)); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentTranslateCompleted)); } } CreateManager.CreateContent(targetSiteInfo.Id, contentInfo.ChannelId, theContentId); CreateManager.TriggerContentChangedEvent(targetSiteInfo.Id, contentInfo.ChannelId); } }
public IHttpActionResult Submit() { try { var request = new AuthenticatedRequest(); var siteId = request.GetPostInt("siteId"); var channelId = request.GetPostInt("channelId"); var isFirstLineTitle = request.GetPostBool("isFirstLineTitle"); var isFirstLineRemove = request.GetPostBool("isFirstLineRemove"); var isClearFormat = request.GetPostBool("isClearFormat"); var isFirstLineIndent = request.GetPostBool("isFirstLineIndent"); var isClearFontSize = request.GetPostBool("isClearFontSize"); var isClearFontFamily = request.GetPostBool("isClearFontFamily"); var isClearImages = request.GetPostBool("isClearImages"); var checkedLevel = request.GetPostInt("checkedLevel"); var fileNames = TranslateUtils.StringCollectionToStringList(request.GetPostString("fileNames")); if (!request.IsUserLoggin || !request.UserPermissionsImpl.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentAdd)) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var styleInfoList = TableStyleManager.GetContentStyleInfoList(siteInfo, channelInfo); var isChecked = checkedLevel >= siteInfo.Additional.CheckContentLevel; var contentIdList = new List <int>(); foreach (var fileName in fileNames) { if (string.IsNullOrEmpty(fileName)) { continue; } var formCollection = WordUtils.GetWordNameValueCollection(siteId, isFirstLineTitle, isFirstLineRemove, isClearFormat, isFirstLineIndent, isClearFontSize, isClearFontFamily, isClearImages, fileName); if (string.IsNullOrEmpty(formCollection[ContentAttribute.Title])) { continue; } var dict = BackgroundInputTypeParser.SaveAttributes(siteInfo, styleInfoList, formCollection, ContentAttribute.AllAttributes.Value); var contentInfo = new ContentInfo(dict) { ChannelId = channelInfo.Id, SiteId = siteId, AddUserName = request.AdminName, AddDate = DateTime.Now, SourceId = SourceManager.User, AdminId = request.AdminId, UserId = request.UserId, IsChecked = isChecked, CheckedLevel = checkedLevel }; contentInfo.LastEditUserName = contentInfo.AddUserName; contentInfo.LastEditDate = contentInfo.AddDate; contentInfo.Title = formCollection[ContentAttribute.Title]; contentInfo.Id = DataProvider.ContentDao.Insert(tableName, siteInfo, channelInfo, contentInfo); contentIdList.Add(contentInfo.Id); } if (isChecked) { foreach (var contentId in contentIdList) { CreateManager.CreateContent(siteId, channelInfo.Id, contentId); } CreateManager.TriggerContentChangedEvent(siteId, channelInfo.Id); } return(Ok(new { Value = contentIdList })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
public IHttpActionResult Submit() { try { var request = new RequestImpl(); var siteId = request.GetPostInt("siteId"); var channelId = request.GetPostInt("channelId"); var contentIdList = TranslateUtils.StringCollectionToIntList(request.GetPostString("contentIds")); var checkedLevel = request.GetPostInt("checkedLevel"); var isTranslate = request.GetPostBool("isTranslate"); var translateChannelId = request.GetPostInt("translateChannelId"); var reasons = request.GetPostString("reasons"); if (!request.IsUserLoggin || !request.UserPermissionsImpl.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 isChecked = checkedLevel >= siteInfo.Additional.CheckContentLevel; if (isChecked) { checkedLevel = 0; } var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var contentInfoList = new List <ContentInfo>(); foreach (var contentId in contentIdList) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); if (contentInfo == null) { continue; } contentInfo.Set(ContentAttribute.CheckUserName, request.AdminName); contentInfo.Set(ContentAttribute.CheckDate, DateTime.Now); contentInfo.Set(ContentAttribute.CheckReasons, reasons); contentInfo.IsChecked = isChecked; contentInfo.CheckedLevel = checkedLevel; if (isTranslate && translateChannelId > 0) { var translateChannelInfo = ChannelManager.GetChannelInfo(siteId, translateChannelId); contentInfo.ChannelId = translateChannelInfo.Id; DataProvider.ContentDao.Update(siteInfo, translateChannelInfo, contentInfo); } else { DataProvider.ContentDao.Update(siteInfo, channelInfo, contentInfo); } contentInfoList.Add(contentInfo); var checkInfo = new ContentCheckInfo(0, tableName, siteId, contentInfo.ChannelId, contentInfo.Id, request.AdminName, isChecked, checkedLevel, DateTime.Now, reasons); DataProvider.ContentCheckDao.Insert(checkInfo); } if (isTranslate && translateChannelId > 0) { ContentManager.RemoveCache(tableName, channelId); var translateTableName = ChannelManager.GetTableName(siteInfo, translateChannelId); ContentManager.RemoveCache(translateTableName, translateChannelId); } request.AddSiteLog(siteId, "批量审核内容"); foreach (var contentInfo in contentInfoList) { CreateManager.CreateContent(siteId, contentInfo.ChannelId, contentInfo.Id); } CreateManager.TriggerContentChangedEvent(siteId, channelId); if (isTranslate && translateChannelId > 0) { CreateManager.TriggerContentChangedEvent(siteId, translateChannelId); } return(Ok(new { Value = contentIdList })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } var contentId = AuthRequest.GetQueryInt("id"); var redirectUrl = string.Empty; if (contentId == 0) { try { var dict = BackgroundInputTypeParser.SaveAttributes(SiteInfo, _styleInfoList, Request.Form, ContentAttribute.AllAttributes.Value); var contentInfo = new ContentInfo(dict) { ChannelId = _channelInfo.Id, SiteId = SiteId, AddUserName = AuthRequest.AdminName, AdminId = AuthRequest.AdminId, LastEditDate = DateTime.Now, GroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroups.Items), 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); contentInfo.LastEditUserName = contentInfo.AddUserName; 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; contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(RblContentLevel.SelectedValue); contentInfo.IsChecked = contentInfo.CheckedLevel >= SiteInfo.Additional.CheckContentLevel; contentInfo.Tags = TranslateUtils.ObjectCollectionToString(TagUtils.ParseTagsString(TbTags.Text), " "); foreach (var service in PluginManager.Services) { try { service.OnContentFormSubmit(new ContentFormSubmitEventArgs(SiteId, _channelInfo.Id, contentInfo.Id, TranslateUtils.ToDictionary(Request.Form), contentInfo)); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit)); } } //判断是不是有审核权限 int checkedLevelOfUser; var isCheckedOfUser = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissionsImpl, SiteInfo, contentInfo.ChannelId, out checkedLevelOfUser); if (CheckManager.IsCheckable(contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser)) { if (contentInfo.IsChecked) { contentInfo.CheckedLevel = 0; } contentInfo.Set(ContentAttribute.CheckUserName, AuthRequest.AdminName); contentInfo.Set(ContentAttribute.CheckDate, DateUtils.GetDateAndTimeString(DateTime.Now)); contentInfo.Set(ContentAttribute.CheckReasons, string.Empty); } contentInfo.Id = DataProvider.ContentDao.Insert(_tableName, SiteInfo, _channelInfo, contentInfo); TagUtils.UpdateTags(string.Empty, TbTags.Text, SiteId, contentInfo.Id); CreateManager.CreateContent(SiteId, _channelInfo.Id, contentInfo.Id); CreateManager.TriggerContentChangedEvent(SiteId, _channelInfo.Id); AuthRequest.AddSiteLog(SiteId, _channelInfo.Id, contentInfo.Id, "添加内容", $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId)},内容标题:{contentInfo.Title}"); ContentUtility.Translate(SiteInfo, _channelInfo.Id, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(DdlTranslateType.SelectedValue), AuthRequest.AdminName); redirectUrl = PageContentAddAfter.GetRedirectUrl(SiteId, _channelInfo.Id, contentInfo.Id, ReturnUrl); } catch (Exception ex) { LogUtils.AddErrorLog(ex); FailMessage($"内容添加失败:{ex.Message}"); } } else { var contentInfo = ContentManager.GetContentInfo(SiteInfo, _channelInfo, contentId); try { contentInfo.LastEditUserName = AuthRequest.AdminName; contentInfo.LastEditDate = DateTime.Now; var dict = BackgroundInputTypeParser.SaveAttributes(SiteInfo, _styleInfoList, Request.Form, ContentAttribute.AllAttributes.Value); contentInfo.Load(dict); contentInfo.GroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroups.Items); 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(RblContentLevel.SelectedValue); contentInfo.IsChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel; contentInfo.CheckedLevel = checkedLevel; TagUtils.UpdateTags(contentInfo.Tags, TbTags.Text, SiteId, contentId); contentInfo.Tags = TranslateUtils.ObjectCollectionToString(TagUtils.ParseTagsString(TbTags.Text), " "); foreach (var service in PluginManager.Services) { try { service.OnContentFormSubmit(new ContentFormSubmitEventArgs(SiteId, _channelInfo.Id, contentInfo.Id, TranslateUtils.ToDictionary(Request.Form), contentInfo)); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit)); } } DataProvider.ContentDao.Update(SiteInfo, _channelInfo, contentInfo); ContentUtility.Translate(SiteInfo, _channelInfo.Id, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(DdlTranslateType.SelectedValue), AuthRequest.AdminName); CreateManager.CreateContent(SiteId, _channelInfo.Id, contentId); CreateManager.TriggerContentChangedEvent(SiteId, _channelInfo.Id); AuthRequest.AddSiteLog(SiteId, _channelInfo.Id, contentId, "修改内容", $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId)},内容标题:{contentInfo.Title}"); redirectUrl = ReturnUrl; //更新引用该内容的信息 //如果不是异步自动保存,那么需要将引用此内容的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; } } PageUtils.Redirect(redirectUrl); }
public IHttpActionResult Submit() { try { var request = new RequestImpl(); var siteId = request.GetPostInt("siteId"); var channelId = request.GetPostInt("channelId"); var contentIdList = TranslateUtils.StringCollectionToIntList(request.GetPostString("contentIds")); var isRetainFiles = request.GetPostBool("isRetainFiles"); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentDelete)) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } if (!isRetainFiles) { DeleteManager.DeleteContents(siteInfo, channelId, contentIdList); } var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); if (contentIdList.Count == 1) { var contentId = contentIdList[0]; var contentTitle = DataProvider.ContentDao.GetValue(tableName, contentId, ContentAttribute.Title); request.AddSiteLog(siteId, channelId, contentId, "删除内容", $"栏目:{ChannelManager.GetChannelNameNavigation(siteId, channelId)},内容标题:{contentTitle}"); } else { request.AddSiteLog(siteId, "批量删除内容", $"栏目:{ChannelManager.GetChannelNameNavigation(siteId, channelId)},内容条数:{contentIdList.Count}"); } DataProvider.ContentDao.UpdateTrashContents(siteId, channelId, tableName, contentIdList); CreateManager.TriggerContentChangedEvent(siteId, channelId); return(Ok(new { Value = contentIdList })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
public IHttpActionResult Create(int siteId, int channelId) { try { var request = new RequestImpl(); var sourceId = request.GetPostInt(ContentAttribute.SourceId.ToCamelCase()); bool isAuth; if (sourceId == SourceManager.User) { isAuth = request.IsUserLoggin && request.UserPermissions.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentAdd); } else { isAuth = request.IsApiAuthenticated && AccessTokenManager.IsScope(request.ApiToken, AccessTokenManager.ScopeContents) || request.IsUserLoggin && request.UserPermissions.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentAdd) || request.IsAdminLoggin && request.AdminPermissions.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentAdd); } if (!isAuth) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } if (!channelInfo.Additional.IsContentAddable) { return(BadRequest("此栏目不能添加内容")); } var attributes = request.GetPostObject <Dictionary <string, object> >(); if (attributes == null) { return(BadRequest("无法从body中获取内容实体")); } var checkedLevel = request.GetPostInt("checkedLevel"); var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var adminName = request.AdminName; var isChecked = checkedLevel >= siteInfo.Additional.CheckContentLevel; if (isChecked) { if (sourceId == SourceManager.User || request.IsUserLoggin) { isChecked = request.UserPermissionsImpl.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentCheck); } else if (request.IsAdminLoggin) { isChecked = request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentCheck); } } var contentInfo = new ContentInfo(attributes) { SiteId = siteId, ChannelId = channelId, AddUserName = adminName, LastEditDate = DateTime.Now, LastEditUserName = adminName, AdminId = request.AdminId, UserId = request.UserId, SourceId = sourceId, IsChecked = isChecked, CheckedLevel = checkedLevel }; contentInfo.Id = DataProvider.ContentDao.Insert(tableName, siteInfo, channelInfo, contentInfo); foreach (var service in PluginManager.Services) { try { service.OnContentFormSubmit(new ContentFormSubmitEventArgs(siteId, channelId, contentInfo.Id, new AttributesImpl(attributes), contentInfo)); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit)); } } if (contentInfo.IsChecked) { CreateManager.CreateContent(siteId, channelId, contentInfo.Id); CreateManager.TriggerContentChangedEvent(siteId, channelId); } request.AddSiteLog(siteId, channelId, contentInfo.Id, "添加内容", $"栏目:{ChannelManager.GetChannelNameNavigation(siteId, contentInfo.ChannelId)},内容标题:{contentInfo.Title}"); return(Ok(new { Value = contentInfo })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }