private List <int> GetKeywordIDList(List <int> appointmentIDList) { var keywordIDList = new List <int>(); string sqlString = $"SELECT {AppointmentAttribute.KeywordID} FROM {TABLE_NAME} WHERE ID IN ({TranslateUtils.ToSqlInStringWithoutQuote(appointmentIDList)})"; using (var rdr = ExecuteReader(sqlString)) { while (rdr.Read()) { keywordIDList.Add(rdr.GetInt32(0)); } rdr.Close(); } return(keywordIDList); }
public static string GetScript(PageInfo pageInfo, string target, bool isShowTreeLine, bool isShowContentNum, string currentFormatString, int topChannelId, int topParentsCount, int currentChannelId) { var script = @" <script language=""JavaScript""> function stltree_isNull(obj){ if (typeof(obj) == 'undefined') return true; if (obj == undefined) return true; if (obj == null) return true; return false; } function stltree_getTreeLevel(e) { var length = 0; if (!stltree_isNull(e)){ if (e.tagName == 'TR') { length = parseInt(e.getAttribute('treeItemLevel')); } } return length; } function stltree_getTrElement(element){ if (stltree_isNull(element)) return; for (element = element.parentNode;;){ if (element != null && element.tagName == 'TR'){ break; }else{ element = element.parentNode; } } return element; } function stltree_getImgClickableElementByTr(element){ if (stltree_isNull(element) || element.tagName != 'TR') return; var img = null; if (!stltree_isNull(element.childNodes)){ var imgCol = element.getElementsByTagName('IMG'); if (!stltree_isNull(imgCol)){ for (x=0;x<imgCol.length;x++){ if (!stltree_isNull(imgCol.item(x).getAttribute('isOpen'))){ img = imgCol.item(x); break; } } } } return img; } var weightedLink = null; function fontWeightLink(element){ if (weightedLink != null) { weightedLink.style.fontWeight = 'normal'; } element.style.fontWeight = 'bold'; weightedLink = element; } var completedChannelId = null; function stltree_displayChildren(img){ if (stltree_isNull(img)) return; var tr = stltree_getTrElement(img); var isToOpen = img.getAttribute('isOpen') == 'false'; var isByAjax = img.getAttribute('isAjax') == 'true'; var channelId = img.getAttribute('id'); if (!stltree_isNull(img) && img.getAttribute('isOpen') != null){ if (img.getAttribute('isOpen') == 'false'){ img.setAttribute('isOpen', 'true'); img.setAttribute('src', '{iconMinusUrl}'); }else{ img.setAttribute('isOpen', 'false'); img.setAttribute('src', '{iconPlusUrl}'); } } if (isToOpen && isByAjax) { var div = document.createElement('div'); div.innerHTML = ""<img align='absmiddle' border='0' src='{iconLoadingUrl}' /> 加载中,请稍候...""; img.parentNode.appendChild(div); //Element.addClassName(div, 'loading'); loadingChannels(tr, img, div, channelId); } else { var level = stltree_getTreeLevel(tr); var collection = new Array(); var index = 0; for ( var e = tr.nextSibling; !stltree_isNull(e) ; e = e.nextSibling) { if (!stltree_isNull(e) && !stltree_isNull(e.tagName) && e.tagName == 'TR'){ var currentLevel = stltree_getTreeLevel(e); if (currentLevel <= level) break; if(e.style.display == '') { e.style.display = 'none'; }else{ if (currentLevel != level + 1) continue; e.style.display = ''; var imgClickable = stltree_getImgClickableElementByTr(e); if (!stltree_isNull(imgClickable)){ if (!stltree_isNull(imgClickable.getAttribute('isOpen')) && imgClickable.getAttribute('isOpen') =='true'){ imgClickable.setAttribute('isOpen', 'false'); imgClickable.setAttribute('src', '{iconPlusUrl}'); collection[index] = imgClickable; index++; } } } } } if (index > 0){ for (i=0;i<=index;i++){ stltree_displayChildren(collection[i]); } } } } "; var loadingUrl = ApiRouteActionsLoadingChannels.GetUrl(pageInfo.ApiUrl); var formatString = TranslateUtils.EncryptStringBySecretKey(currentFormatString); script += $@" function loadingChannels(tr, img, div, channelId){{ var url = '{loadingUrl}'; var pars = 'siteID={pageInfo.SiteId}&parentID=' + channelId + '&target={target}&isShowTreeLine={isShowTreeLine}&isShowContentNum={isShowContentNum}¤tFormatString={formatString}&topChannelId={topChannelId}&topParentsCount={topParentsCount}¤tChannelId={currentChannelId}'; //jQuery.post(url, pars, function(data, textStatus){{ //$($.parseHTML(data)).insertAfter($(tr)); //img.setAttribute('isAjax', 'false'); //img.parentNode.removeChild(div); //completedChannelId = channelId; //}}); $.ajax({{ url: url, type: ""POST"", mimeType:""multipart/form-data"", contentType: false, processData: false, cache: false, xhrFields: {{ withCredentials: true }}, data: pars, success: function(json, textStatus){{ $($.parseHTML(data)).insertAfter($(tr)); img.setAttribute('isAjax', 'false'); img.parentNode.removeChild(div); completedChannelId = channelId; }} }}); }} function loadingChannelsOnLoad(path){{ if (path && path.length > 0){{ var channelIds = path.split(','); var channelId = channelIds[0]; var img = $(channelId); if (!img) return; if (img.getAttribute('isOpen') == 'false'){{ stltree_displayChildren(img); new PeriodicalExecuter(function(pe){{ if (completedChannelId && completedChannelId == channelId){{ if (path.indexOf(',') != -1){{ var thePath = path.substring(path.indexOf(',') + 1); loadingChannelsOnLoad(thePath); }} pe.stop(); }} }}, 1); }} }} }} </script> "; script += GetScriptOnLoad(pageInfo.SiteId, topChannelId, pageInfo.PageChannelId); var treeDirectoryUrl = SiteFilesAssets.GetUrl(pageInfo.ApiUrl, "tree"); var iconFolderUrl = PageUtils.Combine(treeDirectoryUrl, "folder.gif"); var iconOpenedFolderUrl = PageUtils.Combine(treeDirectoryUrl, "openedfolder.gif"); var iconMinusUrl = PageUtils.Combine(treeDirectoryUrl, "minus.png"); var iconPlusUrl = PageUtils.Combine(treeDirectoryUrl, "plus.png"); script = script.Replace("{iconFolderUrl}", iconFolderUrl); script = script.Replace("{iconMinusUrl}", iconMinusUrl); script = script.Replace("{iconOpenedFolderUrl}", iconOpenedFolderUrl); script = script.Replace("{iconPlusUrl}", iconPlusUrl); script = script.Replace("{isNodeTree}", "true"); script = script.Replace("{iconLoadingUrl}", SiteFilesAssets.GetUrl(pageInfo.ApiUrl, SiteFilesAssets.FileLoading)); return(script); }
private async Task ImportContentsAsync(AtomEntryCollection entries, Channel channel, int taxis, int importStart, int importCount, bool isCheckedBySettings, bool isChecked, int checkedLevel, bool isOverride, int adminId, string guid) { if (importStart > 1 || importCount > 0) { var theEntries = new AtomEntryCollection(); if (importStart == 0) { importStart = 1; } if (importCount == 0) { importCount = entries.Count; } var firstIndex = entries.Count - importStart - importCount + 1; if (firstIndex <= 0) { firstIndex = 0; } var addCount = 0; for (var i = 0; i < entries.Count; i++) { if (addCount >= importCount) { break; } if (i >= firstIndex) { theEntries.Add(entries[i]); addCount++; } } entries = theEntries; } var contents = new List <Content>(); foreach (AtomEntry entry in entries) { try { taxis++; var groupNames = AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.GroupNames), "GroupNameCollection", "ContentGroupNameCollection" }); var tagNames = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.TagNames), "Tags" })); if (isCheckedBySettings) { isChecked = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.Checked), "IsChecked" })); checkedLevel = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.CheckedLevel))); } var hits = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.Hits))); var hitsByDay = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.HitsByDay))); var hitsByWeek = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.HitsByWeek))); var hitsByMonth = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.HitsByMonth))); var lastHitsDate = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.LastHitsDate)); var downloads = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.Downloads))); var title = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.Title)); var isTop = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.Top), "IsTop" })); var isRecommend = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.Recommend), "IsRecommend" })); var isHot = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.Hot), "IsHot" })); var isColor = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.Color), "IsColor" })); var linkUrl = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.LinkUrl))); var addDate = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.AddDate)); var body = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.Body), "Content" })); var topTaxis = 0; if (isTop) { topTaxis = taxis - 1; taxis = await _databaseManager.ContentRepository.GetMaxTaxisAsync(_site, channel, true) + 1; } var dict = new Dictionary <string, object>(); var attributes = AtomUtility.GetDcElementNameValueCollection(entry.AdditionalElements); foreach (string attributeName in attributes.Keys) { dict[attributeName] = AtomUtility.Decrypt(attributes[attributeName]); } var content = new Content(); content.LoadDict(dict); content.SiteId = _site.Id; content.ChannelId = channel.Id; content.AddDate = TranslateUtils.ToDateTime(addDate); content.AdminId = adminId; content.LastEditAdminId = adminId; content.GroupNames = ListUtils.GetStringList(groupNames); content.TagNames = ListUtils.GetStringList(tagNames); content.Checked = isChecked; content.CheckedLevel = checkedLevel; content.Hits = hits; content.HitsByDay = hitsByDay; content.HitsByWeek = hitsByWeek; content.HitsByMonth = hitsByMonth; content.LastHitsDate = TranslateUtils.ToDateTime(lastHitsDate); content.Downloads = downloads; content.Title = AtomUtility.Decrypt(title); content.Top = isTop; content.Recommend = isRecommend; content.Hot = isHot; content.Color = isColor; content.LinkUrl = linkUrl; content.Body = body; var isInsert = false; if (isOverride) { var existsIDs = await _databaseManager.ContentRepository.GetContentIdsBySameTitleAsync(_site, channel, content.Title); if (existsIDs.Count > 0) { foreach (var id in existsIDs) { content.Id = id; contents.Add(content); } } else { isInsert = true; } } else { isInsert = true; } if (isInsert) { content.Taxis = taxis; contents.Add(content); if (!string.IsNullOrEmpty(tagNames)) { foreach (var tagName in ListUtils.GetStringList(tagNames)) { await _databaseManager.ContentTagRepository.InsertAsync(_site.Id, tagName); } } } if (isTop) { taxis = topTaxis; } } catch (Exception ex) { await _databaseManager.ErrorLogRepository.AddErrorLogAsync(ex, "导入内容"); } } foreach (var content in contents) { _caching.SetProcess(guid, $"导入内容: {content.Title}"); if (content.Id > 0) { await _databaseManager.ContentRepository.UpdateAsync(_site, channel, content); } else { await _databaseManager.ContentRepository.InsertWithTaxisAsync(_site, channel, content, content.Taxis); } } }
public static int GetChannelIdByParentIdAndChannelName(int siteId, int parentId, string channelName, bool recursive) { if (parentId <= 0 || string.IsNullOrEmpty(channelName)) { return(0); } var dict = ChannelManagerCache.GetChannelInfoDictionaryBySiteId(siteId); var channelInfoList = dict.Values.OrderBy(x => x.Taxis).ToList(); ChannelInfo channelInfo; if (recursive) { if (siteId == parentId) { channelInfo = channelInfoList.FirstOrDefault(x => x.ChannelName == channelName); //sqlString = $"SELECT Id FROM siteserver_Channel WHERE (SiteId = {siteId} AND ChannelName = '{AttackUtils.FilterSql(channelName)}') ORDER BY Taxis"; } else { channelInfo = channelInfoList.FirstOrDefault(x => (x.ParentId == parentId || TranslateUtils.StringCollectionToIntList(x.ParentsPath).Contains(parentId)) && x.ChannelName == channelName); // sqlString = $@"SELECT Id //FROM siteserver_Channel //WHERE ((ParentId = {parentId}) OR // (ParentsPath = '{parentId}') OR // (ParentsPath LIKE '{parentId},%') OR // (ParentsPath LIKE '%,{parentId},%') OR // (ParentsPath LIKE '%,{parentId}')) AND ChannelName = '{AttackUtils.FilterSql(channelName)}' //ORDER BY Taxis"; } } else { channelInfo = channelInfoList.FirstOrDefault(x => x.ParentId == parentId && x.ChannelName == channelName); //sqlString = $"SELECT Id FROM siteserver_Channel WHERE (ParentId = {parentId} AND ChannelName = '{AttackUtils.FilterSql(channelName)}') ORDER BY Taxis"; } return(channelInfo?.Id ?? 0); }
private static string ParseImplNotAjax(PageInfo pageInfo, ContextInfo contextInfo, string channelIndex, string channelName, int upLevel, int topLevel, string groupChannel, string groupChannelNot, string title, bool isShowContentNum, bool isShowTreeLine, string currentFormatString) { var channelId = StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, contextInfo.ChannelId, upLevel, topLevel); channelId = StlDataUtility.GetChannelIdByChannelIdOrChannelIndexOrChannelName(pageInfo.SiteId, channelId, channelIndex, channelName); var channel = ChannelManager.GetChannelInfo(pageInfo.SiteId, channelId); var target = ""; var htmlBuilder = new StringBuilder(); htmlBuilder.Append(@"<table border=""0"" cellpadding=""0"" cellspacing=""0"" style=""width:100%;"">"); //var theChannelIdList = DataProvider.ChannelDao.GetIdListByScopeType(channel.ChannelId, channel.ChildrenCount, EScopeType.All, groupChannel, groupChannelNot); var theChannelIdList = ChannelManager.GetChannelIdList(channel, EScopeType.All, groupChannel, groupChannelNot, string.Empty); var isLastNodeArray = new bool[theChannelIdList.Count]; var channelIdList = new List <int>(); var currentChannelInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, pageInfo.PageChannelId); if (currentChannelInfo != null) { channelIdList = TranslateUtils.StringCollectionToIntList(currentChannelInfo.ParentsPath); channelIdList.Add(currentChannelInfo.Id); } foreach (var theChannelId in theChannelIdList) { var theChannelInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, theChannelId); var nodeInfo = new ChannelInfo(theChannelInfo); if (theChannelId == pageInfo.SiteId && !string.IsNullOrEmpty(title)) { nodeInfo.ChannelName = title; } var isDisplay = channelIdList.Contains(theChannelId); if (!isDisplay) { isDisplay = nodeInfo.ParentId == channelId || channelIdList.Contains(nodeInfo.ParentId); } var selected = theChannelId == channelId; if (!selected && channelIdList.Contains(nodeInfo.Id)) { selected = true; } var hasChildren = nodeInfo.ChildrenCount != 0; var linkUrl = PageUtility.GetChannelUrl(pageInfo.SiteInfo, theChannelInfo, pageInfo.IsLocal); var level = theChannelInfo.ParentsCount - channel.ParentsCount; var item = new StlTreeItemNotAjax(isDisplay, selected, pageInfo, nodeInfo, hasChildren, linkUrl, target, isShowTreeLine, isShowContentNum, isLastNodeArray, currentFormatString, channelId, level); htmlBuilder.Append(item.GetTrHtml()); } htmlBuilder.Append("</table>"); if (!pageInfo.BodyCodes.ContainsKey(PageInfo.Const.JsAgStlTreeNotAjax)) { pageInfo.BodyCodes.Add(PageInfo.Const.JsAgStlTreeNotAjax, StlTreeItemNotAjax.GetNodeTreeScript(pageInfo)); } return(htmlBuilder.ToString()); }
internal static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { if (string.IsNullOrEmpty(contextInfo.InnerXml)) { return(string.Empty); } var innerBuilder = new StringBuilder(contextInfo.InnerXml); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); var scrollHtml = innerBuilder.ToString(); var scrollDelay = 40; var direction = DirectionVertical; var width = "width:100%;"; var height = string.Empty; foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, AttributeScrollDelay)) { scrollDelay = TranslateUtils.ToInt(value, 40); } else if (StringUtils.EqualsIgnoreCase(name, AttributeDirection)) { if (value.ToLower().Equals(DirectionHorizontal.ToLower())) { direction = DirectionHorizontal; } } else if (StringUtils.EqualsIgnoreCase(name, AttributeWidth)) { value = value.Trim(); if (!string.IsNullOrEmpty(value)) { if (char.IsDigit(value[value.Length - 1])) { width = "width:" + value + "px;"; } else { width = "width:" + value + ";"; } } } else if (StringUtils.EqualsIgnoreCase(name, AttributeHeight)) { value = value.Trim(); if (!string.IsNullOrEmpty(value)) { if (char.IsDigit(value[value.Length - 1])) { height = "height:" + value + "px;"; } else { height = "height:" + value + ";"; } } } } return(ParseImpl(pageInfo, scrollHtml, scrollDelay, direction, width, height)); }
public IHttpActionResult GetConfig() { try { var request = new RequestImpl(); var siteId = request.GetQueryInt("siteId"); var channelId = request.GetQueryInt("channelId"); var contentIdList = TranslateUtils.StringCollectionToIntList(request.GetQueryString("contentIds")); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentCheck)) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } var retval = new List <Dictionary <string, object> >(); foreach (var contentId in contentIdList) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); if (contentInfo == null) { continue; } var dict = contentInfo.ToDictionary(); dict["title"] = WebUtils.GetContentTitle(siteInfo, contentInfo, string.Empty); dict["checkState"] = CheckManager.GetCheckState(siteInfo, contentInfo); retval.Add(dict); } var isChecked = CheckManager.GetUserCheckLevel(request.AdminPermissionsImpl, siteInfo, siteId, out var checkedLevel); var checkedLevels = CheckManager.GetCheckedLevels(siteInfo, isChecked, checkedLevel, true); var allChannels = ChannelManager.GetChannels(siteId, request.AdminPermissionsImpl, ConfigManager.ChannelPermissions.ContentAdd); return(Ok(new { Value = retval, CheckedLevels = checkedLevels, CheckedLevel = checkedLevel, AllChannels = allChannels })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
public IHttpActionResult GetConfig() { try { var request = new AuthenticatedRequest(); var siteId = request.GetQueryInt("siteId"); var channelId = request.GetQueryInt("channelId"); var contentIdList = TranslateUtils.StringCollectionToIntList(request.GetQueryString("contentIds")); var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } var sites = new List <object>(); var channels = new List <object>(); if (channelInfo.Additional.TransType == ECrossSiteTransType.SelfSite || channelInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite || channelInfo.Additional.TransType == ECrossSiteTransType.ParentSite) { int theSiteId; if (channelInfo.Additional.TransType == ECrossSiteTransType.SelfSite) { theSiteId = siteInfo.Id; } else if (channelInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite) { theSiteId = channelInfo.Additional.TransSiteId; } else { theSiteId = SiteManager.GetParentSiteId(siteInfo.Id); } if (theSiteId > 0) { var theSiteInfo = SiteManager.GetSiteInfo(theSiteId); if (theSiteInfo != null) { sites.Add(new { theSiteInfo.Id, theSiteInfo.SiteName }); } } } else if (channelInfo.Additional.TransType == ECrossSiteTransType.AllParentSite) { var siteIdList = SiteManager.GetSiteIdList(); var allParentSiteIdList = new List <int>(); SiteManager.GetAllParentSiteIdList(allParentSiteIdList, siteIdList, siteInfo.Id); foreach (var psId in siteIdList) { if (psId == siteInfo.Id) { continue; } var psInfo = SiteManager.GetSiteInfo(psId); var show = psInfo.IsRoot || allParentSiteIdList.Contains(psInfo.Id); if (show) { sites.Add(new { psInfo.Id, psInfo.SiteName }); } } } else if (channelInfo.Additional.TransType == ECrossSiteTransType.AllSite) { var siteIdList = SiteManager.GetSiteIdList(); foreach (var psId in siteIdList) { var psInfo = SiteManager.GetSiteInfo(psId); sites.Add(new { psInfo.Id, psInfo.SiteName }); } } var retval = new List <Dictionary <string, object> >(); foreach (var contentId in contentIdList) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); if (contentInfo == null) { continue; } var dict = contentInfo.ToDictionary(); dict["checkState"] = CheckManager.GetCheckState(siteInfo, contentInfo); retval.Add(dict); } var channelIdList = ChannelManager.GetChannelIdList(siteInfo.Id); foreach (var permissionChannelId in channelIdList) { var permissionChannelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, permissionChannelId); channels.Add(new { permissionChannelInfo.Id, ChannelName = ChannelManager.GetChannelNameNavigation(siteInfo.Id, permissionChannelId) }); } return(Ok(new { Value = retval, Sites = sites, Channels = channels, Site = siteInfo })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
internal static object Parse(PageInfo pageInfo, ContextInfo contextInfo) { var siteName = string.Empty; var siteDir = string.Empty; var type = string.Empty; var formatString = string.Empty; string separator = null; var startIndex = 0; var length = 0; var wordNum = 0; var ellipsis = StringUtils.Constants.Ellipsis; var replace = string.Empty; var to = string.Empty; var isClearTags = false; var isReturnToBr = false; var isLower = false; var isUpper = false; foreach (var name in contextInfo.Attributes.AllKeys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, SiteName)) { siteName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, SiteDir)) { siteDir = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, Type)) { type = value; } else if (StringUtils.EqualsIgnoreCase(name, FormatString)) { formatString = value; } else if (StringUtils.EqualsIgnoreCase(name, Separator)) { separator = value; } else if (StringUtils.EqualsIgnoreCase(name, StartIndex)) { startIndex = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Length)) { length = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, WordNum)) { wordNum = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Ellipsis)) { ellipsis = value; } else if (StringUtils.EqualsIgnoreCase(name, Replace)) { replace = value; } else if (StringUtils.EqualsIgnoreCase(name, To)) { to = value; } else if (StringUtils.EqualsIgnoreCase(name, IsClearTags)) { isClearTags = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, IsReturnToBr)) { isReturnToBr = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, IsLower)) { isLower = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, IsUpper)) { isUpper = TranslateUtils.ToBool(value, true); } } var siteInfo = contextInfo.SiteInfo; if (!string.IsNullOrEmpty(siteName)) { siteInfo = SiteManager.GetSiteInfoBySiteName(siteName); } else if (!string.IsNullOrEmpty(siteDir)) { siteInfo = SiteManager.GetSiteInfoByDirectory(siteDir); } if (contextInfo.IsStlEntity && string.IsNullOrEmpty(type)) { return(siteInfo); } return(ParseImpl(pageInfo, contextInfo, siteInfo, type, formatString, separator, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper)); }
public static object Parse(PageInfo pageInfo, ContextInfo contextInfo) { var connectionString = string.Empty; var queryString = string.Empty; var leftText = string.Empty; var rightText = string.Empty; var formatString = string.Empty; var startIndex = 0; var length = 0; var wordNum = 0; var ellipsis = Constants.Ellipsis; var replace = string.Empty; var to = string.Empty; var isClearTags = false; var isReturnToBr = false; var isLower = false; var isUpper = false; var type = string.Empty; foreach (var name in contextInfo.Attributes.AllKeys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, ConnectionString)) { connectionString = value; } else if (StringUtils.EqualsIgnoreCase(name, ConnectionStringName)) { if (string.IsNullOrEmpty(connectionString)) { connectionString = WebConfigUtils.ConnectionString; } } else if (StringUtils.EqualsIgnoreCase(name, QueryString)) { queryString = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, Type)) { type = value.ToLower(); } else if (StringUtils.EqualsIgnoreCase(name, LeftText)) { leftText = value; } else if (StringUtils.EqualsIgnoreCase(name, RightText)) { rightText = value; } else if (StringUtils.EqualsIgnoreCase(name, FormatString)) { formatString = value; } else if (StringUtils.EqualsIgnoreCase(name, StartIndex)) { startIndex = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Length)) { length = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, WordNum)) { wordNum = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, Ellipsis)) { ellipsis = value; } else if (StringUtils.EqualsIgnoreCase(name, Replace)) { replace = value; } else if (StringUtils.EqualsIgnoreCase(name, To)) { to = value; } else if (StringUtils.EqualsIgnoreCase(name, IsClearTags)) { isClearTags = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, IsReturnToBr)) { isReturnToBr = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, IsLower)) { isLower = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, IsUpper)) { isUpper = TranslateUtils.ToBool(value, true); } } if (contextInfo.IsStlEntity && string.IsNullOrEmpty(type)) { object dataItem = null; if (contextInfo.ItemContainer?.SqlItem != null) { dataItem = contextInfo.ItemContainer?.SqlItem.DataItem; } else if (!string.IsNullOrEmpty(queryString)) { var dataTable = StlDatabaseCache.GetDataTable(connectionString, queryString); var dictList = TranslateUtils.DataTableToDictionaryList(dataTable); if (dictList != null && dictList.Count >= 1) { dataItem = dictList[0]; } } return(dataItem); } return(ParseImpl(contextInfo, connectionString, queryString, leftText, rightText, formatString, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper, type)); }
public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { var stlAnchor = new HtmlAnchor(); var htmlId = string.Empty; var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; const bool removeTarget = false; var href = string.Empty; var queryString = string.Empty; var host = string.Empty; foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, Id.Name)) { htmlId = value; } else if (StringUtils.EqualsIgnoreCase(name, ChannelIndex.Name)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelIndex)) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, ChannelName.Name)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); if (!string.IsNullOrEmpty(channelName)) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, Parent.Name)) { if (TranslateUtils.ToBool(value)) { upLevel = 1; contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, UpLevel.Name)) { upLevel = TranslateUtils.ToInt(value); if (upLevel > 0) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, TopLevel.Name)) { topLevel = TranslateUtils.ToInt(value); if (topLevel >= 0) { contextInfo.ContextType = EContextType.Channel; } } else if (StringUtils.EqualsIgnoreCase(name, Context.Name)) { contextInfo.ContextType = EContextTypeUtils.GetEnumType(value); } else if (StringUtils.EqualsIgnoreCase(name, Href.Name)) { href = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, QueryString.Name)) { queryString = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, Host.Name)) { host = value; } else { ControlUtils.AddAttributeIfNotExists(stlAnchor, name, value); } } var parsedContent = ParseImpl(pageInfo, contextInfo, stlAnchor, htmlId, channelIndex, channelName, upLevel, topLevel, removeTarget, href, queryString, host); return(parsedContent); }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo) { string parsedContent; if (contextInfo.ItemContainer?.InputItem == null) { return(string.Empty); } try { var leftText = string.Empty; var rightText = string.Empty; var formatString = string.Empty; string separator = null; var startIndex = 0; var length = 0; var wordNum = 0; var ellipsis = StringUtils.Constants.Ellipsis; var replace = string.Empty; var to = string.Empty; var isClearTags = false; var isReturnToBr = false; var isLower = false; var isUpper = false; var type = string.Empty; var isDynamic = false; var attributes = new StringDictionary(); var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeType)) { type = attr.Value.ToLower(); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeLeftText)) { leftText = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeRightText)) { rightText = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeFormatString)) { formatString = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeSeparator)) { separator = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeStartIndex)) { startIndex = TranslateUtils.ToInt(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeLength)) { length = TranslateUtils.ToInt(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeWordNum)) { wordNum = TranslateUtils.ToInt(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeEllipsis)) { ellipsis = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeReplace)) { replace = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTo)) { to = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsClearTags)) { isClearTags = TranslateUtils.ToBool(attr.Value, false); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsReturnToBr)) { isReturnToBr = TranslateUtils.ToBool(attr.Value, false); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsLower)) { isLower = TranslateUtils.ToBool(attr.Value, true); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsUpper)) { isUpper = TranslateUtils.ToBool(attr.Value, true); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else { attributes.Add(attr.Name, attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(node, pageInfo, contextInfo, attributes, leftText, rightText, formatString, separator, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper, type); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } IsEntity.Value = Request.QueryString["isEntity"]; CardId = TranslateUtils.ToInt(Request.QueryString["cardID"]); if (!string.IsNullOrEmpty(Request.QueryString["Delete"])) { var list = TranslateUtils.StringCollectionToIntList(Request.QueryString["IDCollection"]); if (list.Count > 0) { try { DataProviderWx.CardSnDao.Delete(PublishmentSystemId, list); SuccessMessage("会员卡删除成功!"); } catch (Exception ex) { FailMessage(ex, "会员卡删除失败!"); } } } SpContents.ControlToPaginate = RptContents; SpContents.ItemsPerPage = 20; SpContents.SelectCommand = DataProviderWx.CardSnDao.GetSelectString(PublishmentSystemId, TranslateUtils.ToInt(Request.QueryString["cardID"]), Request.QueryString["cardSN"], Request.QueryString["userName"], Request.QueryString["mobile"]); SpContents.SortField = CardSnAttribute.AddDate; SpContents.SortMode = SortMode.DESC; RptContents.ItemDataBound += rptContents_ItemDataBound; if (!IsPostBack) { BreadCrumb(AppManager.WeiXin.LeftMenu.IdFunction, AppManager.WeiXin.LeftMenu.Function.IdCard, "会员卡管理", AppManager.WeiXin.Permission.WebSite.Card); SpContents.DataBind(); TbCardSn.Text = Request.QueryString["cardSN"]; TbUserName.Text = Request.QueryString["userName"]; TbMobile.Text = Request.QueryString["mobile"]; var urlAdd = PageCardSnAdd.GetRedirectUrl(PublishmentSystemId, CardId); BtnAdd.Attributes.Add("onclick", $"location.href='{urlAdd}';return false"); BtnStatus.Attributes.Add("onclick", ModalCardSnSetting.GetOpenWindowString(PublishmentSystemId, CardId, TranslateUtils.ToBool(IsEntity.Value))); BtnExport.Attributes.Add("onclick", ModalExportCardSn.GetOpenWindowString(PublishmentSystemId, CardId)); var urlDelete = PageUtils.AddQueryString(GetRedirectUrl(PublishmentSystemId, CardId, TbCardSn.Text, TbUserName.Text, TbMobile.Text, TranslateUtils.ToBool(IsEntity.Value)), "Delete", "True"); BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlDelete, "IDCollection", "IDCollection", "请选择需要删除的会员卡", "此操作将删除所选会员卡,确认吗?")); BtnReturn.Attributes.Add("onclick", $@"location.href=""{PageCard.GetRedirectUrl(PublishmentSystemId)}"";return false;"); } }
public void Page_Load(object sender, EventArgs e) { var type = Request["type"]; var retString = string.Empty; if (type == TypeGetTitles) { var publishmentSystemId = TranslateUtils.ToInt(Request["publishmentSystemID"]); var channelId = TranslateUtils.ToInt(Request["channelID"]); var nodeId = TranslateUtils.ToInt(Request["nodeID"]); if (channelId > 0) { nodeId = channelId; } var title = Request["title"]; var titles = GetTitles(publishmentSystemId, nodeId, title); Page.Response.Write(titles); Page.Response.End(); return; } if (type == TypeGetWordSpliter) { var publishmentSystemId = TranslateUtils.ToInt(Request["publishmentSystemID"]); var contents = Request.Form["content"]; var tags = WordSpliter.GetKeywords(contents, publishmentSystemId, 10); Page.Response.Write(tags); Page.Response.End(); return; } if (type == TypeGetTags) { var publishmentSystemId = TranslateUtils.ToInt(Request["publishmentSystemID"]); var tag = Request["tag"]; var tags = GetTags(publishmentSystemId, tag); Page.Response.Write(tags); Page.Response.End(); return; } if (type == TypeGetDetection) { var content = Request.Form["content"]; var arraylist = DataProvider.KeywordDao.GetKeywordListByContent(content); var keywords = TranslateUtils.ObjectCollectionToString(arraylist); Page.Response.Write(keywords); Page.Response.End(); } else if (type == TypeGetDetectionReplace) { var content = Request.Form["content"]; var keywordList = DataProvider.KeywordDao.GetKeywordListByContent(content); var keywords = string.Empty; if (keywordList.Count > 0) { var list = DataProvider.KeywordDao.GetKeywordInfoList(keywordList); foreach (var keywordInfo in list) { keywords += keywordInfo.Keyword + "|" + keywordInfo.Alternative + ","; } keywords = keywords.TrimEnd(','); } Page.Response.Write(keywords); Page.Response.End(); } Page.Response.Write(retString); Page.Response.End(); }
public static string GetScript(int publishmentSystemID, ECategoryLoadingType loadingType, NameValueCollection additional) { var script = @" <script language=""JavaScript""> function getTreeLevel(e) { var length = 0; if (!isNull(e)){ if (e.tagName == 'TR') { length = parseInt(e.getAttribute('treeItemLevel')); } } return length; } function getTrElement(element){ if (isNull(element)) return; for (element = element.parentNode;;){ if (element != null && element.tagName == 'TR'){ break; }else{ element = element.parentNode; } } return element; } function getImgClickableElementByTr(element){ if (isNull(element) || element.tagName != 'TR') return; var img = null; if (!isNull(element.childNodes)){ var imgCol = element.getElementsByTagName('IMG'); if (!isNull(imgCol)){ for (x=0;x<imgCol.length;x++){ if (!isNull(imgCol.item(x).getAttribute('isOpen'))){ img = imgCol.item(x); break; } } } } return img; } var weightedLink = null; function fontWeightLink(element){ if (weightedLink != null) { weightedLink.style.fontWeight = 'normal'; } element.style.fontWeight = 'bold'; weightedLink = element; } var completedNodeID = null; function displayChildren(img){ if (isNull(img)) return; var tr = getTrElement(img); var isToOpen = img.getAttribute('isOpen') == 'false'; var isByAjax = img.getAttribute('isAjax') == 'true'; var nodeID = img.getAttribute('id'); if (!isNull(img) && img.getAttribute('isOpen') != null){ if (img.getAttribute('isOpen') == 'false'){ img.setAttribute('isOpen', 'true'); img.setAttribute('src', '{iconMinusUrl}'); }else{ img.setAttribute('isOpen', 'false'); img.setAttribute('src', '{iconPlusUrl}'); } } if (isToOpen && isByAjax) { var div = document.createElement('div'); div.innerHTML = ""<img align='absmiddle' border='0' src='{iconLoadingUrl}' /> 栏目加载中,请稍候...""; img.parentNode.appendChild(div); $(div).addClass('loading'); loadingChannels(tr, img, div, nodeID); } else { var level = getTreeLevel(tr); var collection = new Array(); var index = 0; for ( var e = tr.nextSibling; !isNull(e) ; e = e.nextSibling) { if (!isNull(e) && !isNull(e.tagName) && e.tagName == 'TR'){ var currentLevel = getTreeLevel(e); if (currentLevel <= level) break; if(e.style.display == '') { e.style.display = 'none'; }else{ if (currentLevel != level + 1) continue; e.style.display = ''; var imgClickable = getImgClickableElementByTr(e); if (!isNull(imgClickable)){ if (!isNull(imgClickable.getAttribute('isOpen')) && imgClickable.getAttribute('isOpen') =='true'){ imgClickable.setAttribute('isOpen', 'false'); imgClickable.setAttribute('src', '{iconPlusUrl}'); collection[index] = imgClickable; index++; } } } } } if (index > 0){ for (i=0;i<=index;i++){ displayChildren(collection[i]); } } } } "; //BackgroundService.GetRedirectUrl(publishmentSystemID, BackgroundService.TYPE_GetLoadingCategorys) script += $@" function loadingChannels(tr, img, div, nodeID){{ var url = '{string.Empty}'; var pars = 'parentID=' + nodeID + '&loadingType={ECategoryLoadingTypeUtils.GetValue(loadingType)}&additional={TranslateUtils.EncryptStringBySecretKey(TranslateUtils.NameValueCollectionToString(additional))}'; jQuery.post(url, pars, function(data, textStatus) {{ $($.parseHTML(data)).insertAfter($(tr)); img.setAttribute('isAjax', 'false'); img.parentNode.removeChild(div); }}); completedNodeID = nodeID; }} function loadingChannelsOnLoad(paths){{ if (paths && paths.length > 0){{ var nodeIDs = paths.split(','); var nodeID = nodeIDs[0]; var img = $('#' + nodeID); if (img.attr('isOpen') == 'false'){{ displayChildren(img[0]); // if (completedNodeID && completedNodeID == nodeID){{ // if (paths.indexOf(',') != -1){{ // setTimeout(""loadingChannelsOnLoad("" + paths + "")"", 3000); // }} // }} }} }} }} </script> "; var item = new CategoryTreeItem(); script = script.Replace("{iconEmptyUrl}", item.iconEmptyUrl); script = script.Replace("{iconFolderUrl}", item.iconFolderUrl); script = script.Replace("{iconMinusUrl}", item.iconMinusUrl); script = script.Replace("{iconPlusUrl}", item.iconPlusUrl); script = script.Replace("{iconLoadingUrl}", SiteServerAssets.GetIconUrl("loading.gif")); script = script.Replace("loadingChannels", "loadingChannels_Category"); script = script.Replace("displayChildren", "displayChildren_Category"); return(script); }
public void RblIsSeparatedApi_SelectedIndexChanged(object sender, EventArgs e) { PhSeparatedApi.Visible = TranslateUtils.ToBool(RblIsSeparatedApi.SelectedValue); }
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 pageType = request.GetPostString("pageType"); var isRecommend = request.GetPostBool("isRecommend"); var isHot = request.GetPostBool("isHot"); var isColor = request.GetPostBool("isColor"); var isTop = request.GetPostBool("isTop"); var hits = request.GetPostInt("hits"); 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 (pageType == "setAttributes") { if (isRecommend || isHot || isColor || isTop) { foreach (var contentId in contentIdList) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); if (contentInfo == null) { continue; } if (isRecommend) { contentInfo.IsRecommend = true; } if (isHot) { contentInfo.IsHot = true; } if (isColor) { contentInfo.IsColor = true; } if (isTop) { contentInfo.IsTop = true; } DataProvider.ContentDao.Update(siteInfo, channelInfo, contentInfo); } request.AddSiteLog(siteId, "设置内容属性"); } } else if (pageType == "cancelAttributes") { if (isRecommend || isHot || isColor || isTop) { foreach (var contentId in contentIdList) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); if (contentInfo == null) { continue; } if (isRecommend) { contentInfo.IsRecommend = false; } if (isHot) { contentInfo.IsHot = false; } if (isColor) { contentInfo.IsColor = false; } if (isTop) { contentInfo.IsTop = false; } DataProvider.ContentDao.Update(siteInfo, channelInfo, contentInfo); } request.AddSiteLog(siteId, "取消内容属性"); } } else if (pageType == "setHits") { foreach (var contentId in contentIdList) { var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId); if (contentInfo == null) { continue; } contentInfo.Hits = hits; DataProvider.ContentDao.Update(siteInfo, channelInfo, contentInfo); } request.AddSiteLog(siteId, "设置内容点击量"); } 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 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 static async Task <string> ParseDynamicAsync(IParseManager parseManager, Dynamic dynamicInfo, string template) { var databaseManager = parseManager.DatabaseManager; if (string.IsNullOrEmpty(template)) { return(string.Empty); } var templateInfo = await databaseManager.TemplateRepository.GetAsync(dynamicInfo.TemplateId); var siteInfo = await databaseManager.SiteRepository.GetAsync(dynamicInfo.SiteId); await parseManager.InitAsync(EditMode.Default, siteInfo, dynamicInfo.ChannelId, dynamicInfo.ContentId, templateInfo); parseManager.PageInfo.User = dynamicInfo.User; var templateContent = StlRequest.ParseRequestEntities(dynamicInfo.QueryString, template); var contentBuilder = new StringBuilder(templateContent); var stlElementList = ParseUtils.GetStlElements(contentBuilder.ToString()); var pageIndex = dynamicInfo.Page - 1; //如果标签中存在<stl:pageContents> if (ParseUtils.IsStlElementExists(StlPageContents.ElementName, stlElementList)) { var stlElement = ParseUtils.GetStlElement(StlPageContents.ElementName, stlElementList); var stlPageContentsElement = stlElement; var stlPageContentsElementReplaceString = stlElement; var pageContentsElementParser = await StlPageContents.GetAsync(stlPageContentsElement, parseManager, dynamicInfo.Query); var(pageCount, totalNum) = pageContentsElementParser.GetPageCount(); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { if (currentPageIndex == pageIndex) { var pageHtml = await pageContentsElementParser.ParseAsync(totalNum, currentPageIndex, pageCount, false); contentBuilder.Replace(stlPageContentsElementReplaceString, pageHtml); await parseManager.ReplacePageElementsInDynamicPageAsync(contentBuilder, stlElementList, currentPageIndex, pageCount, totalNum, false, dynamicInfo.ElementId); break; } } } //如果标签中存在<stl:pageChannels> else if (ParseUtils.IsStlElementExists(StlPageChannels.ElementName, stlElementList)) { var stlElement = ParseUtils.GetStlElement(StlPageChannels.ElementName, stlElementList); var stlPageChannelsElement = stlElement; var stlPageChannelsElementReplaceString = stlElement; var pageChannelsElementParser = await StlPageChannels.GetAsync(stlPageChannelsElement, parseManager); var pageCount = pageChannelsElementParser.GetPageCount(out var totalNum); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { if (currentPageIndex != pageIndex) { continue; } var pageHtml = await pageChannelsElementParser.ParseAsync(currentPageIndex, pageCount); contentBuilder.Replace(stlPageChannelsElementReplaceString, pageHtml); await parseManager.ReplacePageElementsInDynamicPageAsync(contentBuilder, stlElementList, currentPageIndex, pageCount, totalNum, false, dynamicInfo.ElementId); break; } } //如果标签中存在<stl:pageSqlContents> else if (ParseUtils.IsStlElementExists(StlPageSqlContents.ElementName, stlElementList)) { var stlElement = ParseUtils.GetStlElement(StlPageSqlContents.ElementName, stlElementList); var stlPageSqlContentsElement = stlElement; var stlPageSqlContentsElementReplaceString = stlElement; var pageSqlContentsElementParser = await StlPageSqlContents.GetAsync(stlPageSqlContentsElement, parseManager); var pageCount = pageSqlContentsElementParser.GetPageCount(out var totalNum); for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { if (currentPageIndex != pageIndex) { continue; } var pageHtml = await pageSqlContentsElementParser.ParseAsync(totalNum, currentPageIndex, pageCount); contentBuilder.Replace(stlPageSqlContentsElementReplaceString, pageHtml); await parseManager.ReplacePageElementsInDynamicPageAsync(contentBuilder, stlElementList, currentPageIndex, pageCount, totalNum, false, dynamicInfo.ElementId); break; } } else if (ParseUtils.IsStlElementExists(StlPageItems.ElementName, stlElementList)) { var pageCount = TranslateUtils.ToInt(dynamicInfo.QueryString["pageCount"]); var totalNum = TranslateUtils.ToInt(dynamicInfo.QueryString["totalNum"]); var pageContentsAjaxDivId = dynamicInfo.QueryString["pageContentsAjaxDivId"]; for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { if (currentPageIndex != pageIndex) { continue; } await parseManager.ReplacePageElementsInDynamicPageAsync(contentBuilder, stlElementList, currentPageIndex, pageCount, totalNum, false, pageContentsAjaxDivId); break; } } await parseManager.ParseInnerContentAsync(contentBuilder); //var parsedContent = StlParserUtility.GetBackHtml(contentBuilder.ToString(), pageInfo); //return pageInfo.HeadCodesHtml + pageInfo.BodyCodesHtml + parsedContent + pageInfo.FootCodesHtml; return(contentBuilder.ToString()); }
internal static string Parse(string stlEntity, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; try { var entityName = StlParserUtility.GetNameFromEntity(stlEntity); var channelIndex = StlParserUtility.GetValueFromEntity(stlEntity); var attributeName = entityName.Substring(9, entityName.Length - 10); var upLevel = 0; var topLevel = -1; var channelId = contextInfo.ChannelId; if (!string.IsNullOrEmpty(channelIndex)) { //channelId = DataProvider.ChannelDao.GetIdByIndexName(pageInfo.SiteId, channelIndex); channelId = ChannelManager.GetChannelIdByIndexName(pageInfo.SiteId, channelIndex); if (channelId == 0) { channelId = contextInfo.ChannelId; } } if (attributeName.ToLower().StartsWith("up") && attributeName.IndexOf(".", StringComparison.Ordinal) != -1) { if (attributeName.ToLower().StartsWith("up.")) { upLevel = 1; } else { var upLevelStr = attributeName.Substring(2, attributeName.IndexOf(".", StringComparison.Ordinal) - 2); upLevel = TranslateUtils.ToInt(upLevelStr); } topLevel = -1; attributeName = attributeName.Substring(attributeName.IndexOf(".", StringComparison.Ordinal) + 1); } else if (attributeName.ToLower().StartsWith("top") && attributeName.IndexOf(".", StringComparison.Ordinal) != -1) { if (attributeName.ToLower().StartsWith("top.")) { topLevel = 1; } else { var topLevelStr = attributeName.Substring(3, attributeName.IndexOf(".", StringComparison.Ordinal) - 3); topLevel = TranslateUtils.ToInt(topLevelStr); } upLevel = 0; attributeName = attributeName.Substring(attributeName.IndexOf(".", StringComparison.Ordinal) + 1); } var nodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, channelId, upLevel, topLevel)); if (StringUtils.EqualsIgnoreCase(ChannelId, attributeName))//栏目ID { parsedContent = nodeInfo.Id.ToString(); } else if (StringUtils.EqualsIgnoreCase(Title, attributeName) || StringUtils.EqualsIgnoreCase(ChannelName, attributeName))//栏目名称 { parsedContent = nodeInfo.ChannelName; } else if (StringUtils.EqualsIgnoreCase(ChannelIndex, attributeName))//栏目索引 { parsedContent = nodeInfo.IndexName; } else if (StringUtils.EqualsIgnoreCase(Content, attributeName))//栏目正文 { parsedContent = ContentUtility.TextEditorContentDecode(pageInfo.SiteInfo, nodeInfo.Content, pageInfo.IsLocal); } else if (StringUtils.EqualsIgnoreCase(NavigationUrl, attributeName))//栏目链接地址 { parsedContent = PageUtility.GetChannelUrl(pageInfo.SiteInfo, nodeInfo, pageInfo.IsLocal); } else if (StringUtils.EqualsIgnoreCase(ImageUrl, attributeName))//栏目图片地址 { parsedContent = nodeInfo.ImageUrl; if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } } else if (StringUtils.EqualsIgnoreCase(AddDate, attributeName))//栏目添加日期 { parsedContent = DateUtils.Format(nodeInfo.AddDate, string.Empty); } else if (StringUtils.EqualsIgnoreCase(DirectoryName, attributeName))//生成文件夹名称 { parsedContent = PathUtils.GetDirectoryName(nodeInfo.FilePath, true); } else if (StringUtils.EqualsIgnoreCase(Group, attributeName))//栏目组别 { parsedContent = nodeInfo.GroupNameCollection; } else if (StringUtils.StartsWithIgnoreCase(attributeName, StlParserUtility.ItemIndex) && contextInfo.ItemContainer?.ChannelItem != null) { parsedContent = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.ChannelItem.ItemIndex, attributeName, contextInfo).ToString(); } else if (StringUtils.EqualsIgnoreCase(ChannelAttribute.Keywords, attributeName))//栏目组别 { parsedContent = nodeInfo.Keywords; } else if (StringUtils.EqualsIgnoreCase(ChannelAttribute.Description, attributeName))//栏目组别 { parsedContent = nodeInfo.Description; } else { //var styleInfo = TableStyleManager.GetTableStyleInfo(ETableStyle.Channel, DataProvider.ChannelDao.TableName, attributeName, RelatedIdentities.GetChannelRelatedIdentities(pageInfo.SiteId, nodeInfo.ChannelId)); //parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, ",", pageInfo.SiteInfo, ETableStyle.Channel, styleInfo, string.Empty, null, string.Empty, true); var styleInfo = TableStyleManager.GetTableStyleInfo(DataProvider.ChannelDao.TableName, attributeName, TableStyleManager.GetRelatedIdentities(nodeInfo)); // 如果 styleInfo.TableStyleId <= 0,表示此字段已经被删除了,不需要再显示值了 ekun008 if (styleInfo.Id > 0) { parsedContent = GetValue(attributeName, nodeInfo.Additional, false, styleInfo.DefaultValue); if (!string.IsNullOrEmpty(parsedContent)) { if (InputTypeUtils.EqualsAny(styleInfo.InputType, InputType.Image, InputType.File)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } else { parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, null, pageInfo.SiteInfo, styleInfo, string.Empty, null, string.Empty, true); } } } } } catch { // ignored } return(parsedContent); }
public IHttpActionResult Submit() { try { var request = new RequestImpl(); var siteId = request.GetPostInt("siteId"); var channelId = request.GetPostInt("channelId"); var contentIdList = TranslateUtils.StringCollectionToIntList(request.GetPostString("contentIds")); var checkedLevel = request.GetPostInt("checkedLevel"); var isTranslate = request.GetPostBool("isTranslate"); var translateChannelId = request.GetPostInt("translateChannelId"); var reasons = request.GetPostString("reasons"); if (!request.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)); } }
private static void ContentTableCreateOrUpdateStyles(string tableName, List <TableColumn> tableColumns) { var styleInfoList = new List <TableStyleInfo>(); var columnTaxis = 0; foreach (var tableColumn in tableColumns) { var inputStyle = tableColumn.InputStyle ?? new InputStyle { InputType = InputType.Hidden }; columnTaxis++; var styleInfo = TableStyleManager.GetTableStyleInfo(tableName, tableColumn.AttributeName, new List <int> { 0 }); var isEquals = true; if (styleInfo.InputType != inputStyle.InputType) { isEquals = false; styleInfo.InputType = inputStyle.InputType; } if (!StringUtils.EqualsIgnoreNull(styleInfo.DisplayName, inputStyle.DisplayName)) { isEquals = false; styleInfo.DisplayName = inputStyle.DisplayName; } if (!StringUtils.EqualsIgnoreNull(styleInfo.HelpText, inputStyle.HelpText)) { isEquals = false; styleInfo.HelpText = inputStyle.HelpText; } if (!StringUtils.EqualsIgnoreNull(styleInfo.DefaultValue, inputStyle.DefaultValue)) { isEquals = false; styleInfo.DefaultValue = inputStyle.DefaultValue; } if (styleInfo.Taxis != columnTaxis) { isEquals = false; styleInfo.Taxis = columnTaxis; } if (styleInfo.Additional.IsRequired != inputStyle.IsRequired) { isEquals = false; styleInfo.Additional.IsRequired = inputStyle.IsRequired; } if (styleInfo.Additional.ValidateType != inputStyle.ValidateType) { isEquals = false; styleInfo.Additional.ValidateType = inputStyle.ValidateType; } if (styleInfo.Additional.MinNum != inputStyle.MinNum) { isEquals = false; styleInfo.Additional.MinNum = inputStyle.MinNum; } if (styleInfo.Additional.MaxNum != inputStyle.MaxNum) { isEquals = false; styleInfo.Additional.MaxNum = inputStyle.MaxNum; } if (!StringUtils.EqualsIgnoreNull(styleInfo.Additional.RegExp, inputStyle.RegExp)) { isEquals = false; styleInfo.Additional.RegExp = inputStyle.RegExp; } if (!StringUtils.EqualsIgnoreNull(styleInfo.Additional.Width, inputStyle.Width)) { isEquals = false; styleInfo.Additional.Width = inputStyle.Width; } if (!(styleInfo.Additional.Height == 0 && string.IsNullOrEmpty(inputStyle.Height)) && styleInfo.Additional.Height != TranslateUtils.ToInt(inputStyle.Height)) { isEquals = false; styleInfo.Additional.Height = TranslateUtils.ToInt(inputStyle.Height); } if (!(styleInfo.StyleItems == null && inputStyle.ListItems == null)) { var styleItems = styleInfo.StyleItems ?? new List <TableStyleItemInfo>(); var listItems = inputStyle.ListItems ?? new List <ListItem>(); if (styleItems.Count > listItems.Count) { isEquals = false; styleItems.RemoveRange(listItems.Count, styleItems.Count - listItems.Count); } for (var i = 0; i < listItems.Count; i++) { var listItem = listItems[i]; if (styleItems.Count < i + 1) { isEquals = false; styleItems.Add(new TableStyleItemInfo { TableStyleId = styleInfo.Id, ItemTitle = listItem.Text, ItemValue = listItem.Value, IsSelected = listItem.Selected }); } else { var styleItem = styleItems[i]; if (!StringUtils.EqualsIgnoreNull(styleItem.ItemTitle, listItem.Text)) { isEquals = false; styleItem.ItemTitle = listItem.Text; } if (!StringUtils.EqualsIgnoreNull(styleItem.ItemValue, listItem.Value)) { isEquals = false; styleItem.ItemValue = listItem.Value; } if (styleItem.IsSelected != listItem.Selected) { isEquals = false; styleItem.IsSelected = listItem.Selected; } } } } if (isEquals) { continue; } styleInfo.IsVisibleInList = false; styleInfo.Additional.IsValidate = true; styleInfoList.Add(styleInfo); } foreach (var styleInfo in styleInfoList) { if (styleInfo.Id == 0) { TableStyleManager.Insert(styleInfo); } else { TableStyleManager.Update(styleInfo); TableStyleManager.DeleteAndInsertStyleItems(styleInfo.Id, styleInfo.StyleItems); } } }
public static List <InputListItem> GetContentsColumns(SiteInfo siteInfo, ChannelInfo channelInfo, bool includeAll) { var items = new List <InputListItem>(); var attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(channelInfo.Additional.ContentAttributesOfDisplay); var pluginIds = PluginContentManager.GetContentPluginIds(channelInfo); var pluginColumns = PluginContentManager.GetContentColumns(pluginIds); var styleInfoList = ContentUtility.GetAllTableStyleInfoList(TableStyleManager.GetContentStyleInfoList(siteInfo, channelInfo)); styleInfoList.Insert(0, new TableStyleInfo { AttributeName = ContentAttribute.Sequence, DisplayName = "序号" }); foreach (var styleInfo in styleInfoList) { if (styleInfo.InputType == InputType.TextEditor) { continue; } var listitem = new InputListItem { Text = styleInfo.DisplayName, Value = styleInfo.AttributeName }; if (styleInfo.AttributeName == ContentAttribute.Title) { listitem.Selected = true; } else { if (attributesOfDisplay.Contains(styleInfo.AttributeName)) { listitem.Selected = true; } } if (includeAll || listitem.Selected) { items.Add(listitem); } } if (pluginColumns != null) { foreach (var pluginId in pluginColumns.Keys) { var contentColumns = pluginColumns[pluginId]; if (contentColumns == null || contentColumns.Count == 0) { continue; } foreach (var columnName in contentColumns.Keys) { var attributeName = $"{pluginId}:{columnName}"; var listitem = new InputListItem { Text = $"{columnName}({pluginId})", Value = attributeName }; if (attributesOfDisplay.Contains(attributeName)) { listitem.Selected = true; } if (includeAll || listitem.Selected) { items.Add(listitem); } } } } return(items); }
public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { var title = string.Empty; var description = string.Empty; var scopeTypeString = string.Empty; var groupChannel = string.Empty; var groupChannelNot = string.Empty; var groupContent = string.Empty; var groupContentNot = string.Empty; var tags = string.Empty; var channelIndex = string.Empty; var channelName = string.Empty; var totalNum = 0; var startNum = 1; var orderByString = ETaxisTypeUtils.GetContentOrderByString(ETaxisType.OrderByTaxisDesc); var isTop = false; var isTopExists = false; var isRecommend = false; var isRecommendExists = false; var isHot = false; var isHotExists = false; var isColor = false; var isColorExists = false; foreach (var name in contextInfo.Attributes.Keys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, AttributeTitle)) { title = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeDescription)) { description = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeScope)) { scopeTypeString = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeChannelIndex)) { channelIndex = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeChannelName)) { channelName = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeGroupChannel)) { groupChannel = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeGroupChannelNot)) { groupChannelNot = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeGroupContent)) { groupContent = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeGroupContentNot)) { groupContentNot = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeTags)) { tags = value; } else if (StringUtils.EqualsIgnoreCase(name, AttributeTotalNum)) { totalNum = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeStartNum)) { startNum = TranslateUtils.ToInt(value, 1); } else if (StringUtils.EqualsIgnoreCase(name, AttributeOrder)) { orderByString = StlDataUtility.GetContentOrderByString(pageInfo.SiteId, value, ETaxisType.OrderByTaxisDesc); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsTop)) { isTopExists = true; isTop = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsRecommend)) { isRecommendExists = true; isRecommend = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsHot)) { isHotExists = true; isHot = TranslateUtils.ToBool(value); } else if (StringUtils.EqualsIgnoreCase(name, AttributeIsColor)) { isColorExists = true; isColor = TranslateUtils.ToBool(value); } } return(ParseImpl(pageInfo, contextInfo, title, description, scopeTypeString, groupChannel, groupChannelNot, groupContent, groupContentNot, tags, channelIndex, channelName, totalNum, startNum, orderByString, isTop, isTopExists, isRecommend, isRecommendExists, isHot, isHotExists, isColor, isColorExists)); }
public static string Parse(PageInfo pageInfo, ContextInfo contextInfo) { var channelIndex = string.Empty; var channelName = string.Empty; var upLevel = 0; var topLevel = -1; var groupChannel = string.Empty; var groupChannelNot = string.Empty; var title = string.Empty; var isLoading = false; var isShowContentNum = false; var isShowTreeLine = true; var currentFormatString = "<strong>{0}</strong>"; foreach (var name in contextInfo.Attributes.AllKeys) { var value = contextInfo.Attributes[name]; if (StringUtils.EqualsIgnoreCase(name, ChannelIndex.Name)) { channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, ChannelName.Name)) { channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, UpLevel.Name)) { upLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, TopLevel.Name)) { topLevel = TranslateUtils.ToInt(value); } else if (StringUtils.EqualsIgnoreCase(name, GroupChannel.Name)) { groupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, GroupChannelNot.Name)) { groupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, Title.Name)) { title = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo); } else if (StringUtils.EqualsIgnoreCase(name, IsLoading.Name)) { isLoading = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, IsShowContentNum.Name)) { isShowContentNum = TranslateUtils.ToBool(value, false); } else if (StringUtils.EqualsIgnoreCase(name, IsShowTreeLine.Name)) { isShowTreeLine = TranslateUtils.ToBool(value, true); } else if (StringUtils.EqualsIgnoreCase(name, CurrentFormatString.Name)) { currentFormatString = value; if (!StringUtils.Contains(currentFormatString, "{0}")) { currentFormatString += "{0}"; } } } return(isLoading ? ParseImplAjax(pageInfo, contextInfo, channelIndex, channelName, upLevel, topLevel, groupChannel, groupChannelNot, title, isShowContentNum, isShowTreeLine, currentFormatString, pageInfo.IsLocal) : ParseImplNotAjax(pageInfo, contextInfo, channelIndex, channelName, upLevel, topLevel, groupChannel, groupChannelNot, title, isShowContentNum, isShowTreeLine, currentFormatString)); }
public static string GetChannelRowHtml(PublishmentSystemInfo publishmentSystemInfo, NodeInfo nodeInfo, bool enabled, ELoadingType loadingType, NameValueCollection additional, string administratorName) { var nodeTreeItem = NodeTreeItem.CreateInstance(nodeInfo, enabled, administratorName); var title = nodeTreeItem.GetItemHtml(loadingType, PageChannel.GetRedirectUrl(publishmentSystemInfo.PublishmentSystemId, nodeInfo.NodeId), additional); var rowHtml = string.Empty; if (loadingType == ELoadingType.ContentTree) { rowHtml = $@" <tr treeItemLevel=""{nodeInfo.ParentsCount + 1}""> <td align=""left"" nowrap> {title} </td> </tr> "; } else if (loadingType == ELoadingType.Channel) { var upLink = string.Empty; var downLink = string.Empty; var editUrl = string.Empty; var checkBoxHtml = string.Empty; if (enabled) { if (AdminUtility.HasChannelPermissions(administratorName, nodeInfo.PublishmentSystemId, nodeInfo.NodeId, AppManager.Cms.Permission.Channel.ChannelEdit)) { var urlEdit = PageChannelEdit.GetRedirectUrl(nodeInfo.PublishmentSystemId, nodeInfo.NodeId, PageChannel.GetRedirectUrl(nodeInfo.PublishmentSystemId, nodeInfo.NodeId)); editUrl = $"<a href=\"{urlEdit}\">编辑</a>"; var urlSubtract = PageUtils.GetCmsUrl(nameof(PageChannel), new NameValueCollection { { "PublishmentSystemID", nodeInfo.PublishmentSystemId.ToString() }, { "Subtract", true.ToString() }, { "NodeID", nodeInfo.NodeId.ToString() } }); upLink = $@"<a href=""{urlSubtract}""><img src=""../Pic/icon/up.gif"" border=""0"" alt=""上升"" /></a>"; var urlAdd = PageUtils.GetCmsUrl(nameof(PageChannel), new NameValueCollection { { "PublishmentSystemID", nodeInfo.PublishmentSystemId.ToString() }, { "Add", true.ToString() }, { "NodeID", nodeInfo.NodeId.ToString() } }); downLink = $@"<a href=""{urlAdd}""><img src=""../Pic/icon/down.gif"" border=""0"" alt=""下降"" /></a>"; } checkBoxHtml = $"<input type='checkbox' name='ChannelIDCollection' value='{nodeInfo.NodeId}' />"; } rowHtml = $@" <tr treeItemLevel=""{nodeInfo.ParentsCount + 1}""> <td>{title}</td> <td>{nodeInfo.NodeGroupNameCollection}</td> <td><nobr>{nodeInfo.NodeIndexName}</nobr></td> <td class=""center""> {upLink} </td> <td class=""center""> {downLink} </td> <td class=""center""> {editUrl} </td> <td class=""center""> {checkBoxHtml} </td> </tr> "; } else if (loadingType == ELoadingType.SiteAnalysis) { var contentAddNum = string.Empty; var contentUpdateNum = string.Empty; var startDate = TranslateUtils.ToDateTime(additional["StartDate"]); var endDate = TranslateUtils.ToDateTime(additional["EndDate"]); var tableName = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo); var num = DataProvider.ContentDao.GetCountOfContentAdd(tableName, publishmentSystemInfo.PublishmentSystemId, nodeInfo.NodeId, startDate, endDate, string.Empty); contentAddNum = (num == 0) ? "0" : $"<strong>{num}</strong>"; num = DataProvider.ContentDao.GetCountOfContentUpdate(tableName, publishmentSystemInfo.PublishmentSystemId, nodeInfo.NodeId, startDate, endDate, string.Empty); contentUpdateNum = (num == 0) ? "0" : $"<strong>{num}</strong>"; rowHtml = $@" <tr treeItemLevel=""{nodeInfo.ParentsCount + 1}""> <td> <nobr>{title}</nobr> </td> <td> {contentAddNum} </td> <td> {contentUpdateNum} </td> </tr> "; } else if (loadingType == ELoadingType.TemplateFilePathRule) { var editLink = string.Empty; var filePath = string.Empty; if (enabled) { var showPopWinString = ModalTemplateFilePathRule.GetOpenWindowString(nodeInfo.PublishmentSystemId, nodeInfo.NodeId); editLink = $"<a href=\"javascript:;\" onclick=\"{showPopWinString}\">更改</a>"; } filePath = PageUtility.GetInputChannelUrl(publishmentSystemInfo, nodeInfo); rowHtml = $@" <tr treeItemLevel=""{nodeInfo.ParentsCount + 1}""> <td> <nobr>{title}</nobr> </td> <td> <nobr>{filePath}</nobr> </td> <td class=""center""> {editLink} </td> </tr> "; } else if (loadingType == ELoadingType.ConfigurationCreateDetails) { var editChannelLink = string.Empty; var nodeNames = string.Empty; if (enabled) { var showPopWinString = ModalConfigurationCreateChannel.GetOpenWindowString(nodeInfo.PublishmentSystemId, nodeInfo.NodeId); editChannelLink = $"<a href=\"javascript:;\" onclick=\"{showPopWinString}\">触发栏目</a>"; } if (nodeInfo.Additional.Attributes.Count > 0) { var nodeNameBuilder = new StringBuilder(); var nodeIDArrayList = TranslateUtils.StringCollectionToIntList(nodeInfo.Additional.CreateChannelIDsIfContentChanged); foreach (int theNodeID in nodeIDArrayList) { var theNodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, theNodeID); if (theNodeInfo != null) { nodeNameBuilder.Append(theNodeInfo.NodeName).Append(","); } } if (nodeNameBuilder.Length > 0) { nodeNameBuilder.Length--; nodeNames = nodeNameBuilder.ToString(); } } rowHtml = $@" <tr treeItemLevel=""{nodeInfo.ParentsCount + 1}""> <td> <nobr>{title}</nobr> </td> <td> {nodeNames} </td> <td class=""center""> {editChannelLink} </td> </tr> "; } else if (loadingType == ELoadingType.ConfigurationCrossSiteTrans) { var editLink = string.Empty; var contribute = string.Empty; if (enabled) { var showPopWinString = ModalCrossSiteTransEdit.GetOpenWindowString(nodeInfo.PublishmentSystemId, nodeInfo.NodeId); editLink = $"<a href=\"javascript:;\" onclick=\"{showPopWinString}\">更改</a>"; } contribute = CrossSiteTransUtility.GetDescription(nodeInfo.PublishmentSystemId, nodeInfo); rowHtml = $@" <tr treeItemLevel=""{nodeInfo.ParentsCount + 1}""> <td>{title}</td> <td>{contribute}</td> <td class=""center"" width=""50"">{editLink}</td> </tr> "; } else if (loadingType == ELoadingType.ConfigurationSignin) { var editLink = string.Empty; if (enabled) { var showPopWinString = ModalConfigurationSignin.GetOpenWindowString(nodeInfo.PublishmentSystemId, nodeInfo.NodeId); editLink = $"<a href=\"javascript:;\" onclick=\"{showPopWinString}\">更改</a>"; } //string contribute = CrossSiteTransUtility.GetDescription(nodeInfo.PublishmentSystemID, nodeInfo); var isSign = ""; var SignUser = ""; if (nodeInfo.Additional.IsSignin) { isSign = "是"; } else { isSign = "否"; } //if (!string.IsNullOrEmpty(nodeInfo.Additional.SigninUserGroupCollection)) //{ // ArrayList groupIDlist = TranslateUtils.StringCollectionToIntList(nodeInfo.Additional.SigninUserGroupCollection); // UserGroupInfo userGroupInfo = null; // foreach (int groupID in groupIDlist) // { // userGroupInfo = DataProvider.UserGroupDAO.GetUserGroupMessage(groupID); // SignUser += userGroupInfo.GroupName + ','; // } // SignUser = SignUser.TrimEnd(','); //} //else //{ SignUser = nodeInfo.Additional.SigninUserNameCollection; //} rowHtml = $@" <tr treeItemLevel=""{nodeInfo.ParentsCount + 1}""> <td>{title}</td> <td>{SignUser}</td> <td class=""center"">{isSign}</td> <td class=""center"">{editLink}</td> </tr> "; } else if (loadingType == ELoadingType.ChannelSelect || loadingType == ELoadingType.GovPublicChannelAdd || loadingType == ELoadingType.GovPublicChannelTree) { rowHtml = $@" <tr treeItemLevel=""{nodeInfo.ParentsCount + 1}""> <td nowrap>{title}</td> </tr> "; } else if (loadingType == ELoadingType.GovPublicChannel) { var editUrl = string.Empty; var upLink = string.Empty; var downLink = string.Empty; var checkBoxHtml = string.Empty; if (!EContentModelTypeUtils.Equals(EContentModelType.GovPublic, nodeInfo.ContentModelId)) { enabled = false; } if (enabled) { editUrl = $@"<a href=""javascript:;"" onclick=""{ModalGovPublicChannelAdd .GetOpenWindowStringToEdit(publishmentSystemInfo.PublishmentSystemId, nodeInfo.NodeId, string.Empty)}"">编辑</a>"; var urlUp = PageUtils.GetWcmUrl(nameof(PageGovPublicChannel), new NameValueCollection { { "PublishmentSystemID", nodeInfo.PublishmentSystemId.ToString() }, { "NodeID", nodeInfo.NodeId.ToString() }, { "Subtract", true.ToString() } }); upLink = $@"<a href=""{urlUp}""><img src=""../Pic/icon/up.gif"" border=""0"" alt=""上升"" /></a>"; var urlDown = PageUtils.GetWcmUrl(nameof(PageGovPublicChannel), new NameValueCollection { { "PublishmentSystemID", nodeInfo.PublishmentSystemId.ToString() }, { "NodeID", nodeInfo.NodeId.ToString() }, { "Add", true.ToString() } }); downLink = $@"<a href=""{urlDown}""><img src=""../Pic/icon/down.gif"" border=""0"" alt=""下降"" /></a>"; checkBoxHtml = $"<input type='checkbox' name='ChannelIDCollection' value='{nodeInfo.NodeId}' />"; } var channelCode = DataProvider.GovPublicChannelDao.GetCode(nodeInfo.NodeId); rowHtml = $@" <tr treeItemLevel=""{nodeInfo.ParentsCount + 1}""> <td>{title}</td> <td>{channelCode}</td> <td class=""center"">{upLink}</td> <td class=""center"">{downLink}</td> <td class=""center"">{editUrl}</td> <td class=""center"">{checkBoxHtml}</td> </tr> "; } else if (loadingType == ELoadingType.GovInteractChannel) { var editUrl = string.Empty; var upLink = string.Empty; var downLink = string.Empty; var styleAddUrl = string.Empty; var checkBoxHtml = string.Empty; if (enabled) { var applyStyleId = DataProvider.GovInteractChannelDao.GetApplyStyleId(nodeInfo.PublishmentSystemId, nodeInfo.NodeId); editUrl = $@"<a href=""javascript:;"" onclick=""{ModalGovInteractChannelAdd .GetOpenWindowStringToEdit(publishmentSystemInfo.PublishmentSystemId, nodeInfo.NodeId, string.Empty)}"">编辑</a>"; var urlUp = PageUtils.GetWcmUrl(nameof(PageGovInteractChannel), new NameValueCollection { { "PublishmentSystemID", nodeInfo.PublishmentSystemId.ToString() }, { "NodeID", nodeInfo.NodeId.ToString() }, { "Subtract", true.ToString() } }); upLink = $@"<a href=""{urlUp}""><img src=""../Pic/icon/up.gif"" border=""0"" alt=""上升"" /></a>"; var urlDown = PageUtils.GetWcmUrl(nameof(PageGovInteractChannel), new NameValueCollection { { "PublishmentSystemID", nodeInfo.PublishmentSystemId.ToString() }, { "NodeID", nodeInfo.NodeId.ToString() }, { "Add", true.ToString() } }); downLink = $@"<a href=""{urlDown}""><img src=""../Pic/icon/down.gif"" border=""0"" alt=""下降"" /></a>"; styleAddUrl = $@"<a href=""javascript:;"" onclick=""{ModalTagStyleGovInteractApplyAdd.GetOpenWindowStringToEdit(publishmentSystemInfo.PublishmentSystemId, applyStyleId)}"">提交设置</a>"; checkBoxHtml = $"<input type='checkbox' name='ChannelIDCollection' value='{nodeInfo.NodeId}' />"; } var summary = DataProvider.GovInteractChannelDao.GetSummary(nodeInfo.NodeId); rowHtml = $@" <tr treeItemLevel=""{nodeInfo.ParentsCount + 1}""> <td>{title}</td> <td>{summary}</td> <td class=""center"">{upLink}</td> <td class=""center"">{downLink}</td> <td class=""center"">{styleAddUrl}</td> <td class=""center"">{editUrl}</td> <td class=""center"">{checkBoxHtml}</td> </tr> "; } else if (loadingType == ELoadingType.GovPublicChannelAdd || loadingType == ELoadingType.GovPublicChannelTree) { rowHtml = $@" <tr treeItemLevel=""{nodeInfo.ParentsCount + 1}""> <td nowrap>{title}</td> </tr> "; } return(rowHtml); }
private async Task <List <int> > ImportContentsAsync(AtomEntryCollection entries, Channel channel, int taxis, bool isCheckedBySettings, bool isChecked, int checkedLevel, bool isOverride, int adminId, int userId, int sourceId) { var contents = new List <Content>(); foreach (AtomEntry entry in entries) { try { taxis++; var groupNameCollection = AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.GroupNames), "GroupNameCollection", "ContentGroupNameCollection" }); if (isCheckedBySettings) { isChecked = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.Checked), "IsChecked" })); checkedLevel = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.CheckedLevel))); } var hits = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.Hits))); var hitsByDay = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.HitsByDay))); var hitsByWeek = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.HitsByWeek))); var hitsByMonth = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.HitsByMonth))); var lastHitsDate = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.LastHitsDate)); var downloads = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.Downloads))); var title = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.Title)); var subTitle = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.SubTitle)); var imageUrl = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.ImageUrl)); var videoUrl = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.VideoUrl)); var fileUrl = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.FileUrl)); var body = AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.Body), "Content" }); var summary = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.Summary)); var author = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.Author)); var source = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.Source)); var isTop = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.Top), "IsTop" })); var isRecommend = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.Recommend), "IsRecommend" })); var isHot = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.Hot), "IsHot" })); var isColor = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.Color), "IsColor" })); var linkUrl = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.LinkUrl))); var addDate = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(Content.AddDate)); var topTaxis = 0; if (isTop) { topTaxis = taxis - 1; taxis = await _databaseManager.ContentRepository.GetMaxTaxisAsync(_site, channel, true) + 1; } var tags = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(Content.TagNames), "Tags" })); var contentInfo = new Content { SiteId = _site.Id, ChannelId = channel.Id, AdminId = adminId, LastEditAdminId = adminId, UserId = userId, SourceId = sourceId, AddDate = TranslateUtils.ToDateTime(addDate), GroupNames = ListUtils.GetStringList(groupNameCollection), TagNames = ListUtils.GetStringList(tags), Checked = isChecked, CheckedLevel = checkedLevel, Hits = hits, HitsByDay = hitsByDay, HitsByWeek = hitsByWeek, HitsByMonth = hitsByMonth, LastHitsDate = TranslateUtils.ToDateTime(lastHitsDate), Downloads = downloads, Title = AtomUtility.Decrypt(title), SubTitle = AtomUtility.Decrypt(subTitle), ImageUrl = AtomUtility.Decrypt(imageUrl), VideoUrl = AtomUtility.Decrypt(videoUrl), FileUrl = AtomUtility.Decrypt(fileUrl), Body = AtomUtility.Decrypt(body), Summary = AtomUtility.Decrypt(summary), Author = AtomUtility.Decrypt(author), Source = AtomUtility.Decrypt(source), Top = isTop, Recommend = isRecommend, Hot = isHot, Color = isColor, LinkUrl = linkUrl }; var attributes = AtomUtility.GetDcElementNameValueCollection(entry.AdditionalElements); foreach (string attributeName in attributes.Keys) { if (!contentInfo.ContainsKey(StringUtils.ToLower(attributeName))) { contentInfo.Set(attributeName, AtomUtility.Decrypt(attributes[attributeName])); } } var isInsert = false; if (isOverride) { var existsIDs = await _databaseManager.ContentRepository.GetContentIdsBySameTitleAsync(_site, channel, contentInfo.Title); if (existsIDs.Count > 0) { foreach (var id in existsIDs) { contentInfo.Id = id; contents.Add(contentInfo); } } else { isInsert = true; } } else { isInsert = true; } if (isInsert) { contentInfo.Taxis = taxis; contents.Add(contentInfo); if (!string.IsNullOrEmpty(tags)) { foreach (var tagName in ListUtils.GetStringList(tags)) { await _databaseManager.ContentTagRepository.InsertAsync(_site.Id, tagName); } } } if (isTop) { taxis = topTaxis; } } catch { // ignored } } var contentIdList = new List <int>(); foreach (var content in contents) { if (content.Id > 0) { await _databaseManager.ContentRepository.UpdateAsync(_site, channel, content); } else { contentIdList.Add(await _databaseManager.ContentRepository.InsertWithTaxisAsync(_site, channel, content, content.Taxis)); } } return(contentIdList); }
/// <summary> /// 将频道模板中的辅助表导入发布系统中,返回修改了的表名对照 /// 在导入辅助表的同时检查发布系统辅助表并替换对应表 /// </summary> public NameValueCollection ImportAuxiliaryTables(int publishmentSystemId, bool isUserTables) { if (!DirectoryUtils.IsDirectoryExists(_directoryPath)) { return(null); } var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId); var nameValueCollection = new NameValueCollection(); var tableNamePrefix = publishmentSystemInfo.PublishmentSystemDir + "_"; var filePaths = DirectoryUtils.GetFilePaths(_directoryPath); foreach (var filePath in filePaths) { var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(filePath)); var tableName = AtomUtility.GetDcElementContent(feed.AdditionalElements, "TableENName"); var tableType = EAuxiliaryTableTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(feed.AdditionalElements, "AuxiliaryTableType")); if (!isUserTables) { nameValueCollection[tableName] = NodeManager.GetTableName(publishmentSystemInfo, tableType); continue; } var tableCnName = AtomUtility.GetDcElementContent(feed.AdditionalElements, "TableCNName"); var serializedString = AtomUtility.GetDcElementContent(feed.AdditionalElements, "SerializedString"); var tableNameToInsert = string.Empty;//需要增加的表名,空代表不需要添加辅助表 var tableInfo = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableInfo(tableName); if (tableInfo == null)//如果当前系统无此表名 { tableNameToInsert = tableName; } else { var serializedStringForExistTable = TableManager.GetSerializedString(tableName); if (!string.IsNullOrEmpty(serializedString)) { if (serializedString != serializedStringForExistTable)//仅有此时,导入表需要修改表名 { tableNameToInsert = tableNamePrefix + tableName; tableCnName = tableNamePrefix + tableCnName; nameValueCollection[tableName] = tableNameToInsert; } } } if (!string.IsNullOrEmpty(tableNameToInsert))//需要添加 { if (!BaiRongDataProvider.TableStructureDao.IsTableExists(tableNameToInsert)) { tableInfo = new AuxiliaryTableInfo { TableEnName = tableNameToInsert, TableCnName = tableCnName, AttributeNum = 0, AuxiliaryTableType = tableType, IsCreatedInDb = false, IsChangedAfterCreatedInDb = false, Description = AtomUtility.GetDcElementContent(feed.AdditionalElements, "Description") }; BaiRongDataProvider.TableCollectionDao.Insert(tableInfo); var tableStyle = EAuxiliaryTableTypeUtils.GetTableStyle(tableInfo.AuxiliaryTableType); var attributeNameList = TableManager.GetAttributeNameList(tableStyle, tableInfo.TableEnName, true); attributeNameList.AddRange( TableManager.GetHiddenAttributeNameList(tableStyle)); foreach (AtomEntry entry in feed.Entries) { var metaInfo = new TableMetadataInfo { AuxiliaryTableEnName = tableNameToInsert, AttributeName = AtomUtility.GetDcElementContent(entry.AdditionalElements, "AttributeName"), DataType = EDataTypeUtils.GetEnumType( AtomUtility.GetDcElementContent(entry.AdditionalElements, "DataType")), DataLength = TranslateUtils.ToInt( AtomUtility.GetDcElementContent(entry.AdditionalElements, "DataLength")), Taxis = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "Taxis")), IsSystem = TranslateUtils.ToBool( AtomUtility.GetDcElementContent(entry.AdditionalElements, "IsSystem")) }; if (attributeNameList.IndexOf(metaInfo.AttributeName.Trim().ToLower()) != -1) { continue; } if (metaInfo.IsSystem) { continue; } BaiRongDataProvider.TableMetadataDao.Insert(metaInfo); } BaiRongDataProvider.TableMetadataDao.CreateAuxiliaryTable(tableNameToInsert); } } var tableNameToChange = (!string.IsNullOrEmpty(tableNameToInsert)) ? tableNameToInsert : tableName; //更新发布系统后台内容表及栏目表 if (tableType == EAuxiliaryTableType.BackgroundContent) { publishmentSystemInfo.AuxiliaryTableForContent = tableNameToChange; DataProvider.PublishmentSystemDao.Update(publishmentSystemInfo); } else if (tableType == EAuxiliaryTableType.GovPublicContent) { publishmentSystemInfo.AuxiliaryTableForGovPublic = tableNameToChange; DataProvider.PublishmentSystemDao.Update(publishmentSystemInfo); } else if (tableType == EAuxiliaryTableType.GovInteractContent) { publishmentSystemInfo.AuxiliaryTableForGovInteract = tableNameToChange; DataProvider.PublishmentSystemDao.Update(publishmentSystemInfo); } else if (tableType == EAuxiliaryTableType.JobContent) { publishmentSystemInfo.AuxiliaryTableForJob = tableNameToChange; DataProvider.PublishmentSystemDao.Update(publishmentSystemInfo); } else if (tableType == EAuxiliaryTableType.VoteContent) { publishmentSystemInfo.AuxiliaryTableForVote = tableNameToChange; DataProvider.PublishmentSystemDao.Update(publishmentSystemInfo); } } return(nameValueCollection); }
public override void Submit_OnClick(object sender, EventArgs e) { var isChanged = false; try { if (!isEntity) { DataProviderWX.CardSNDAO.UpdateStatus(cardID, TranslateUtils.ToBool(ddlIsDisabled.SelectedValue), TranslateUtils.StringCollectionToIntList(Request.QueryString["IDCollection"])); } else { var cardEntitySNIDList = TranslateUtils.StringCollectionToIntList(Request.QueryString["IDCollection"]); if (cardEntitySNIDList.Count > 0) { for (var i = 0; i < cardEntitySNIDList.Count; i++) { var cardEntitySNInfo = DataProviderWX.CardEntitySNDAO.GetCardEntitySNInfo(cardEntitySNIDList[i]); var userID = BaiRongDataProvider.UserDao.GetUserIdByEmailOrMobile(string.Empty, cardEntitySNInfo.Mobile); var userInfo = BaiRongDataProvider.UserDao.GetUserInfo(userID); if (userInfo != null) { var cardSNInfo = DataProviderWX.CardSNDAO.GetCardSNInfo(PublishmentSystemID, cardID, string.Empty, userInfo.UserName); var cardCashLogInfo = new CardCashLogInfo(); cardCashLogInfo.PublishmentSystemID = PublishmentSystemID; cardCashLogInfo.UserName = userInfo.UserName; cardCashLogInfo.CardID = cardSNInfo.CardID; cardCashLogInfo.CardSNID = cardSNInfo.ID; cardCashLogInfo.Amount = cardEntitySNInfo.Amount; cardCashLogInfo.CurAmount += cardEntitySNInfo.Amount;; cardCashLogInfo.CashType = ECashTypeUtils.GetValue(ECashType.Recharge); cardCashLogInfo.Operator = AdminManager.Current.UserName; cardCashLogInfo.Description = "绑定实体卡充值"; cardCashLogInfo.AddDate = DateTime.Now; var userCreditsLogInfo = new UserCreditsLogInfo(); userCreditsLogInfo.UserName = userInfo.UserName; userCreditsLogInfo.ProductId = AppManager.WeiXin.AppID; userCreditsLogInfo.Num = cardEntitySNInfo.Credits; userCreditsLogInfo.IsIncreased = true; userCreditsLogInfo.Action = "绑定实体卡添加积分"; userCreditsLogInfo.AddDate = DateTime.Now; if (!cardEntitySNInfo.IsBinding) { cardEntitySNInfo.IsBinding = true; DataProviderWX.CardEntitySNDAO.Update(cardEntitySNInfo); DataProviderWX.CardCashLogDAO.Insert(cardCashLogInfo); DataProviderWX.CardSNDAO.Recharge(cardSNInfo.ID, userInfo.UserName, cardEntitySNInfo.Amount); BaiRongDataProvider.UserCreditsLogDao.Insert(userCreditsLogInfo); BaiRongDataProvider.UserDao.AddCredits(userInfo.UserName, cardEntitySNInfo.Credits); } } } } } isChanged = true; } catch (Exception ex) { FailMessage(ex, "失败:" + ex.Message); } if (isChanged) { JsUtils.OpenWindow.CloseModalPage(Page); } }
public Select(Enum e) { Value = TranslateUtils.Get <T>(e.GetValue()); Label = e.GetDisplayName(); }