public static void UpdateCache(SiteInfo siteInfo, ChannelInfo channelInfo, IContentInfo contentInfoToUpdate) { var dict = ContentCache.GetContentDict(channelInfo.Id); var contentInfo = GetContentInfo(siteInfo, channelInfo, contentInfoToUpdate.Id); if (contentInfo != null) { var isClearCache = contentInfo.IsTop != contentInfoToUpdate.IsTop; if (!isClearCache) { var orderAttributeName = ETaxisTypeUtils.GetContentOrderAttributeName( ETaxisTypeUtils.GetEnumType(channelInfo.Additional.DefaultTaxisType)); if (contentInfo.Get(orderAttributeName) != contentInfoToUpdate.Get(orderAttributeName)) { isClearCache = true; } } if (isClearCache) { ListCache.Remove(channelInfo.Id); } } dict[contentInfoToUpdate.Id] = (ContentInfo)contentInfoToUpdate; StlContentCache.ClearCache(); }
public void Update(int siteId, int channelId, IContentInfo contentInfo) { var siteInfo = SiteManager.GetSiteInfo(siteId); var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); DataProvider.ContentDao.Update(siteInfo, channelInfo, (ContentInfo)contentInfo); }
private ActionResult UpdateContent(IContentInfo contentInfo, Func <string, ContentPath> makeNewPath, Func <ContentPath, ActionResult> onSuccess) { var modelUpdated = (bool)_tryUpdateModelMethod .MakeGenericMethod(contentInfo.ContentType) .Invoke(this, new object[] { contentInfo.Content, "Content" }); if (modelUpdated) { _contentRepository.SaveChanges(); var newPath = makeNewPath(contentInfo.Content.Alias); if (contentInfo.Path != null) { if (!newPath.Equals(contentInfo.Path)) { _contentPathCache.UpdatePath(contentInfo.Path, newPath); } } else { _contentPathCache.AddPath(newPath, contentInfo.Content.Id, contentInfo.ContentType); } SetSuccessMessage(Resources.SavedSuccessfully); return(onSuccess(newPath)); } else { SetErrorMessage(Resources.ThereWereValidationErrors); return(View("Celes.Edit", contentInfo)); } }
public ContentFormSubmitEventArgs(int siteId, int channelId, IContentInfo contentInfo, IAttributes form) { SiteId = siteId; ChannelId = channelId; ContentInfo = contentInfo; Form = form; }
public static ELimitType GetLimitType(int siteId, IContentInfo contentInfo) { var configInfo = Main.GetConfigInfo(siteId); var ts = new TimeSpan(DateTime.Now.Ticks - contentInfo.AddDate.Ticks); var alert = configInfo.ApplyDateLimit + configInfo.ApplyAlertDate; var yellow = alert + configInfo.ApplyYellowAlertDate; var red = yellow + configInfo.ApplyRedAlertDate; if (ts.Days >= red) { return(ELimitType.Red); } else if (ts.Days >= yellow) { return(ELimitType.Yellow); } else if (ts.Days >= alert) { return(ELimitType.Alert); } return(ELimitType.Normal); }
public static string Parse(SiteInfo siteInfo, int channelId, IContentInfo contentInfo) { var contentFilePathRule = GetContentFilePathRule(siteInfo, channelId); var filePath = ParseContentPath(siteInfo, channelId, contentInfo, contentFilePathRule); return(filePath); }
public void Update(int siteId, int channelId, IContentInfo contentInfo) { var siteInfo = SiteManager.GetSiteInfo(siteId); var nodeInfo = ChannelManager.GetChannelInfo(siteId, channelId); var tableName = ChannelManager.GetTableName(siteInfo, nodeInfo); DataProvider.ContentDao.Update(tableName, siteInfo, contentInfo); }
//public void SetValuesToContentInfo(int siteId, int channelId, NameValueCollection form, IContentInfo contentInfo) //{ // var siteInfo = SiteManager.GetSiteInfo(siteId); // var nodeInfo = NodeManager.GetChannelInfo(siteId, channelId); // var tableName = NodeManager.GetTableName(siteInfo, nodeInfo); // var tableStyle = NodeManager.GetTableStyle(siteInfo, nodeInfo); // var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(siteId, channelId); // var extendImageUrl = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl); // if (form.AllKeys.Contains(StringUtils.LowerFirst(extendImageUrl))) // { // form[extendImageUrl] = form[StringUtils.LowerFirst(extendImageUrl)]; // } // InputTypeParser.AddValuesToAttributes(tableStyle, tableName, siteInfo, relatedIdentities, form, contentInfo.ToNameValueCollection(), ContentAttribute.HiddenAttributes); //} public int Insert(int siteId, int channelId, IContentInfo contentInfo) { var siteInfo = SiteManager.GetSiteInfo(siteId); var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); return(DataProvider.ContentDao.Insert(tableName, siteInfo, channelInfo, (ContentInfo)contentInfo)); }
/// <summary> /// 初始化 <see cref="T:SiteServer.Plugin.ContentFormSubmitEventArgs" /> 类的新实例。 /// </summary> /// <param name="siteId">站点Id。</param> /// <param name="channelId">栏目Id。</param> /// <param name="contentId">内容Id。</param> /// <param name="form">表单数据。</param> /// <param name="contentInfo">内容对象。</param> public ContentFormSubmitEventArgs(int siteId, int channelId, int contentId, IDictionary <string, object> form, IContentInfo contentInfo) { SiteId = siteId; ChannelId = channelId; ContentId = contentId; Form = form; ContentInfo = contentInfo; }
public PluginParseContext(Dictionary <string, string> attributes, string innerXml, int siteId, int channelId, int contentId, IContentInfo contentInfo, TemplateType templateType, int templateId) { Attributes = attributes; InnerXml = innerXml; SiteId = siteId; ChannelId = channelId; ContentId = contentId; ContentInfo = contentInfo; TemplateType = templateType; TemplateId = templateId; }
public static void Write(string fileName, IContentInfo info) { FileInfo file = new FileInfo($"{fileName}.{info.Extension}"); if (!file.Exists) { var writer = file.CreateText(); writer.WriteLine(info.GetContent()); writer.Close(); } }
public void ContentFormSubmited(int siteId, int channelId, IContentInfo contentInfo, IDictionary <string, object> form) { var categoryChannelId = TranslateUtils.Get <int>(form, "categoryChannelId"); var categoryDepartmentId = TranslateUtils.Get <int>(form, "categoryDepartmentId"); if (categoryChannelId == 0) { throw new Exception("请选择正确的主题分类"); } contentInfo.ChannelId = categoryChannelId; if (categoryDepartmentId == 0) { throw new Exception("请选择正确的机构分类"); } contentInfo.Set(ContentAttribute.DepartmentId, categoryDepartmentId.ToString()); var classInfoList = Main.CategoryClassRepository.GetCategoryClassInfoList(siteId); foreach (var classInfo in classInfoList) { if (classInfo.IsSystem || !classInfo.IsEnabled) { continue; } var attributeName = PublicManager.GetCategoryContentAttributeName(classInfo.ClassCode); var attributeValue = TranslateUtils.Get <int>(form, attributeName); contentInfo.Set(attributeName, attributeValue.ToString()); //if (attributeValue > 0) //{ // CategoryDao.UpdateContentNum(PublishmentSystemInfo, categoryClassInfo.ContentAttributeName, categoryId); //} } if (contentInfo.Id == 0) { var identifier = PublicManager.GetIdentifier(siteId, categoryChannelId, categoryDepartmentId, contentInfo); contentInfo.Set(nameof(ContentAttribute.Identifier), identifier); } else { var effectDate = contentInfo.Get <DateTime>(ContentAttribute.EffectDate); if (string.IsNullOrEmpty(contentInfo.Get <string>(ContentAttribute.Identifier)) || PublicManager.IsIdentifierChanged(siteId, categoryChannelId, categoryDepartmentId, effectDate, contentInfo)) { var identifier = PublicManager.GetIdentifier(siteId, categoryChannelId, categoryDepartmentId, contentInfo); contentInfo.Set(nameof(ContentAttribute.Identifier), identifier); } } }
/// <summary> /// 初始化 <see cref="T:SiteServer.Plugin.ParseEventArgs" /> 类的新实例。 /// </summary> /// <param name="siteId">站点Id。</param> /// <param name="channelId">栏目Id。</param> /// <param name="contentId">内容Id。</param> /// <param name="contentInfo">内容实体。</param> /// <param name="templateType">模板类型。</param> /// <param name="templateId">模板Id。</param> /// <param name="filePath">生成页面的绝对路径。</param> /// <param name="headCodes">生成的Html页面中包含在head标签内的代码。</param> /// <param name="bodyCodes">生成的Html页面中包含在body标签内的代码。</param> /// <param name="footCodes">生成的Html页面中包含在页面最底部的代码。</param> /// <param name="contentBuilder">生成的Html页面代码。</param> public ParseEventArgs(int siteId, int channelId, int contentId, IContentInfo contentInfo, TemplateType templateType, int templateId, string filePath, SortedDictionary <string, string> headCodes, SortedDictionary <string, string> bodyCodes, SortedDictionary <string, string> footCodes, StringBuilder contentBuilder) { SiteId = siteId; ChannelId = channelId; ContentId = contentId; ContentInfo = contentInfo; TemplateType = templateType; TemplateId = templateId; FilePath = filePath; HeadCodes = headCodes; BodyCodes = bodyCodes; FootCodes = footCodes; ContentBuilder = contentBuilder; }
public PluginParseContext(Dictionary <string, string> stlElementAttributes, string stlElementInnerXml, PageInfo pageInfo, int channelId, int contentId, IContentInfo contentInfo) { StlElementAttributes = stlElementAttributes; StlElementInnerXml = stlElementInnerXml; SiteId = pageInfo.SiteId; ChannelId = channelId; ContentId = contentId; ContentInfo = contentInfo; TemplateType = pageInfo.TemplateInfo.TemplateType; TemplateId = pageInfo.TemplateInfo.Id; HeadCodes = pageInfo.HeadCodes; BodyCodes = pageInfo.BodyCodes; FootCodes = pageInfo.FootCodes; }
private static void Prefix() { IContentInfo[] newContent = new IContentInfo[] { new InfiniteStorageConfig(), new ArtConfig(), new LightConfig(), new InfiniteBatteryConfig(), new ArtLightConfig(), new ArtNightLightConfig() , new InfiniteFridgeConfig(), new SwallowStorageConfig() }; foreach (IContentInfo info in newContent) { Strings.Add($"STRINGS.BUILDINGS.PREFABS.{ info.GetContentBasicInfo().ID.ToUpperInvariant() }.NAME", info.GetContentBasicInfo().DisplayName); Strings.Add($"STRINGS.BUILDINGS.PREFABS.{ info.GetContentBasicInfo().ID.ToUpperInvariant() }.DESC", info.GetContentBasicInfo().Description); Strings.Add($"STRINGS.BUILDINGS.PREFABS.{ info.GetContentBasicInfo().ID.ToUpperInvariant() }.EFFECT", info.GetContentBasicInfo().Effect); ModUtil.AddBuildingToPlanScreen(info.GetContentBasicInfo().Category, info.GetContentBasicInfo().ID); } }
public static bool IsCreatable(ChannelInfo channelInfo, IContentInfo contentInfo) { if (channelInfo == null || contentInfo == null) { return(false); } //引用链接,不需要生成内容页;引用内容,需要生成内容页; if (contentInfo.ReferenceId > 0 && ETranslateContentTypeUtils.GetEnumType(contentInfo.GetString(ContentAttribute.TranslateContentType)) != ETranslateContentType.ReferenceContent) { return(false); } return(channelInfo.Additional.IsContentCreatable && string.IsNullOrEmpty(contentInfo.LinkUrl) && contentInfo.IsChecked && contentInfo.SourceId != SourceManager.Preview && contentInfo.ChannelId > 0); }
public static Dictionary <string, object> ToDict(IContentInfo contentInfo) { var result = new Dictionary <string, object>(); if (contentInfo != null) { var nvc = contentInfo.ToNameValueCollection(); foreach (string key in nvc.Keys) { if (key != "settingsxml") { result.Add(key, nvc[key]); } } } return(result); }
public void Page_Load(object sender, EventArgs e) { _channelId = Utils.ToInt(Request.QueryString["channelId"]); _contentId = Utils.ToInt(Request.QueryString["contentId"]); _contentInfo = Main.ContentApi.GetContentInfo(SiteId, _channelId, _contentId); _adminInfo = Main.AdminApi.GetAdminInfoByUserId(AuthRequest.AdminId); if (!IsPostBack) { LtlDepartmentName.Text = DepartmentManager.GetDepartmentName(_adminInfo.DepartmentId); LtlUserName.Text = _adminInfo.DisplayName; var replyInfo = ReplyDao.GetReplyInfoByContentId(SiteId, _contentId); if (replyInfo != null) { TbReply.Text = replyInfo.Reply; } } }
public static void InsertCache(SiteInfo siteInfo, ChannelInfo channelInfo, IContentInfo contentInfo) { if (contentInfo.SourceId == SourceManager.Preview) { return; } var contentIdList = ListCache.GetContentIdList(channelInfo.Id); if (ETaxisTypeUtils.Equals(ETaxisType.OrderByTaxisDesc, channelInfo.Additional.DefaultTaxisType)) { contentIdList.Insert(0, contentInfo.Id); } else { ListCache.Remove(channelInfo.Id); } var dict = ContentCache.GetContentDict(contentInfo.ChannelId); dict[contentInfo.Id] = (ContentInfo)contentInfo; var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var countInfoList = GetContentCountInfoList(tableName); var countInfo = countInfoList.FirstOrDefault(x => x.SiteId == siteInfo.Id && x.ChannelId == channelInfo.Id && x.IsChecked == contentInfo.IsChecked.ToString() && x.CheckedLevel == contentInfo.CheckedLevel); if (countInfo != null) { countInfo.Count++; } StlContentCache.ClearCache(); CountCache.Clear(tableName); }
private ActionResult UpdateContent(IContentInfo contentInfo, Func<string, ContentPath> makeNewPath, Func<ContentPath, ActionResult> onSuccess) { var modelUpdated = (bool)_tryUpdateModelMethod .MakeGenericMethod(contentInfo.ContentType) .Invoke(this, new object[] { contentInfo.Content, "Content" }); if (modelUpdated) { _contentRepository.SaveChanges(); var newPath = makeNewPath(contentInfo.Content.Alias); if (contentInfo.Path != null) { if (!newPath.Equals(contentInfo.Path)) { _contentPathCache.UpdatePath(contentInfo.Path, newPath); } } else { _contentPathCache.AddPath(newPath, contentInfo.Content.Id, contentInfo.ContentType); } SetSuccessMessage(Resources.SavedSuccessfully); return onSuccess(newPath); } else { SetErrorMessage(Resources.ThereWereValidationErrors); return View("Celes.Edit", contentInfo); } }
public bool IsAuthorizedToView(IPrincipal user, IContentInfo contentInfo) { return(true); }
public static string GetIdentifier(int siteId, int channelId, int departmentId, IContentInfo contentInfo) { if (contentInfo == null) { return(string.Empty); } var channelInfo = Context.ChannelApi.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(string.Empty); } var builder = new StringBuilder(); var ruleInfoList = Main.IdentifierRuleRepository.GetRuleInfoList(siteId); foreach (var ruleInfo in ruleInfoList) { var identifierType = EIdentifierTypeUtils.GetEnumType(ruleInfo.IdentifierType); if (identifierType == EIdentifierType.Department) { var departmentCode = DepartmentManager.GetDepartmentCode(siteId, departmentId); if (ruleInfo.MinLength > 0) { builder.Append(departmentCode.PadLeft(ruleInfo.MinLength, '0')).Append(ruleInfo.Suffix); } else { builder.Append(departmentCode).Append(ruleInfo.Suffix); } } else if (identifierType == EIdentifierType.Channel) { var channelCode = channelInfo.Id.ToString(); if (ruleInfo.MinLength > 0) { builder.Append(channelCode.PadLeft(ruleInfo.MinLength, '0')).Append(ruleInfo.Suffix); } else { builder.Append(channelCode).Append(ruleInfo.Suffix); } } else if (identifierType == EIdentifierType.Attribute) { if (ruleInfo.AttributeName == ContentAttribute.AbolitionDate || ruleInfo.AttributeName == ContentAttribute.EffectDate || ruleInfo.AttributeName == ContentAttribute.PublishDate || ruleInfo.AttributeName == nameof(IContentInfo.AddDate)) { var dateTime = TranslateUtils.ToDateTime(contentInfo.Get <string>(ruleInfo.AttributeName)); if (ruleInfo.MinLength > 0) { builder.Append(dateTime.ToString(ruleInfo.FormatString).PadLeft(ruleInfo.MinLength, '0')).Append(ruleInfo.Suffix); } else { builder.Append(dateTime.ToString(ruleInfo.FormatString)).Append(ruleInfo.Suffix); } } else { var attributeValue = contentInfo.Get <string>(ruleInfo.AttributeName); if (ruleInfo.MinLength > 0) { builder.Append(attributeValue.PadLeft(ruleInfo.MinLength, '0')).Append(ruleInfo.Suffix); } else { builder.Append(attributeValue).Append(ruleInfo.Suffix); } } } else if (identifierType == EIdentifierType.Sequence) { var targetSiteId = siteId; var targetChannelId = 0; if (ruleInfo.IsSequenceChannelZero) { targetChannelId = channelInfo.Id; } var targetDepartmentId = 0; if (ruleInfo.IsSequenceDepartmentZero) { targetDepartmentId = departmentId; } var targetAddYear = 0; if (ruleInfo.IsSequenceYearZero && contentInfo.AddDate != null) { targetAddYear = contentInfo.AddDate.Value.Year; } var sequence = Main.IdentifierSeqRepository.GetSequence(targetSiteId, targetChannelId, targetDepartmentId, targetAddYear, ruleInfo.Sequence); if (ruleInfo.MinLength > 0) { builder.Append(sequence.ToString().PadLeft(ruleInfo.MinLength, '0')).Append(ruleInfo.Suffix); } else { builder.Append(sequence.ToString()).Append(ruleInfo.Suffix); } } } return(builder.ToString()); }
public static bool IsIdentifierChanged(int siteId, int channelId, int departmentId, DateTime effectDate, IContentInfo contentInfo) { var isIdentifierChanged = false; var ruleInfoList = Main.IdentifierRuleRepository.GetRuleInfoList(siteId); foreach (var ruleInfo in ruleInfoList) { var identifierType = EIdentifierTypeUtils.GetEnumType(ruleInfo.IdentifierType); if (identifierType == EIdentifierType.Department) { if (contentInfo.Get <int>(nameof(ContentAttribute.DepartmentId)) != departmentId) { isIdentifierChanged = true; } } else if (identifierType == EIdentifierType.Channel) { if (contentInfo.Id != channelId) { isIdentifierChanged = true; } } else if (identifierType == EIdentifierType.Attribute) { if (Utils.EqualsIgnoreCase(ruleInfo.AttributeName, ContentAttribute.EffectDate) && TranslateUtils.ToDateTime(contentInfo.Get <string>(ruleInfo.AttributeName)) != effectDate) { isIdentifierChanged = true; } } } return(isIdentifierChanged); }
public static string GetStlCurrentUrl(SiteInfo siteInfo, int channelId, int contentId, IContentInfo contentInfo, TemplateType templateType, int templateId, bool isLocal) { var currentUrl = string.Empty; if (templateType == TemplateType.IndexPageTemplate) { currentUrl = siteInfo.Additional.WebUrl; } else if (templateType == TemplateType.ContentTemplate) { if (contentInfo == null) { var nodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId); currentUrl = PageUtility.GetContentUrl(siteInfo, nodeInfo, contentId, isLocal); } else { currentUrl = PageUtility.GetContentUrl(siteInfo, contentInfo, isLocal); } } else if (templateType == TemplateType.ChannelTemplate) { currentUrl = PageUtility.GetChannelUrl(siteInfo, ChannelManager.GetChannelInfo(siteInfo.Id, channelId), isLocal); } else if (templateType == TemplateType.FileTemplate) { currentUrl = PageUtility.GetFileUrl(siteInfo, templateId, isLocal); } //currentUrl是当前页面的地址,前后台分离的时候,不允许带上protocol //return PageUtils.AddProtocolToUrl(currentUrl); return(currentUrl); }
/// <summary> /// 对GetContentUrlByID的优化 /// 通过传入参数contentInfoCurrent,避免对ContentInfo查询太多 /// </summary> private static string GetContentUrlById(SiteInfo siteInfo, IContentInfo contentInfoCurrent, bool isLocal) { if (contentInfoCurrent == null) { return(PageUtils.UnclickedUrl); } if (isLocal) { return(ApiRoutePreview.GetContentUrl(siteInfo.Id, contentInfoCurrent.ChannelId, contentInfoCurrent.Id)); } var sourceId = contentInfoCurrent.SourceId; var referenceId = contentInfoCurrent.ReferenceId; var linkUrl = contentInfoCurrent.GetString(ContentAttribute.LinkUrl); var channelId = contentInfoCurrent.ChannelId; if (referenceId > 0 && contentInfoCurrent.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString()) { if (sourceId > 0 && (ChannelManager.IsExists(siteInfo.Id, sourceId) || ChannelManager.IsExists(sourceId))) { var targetChannelId = sourceId; var targetSiteId = StlChannelCache.GetSiteId(targetChannelId); var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId); var targetChannelInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId); var contentInfo = ContentManager.GetContentInfo(targetSiteInfo, targetChannelInfo, referenceId); if (contentInfo == null || contentInfo.ChannelId <= 0) { return(PageUtils.UnclickedUrl); } if (contentInfo.SiteId == targetSiteInfo.Id) { return(GetContentUrlById(targetSiteInfo, contentInfo, false)); } var siteInfoTmp = SiteManager.GetSiteInfo(contentInfo.SiteId); return(GetContentUrlById(siteInfoTmp, contentInfo, false)); } else { var tableName = ChannelManager.GetTableName(siteInfo, channelId); channelId = StlContentCache.GetChannelId(tableName, referenceId); linkUrl = StlContentCache.GetValue(tableName, referenceId, ContentAttribute.LinkUrl); if (ChannelManager.IsExists(siteInfo.Id, channelId)) { return(GetContentUrlById(siteInfo, channelId, referenceId, 0, 0, linkUrl, false)); } var targetSiteId = StlChannelCache.GetSiteId(channelId); var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId); return(GetContentUrlById(targetSiteInfo, channelId, referenceId, 0, 0, linkUrl, false)); } } if (!string.IsNullOrEmpty(linkUrl)) { return(ParseNavigationUrl(siteInfo, linkUrl, false)); } var contentUrl = PathUtility.ContentFilePathRules.Parse(siteInfo, channelId, contentInfoCurrent); return(GetSiteUrl(siteInfo, contentUrl, false)); }
public static string GetContentUrl(SiteInfo siteInfo, IContentInfo contentInfo, bool isLocal) { return(GetContentUrlById(siteInfo, contentInfo, isLocal)); }
public ScenarioInfo(IContentInfo contentInfo, ScenarioDescription description) { ContentInfo = contentInfo; Description = description; }
private static string ParseContentPath(SiteInfo siteInfo, int channelId, IContentInfo contentInfo, string contentFilePathRule) { var filePath = contentFilePathRule.Trim(); var regex = "(?<element>{@[^}]+})"; var elements = RegexUtils.GetContents("element", regex, filePath); var addDate = contentInfo.AddDate; var contentId = contentInfo.Id; foreach (var element in elements) { var value = string.Empty; if (StringUtils.EqualsIgnoreCase(element, ChannelId)) { value = channelId.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, ContentId)) { value = contentId.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, Sequence)) { var tableName = ChannelManager.GetTableName(siteInfo, channelId); value = StlContentCache.GetSequence(tableName, channelId, contentId).ToString(); } else if (StringUtils.EqualsIgnoreCase(element, ParentRule))//继承父级设置 20151113 sessionliang { var nodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId); var parentInfo = ChannelManager.GetChannelInfo(siteInfo.Id, nodeInfo.ParentId); if (parentInfo != null) { var parentRule = GetContentFilePathRule(siteInfo, parentInfo.Id); value = DirectoryUtils.GetDirectoryPath(ParseContentPath(siteInfo, parentInfo.Id, contentInfo, parentRule)).Replace("\\", "/"); } } else if (StringUtils.EqualsIgnoreCase(element, ChannelName)) { var nodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId); if (nodeInfo != null) { value = nodeInfo.ChannelName; } } else if (StringUtils.EqualsIgnoreCase(element, LowerChannelName)) { var nodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId); if (nodeInfo != null) { value = nodeInfo.ChannelName.ToLower(); } } else if (StringUtils.EqualsIgnoreCase(element, ChannelIndex)) { var nodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId); if (nodeInfo != null) { value = nodeInfo.IndexName; } } else if (StringUtils.EqualsIgnoreCase(element, LowerChannelIndex)) { var nodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId); if (nodeInfo != null) { value = nodeInfo.IndexName.ToLower(); } } else if (StringUtils.EqualsIgnoreCase(element, Year) || StringUtils.EqualsIgnoreCase(element, Month) || StringUtils.EqualsIgnoreCase(element, Day) || StringUtils.EqualsIgnoreCase(element, Hour) || StringUtils.EqualsIgnoreCase(element, Minute) || StringUtils.EqualsIgnoreCase(element, Second)) { if (StringUtils.EqualsIgnoreCase(element, Year)) { value = addDate.Year.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, Month)) { value = addDate.Month.ToString("D2"); //value = addDate.ToString("MM"); } else if (StringUtils.EqualsIgnoreCase(element, Day)) { value = addDate.Day.ToString("D2"); //value = addDate.ToString("dd"); } else if (StringUtils.EqualsIgnoreCase(element, Hour)) { value = addDate.Hour.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, Minute)) { value = addDate.Minute.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, Second)) { value = addDate.Second.ToString(); } } else { var attributeName = element.Replace("{@", string.Empty).Replace("}", string.Empty); var isLower = false; if (StringUtils.StartsWithIgnoreCase(attributeName, "lower")) { isLower = true; attributeName = attributeName.Substring(5); } value = contentInfo.GetString(attributeName); if (isLower) { value = value.ToLower(); } } value = StringUtils.HtmlDecode(value); filePath = filePath.Replace(element, value); } if (filePath.Contains("//")) { filePath = Regex.Replace(filePath, @"(/)\1{2,}", "/"); filePath = filePath.Replace("//", "/"); } if (filePath.Contains("(")) { regex = @"(?<element>\([^\)]+\))"; elements = RegexUtils.GetContents("element", regex, filePath); foreach (var element in elements) { if (!element.Contains("|")) { continue; } var value = element.Replace("(", string.Empty).Replace(")", string.Empty); var value1 = value.Split('|')[0]; var value2 = value.Split('|')[1]; value = value1 + value2; if (!string.IsNullOrEmpty(value1) && !string.IsNullOrEmpty(value1)) { value = value1; } filePath = filePath.Replace(element, value); } } return(filePath); }
protected override void OnInit(EventArgs e) { base.OnInit(e); var channelId = AuthRequest.GetQueryInt("channelId"); var contentId = AuthRequest.GetQueryInt("contentId"); _returnUrl = AuthRequest.GetQueryString("returnUrl"); _contentInfo = Main.ContentApi.GetContentInfo(SiteId, channelId, contentId); _adminInfo = Main.AdminApi.GetAdminInfoByUserId(AuthRequest.AdminId); var state = EStateUtils.GetEnumType(_contentInfo.GetString(ContentAttribute.State)); if (IsPostBack) { return; } if (PhBtnAccept != null) { PhBtnAccept.Visible = InteractManager.IsPermission(SiteId, _contentInfo.ChannelId, Permissions.Accept); } if (PhBtnSwitchToTranslate != null) { PhBtnSwitchToTranslate.Visible = InteractManager.IsPermission(SiteId, _contentInfo.ChannelId, Permissions.SwitchToTranslate); } if (PhBtnReply != null) { PhBtnReply.Visible = InteractManager.IsPermission(SiteId, _contentInfo.ChannelId, Permissions.Reply); } if (PhBtnCheck != null) { PhBtnCheck.Visible = state != EState.Checked && InteractManager.IsPermission(SiteId, _contentInfo.ChannelId, Permissions.Check); } if (PhBtnComment != null) { PhBtnComment.Visible = state != EState.Checked && InteractManager.IsPermission(SiteId, _contentInfo.ChannelId, Permissions.Comment); } if (PhBtnReturn != null) { PhBtnReturn.Visible = !ConfigInfo.ApplyIsOpenWindow; } var tableColumns = Main.ContentApi.GetTableColumns(SiteId, _contentInfo.ChannelId); var isSingle = true; var builder = new StringBuilder(); foreach (var tableColumn in tableColumns) { if (tableColumn.InputStyle == null || Utils.EqualsIgnoreCase(tableColumn.AttributeName, nameof(IContentInfo.Title)) || Utils.EqualsIgnoreCase(tableColumn.AttributeName, nameof(IContentInfo.IsHot)) || Utils.EqualsIgnoreCase(tableColumn.AttributeName, nameof(IContentInfo.IsColor)) || Utils.EqualsIgnoreCase(tableColumn.AttributeName, nameof(IContentInfo.IsRecommend)) || Utils.EqualsIgnoreCase(tableColumn.AttributeName, nameof(IContentInfo.IsTop)) || Utils.EqualsIgnoreCase(tableColumn.AttributeName, ContentAttribute.DepartmentId) || Utils.EqualsIgnoreCase(tableColumn.AttributeName, ContentAttribute.Content)) { continue; } var value = _contentInfo.GetString(tableColumn.AttributeName); if (Utils.EqualsIgnoreCase(tableColumn.AttributeName, ContentAttribute.TypeId)) { value = InteractManager.GetTypeName(Utils.ToInt(value)); } else if (Utils.EqualsIgnoreCase(tableColumn.AttributeName, ContentAttribute.IsPublic)) { value = Utils.ToBool(value) ? "公开" : "不公开"; } else if (Utils.EqualsIgnoreCase(tableColumn.AttributeName, ContentAttribute.FileUrl)) { if (!string.IsNullOrEmpty(value)) { value = $@"<a href=""{value}"" target=""_blank"">{value}</a>"; } } else if (Utils.EqualsIgnoreCase(tableColumn.AttributeName, ContentAttribute.State)) { value = EStateUtils.GetText(state); } if (isSingle) { builder.Append("<tr>"); } builder.Append( $@"<th>{tableColumn.InputStyle.DisplayName}</th><td>{value}</td>"); if (!isSingle) { builder.Append("</tr>"); } isSingle = !isSingle; } if (!isSingle) { builder.Append("</tr>"); } LtlTitle.Text = _contentInfo.Title; LtlApplyAttributes.Text = builder.ToString(); LtlContent.Text = _contentInfo.GetString(ContentAttribute.Content); if (PhReply != null) { if (state == EState.Denied || state == EState.Replied || state == EState.Redo || state == EState.Checked) { var replyInfo = ReplyDao.GetReplyInfoByContentId(SiteId, _contentInfo.Id); if (replyInfo != null) { PhReply.Visible = true; LtlDepartmentAndUserName.Text = $"{DepartmentManager.GetDepartmentName(replyInfo.DepartmentId)}({replyInfo.UserName})"; LtlReplyAddDate.Text = Utils.GetDateAndTimeString(replyInfo.AddDate); LtlReply.Text = replyInfo.Reply; if (!string.IsNullOrEmpty(replyInfo.FileUrl)) { LtlReplyFileUrl.Text = $@"<a href=""{replyInfo.FileUrl}"" target=""_blank"">{replyInfo.FileUrl}</a>"; } } } } if (BtnSwitchTo != null) { var departmentId = _contentInfo.GetInt(ContentAttribute.DepartmentId); BtnSwitchTo.Attributes.Add("onclick", ModalDepartmentSelectSingle.GetOpenWindowString(SiteId, _contentInfo.ChannelId)); var scriptBuilder = new StringBuilder(); if (departmentId > 0) { var departmentName = DepartmentManager.GetDepartmentName(departmentId); scriptBuilder.Append( $@"<script>departmentSelect('{departmentName}', {departmentId});</script>"); } LtlScript.Text = scriptBuilder.ToString(); } if (DdlTranslateChannelId != null) { var nodeInfoList = InteractManager.GetInteractChannelInfoList(SiteId); foreach (var nodeInfo in nodeInfoList) { if (nodeInfo.Id != _contentInfo.ChannelId) { var listItem = new ListItem(nodeInfo.ChannelName, nodeInfo.Id.ToString()); DdlTranslateChannelId.Items.Add(listItem); } } } RptRemarks.DataSource = RemarkDao.GetDataSourceByContentId(SiteId, _contentInfo.Id); RptRemarks.ItemDataBound += RptRemarks_ItemDataBound; RptRemarks.DataBind(); if (RptLogs != null) { RptLogs.DataSource = LogDao.GetDataSourceByContentId(SiteId, _contentInfo.Id); RptLogs.ItemDataBound += RptLogs_ItemDataBound; RptLogs.DataBind(); } }
public bool IsAuthorizedToView(IPrincipal user, IContentInfo contentInfo) { return true; }