public ContentInfo GetContentInfo(ETableStyle tableStyle, string tableName, int contentId) { ContentInfo info = null; if (contentId > 0) { if (!string.IsNullOrEmpty(tableName)) { string sqlWhere = $"WHERE ID = {contentId}"; var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(tableName, SqlUtils.Asterisk, sqlWhere); using (var rdr = ExecuteReader(sqlSelect)) { if (rdr.Read()) { info = ContentUtility.GetContentInfo(tableStyle); BaiRongDataProvider.DatabaseDao.ReadResultsToExtendedAttributes(rdr, info); } rdr.Close(); } } } info?.AfterExecuteReader(); return(info); }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { var fileCount = TranslateUtils.ToInt(Request.Form["File_Count"]); if (fileCount == 1) { var fileName = Request.Form["fileName_1"]; var redirectUrl = WebUtils.GetContentAddUploadWordUrl(PublishmentSystemId, _nodeInfo, cbIsFirstLineTitle.Checked, cbIsFirstLineRemove.Checked, cbIsClearFormat.Checked, cbIsFirstLineIndent.Checked, cbIsClearFontSize.Checked, cbIsClearFontFamily.Checked, cbIsClearImages.Checked, TranslateUtils.ToIntWithNagetive(rblContentLevel.SelectedValue), fileName, _returnUrl); PageUtils.CloseModalPageAndRedirect(Page, redirectUrl); return; } if (fileCount > 1) { var tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, _nodeInfo); var tableName = NodeManager.GetTableName(PublishmentSystemInfo, _nodeInfo); var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, _nodeInfo.NodeId); for (var index = 1; index <= fileCount; index++) { var fileName = Request.Form["fileName_" + index]; if (!string.IsNullOrEmpty(fileName)) { var formCollection = WordUtils.GetWordNameValueCollection(PublishmentSystemId, _nodeInfo.ContentModelId, cbIsFirstLineTitle.Checked, cbIsFirstLineRemove.Checked, cbIsClearFormat.Checked, cbIsFirstLineIndent.Checked, cbIsClearFontSize.Checked, cbIsClearFontFamily.Checked, cbIsClearImages.Checked, TranslateUtils.ToInt(rblContentLevel.SelectedValue), fileName); if (!string.IsNullOrEmpty(formCollection[ContentAttribute.Title])) { var contentInfo = ContentUtility.GetContentInfo(tableStyle); BackgroundInputTypeParser.AddValuesToAttributes(tableStyle, tableName, PublishmentSystemInfo, relatedIdentities, formCollection, contentInfo.Attributes, ContentAttribute.HiddenAttributes); contentInfo.NodeId = _nodeInfo.NodeId; contentInfo.PublishmentSystemId = PublishmentSystemId; contentInfo.AddUserName = Body.AdministratorName; contentInfo.AddDate = DateTime.Now; contentInfo.LastEditUserName = contentInfo.AddUserName; contentInfo.LastEditDate = contentInfo.AddDate; contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(rblContentLevel.SelectedValue); contentInfo.IsChecked = contentInfo.CheckedLevel >= PublishmentSystemInfo.CheckContentLevel; contentInfo.Id = DataProvider.ContentDao.Insert(tableName, PublishmentSystemInfo, contentInfo); if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id); } } } } } PageUtils.CloseModalPage(Page); } }
public IHttpActionResult Main() { try { var body = new RequestBody(); if (!body.IsUserLoggin) { return(Unauthorized()); } var publishmentSystemId = body.GetPostInt("publishmentSystemId"); var nodeId = body.GetPostInt("nodeId"); var user = new User(body.UserInfo); var groupInfo = UserGroupManager.GetGroupInfo(user.GroupId); var adminUserName = groupInfo.Additional.WritingAdminUserName; var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId); var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemId, nodeId); var tableName = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo); var tableStyle = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo); var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(publishmentSystemId, nodeId); var contentInfo = ContentUtility.GetContentInfo(tableStyle); var postCollection = body.GetPostCollection(); InputTypeParser.AddValuesToAttributes(tableStyle, tableName, publishmentSystemInfo, relatedIdentities, postCollection, contentInfo.Attributes, ContentAttribute.HiddenAttributes); contentInfo.IsChecked = false; contentInfo.PublishmentSystemId = publishmentSystemId; contentInfo.NodeId = nodeId; contentInfo.AddUserName = adminUserName; contentInfo.WritingUserName = user.UserName; contentInfo.LastEditUserName = adminUserName; contentInfo.AddDate = DateTime.Now; contentInfo.LastEditDate = DateTime.Now; var contentId = DataProvider.ContentDao.Insert(tableName, publishmentSystemInfo, contentInfo); LogUtils.AddUserLog(body.UserName, EUserActionType.WritingAdd, contentInfo.Title); return(Ok(new { ID = contentId })); } catch (Exception ex) { //return InternalServerError(ex); return(InternalServerError(new Exception("程序错误"))); } }
public ContentInfo GetContentInfo(ETableStyle tableStyle, string sqlString) { ContentInfo info = null; if (!string.IsNullOrEmpty(sqlString)) { using (var rdr = ExecuteReader(sqlString)) { if (rdr.Read()) { info = ContentUtility.GetContentInfo(tableStyle); BaiRongDataProvider.DatabaseDao.ReadResultsToExtendedAttributes(rdr, info); } rdr.Close(); } } info?.AfterExecuteReader(); return(info); }
private int SaveContentInfo(bool isAjaxSubmit, bool isPreview, out string errorMessage) { int savedContentId; errorMessage = string.Empty; var contentId = 0; if (!isPreview) { contentId = isAjaxSubmit ? TranslateUtils.ToInt(Request.Form["savedContentID"]) : Body.GetQueryInt("ID"); } if (contentId == 0) { var contentInfo = ContentUtility.GetContentInfo(_tableStyle); try { int nodeId = 0; //contentInfo.NodeId = _nodeInfo.NodeId; if (PhCategory.Visible == true) { nodeId = Convert.ToInt32(TbCategory.SelectedValue); } else { nodeId = _nodeInfo.NodeId; } contentInfo.NodeId = 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; //自动保存的时候,不保存编辑器的图片 var dic = new Dictionary <string, string>(); if (Body.GetQueryInt("ArticleId") > 0) { dic.Add("ExaminationPaperId", Body.GetQueryString("ArticleId")); } InputTypeParser.AddValuesToAttributes(_tableStyle, _tableName, PublishmentSystemInfo, _relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes, !_isAjaxSubmit, dic); StringCollection tagCollection; if (isAjaxSubmit) { contentInfo.ContentGroupNameCollection = Request.Form[ContentAttribute.ContentGroupNameCollection]; tagCollection = TagUtils.ParseTagsString(Request.Form[ContentAttribute.Tags]); contentInfo.CheckedLevel = LevelManager.LevelInt.CaoGao; contentInfo.IsChecked = false; } else { contentInfo.ContentGroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroupNameCollection.Items); 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 (!isAjaxSubmit) { 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); string contentType = WebUtils.GetContentType(_nodeInfo.ContentModelId); if (contentType.Equals("PageExamination")) { PageUtils.Redirect($@"/siteserver/cms/{contentType}.aspx?PublishmentSystemID={Body.GetQueryString("PublishmentSystemID")}&NodeID={(string.IsNullOrEmpty(Body.GetQueryString("PNodeID")) ? Body.GetQueryString("NodeId") : Body.GetQueryString("PNodeID"))}&ArticleId={Body.GetQueryString("ArticleId")}"); } 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; //自动保存的时候,不保存编辑器的图片 InputTypeParser.AddValuesToAttributes(_tableStyle, _tableName, PublishmentSystemInfo, _relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes, !_isAjaxSubmit); StringCollection tagCollection; if (isAjaxSubmit) { contentInfo.ContentGroupNameCollection = Request.Form[ContentAttribute.ContentGroupNameCollection]; tagCollection = TagUtils.ParseTagsString(Request.Form[ContentAttribute.Tags]); } else { contentInfo.ContentGroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroupNameCollection.Items); 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); } if (!isAjaxSubmit) { 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 (!isAjaxSubmit) { if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(PublishmentSystemId, _nodeInfo.NodeId, contentId); } Body.AddSiteLog(PublishmentSystemId, _nodeInfo.NodeId, contentId, "修改内容", $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},内容标题:{contentInfo.Title}"); string contentType = WebUtils.GetContentType(_nodeInfo.ContentModelId); PageUtils.Redirect($@"/siteserver/cms/{contentType}.aspx?PublishmentSystemID={Body.GetQueryString("PublishmentSystemID")}&NodeID={(string.IsNullOrEmpty( Body.GetQueryString("PNodeID"))? Body.GetQueryString("NodeId"): Body.GetQueryString("PNodeID"))}"); //PageUtils.Redirect(ReturnUrl); } savedContentId = contentId; } return(savedContentId); }