public override void Submit_OnClick(object sender, EventArgs e) { var isUp = DdlTaxisType.SelectedValue == "Up"; var taxisNum = TranslateUtils.ToInt(TbTaxisNum.Text); var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); if (ETaxisTypeUtils.Equals(nodeInfo.Additional.DefaultTaxisType, ETaxisType.OrderByTaxis)) { isUp = !isUp; } if (isUp == false) { _contentIdList.Reverse(); } foreach (var contentId in _contentIdList) { var tuple = DataProvider.ContentDao.GetValue(_tableName, contentId, ContentAttribute.IsTop); if (tuple == null) { continue; } var isTop = TranslateUtils.ToBool(tuple.Item2); for (var i = 1; i <= taxisNum; i++) { if (isUp) { if (DataProvider.ContentDao.SetTaxisToUp(SiteId, _tableName, _channelId, contentId, isTop) == false) { break; } } else { if (DataProvider.ContentDao.SetTaxisToDown(SiteId, _tableName, _channelId, contentId, isTop) == false) { break; } } } } CreateManager.TriggerContentChangedEvent(SiteId, _channelId); AuthRequest.AddSiteLog(SiteId, _channelId, 0, "对内容排序", string.Empty); LayerUtils.CloseAndRedirect(Page, _returnUrl); }
public static void Add(ChannelInfo channelInfo, ContentInfo contentInfo) { if (ETaxisTypeUtils.Equals(ETaxisType.OrderByTaxisDesc, channelInfo.Additional.DefaultTaxisType)) { var contentIdList = GetContentIdList(channelInfo.Id, null); contentIdList.Insert(0, contentInfo.Id); contentIdList = GetContentIdList(channelInfo.Id, contentInfo.AdminId); contentIdList.Insert(0, contentInfo.Id); } else { Remove(channelInfo.Id); } }
public static void InsertCache(SiteInfo siteInfo, ChannelInfo channelInfo, IContentInfo contentInfo) { if (contentInfo.SourceId == SourceManager.Preview) { return; } var contentIdList = ListCache.GetContentIdList(channelInfo.Id); if (ETaxisTypeUtils.Equals(ETaxisType.OrderByTaxisDesc, channelInfo.Additional.DefaultTaxisType)) { contentIdList.Insert(0, contentInfo.Id); } else { ListCache.Remove(channelInfo.Id); } var dict = ContentCache.GetContentDict(contentInfo.ChannelId); dict[contentInfo.Id] = (ContentInfo)contentInfo; var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var countInfoList = GetContentCountInfoList(tableName); var countInfo = countInfoList.FirstOrDefault(x => x.SiteId == siteInfo.Id && x.ChannelId == channelInfo.Id && x.IsChecked == contentInfo.IsChecked.ToString() && x.CheckedLevel == contentInfo.CheckedLevel); if (countInfo != null) { countInfo.Count++; } StlContentCache.ClearCache(); CountCache.Clear(tableName); }
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)); } }