private void TranslateContent(PublishmentSystemInfo targetPublishmentSystemInfo, int nodeID, int targetNodeID, bool isChecked, int checkedLevel) { var tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, nodeID); var tableName = NodeManager.GetTableName(PublishmentSystemInfo, nodeID); var orderByString = ETaxisTypeUtils.GetOrderByString(tableStyle, ETaxisType.OrderByTaxis); var targetTableName = NodeManager.GetTableName(targetPublishmentSystemInfo, targetNodeID); var contentIdList = DataProvider.ContentDao.GetContentIdListChecked(tableName, nodeID, orderByString); foreach (var contentId in contentIdList) { var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentId); FileUtility.MoveFileByContentInfo(PublishmentSystemInfo, targetPublishmentSystemInfo, contentInfo); contentInfo.PublishmentSystemId = TranslateUtils.ToInt(PublishmentSystemIDDropDownList.SelectedValue); contentInfo.SourceId = contentInfo.NodeId; contentInfo.NodeId = targetNodeID; contentInfo.IsChecked = isChecked; contentInfo.CheckedLevel = checkedLevel; var theContentID = DataProvider.ContentDao.Insert(targetTableName, targetPublishmentSystemInfo, contentInfo); if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(targetPublishmentSystemInfo.PublishmentSystemId, contentInfo.NodeId, theContentID); } } if (IsDeleteAfterTranslate.Visible && EBooleanUtils.Equals(IsDeleteAfterTranslate.SelectedValue, EBoolean.True)) { try { DataProvider.ContentDao.TrashContents(PublishmentSystemId, tableName, contentIdList, nodeID); } catch { } } }
public IHttpActionResult Create() { try { var request = new AuthenticatedRequest(); var siteId = request.GetPostInt("siteId"); var channelContentIds = request.GetPostObject <List <MinContentInfo> >("channelContentIds"); if (!request.IsAdminLoggin) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } foreach (var channelContentId in channelContentIds) { CreateManager.CreateContent(siteId, channelContentId.ChannelId, channelContentId.Id); } return(Ok(new { Value = true })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
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 targetTableName = ChannelManager.GetTableName(targetSiteInfo, targetChannelId); var channelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId); var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, 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, 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.CreateContentAndTrigger(targetSiteInfo.Id, contentInfo.ChannelId, theContentId); } 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, contentInfo); DataProvider.ContentDao.DeleteContents(siteInfo.Id, tableName, TranslateUtils.ToIntList(contentId), channelId); DataProvider.ChannelDao.UpdateContentNum(siteInfo, channelId, true); DataProvider.ChannelDao.UpdateContentNum(targetSiteInfo, targetChannelId, true); 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.CreateContentAndTrigger(targetSiteInfo.Id, contentInfo.ChannelId, newContentId); } 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()); DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, contentInfo); } 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, 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.CreateContentAndTrigger(targetSiteInfo.Id, contentInfo.ChannelId, theContentId); } }
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(tableName, translateChannelId); } 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 void Create_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } var channelIdList = new List <int>(); var selectedChannelIdArrayList = ControlUtils.GetSelectedListControlValueArrayList(LbChannelIdList); var tableName = SiteInfo.TableName; if (DdlScope.SelectedValue == "Month") { var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, SiteId, 720); foreach (var channelId in lastEditList) { if (selectedChannelIdArrayList.Contains(channelId.ToString())) { channelIdList.Add(channelId); } } } else if (DdlScope.SelectedValue == "Day") { var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, SiteId, 24); foreach (var channelId in lastEditList) { if (selectedChannelIdArrayList.Contains(channelId.ToString())) { channelIdList.Add(channelId); } } } else if (DdlScope.SelectedValue == "2Hour") { var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, SiteId, 2); foreach (var channelId in lastEditList) { if (selectedChannelIdArrayList.Contains(channelId.ToString())) { channelIdList.Add(channelId); } } } else { channelIdList = TranslateUtils.StringCollectionToIntList(TranslateUtils.ObjectCollectionToString(selectedChannelIdArrayList)); } if (channelIdList.Count == 0) { FailMessage("请首先选中希望生成页面的栏目!"); return; } foreach (var channelId in channelIdList) { CreateManager.CreateChannel(SiteId, channelId); } PageCreateStatus.Redirect(SiteId); }
public NameValueCollection CreatePublishmentSystem(int publishmentSystemId, bool isUseSiteTemplate, bool isImportContents, bool isImportTableStyles, string siteTemplateDir, bool isUseTables, string userKeyPrefix, string returnUrl, bool isTop, string administratorName) { var cacheTotalCountKey = userKeyPrefix + CacheTotalCount; var cacheCurrentCountKey = userKeyPrefix + CacheCurrentCount; var cacheMessageKey = userKeyPrefix + CacheMessage; CacheUtils.Max(cacheTotalCountKey, "3"); //存储需要的页面总数 CacheUtils.Max(cacheCurrentCountKey, "0"); //存储当前的页面总数 CacheUtils.Max(cacheMessageKey, string.Empty); //存储消息 //返回“运行结果”、“错误信息”及“执行JS脚本”的字符串数组 NameValueCollection retval; try { CacheUtils.Max(cacheCurrentCountKey, "1"); //存储当前的页面总数 CacheUtils.Max(cacheMessageKey, "正在创建站点..."); //存储消息 var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId); CacheUtils.Max(cacheCurrentCountKey, "2"); //存储当前的页面总数 CacheUtils.Max(cacheMessageKey, "正在导入数据..."); //存储消息 if (isUseSiteTemplate && !string.IsNullOrEmpty(siteTemplateDir)) { SiteTemplateManager.Instance.ImportSiteTemplateToEmptyPublishmentSystem(publishmentSystemId, siteTemplateDir, isUseTables, isImportContents, isImportTableStyles, administratorName); } CreateManager.CreateAll(publishmentSystemId); CacheUtils.Max(cacheCurrentCountKey, "3"); //存储当前的页面总数 CacheUtils.Max(cacheMessageKey, "创建成功!"); //存储消息 if (!string.IsNullOrEmpty(returnUrl)) { returnUrl = PageUtils.AddQueryString(StringUtils.ValueFromUrl(returnUrl), "PublishmentSystemID", publishmentSystemId.ToString()); retval = AjaxManager.GetWaitingTaskNameValueCollection( $"站点 <strong>{publishmentSystemInfo.PublishmentSystemName}<strong> 创建成功!", string.Empty, isTop ? $"top.location.href='{returnUrl}';" : $"location.href='{returnUrl}';"); } else { var initUrl = PageInitialization.GetRedirectUrl(); retval = AjaxManager.GetWaitingTaskNameValueCollection( $"站点 <strong>{publishmentSystemInfo.PublishmentSystemName}<strong> 创建成功!", string.Empty, isTop ? $"location.href='{initUrl}';" : $"top.location.href='{initUrl}';"); } } catch (Exception ex) { retval = AjaxManager.GetWaitingTaskNameValueCollection(string.Empty, ex.Message, string.Empty); LogUtils.AddErrorLog(ex); } CacheUtils.Remove(cacheTotalCountKey); //取消存储需要的页面总数 CacheUtils.Remove(cacheCurrentCountKey); //取消存储当前的页面总数 CacheUtils.Remove(cacheMessageKey); //取消存储消息 CacheUtils.Clear(); return(retval); }
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.IsUserLoggin || !request.UserPermissionsImpl.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 void init(ArrayList pieceList) { this.pieceList = pieceList; delManager = GameObject.Find ("DeleteManager").GetComponent<DeleteManager> (); createManager = GameObject.Find ("CreateManager").GetComponent<CreateManager> (); }
public IHttpActionResult Create(int siteId) { try { var request = new AuthenticatedRequest(); var parentId = request.GetPostInt(ChannelAttribute.ParentId, siteId); var isAuth = request.IsApiAuthenticated && AccessTokenManager.IsScope(request.ApiToken, AccessTokenManager.ScopeChannels) || request.IsAdminLoggin && request.AdminPermissions.HasChannelPermissions(siteId, parentId, ConfigManager.ChannelPermissions.ChannelAdd); if (!isAuth) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var contentModelPluginId = request.GetPostString(ChannelAttribute.ContentModelPluginId); var contentRelatedPluginIds = request.GetPostString(ChannelAttribute.ContentRelatedPluginIds); var channelName = request.GetPostString(ChannelAttribute.ChannelName); var indexName = request.GetPostString(ChannelAttribute.IndexName); var filePath = request.GetPostString(ChannelAttribute.FilePath); var channelFilePathRule = request.GetPostString(ChannelAttribute.ChannelFilePathRule); var contentFilePathRule = request.GetPostString(ChannelAttribute.ContentFilePathRule); var groupNameCollection = request.GetPostString(ChannelAttribute.GroupNameCollection); var imageUrl = request.GetPostString(ChannelAttribute.ImageUrl); var content = request.GetPostString(ChannelAttribute.Content); var keywords = request.GetPostString(ChannelAttribute.Keywords); var description = request.GetPostString(ChannelAttribute.Description); var linkUrl = request.GetPostString(ChannelAttribute.LinkUrl); var linkType = request.GetPostString(ChannelAttribute.LinkType); var channelTemplateId = request.GetPostInt(ChannelAttribute.ChannelTemplateId); var contentTemplateId = request.GetPostInt(ChannelAttribute.ContentTemplateId); var channelInfo = new ChannelInfo { SiteId = siteId, ParentId = parentId, ContentModelPluginId = contentModelPluginId, ContentRelatedPluginIds = contentRelatedPluginIds }; if (!string.IsNullOrEmpty(indexName)) { var indexNameList = DataProvider.ChannelDao.GetIndexNameList(siteId); if (indexNameList.IndexOf(indexName) != -1) { return(BadRequest("栏目添加失败,栏目索引已存在!")); } } if (!string.IsNullOrEmpty(filePath)) { if (!DirectoryUtils.IsDirectoryNameCompliant(filePath)) { return(BadRequest("栏目页面路径不符合系统要求!")); } if (PathUtils.IsDirectoryPath(filePath)) { filePath = PageUtils.Combine(filePath, "index.html"); } var filePathList = DataProvider.ChannelDao.GetAllFilePathBySiteId(siteId); if (filePathList.IndexOf(filePath) != -1) { return(BadRequest("栏目添加失败,栏目页面路径已存在!")); } } if (!string.IsNullOrEmpty(channelFilePathRule)) { if (!DirectoryUtils.IsDirectoryNameCompliant(channelFilePathRule)) { return(BadRequest("栏目页面命名规则不符合系统要求!")); } if (PathUtils.IsDirectoryPath(channelFilePathRule)) { return(BadRequest("栏目页面命名规则必须包含生成文件的后缀!")); } } if (!string.IsNullOrEmpty(contentFilePathRule)) { if (!DirectoryUtils.IsDirectoryNameCompliant(contentFilePathRule)) { return(BadRequest("内容页面命名规则不符合系统要求!")); } if (PathUtils.IsDirectoryPath(contentFilePathRule)) { return(BadRequest("内容页面命名规则必须包含生成文件的后缀!")); } } //var parentChannelInfo = ChannelManager.GetChannelInfo(siteId, parentId); //var styleInfoList = TableStyleManager.GetChannelStyleInfoList(parentChannelInfo); //var extendedAttributes = BackgroundInputTypeParser.SaveAttributes(siteInfo, styleInfoList, Request.Form, null); channelInfo.Additional.Load(request.GetPostObject <Dictionary <string, object> >()); //foreach (string key in attributes) //{ // channelInfo.Additional.SetExtendedAttribute(key, attributes[key]); //} channelInfo.ChannelName = channelName; channelInfo.IndexName = indexName; channelInfo.FilePath = filePath; channelInfo.ChannelFilePathRule = channelFilePathRule; channelInfo.ContentFilePathRule = contentFilePathRule; channelInfo.GroupNameCollection = groupNameCollection; channelInfo.ImageUrl = imageUrl; channelInfo.Content = content; channelInfo.Keywords = keywords; channelInfo.Description = description; channelInfo.LinkUrl = linkUrl; channelInfo.LinkType = linkType; channelInfo.ChannelTemplateId = channelTemplateId; channelInfo.ContentTemplateId = contentTemplateId; channelInfo.AddDate = DateTime.Now; channelInfo.Id = DataProvider.ChannelDao.Insert(channelInfo); //栏目选择投票样式后,内容 CreateManager.CreateChannel(siteId, channelInfo.Id); request.AddSiteLog(siteId, "添加栏目", $"栏目:{channelName}"); return(Ok(new { Value = channelInfo.ToDictionary() })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
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) { DirectoryUtility.DeleteContents(SiteInfo, channelId, contentIdList); SuccessMessage("成功删除内容以及生成页面!"); } else { SuccessMessage("成功删除内容,生成页面未被删除!"); } if (contentIdList.Count == 1) { var contentId = contentIdList[0]; var contentTitle = DataProvider.ContentDao.GetValue(tableName, contentId, ContentAttribute.Title); Body.AddSiteLog(SiteId, channelId, contentId, "删除内容", $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, channelId)},内容标题:{contentTitle}"); } else { Body.AddSiteLog(SiteId, "批量删除内容", $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, channelId)},内容条数:{contentIdList.Count}"); } DataProvider.ContentDao.TrashContents(SiteId, tableName, contentIdList); //引用内容,需要删除 var tableList = DataProvider.TableDao.GetTableCollectionInfoListCreatedInDb(); foreach (var table in tableList) { var targetContentIdList = DataProvider.ContentDao.GetReferenceIdList(table.TableName, contentIdList); if (targetContentIdList.Count > 0) { var targetContentInfo = DataProvider.ContentDao.GetContentInfo(table.TableName, TranslateUtils.ToInt(targetContentIdList[0].ToString())); DataProvider.ContentDao.DeleteContents(targetContentInfo.SiteId, table.TableName, targetContentIdList, targetContentInfo.ChannelId); } } CreateManager.CreateContentTrigger(SiteId, channelId); } else { SuccessMessage("成功从回收站清空内容!"); DataProvider.ContentDao.DeleteContents(SiteId, tableName, contentIdList, channelId); Body.AddSiteLog(SiteId, "从回收站清空内容", $"内容条数:{contentIdList.Count}"); } } AddWaitAndRedirectScript(_returnUrl); } catch (Exception ex) { LogUtils.AddSystemErrorLog(ex); FailMessage(ex, "删除内容失败!"); } }
public override void Submit_OnClick(object sender, EventArgs e) { bool isChanged; var parentNodeId = TranslateUtils.ToInt(Request.Form["nodeID"]); if (parentNodeId == 0) { parentNodeId = PublishmentSystemId; } try { if (string.IsNullOrEmpty(NodeNames.Text)) { FailMessage("请填写需要添加的栏目名称"); return; } var insertedNodeIdHashtable = new Hashtable();//key为栏目的级别,1为第一级栏目 insertedNodeIdHashtable[1] = parentNodeId; var nodeNameArray = NodeNames.Text.Split('\n'); List <string> nodeIndexNameList = null; foreach (var item in nodeNameArray) { if (!string.IsNullOrEmpty(item)) { //count为栏目的级别 var count = (StringUtils.GetStartCount('-', item) == 0) ? StringUtils.GetStartCount('-', item) : StringUtils.GetStartCount('-', item); var nodeName = item.Substring(count, item.Length - count); var nodeIndex = string.Empty; count++; if (!string.IsNullOrEmpty(nodeName) && insertedNodeIdHashtable.Contains(count)) { if (ckNameToIndex.Checked) { nodeIndex = nodeName.Trim(); } if (StringUtils.Contains(nodeName, "(") && StringUtils.Contains(nodeName, ")")) { var length = nodeName.IndexOf(')') - nodeName.IndexOf('('); if (length > 0) { nodeIndex = nodeName.Substring(nodeName.IndexOf('(') + 1, length); nodeName = nodeName.Substring(0, nodeName.IndexOf('(')); } } nodeName = nodeName.Trim(); nodeIndex = nodeIndex.Trim(' ', '(', ')'); if (!string.IsNullOrEmpty(nodeIndex)) { if (nodeIndexNameList == null) { nodeIndexNameList = DataProvider.NodeDao.GetNodeIndexNameList(PublishmentSystemId); } if (nodeIndexNameList.IndexOf(nodeIndex) != -1) { nodeIndex = string.Empty; } else { nodeIndexNameList.Add(nodeIndex); } } var parentId = (int)insertedNodeIdHashtable[count]; var contentModelId = ContentModelID.SelectedValue; if (string.IsNullOrEmpty(contentModelId)) { var parentNodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, parentId); contentModelId = parentNodeInfo.ContentModelId; } var channelTemplateId = TranslateUtils.ToInt(ChannelTemplateID.SelectedValue); var contentTemplateId = TranslateUtils.ToInt(ContentTemplateID.SelectedValue); var insertedNodeId = DataProvider.NodeDao.InsertNodeInfo(PublishmentSystemId, parentId, nodeName, nodeIndex, contentModelId, channelTemplateId, contentTemplateId); insertedNodeIdHashtable[count + 1] = insertedNodeId; CreateManager.CreateChannel(PublishmentSystemId, insertedNodeId); } } } Body.AddSiteLog(PublishmentSystemId, parentNodeId, 0, "快速添加栏目", $"父栏目:{NodeManager.GetNodeName(PublishmentSystemId, parentNodeId)},栏目:{NodeNames.Text.Replace('\n', ',')}"); isChanged = true; } catch (Exception ex) { isChanged = false; FailMessage(ex, ex.Message); } if (isChanged) { PageUtils.CloseModalPageAndRedirect(Page, _returnUrl); } }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } ChannelInfo nodeInfo; try { nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); if (!nodeInfo.IndexName.Equals(TbNodeIndexName.Text) && TbNodeIndexName.Text.Length != 0) { var nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId); if (nodeIndexNameList.IndexOf(TbNodeIndexName.Text) != -1) { FailMessage("栏目属性修改失败,栏目索引已存在!"); return; } } if (nodeInfo.ContentModelPluginId != DdlContentModelPluginId.SelectedValue) { nodeInfo.ContentModelPluginId = DdlContentModelPluginId.SelectedValue; nodeInfo.ContentNum = DataProvider.ContentDao.GetCount(ChannelManager.GetTableName(SiteInfo, nodeInfo.ContentModelPluginId), nodeInfo.Id); } nodeInfo.ContentRelatedPluginIds = ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds); TbFilePath.Text = TbFilePath.Text.Trim(); if (!nodeInfo.FilePath.Equals(TbFilePath.Text) && TbFilePath.Text.Length != 0) { if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text)) { FailMessage("栏目页面路径不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(TbFilePath.Text)) { TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html"); } var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId); if (filePathArrayList.IndexOf(TbFilePath.Text) != -1) { FailMessage("栏目修改失败,栏目页面路径已存在!"); return; } } if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text)) { var filePathRule = TbChannelFilePathRule.Text.Replace("|", string.Empty); if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule)) { FailMessage("栏目页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(filePathRule)) { FailMessage("栏目页面命名规则必须包含生成文件的后缀!"); return; } } if (!string.IsNullOrEmpty(TbContentFilePathRule.Text)) { var filePathRule = TbContentFilePathRule.Text.Replace("|", string.Empty); if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule)) { FailMessage("内容页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(filePathRule)) { FailMessage("内容页面命名规则必须包含生成文件的后缀!"); return; } } var extendedAttributes = new ExtendedAttributes(); var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId); var styleInfoList = TableStyleManager.GetTableStyleInfoList(DataProvider.ChannelDao.TableName, relatedIdentities); BackgroundInputTypeParser.SaveAttributes(extendedAttributes, SiteInfo, styleInfoList, Request.Form, null); var attributes = extendedAttributes.ToNameValueCollection(); foreach (string key in attributes) { nodeInfo.Additional.Set(key, attributes[key]); } nodeInfo.ChannelName = TbNodeName.Text; nodeInfo.IndexName = TbNodeIndexName.Text; nodeInfo.FilePath = TbFilePath.Text; nodeInfo.ChannelFilePathRule = TbChannelFilePathRule.Text; nodeInfo.ContentFilePathRule = TbContentFilePathRule.Text; var list = new ArrayList(); foreach (ListItem item in CblNodeGroupNameCollection.Items) { if (item.Selected) { list.Add(item.Value); } } nodeInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list); nodeInfo.ImageUrl = TbImageUrl.Text; nodeInfo.Content = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]); nodeInfo.Keywords = TbKeywords.Text; nodeInfo.Description = TbDescription.Text; nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(RblIsChannelAddable.SelectedValue); nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(RblIsContentAddable.SelectedValue); nodeInfo.LinkUrl = TbLinkUrl.Text; nodeInfo.LinkType = DdlLinkType.SelectedValue; nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue)); nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0; nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0; DataProvider.ChannelDao.Update(nodeInfo); } catch (Exception ex) { FailMessage(ex, $"栏目修改失败:{ex.Message}"); LogUtils.AddSystemErrorLog(ex); return; } CreateManager.CreateChannel(SiteId, nodeInfo.Id); Body.AddSiteLog(SiteId, "修改栏目", $"栏目:{TbNodeName.Text}"); SuccessMessage("栏目修改成功!"); PageUtils.Redirect(ReturnUrl); }
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 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) { foreach (var channelContentId in channelContentIds) { DeleteManager.DeleteContent(siteInfo, channelContentId.ChannelId, channelContentId.Id); } } var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); if (channelContentIds.Count == 1) { var channelContentId = channelContentIds[0]; var contentTitle = DataProvider.ContentDao.GetValue(tableName, channelContentId.Id, ContentAttribute.Title); request.AddSiteLog(siteId, channelContentId.ChannelId, channelContentId.Id, "删除内容", $"栏目:{ChannelManager.GetChannelNameNavigation(siteId, channelContentId.ChannelId)},内容标题:{contentTitle}"); } else { request.AddSiteLog(siteId, "批量删除内容", $"栏目:{ChannelManager.GetChannelNameNavigation(siteId, channelId)},内容条数:{channelContentIds.Count}"); } foreach (var distinctChannelId in channelContentIds.Select(x => x.ChannelId).Distinct()) { var contentIdList = channelContentIds.Where(x => x.ChannelId == distinctChannelId) .Select(x => x.Id).ToList(); DataProvider.ContentDao.UpdateTrashContents(siteId, distinctChannelId, tableName, contentIdList); CreateManager.TriggerContentChangedEvent(siteId, distinctChannelId); } return(Ok(new { Value = true })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
private int SaveContentInfo(bool isPreview, out string errorMessage) { int savedContentId; errorMessage = string.Empty; var contentId = 0; string redirectUrl; if (!isPreview) { contentId = Body.GetQueryInt("id"); } if (contentId == 0) { var contentInfo = new ContentInfo(); try { contentInfo.ChannelId = _nodeInfo.Id; contentInfo.SiteId = SiteId; contentInfo.AddUserName = Body.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.AddPluginErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit)); } } if (isPreview) { savedContentId = DataProvider.ContentDao.InsertPreview(_tableName, SiteInfo, _nodeInfo, contentInfo); } else { savedContentId = DataProvider.ContentDao.Insert(_tableName, SiteInfo, contentInfo); //判断是不是有审核权限 int checkedLevelOfUser; var isCheckedOfUser = CheckManager.GetUserCheckLevel(Body.AdminName, 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> { savedContentId }, 0, true, Body.AdminName, contentInfo.IsChecked, contentInfo.CheckedLevel, ""); } TagUtils.AddTags(tagCollection, SiteId, savedContentId); } contentInfo.Id = savedContentId; } catch (Exception ex) { LogUtils.AddSystemErrorLog(ex); errorMessage = $"内容添加失败:{ex.Message}"; return(0); } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(SiteId, _nodeInfo.Id, contentInfo.Id); } Body.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), Body.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 = Body.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.AddPluginErrorLog(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), Body.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.AddSystemErrorLog(ex); errorMessage = $"内容修改失败:{ex.Message}"; return(0); } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(SiteId, _nodeInfo.Id, contentId); } Body.AddSiteLog(SiteId, _nodeInfo.Id, contentId, "修改内容", $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId)},内容标题:{contentInfo.Title}"); redirectUrl = ReturnUrl; savedContentId = contentId; } if (!isPreview) { PageUtils.Redirect(redirectUrl); } return(savedContentId); }
public override void Submit_OnClick(object sender, EventArgs e) { bool isChanged; var parentChannelId = TranslateUtils.ToInt(Request.Form["channelId"]); if (parentChannelId == 0) { parentChannelId = SiteId; } try { if (string.IsNullOrEmpty(TbNodeNames.Text)) { FailMessage("请填写需要添加的栏目名称"); return; } var insertedChannelIdHashtable = new Hashtable { [1] = parentChannelId }; //key为栏目的级别,1为第一级栏目 var nodeNameArray = TbNodeNames.Text.Split('\n'); List <string> nodeIndexNameList = null; foreach (var item in nodeNameArray) { if (string.IsNullOrEmpty(item)) { continue; } //count为栏目的级别 var count = (StringUtils.GetStartCount('-', item) == 0) ? StringUtils.GetStartCount('-', item) : StringUtils.GetStartCount('-', item); var nodeName = item.Substring(count, item.Length - count); var nodeIndex = string.Empty; count++; if (!string.IsNullOrEmpty(nodeName) && insertedChannelIdHashtable.Contains(count)) { if (CbIsNameToIndex.Checked) { nodeIndex = nodeName.Trim(); } if (StringUtils.Contains(nodeName, "(") && StringUtils.Contains(nodeName, ")")) { var length = nodeName.IndexOf(')') - nodeName.IndexOf('('); if (length > 0) { nodeIndex = nodeName.Substring(nodeName.IndexOf('(') + 1, length); nodeName = nodeName.Substring(0, nodeName.IndexOf('(')); } } nodeName = nodeName.Trim(); nodeIndex = nodeIndex.Trim(' ', '(', ')'); if (!string.IsNullOrEmpty(nodeIndex)) { if (nodeIndexNameList == null) { nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId); } if (nodeIndexNameList.IndexOf(nodeIndex) != -1) { nodeIndex = string.Empty; } else { nodeIndexNameList.Add(nodeIndex); } } var parentId = (int)insertedChannelIdHashtable[count]; var contentModelPluginId = DdlContentModelPluginId.SelectedValue; if (string.IsNullOrEmpty(contentModelPluginId)) { var parentNodeInfo = ChannelManager.GetChannelInfo(SiteId, parentId); contentModelPluginId = parentNodeInfo.ContentModelPluginId; } var channelTemplateId = TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue); var contentTemplateId = TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue); var insertedChannelId = DataProvider.ChannelDao.Insert(SiteId, parentId, nodeName, nodeIndex, contentModelPluginId, ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds), channelTemplateId, contentTemplateId); insertedChannelIdHashtable[count + 1] = insertedChannelId; CreateManager.CreateChannel(SiteId, insertedChannelId); } } AuthRequest.AddSiteLog(SiteId, parentChannelId, 0, "快速添加栏目", $"父栏目:{ChannelManager.GetChannelName(SiteId, parentChannelId)},栏目:{TbNodeNames.Text.Replace('\n', ',')}"); isChanged = true; } catch (Exception ex) { isChanged = false; FailMessage(ex, ex.Message); } if (isChanged) { LayerUtils.CloseAndRedirect(Page, _returnUrl); } }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } var isChanged = false; try { var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); if (!nodeInfo.IndexName.Equals(TbNodeIndexName.Text) && TbNodeIndexName.Text.Length != 0) { var nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId); if (nodeIndexNameList.IndexOf(TbNodeIndexName.Text) != -1) { FailMessage("栏目修改失败,栏目索引已存在!"); return; } } if (PhFilePath.Visible) { TbFilePath.Text = TbFilePath.Text.Trim(); if (!nodeInfo.FilePath.Equals(TbFilePath.Text) && TbFilePath.Text.Length != 0) { if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text)) { FailMessage("栏目页面路径不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(TbFilePath.Text)) { TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html"); } var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId); if (filePathArrayList.IndexOf(TbFilePath.Text) != -1) { FailMessage("栏目修改失败,栏目页面路径已存在!"); return; } } } var extendedAttributes = new ExtendedAttributes(); var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId); var styleInfoList = TableStyleManager.GetTableStyleInfoList(DataProvider.ChannelDao.TableName, relatedIdentities); BackgroundInputTypeParser.SaveAttributes(extendedAttributes, SiteInfo, styleInfoList, Request.Form, null); if (extendedAttributes.ToNameValueCollection().Count > 0) { nodeInfo.Additional.Load(extendedAttributes.ToNameValueCollection()); } nodeInfo.ChannelName = TbNodeName.Text; nodeInfo.IndexName = TbNodeIndexName.Text; if (PhFilePath.Visible) { nodeInfo.FilePath = TbFilePath.Text; } var list = new ArrayList(); foreach (ListItem item in CblNodeGroupNameCollection.Items) { if (item.Selected) { list.Add(item.Value); } } nodeInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list); nodeInfo.ImageUrl = TbImageUrl.Text; nodeInfo.Content = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]); if (TbKeywords.Visible) { nodeInfo.Keywords = TbKeywords.Text; } if (TbDescription.Visible) { nodeInfo.Description = TbDescription.Text; } if (PhLinkUrl.Visible) { nodeInfo.LinkUrl = TbLinkUrl.Text; } if (PhLinkType.Visible) { nodeInfo.LinkType = DdlLinkType.SelectedValue; } nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue)); if (PhChannelTemplateId.Visible) { nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0; } nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0; DataProvider.ChannelDao.Update(nodeInfo); AuthRequest.AddSiteLog(SiteId, _channelId, 0, "修改栏目", $"栏目:{nodeInfo.ChannelName}"); isChanged = true; } catch (Exception ex) { FailMessage(ex, $"栏目修改失败:{ex.Message}"); LogUtils.AddErrorLog(ex); } if (isChanged) { CreateManager.CreateChannel(SiteId, _channelId); if (string.IsNullOrEmpty(_returnUrl)) { LayerUtils.Close(Page); } else { LayerUtils.CloseAndRedirect(Page, _returnUrl); } } }
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 AuthenticatedRequest(); 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.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 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 void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } Page.Response.Cache.SetCacheability(HttpCacheability.NoCache); if (Body.IsQueryExists("Gather") && Body.IsQueryExists("GatherRuleNameCollection")) { var userKeyPrefix = StringUtils.Guid(); var parameters = AjaxGatherService.GetGatherParameters(PublishmentSystemId, Body.GetQueryString("GatherRuleNameCollection"), userKeyPrefix); RegisterScripts.Text = AjaxManager.RegisterProgressTaskScript(AjaxGatherService.GetGatherUrl(), parameters, userKeyPrefix, AjaxGatherService.GetCountArrayUrl()); } else if (Body.IsQueryExists("GatherDatabase") && Body.IsQueryExists("GatherRuleNameCollection")) { var userKeyPrefix = StringUtils.Guid(); var parameters = AjaxGatherService.GetGatherDatabaseParameters(PublishmentSystemId, Body.GetQueryString("GatherRuleNameCollection"), userKeyPrefix); RegisterScripts.Text = AjaxManager.RegisterProgressTaskScript(AjaxGatherService.GetGatherDatabaseUrl(), parameters, userKeyPrefix, AjaxGatherService.GetCountArrayUrl()); } else if (Body.IsQueryExists("GatherFile") && Body.IsQueryExists("GatherRuleNameCollection")) { var userKeyPrefix = StringUtils.Guid(); var parameters = AjaxGatherService.GetGatherFileParameters(PublishmentSystemId, Body.GetQueryString("GatherRuleNameCollection"), userKeyPrefix); RegisterScripts.Text = AjaxManager.RegisterProgressTaskScript(AjaxGatherService.GetGatherFileUrl(), parameters, userKeyPrefix, AjaxGatherService.GetCountArrayUrl()); } //----------------------------------------------------------------------------------------// else if (Body.IsQueryExists("CreateChannelsOneByOne") && Body.IsQueryExists("ChannelIDCollection")) { foreach (var channelId in TranslateUtils.StringCollectionToIntList(Body.GetQueryString("ChannelIDCollection"))) { CreateManager.CreateChannel(PublishmentSystemId, channelId); } PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString("已成功将栏目放入生成队列")); } else if (Body.IsQueryExists("CreateContentsOneByOne") && Body.IsQueryExists("NodeID") && Body.IsQueryExists("ContentIDCollection")) { foreach (var contentId in TranslateUtils.StringCollectionToIntList(Body.GetQueryString("ContentIDCollection"))) { CreateManager.CreateContent(PublishmentSystemId, Body.GetQueryInt("NodeID"), contentId); } PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString("已成功将内容放入生成队列")); } else if (Body.IsQueryExists("CreateByTemplate") && Body.IsQueryExists("templateID")) { CreateManager.CreateFile(PublishmentSystemId, Body.GetQueryInt("templateID")); PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString("已成功将文件放入生成队列")); } else if (Body.IsQueryExists("CreateByIDsCollection") && Body.IsQueryExists("IDsCollection")) { foreach (var nodeIdContentId in TranslateUtils.StringCollectionToStringCollection(Body.GetQueryString("IDsCollection"))) { var pair = nodeIdContentId.Split('_'); CreateManager.CreateContent(PublishmentSystemId, TranslateUtils.ToInt(pair[0]), TranslateUtils.ToInt(pair[1])); } PageUtils.Redirect(ModalTipMessage.GetRedirectUrlString("已成功将文件放入生成队列")); } //---------------------------------------------------------------------------------------// else if (Body.IsQueryExists("SiteTemplateDownload")) { var userKeyPrefix = StringUtils.Guid(); var parameters = AjaxOtherService.GetSiteTemplateDownloadParameters(Body.GetQueryString("DownloadUrl"), Body.GetQueryString("DirectoryName"), userKeyPrefix); RegisterScripts.Text = AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateDownloadUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl()); } else if (Body.IsQueryExists("SiteTemplateZip")) { var userKeyPrefix = StringUtils.Guid(); var parameters = AjaxOtherService.GetSiteTemplateZipParameters(Body.GetQueryString("DirectoryName"), userKeyPrefix); RegisterScripts.Text = AjaxManager.RegisterProgressTaskScript(AjaxOtherService.GetSiteTemplateZipUrl(), parameters, userKeyPrefix, AjaxOtherService.GetCountArrayUrl()); } }
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)); } }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } var fileNames = TranslateUtils.StringCollectionToStringList(HihFileNames.Value); if (fileNames.Count == 1) { var fileName = fileNames[0]; if (!string.IsNullOrEmpty(fileName)) { var redirectUrl = WebUtils.GetContentAddUploadWordUrl(SiteId, _channelInfo, CbIsFirstLineTitle.Checked, CbIsFirstLineRemove.Checked, CbIsClearFormat.Checked, CbIsFirstLineIndent.Checked, CbIsClearFontSize.Checked, CbIsClearFontFamily.Checked, CbIsClearImages.Checked, TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue), fileName, _returnUrl); LayerUtils.CloseAndRedirect(Page, redirectUrl); } return; } if (fileNames.Count > 1) { var tableName = ChannelManager.GetTableName(SiteInfo, _channelInfo); var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelInfo.Id); var styleInfoList = TableStyleManager.GetTableStyleInfoList(tableName, relatedIdentities); foreach (var fileName in fileNames) { if (!string.IsNullOrEmpty(fileName)) { var formCollection = WordUtils.GetWordNameValueCollection(SiteId, CbIsFirstLineTitle.Checked, CbIsFirstLineRemove.Checked, CbIsClearFormat.Checked, CbIsFirstLineIndent.Checked, CbIsClearFontSize.Checked, CbIsClearFontFamily.Checked, CbIsClearImages.Checked, TranslateUtils.ToInt(DdlContentLevel.SelectedValue), fileName); if (!string.IsNullOrEmpty(formCollection[ContentAttribute.Title])) { var contentInfo = new ContentInfo(); BackgroundInputTypeParser.SaveAttributes(contentInfo, SiteInfo, styleInfoList, formCollection, ContentAttribute.AllAttributesLowercase); contentInfo.ChannelId = _channelInfo.Id; contentInfo.SiteId = SiteId; contentInfo.AddUserName = Body.AdminName; contentInfo.AddDate = DateTime.Now; contentInfo.LastEditUserName = contentInfo.AddUserName; contentInfo.LastEditDate = contentInfo.AddDate; contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue); contentInfo.IsChecked = contentInfo.CheckedLevel >= SiteInfo.Additional.CheckContentLevel; contentInfo.Title = formCollection[ContentAttribute.Title]; contentInfo.Id = DataProvider.ContentDao.Insert(tableName, SiteInfo, contentInfo); if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(SiteId, _channelInfo.Id, contentInfo.Id); } } } } } LayerUtils.Close(Page); }
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 tagCollection = TagUtils.ParseTagsString(TbTags.Text); var dict = BackgroundInputTypeParser.SaveAttributes(SiteInfo, _styleInfoList, Request.Form, ContentAttribute.AllAttributes.Value); var contentInfo = new ContentInfo(dict) { ChannelId = _channelInfo.Id, SiteId = SiteId, AddUserName = AuthRequest.AdminName, 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; 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, _channelInfo.Id, contentInfo.Id, new AttributesImpl(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.AddTags(tagCollection, 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 { var tagsLast = contentInfo.Tags; 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); 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, _channelInfo.Id, contentInfo.Id, new AttributesImpl(Request.Form), contentInfo)); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit)); } } DataProvider.ContentDao.Update(SiteInfo, _channelInfo, contentInfo); TagUtils.UpdateTags(tagsLast, contentInfo.Tags, tagCollection, SiteId, contentId); 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 CheckResult Check([FromBody] CheckRequest request) { var req = new AuthenticatedRequest(); if (!req.IsApiAuthenticated || !AccessTokenManager.IsScope(req.ApiToken, AccessTokenManager.ScopeContents)) { return(Request.Unauthorized <CheckResult>()); } var site = SiteManager.GetSiteInfo(request.SiteId); if (site == null) { return(Request.BadRequest <CheckResult>("无法确定内容对应的站点")); } var contents = new List <Dictionary <string, object> >(); foreach (var channelContentId in request.Contents) { var channel = ChannelManager.GetChannelInfo(request.SiteId, channelContentId.ChannelId); var tableName = ChannelManager.GetTableName(site, channel); var content = ContentManager.GetContentInfo(site, channel, channelContentId.Id); if (content == null) { continue; } content.Set(ContentAttribute.CheckUserName, req.AdminName); content.Set(ContentAttribute.CheckDate, DateTime.Now); content.Set(ContentAttribute.CheckReasons, request.Reasons); content.Checked = true; content.CheckedLevel = 0; DataProvider.ContentDao.Update(site, channel, content); contents.Add(content.ToDictionary()); var contentCheck = new ContentCheckInfo { TableName = tableName, SiteId = request.SiteId, ChannelId = content.ChannelId, ContentId = content.Id, UserName = req.AdminName, IsChecked = true, CheckedLevel = 0, CheckDate = DateTime.Now, Reasons = request.Reasons }; DataProvider.ContentCheckDao.Insert(contentCheck); } req.AddSiteLog(request.SiteId, "批量审核内容"); foreach (var content in request.Contents) { CreateManager.CreateContent(request.SiteId, content.ChannelId, content.Id); } foreach (var distinctChannelId in request.Contents.Select(x => x.ChannelId).Distinct()) { CreateManager.TriggerContentChangedEvent(request.SiteId, distinctChannelId); } CreateManager.CreateChannel(request.SiteId, request.SiteId); return(new CheckResult { Contents = contents }); }
public override void Submit_OnClick(object sender, EventArgs e) { var isSuccess = false; try { var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); var filePath = channelInfo.FilePath; if (PhFilePath.Visible) { TbFilePath.Text = TbFilePath.Text.Trim(); if (!string.IsNullOrEmpty(TbFilePath.Text) && !StringUtils.EqualsIgnoreCase(filePath, TbFilePath.Text)) { if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text)) { FailMessage("栏目页面路径不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(TbFilePath.Text)) { TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html"); } var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId); filePathArrayList.AddRange(DataProvider.TemplateMatchDao.GetAllFilePathBySiteId(SiteId)); if (filePathArrayList.IndexOf(TbFilePath.Text) != -1) { FailMessage("栏目修改失败,栏目页面路径已存在!"); return; } } } if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text)) { var filePathRule = TbChannelFilePathRule.Text.Replace("|", string.Empty); if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule)) { FailMessage("栏目页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(filePathRule)) { FailMessage("栏目页面命名规则必须包含生成文件的后缀!"); return; } } if (!string.IsNullOrEmpty(TbContentFilePathRule.Text)) { var filePathRule = TbContentFilePathRule.Text.Replace("|", string.Empty); if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule)) { FailMessage("内容页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(filePathRule)) { FailMessage("内容页面命名规则必须包含生成文件的后缀!"); return; } } if (TbFilePath.Text != PageUtility.GetInputChannelUrl(SiteInfo, channelInfo, false)) { channelInfo.FilePath = TbFilePath.Text; } if (TbChannelFilePathRule.Text != PathUtility.GetChannelFilePathRule(SiteInfo, _channelId)) { channelInfo.ChannelFilePathRule = TbChannelFilePathRule.Text; } if (TbContentFilePathRule.Text != PathUtility.GetContentFilePathRule(SiteInfo, _channelId)) { channelInfo.ContentFilePathRule = TbContentFilePathRule.Text; } DataProvider.ChannelDao.Update(channelInfo); CreateManager.CreateChannel(SiteId, _channelId); AuthRequest.AddSiteLog(SiteId, _channelId, 0, "设置页面命名规则", $"栏目:{channelInfo.ChannelName}"); isSuccess = true; } catch (Exception ex) { FailMessage(ex, ex.Message); } if (isSuccess) { LayerUtils.CloseAndRedirect(Page, PageConfigurationCreateRule.GetRedirectUrl(SiteId, _channelId)); } }
public IHttpActionResult Create([FromBody] CreateParameter parameter) { try { var request = new AuthenticatedRequest(); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasSitePermissions(parameter.SiteId, ConfigManager.WebSitePermissions.Create)) { return(Unauthorized()); } var selectedChannelIdList = new List <int>(); if (parameter.IsAllChecked) { selectedChannelIdList = ChannelManager.GetChannelIdList(parameter.SiteId); } else if (parameter.IsDescendent) { foreach (var channelId in parameter.ChannelIdList) { selectedChannelIdList.Add(channelId); var channelInfo = ChannelManager.GetChannelInfo(parameter.SiteId, channelId); if (channelInfo.ChildrenCount > 0) { var descendentIdList = ChannelManager.GetChannelIdList(channelInfo, EScopeType.Descendant); foreach (var descendentId in descendentIdList) { if (selectedChannelIdList.Contains(descendentId)) { continue; } selectedChannelIdList.Add(descendentId); } } } } else { selectedChannelIdList.AddRange(parameter.ChannelIdList); } var channelIdList = new List <int>(); if (parameter.Scope == "1month" || parameter.Scope == "1day" || parameter.Scope == "2hours") { var siteInfo = SiteManager.GetSiteInfo(parameter.SiteId); var tableName = siteInfo.TableName; if (parameter.Scope == "1month") { var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, parameter.SiteId, 720); foreach (var channelId in lastEditList) { if (selectedChannelIdList.Contains(channelId)) { channelIdList.Add(channelId); } } } else if (parameter.Scope == "1day") { var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, parameter.SiteId, 24); foreach (var channelId in lastEditList) { if (selectedChannelIdList.Contains(channelId)) { channelIdList.Add(channelId); } } } else if (parameter.Scope == "2hours") { var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, parameter.SiteId, 2); foreach (var channelId in lastEditList) { if (selectedChannelIdList.Contains(channelId)) { channelIdList.Add(channelId); } } } } else { channelIdList = selectedChannelIdList; } foreach (var channelId in channelIdList) { if (parameter.IsChannelPage) { CreateManager.CreateChannel(parameter.SiteId, channelId); } if (parameter.IsContentPage) { CreateManager.CreateAllContent(parameter.SiteId, channelId); } } return(Ok(new { })); } catch (Exception ex) { return(InternalServerError(ex)); } }
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); }
public IHttpActionResult Submit() { try { var request = new AuthenticatedRequest(); var siteId = request.GetPostInt("siteId"); var guid = request.GetPostString("guid"); var specialId = request.GetPostInt("specialId"); var isEditOnly = request.GetPostBool("isEditOnly"); var isUploadOnly = request.GetPostBool("isUploadOnly"); var title = request.GetPostString("title"); var url = request.GetPostString("url"); var fileNames = TranslateUtils.StringCollectionToStringList(request.GetPostString("fileNames")); var siteInfo = SiteManager.GetSiteInfo(siteId); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasSitePermissions(siteId, ConfigManager.SitePermissions.Specials)) { return(Unauthorized()); } if (specialId > 0 && isEditOnly) { var specialInfo = SpecialManager.GetSpecialInfo(siteId, specialId); var oldDirectoryPath = string.Empty; var newDirectoryPath = string.Empty; if (specialInfo.Title != title && DataProvider.SpecialDao.IsTitleExists(siteId, title)) { return(BadRequest("专题修改失败,专题名称已存在!")); } if (specialInfo.Url != url) { if (DataProvider.SpecialDao.IsUrlExists(siteId, url)) { return(BadRequest("专题修改失败,专题访问地址已存在!")); } oldDirectoryPath = SpecialManager.GetSpecialDirectoryPath(siteInfo, specialInfo.Url); newDirectoryPath = SpecialManager.GetSpecialDirectoryPath(siteInfo, url); } specialInfo.Title = title; specialInfo.Url = url; DataProvider.SpecialDao.Update(specialInfo); if (oldDirectoryPath != newDirectoryPath) { DirectoryUtils.MoveDirectory(oldDirectoryPath, newDirectoryPath, true); } } else if (specialId > 0 && isUploadOnly) { var specialInfo = SpecialManager.GetSpecialInfo(siteId, specialId); var directoryPath = SpecialManager.GetSpecialDirectoryPath(siteInfo, specialInfo.Url); var srcDirectoryPath = SpecialManager.GetSpecialSrcDirectoryPath(directoryPath); DirectoryUtils.CreateDirectoryIfNotExists(srcDirectoryPath); var uploadDirectoryPath = PathUtils.GetTemporaryFilesPath(guid); foreach (var filePath in DirectoryUtils.GetFilePaths(uploadDirectoryPath)) { var fileName = PathUtils.GetFileName(filePath); if (!StringUtils.ContainsIgnoreCase(fileNames, fileName)) { continue; } if (EFileSystemTypeUtils.IsZip(PathUtils.GetExtension(filePath))) { ZipUtils.ExtractZip(filePath, srcDirectoryPath); } else { FileUtils.MoveFile(filePath, PathUtils.Combine(srcDirectoryPath, fileName), true); } } DirectoryUtils.Copy(srcDirectoryPath, directoryPath); } else if (specialId == 0) { if (DataProvider.SpecialDao.IsTitleExists(siteId, title)) { return(BadRequest("专题添加失败,专题名称已存在!")); } if (DataProvider.SpecialDao.IsUrlExists(siteId, url)) { return(BadRequest("专题添加失败,专题访问地址已存在!")); } var directoryPath = SpecialManager.GetSpecialDirectoryPath(siteInfo, url); var srcDirectoryPath = SpecialManager.GetSpecialSrcDirectoryPath(directoryPath); DirectoryUtils.CreateDirectoryIfNotExists(srcDirectoryPath); var uploadDirectoryPath = PathUtils.GetTemporaryFilesPath(guid); foreach (var filePath in DirectoryUtils.GetFilePaths(uploadDirectoryPath)) { var fileName = PathUtils.GetFileName(filePath); if (!StringUtils.ContainsIgnoreCase(fileNames, fileName)) { continue; } if (EFileSystemTypeUtils.IsZip(PathUtils.GetExtension(filePath))) { ZipUtils.ExtractZip(filePath, srcDirectoryPath); } else { FileUtils.MoveFile(filePath, PathUtils.Combine(srcDirectoryPath, fileName), true); } } DirectoryUtils.Copy(srcDirectoryPath, directoryPath); specialId = DataProvider.SpecialDao.Insert(new SpecialInfo { Id = 0, SiteId = siteId, Title = title, Url = url, AddDate = DateTime.Now }); request.AddSiteLog(siteId, "新建专题", $"专题名称:{title}"); } CreateManager.CreateSpecial(siteId, specialId); return(Ok(new { Value = specialId })); } catch (Exception 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 isUp = request.GetPostBool("isUp"); var taxis = request.GetPostInt("taxis"); if (!request.IsUserLoggin || !request.UserPermissionsImpl.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentEdit)) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } if (ETaxisTypeUtils.Equals(channelInfo.Additional.DefaultTaxisType, ETaxisType.OrderByTaxis)) { isUp = !isUp; } if (isUp == false) { contentIdList.Reverse(); } var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); foreach (var contentId in contentIdList) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); if (contentInfo == null) { continue; } var isTop = contentInfo.IsTop; for (var i = 1; i <= taxis; i++) { if (isUp) { if (DataProvider.ContentDao.SetTaxisToUp(tableName, channelId, contentId, isTop) == false) { break; } } else { if (DataProvider.ContentDao.SetTaxisToDown(tableName, channelId, contentId, isTop) == false) { break; } } } } CreateManager.TriggerContentChangedEvent(siteId, channelId); request.AddSiteLog(siteId, channelId, 0, "对内容排序", string.Empty); return(Ok(new { Value = contentIdList })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
private void SaveExecute() { try { tblEmploye newEmploye = new tblEmploye(); newEmploye.FirstName = Employe.FirstName; newEmploye.Surname = Employe.Surname; newEmploye.JMBG = Employe.JMBG; newEmploye.Salary = Convert.ToInt32(Employe.Salary); newEmploye.Account = Employe.Account; newEmploye.Pasword = Employe.Pasword; newEmploye.Username = Employe.Username; newEmploye.Position = Employe.Position; newEmploye.Email = Employe.Email; string birthdate = CalculateBirth(Employe.JMBG); CreateManager cm = new CreateManager(); cm.tbJMBG.Text = ""; //method checks if jmbg already exists in database AND ONLY IF NOT proceeds to save employe if (KeyCheck(newEmploye.JMBG) == true && PasswordCheck(newEmploye.Pasword) == true && UsernameCheck(newEmploye.Username) == true && NumbersOnly(newEmploye.JMBG) == true) { newEmploye.DateOfBirth = CalculateBirth(Employe.JMBG); context.tblEmployes.Add(newEmploye); context.SaveChanges(); tblManager newManager = new tblManager(); newManager.EmployeID = newEmploye.EmployeID; newManager.SectorID = Sector.SectorID; newManager.LevelID = Level.LevelID; context.tblManagers.Add(newManager); context.SaveChanges(); MessageBox.Show("Manager is created."); if (!worker.IsBusy) { worker.RunWorkerAsync(); } } else { MessageBox.Show("JMBG or password or username already exists"); } } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException MessageBox.Show(message); raise = new InvalidOperationException(message, raise); } } throw raise; } }
void Awake() { _instance = this; }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { int insertNodeId; try { var nodeId = Body.GetQueryInt("NodeID"); var nodeInfo = new NodeInfo { ParentId = nodeId, ContentModelId = ContentModelID.SelectedValue }; if (NodeIndexName.Text.Length != 0) { var nodeIndexNameArrayList = DataProvider.NodeDao.GetNodeIndexNameList(PublishmentSystemId); if (nodeIndexNameArrayList.IndexOf(NodeIndexName.Text) != -1) { FailMessage("栏目添加失败,栏目索引已存在!"); return; } } if (FilePath.Text.Length != 0) { if (!DirectoryUtils.IsDirectoryNameCompliant(FilePath.Text)) { FailMessage("栏目页面路径不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(FilePath.Text)) { FilePath.Text = PageUtils.Combine(FilePath.Text, "index.html"); } var filePathArrayList = DataProvider.NodeDao.GetAllFilePathByPublishmentSystemId(PublishmentSystemId); if (filePathArrayList.IndexOf(FilePath.Text) != -1) { FailMessage("栏目添加失败,栏目页面路径已存在!"); return; } } if (!string.IsNullOrEmpty(ChannelFilePathRule.Text)) { if (!DirectoryUtils.IsDirectoryNameCompliant(ChannelFilePathRule.Text)) { FailMessage("栏目页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(ChannelFilePathRule.Text)) { FailMessage("栏目页面命名规则必须包含生成文件的后缀!"); return; } } if (!string.IsNullOrEmpty(ContentFilePathRule.Text)) { if (!DirectoryUtils.IsDirectoryNameCompliant(ContentFilePathRule.Text)) { FailMessage("内容页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(ContentFilePathRule.Text)) { FailMessage("内容页面命名规则必须包含生成文件的后缀!"); return; } } var extendedAttributes = new ExtendedAttributes(); var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, _nodeId); BackgroundInputTypeParser.AddValuesToAttributes(ETableStyle.Channel, DataProvider.NodeDao.TableName, PublishmentSystemInfo, relatedIdentities, Request.Form, extendedAttributes.Attributes); var attributes = extendedAttributes.Attributes; foreach (string key in attributes) { nodeInfo.Additional.SetExtendedAttribute(key, attributes[key]); } nodeInfo.NodeName = NodeName.Text; nodeInfo.NodeIndexName = NodeIndexName.Text; nodeInfo.FilePath = FilePath.Text; nodeInfo.ChannelFilePathRule = ChannelFilePathRule.Text; nodeInfo.ContentFilePathRule = ContentFilePathRule.Text; var list = new ArrayList(); foreach (ListItem item in NodeGroupNameCollection.Items) { if (item.Selected) { list.Add(item.Value); } } nodeInfo.NodeGroupNameCollection = TranslateUtils.ObjectCollectionToString(list); nodeInfo.ImageUrl = NavigationPicPath.Text; nodeInfo.Content = StringUtility.TextEditorContentEncode(Request.Form[NodeAttribute.Content], PublishmentSystemInfo, PublishmentSystemInfo.Additional.IsSaveImageInTextEditor); nodeInfo.Keywords = Keywords.Text; nodeInfo.Description = Description.Text; nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(IsChannelAddable.SelectedValue); nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(IsContentAddable.SelectedValue); nodeInfo.LinkUrl = LinkURL.Text; nodeInfo.LinkType = ELinkTypeUtils.GetEnumType(LinkType.SelectedValue); nodeInfo.ChannelTemplateId = (ChannelTemplateID.Items.Count > 0) ? int.Parse(ChannelTemplateID.SelectedValue) : 0; nodeInfo.ContentTemplateId = (ContentTemplateID.Items.Count > 0) ? int.Parse(ContentTemplateID.SelectedValue) : 0; nodeInfo.AddDate = DateTime.Now; insertNodeId = DataProvider.NodeDao.InsertNodeInfo(nodeInfo); //栏目选择投票样式后,内容 } catch (Exception ex) { FailMessage(ex, $"栏目添加失败:{ex.Message}"); LogUtils.AddErrorLog(ex); return; } CreateManager.CreateChannel(PublishmentSystemId, insertNodeId); Body.AddSiteLog(PublishmentSystemId, "添加栏目", $"栏目:{NodeName.Text}"); SuccessMessage("栏目添加成功!"); AddWaitAndRedirectScript(_returnUrl); } }