public static string GetFileHtmlWithoutCount(PublishmentSystemInfo publishmentSystemInfo, string fileUrl, StringDictionary attributes, string innerXml, bool isStlEntity) { if (publishmentSystemInfo != null) { var retval = string.Empty; if (!string.IsNullOrEmpty(fileUrl)) { if (isStlEntity) { retval = ActionsDownload.GetUrl(publishmentSystemInfo.Additional.ApiUrl, publishmentSystemInfo.PublishmentSystemId, fileUrl); } else { var stlAnchor = new HtmlAnchor(); ControlUtils.AddAttributesIfNotExists(stlAnchor, attributes); stlAnchor.HRef = ActionsDownload.GetUrl(publishmentSystemInfo.Additional.ApiUrl, publishmentSystemInfo.PublishmentSystemId, fileUrl); if (string.IsNullOrEmpty(innerXml)) { stlAnchor.InnerHtml = PageUtils.GetFileNameFromUrl(fileUrl); } else { stlAnchor.InnerHtml = innerXml; } retval = ControlUtils.GetControlRenderHtml(stlAnchor); } } return(retval); } return(string.Empty); }
public override void Submit_OnClick(object sender, EventArgs e) { try { PhExport.Visible = false; const string fileName = "users.csv"; var filePath = PathUtils.GetTemporaryFilesPath(fileName); ExcelObject.CreateExcelFileForUsers(filePath, ETriStateUtils.GetEnumType(RblCheckedState.SelectedValue)); var link = new HyperLink { NavigateUrl = ActionsDownload.GetUrl(PageUtils.GetApiUrl(), filePath), Text = "下载" }; var successMessage = "成功导出文件! " + ControlUtils.GetControlRenderHtml(link); SuccessMessage(successMessage); } catch (Exception ex) { var failedMessage = "文件导出失败!<br/><br/>原因为:" + ex.Message; FailMessage(ex, failedMessage); } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } _exportType = Body.GetQueryString("ExportType"); if (!IsPostBack) { var fileName = string.Empty; try { if (_exportType == ExportTypeSingleTableStyle) { var tableStyle = ETableStyleUtils.GetEnumType(Body.GetQueryString("TableStyle")); var tableName = Body.GetQueryString("TableName"); fileName = ExportSingleTableStyle(tableStyle, tableName); } var link = new HyperLink(); var filePath = PathUtils.GetTemporaryFilesPath(fileName); link.NavigateUrl = ActionsDownload.GetUrl(PageUtils.GetApiUrl(), filePath); link.Text = "下载"; var successMessage = "成功导出文件! " + ControlUtils.GetControlRenderHtml(link); SuccessMessage(successMessage); } catch (Exception ex) { var failedMessage = "文件导出失败!<br/><br/>原因为:" + ex.Message; FailMessage(ex, failedMessage); } } }
public NameValueCollection Backup(int publishmentSystemId, string backupType, string userKeyPrefix) { //返回“运行结果”和“错误信息”的字符串数组 NameValueCollection retval; try { var eBackupType = EBackupTypeUtils.GetEnumType(backupType); var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId); var filePath = PathUtility.GetBackupFilePath(publishmentSystemInfo, eBackupType); DirectoryUtils.CreateDirectoryIfNotExists(filePath); FileUtils.DeleteFileIfExists(filePath); if (eBackupType == EBackupType.Templates) { BackupUtility.BackupTemplates(publishmentSystemId, filePath); } else if (eBackupType == EBackupType.ChannelsAndContents) { BackupUtility.BackupChannelsAndContents(publishmentSystemId, filePath); } else if (eBackupType == EBackupType.Files) { BackupUtility.BackupFiles(publishmentSystemId, filePath); } else if (eBackupType == EBackupType.Site) { BackupUtility.BackupSite(publishmentSystemId, filePath); } string resultString = $"任务完成,备份地址:<br /><strong> {filePath} </strong> <a href='{ActionsDownload.GetUrl(publishmentSystemInfo.Additional.ApiUrl, filePath)}'><img src='{SiteServerAssets.GetIconUrl("download.gif")}' />下载</a>。"; retval = AjaxManager.GetWaitingTaskNameValueCollection(resultString, string.Empty, string.Empty); } catch (Exception ex) { retval = AjaxManager.GetWaitingTaskNameValueCollection(string.Empty, ex.Message, string.Empty); LogUtils.AddErrorLog(ex); } return(retval); }
internal static string Parse(string stlEntity, PageInfo pageInfo, ContextInfo contextInfo) { var parsedContent = string.Empty; if (contextInfo.ContentId != 0) { try { if (contextInfo.ContentInfo != null && contextInfo.ContentInfo.ReferenceId > 0 && contextInfo.ContentInfo.SourceId > 0 && contextInfo.ContentInfo.GetExtendedAttribute(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString()) { var targetNodeId = contextInfo.ContentInfo.SourceId; var targetPublishmentSystemId = DataProvider.NodeDao.GetPublishmentSystemId(targetNodeId); var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetPublishmentSystemId); var targetNodeInfo = NodeManager.GetNodeInfo(targetPublishmentSystemId, targetNodeId); var tableStyle = NodeManager.GetTableStyle(targetPublishmentSystemInfo, targetNodeInfo); var tableName = NodeManager.GetTableName(targetPublishmentSystemInfo, targetNodeInfo); var targetContentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contextInfo.ContentInfo.ReferenceId); if (targetContentInfo != null && targetContentInfo.NodeId > 0) { //标题可以使用自己的 targetContentInfo.Title = contextInfo.ContentInfo.Title; contextInfo.ContentInfo = targetContentInfo; } } var entityName = StlParserUtility.GetNameFromEntity(stlEntity); var attributeName = entityName.Substring(9, entityName.Length - 10); if (StringUtils.EqualsIgnoreCase(ContentAttribute.Id, attributeName))//内容ID { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.ReferenceId > 0 ? contextInfo.ContentInfo.ReferenceId.ToString() : contextInfo.ContentInfo.Id.ToString(); } else { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId)); parsedContent = BaiRongDataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Id); } } else if (StringUtils.EqualsIgnoreCase(Title, attributeName))//内容标题 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.Title; } else { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId)); parsedContent = BaiRongDataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Title); } } else if (StringUtils.EqualsIgnoreCase(FullTitle, attributeName))//内容标题全称 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.Title; } else { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId)); parsedContent = BaiRongDataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Title); } } else if (StringUtils.EqualsIgnoreCase(NavigationUrl, attributeName))//内容链接地址 { if (contextInfo.ContentInfo != null) { parsedContent = PageUtility.GetContentUrl(pageInfo.PublishmentSystemInfo, contextInfo.ContentInfo); } else { var nodeInfo = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId); parsedContent = PageUtility.GetContentUrl(pageInfo.PublishmentSystemInfo, nodeInfo, contextInfo.ContentId, false); } } else if (StringUtils.EqualsIgnoreCase(ImageUrl, attributeName))//内容图片地址 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetExtendedAttribute(BackgroundContentAttribute.ImageUrl); } else { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId)); parsedContent = BaiRongDataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.ImageUrl); } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.PublishmentSystemInfo, parsedContent); } } else if (StringUtils.EqualsIgnoreCase(VideoUrl, attributeName))//内容视频地址 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetExtendedAttribute(BackgroundContentAttribute.VideoUrl); } else { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId)); parsedContent = BaiRongDataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.VideoUrl); } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.PublishmentSystemInfo, parsedContent); } } else if (StringUtils.EqualsIgnoreCase(FileUrl, attributeName))//内容附件地址 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetExtendedAttribute(BackgroundContentAttribute.FileUrl); } else { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId)); parsedContent = BaiRongDataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.FileUrl); } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.PublishmentSystemInfo, parsedContent); } } else if (StringUtils.EqualsIgnoreCase(DownloadUrl, attributeName))//内容附件地址(可统计下载量) { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetExtendedAttribute(BackgroundContentAttribute.FileUrl); } else { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId)); parsedContent = BaiRongDataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.FileUrl); } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = ActionsDownload.GetUrl(pageInfo.PublishmentSystemInfo.Additional.ApiUrl, pageInfo.PublishmentSystemId, contextInfo.ChannelId, contextInfo.ContentId, parsedContent); } } else if (StringUtils.EqualsIgnoreCase(AddDate, attributeName))//内容添加日期 { if (contextInfo.ContentInfo != null) { parsedContent = DateUtils.Format(contextInfo.ContentInfo.AddDate, string.Empty); } else { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, contextInfo.ChannelId); parsedContent = DateUtils.Format(BaiRongDataProvider.ContentDao.GetAddDate(tableName, contextInfo.ContentId), string.Empty); } } else if (StringUtils.EqualsIgnoreCase(LastEditDate, attributeName))//替换最后修改日期 { if (contextInfo.ContentInfo != null) { parsedContent = DateUtils.Format(contextInfo.ContentInfo.LastEditDate, string.Empty); } else { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, contextInfo.ChannelId); parsedContent = DateUtils.Format(BaiRongDataProvider.ContentDao.GetLastEditDate(tableName, contextInfo.ContentId), string.Empty); } } else if (StringUtils.EqualsIgnoreCase(Content, attributeName))//内容正文 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetExtendedAttribute(BackgroundContentAttribute.Content); } else { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId)); parsedContent = BaiRongDataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.Content); } parsedContent = StringUtility.TextEditorContentDecode(parsedContent, pageInfo.PublishmentSystemInfo); } else if (StringUtils.EqualsIgnoreCase(Group, attributeName))//内容组别 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.ContentGroupNameCollection; } else { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId)); parsedContent = BaiRongDataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.ContentGroupNameCollection); } } else if (StringUtils.EqualsIgnoreCase(Tags, attributeName))//标签 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.Tags; } else { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId)); parsedContent = BaiRongDataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Tags); } } else if (StringUtils.EqualsIgnoreCase(AddUserName, attributeName)) { string addUserName; if (contextInfo.ContentInfo != null) { addUserName = contextInfo.ContentInfo.AddUserName; } else { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId)); addUserName = BaiRongDataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.AddUserName); } if (!string.IsNullOrEmpty(addUserName)) { var displayName = BaiRongDataProvider.AdministratorDao.GetDisplayName(addUserName); parsedContent = string.IsNullOrEmpty(displayName) ? addUserName : displayName; } } else if (StringUtils.StartsWithIgnoreCase(attributeName, StlParserUtility.ItemIndex) && contextInfo.ItemContainer?.ContentItem != null) { parsedContent = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.ContentItem.ItemIndex, attributeName, contextInfo).ToString(); } else { int contentNodeId; if (contextInfo.ContentInfo != null) { contentNodeId = contextInfo.ContentInfo.NodeId; if (contextInfo.ContentInfo.ContainsKey(attributeName)) { parsedContent = contextInfo.ContentInfo.GetExtendedAttribute(attributeName); } } else { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, contextInfo.ChannelId); contentNodeId = BaiRongDataProvider.ContentDao.GetNodeId(tableName, contextInfo.ContentId); tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contentNodeId)); parsedContent = BaiRongDataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, attributeName); } if (!string.IsNullOrEmpty(parsedContent)) { var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(pageInfo.PublishmentSystemId, contentNodeId); var styleInfo = TableStyleManager.GetTableStyleInfo(ETableStyle.BackgroundContent, pageInfo.PublishmentSystemInfo.AuxiliaryTableForContent, attributeName, relatedIdentities); parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, ",", pageInfo.PublishmentSystemInfo, ETableStyle.BackgroundContent, styleInfo, string.Empty, null, string.Empty, true); } } } catch { // ignored } } return(parsedContent); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } _exportType = Body.GetQueryString("ExportType"); if (!IsPostBack) { var isExport = true; var fileName = string.Empty; try { if (_exportType == ExportTypeTrackerHour) { fileName = ExportTrackingHours(); } else if (_exportType == ExportTypeTrackerDay) { fileName = ExportTrackingDays(); } else if (_exportType == ExportTypeTrackerMonth) { fileName = ExportTrackingMonths(); } else if (_exportType == ExportTypeTrackerYear) { fileName = ExportTrackingYears(); } else if (_exportType == ExportTypeTrackerContent) { var startDateString = Body.GetQueryString("StartDateString"); var endDateString = Body.GetQueryString("EndDateString"); var nodeId = Body.GetQueryInt("NodeID"); var contentId = Body.GetQueryInt("ContentID"); var totalNum = Body.GetQueryInt("TotalNum"); var isDelete = Body.GetQueryBool("IsDelete"); fileName = ExportTrackingContents(startDateString, endDateString, nodeId, contentId, totalNum, isDelete); } else if (_exportType == ExportTypeInputContent) { var inputId = Body.GetQueryInt("InputID"); fileName = ExportInputContent(inputId); } else if (_exportType == ExportTypeComment) { var nodeId = Body.GetQueryInt("NodeID"); var contentId = Body.GetQueryInt("ContentID"); fileName = ExportComment(nodeId, contentId); } else if (_exportType == ExportTypeGatherRule) { var gatherRuleNameArrayList = TranslateUtils.StringCollectionToStringList(Body.GetQueryString("GatherRuleNameCollection")); fileName = ExportGatherRule(gatherRuleNameArrayList); } else if (_exportType == ExportTypeInput) { var inputId = Body.GetQueryInt("InputID"); fileName = ExportInput(inputId); } else if (_exportType == ExportTypeRelatedField) { var relatedFieldId = Body.GetQueryInt("RelatedFieldID"); fileName = ExportRelatedField(relatedFieldId); } else if (_exportType == ExportTypeTagStyle) { var styleId = Body.GetQueryInt("StyleID"); fileName = ExportTagStyle(styleId); } else if (_exportType == ExportTypeContentZip) { var nodeId = Body.GetQueryInt("NodeID"); var contentIdCollection = TranslateUtils.StringCollectionToIntList(Body.GetQueryString("ContentIDCollection")); var isPeriods = Body.GetQueryBool("isPeriods"); var startDate = Body.GetQueryString("startDate"); var endDate = Body.GetQueryString("endDate"); var checkedState = ETriStateUtils.GetEnumType(Body.GetQueryString("checkedState")); isExport = ExportContentZip(nodeId, contentIdCollection, isPeriods, startDate, endDate, checkedState, out fileName); } else if (_exportType == ExportTypeContentAccess) { var nodeId = Body.GetQueryInt("NodeID"); var contentIdCollection = TranslateUtils.StringCollectionToIntList(Body.GetQueryString("ContentIDCollection")); var displayAttributes = TranslateUtils.StringCollectionToStringList(Body.GetQueryString("DisplayAttributes")); var isPeriods = Body.GetQueryBool("isPeriods"); var startDate = Body.GetQueryString("startDate"); var endDate = Body.GetQueryString("endDate"); var checkedState = ETriStateUtils.GetEnumType(Body.GetQueryString("checkedState")); isExport = ExportContentAccess(nodeId, contentIdCollection, displayAttributes, isPeriods, startDate, endDate, checkedState, out fileName); } else if (_exportType == ExportTypeContentExcel) { var nodeId = Body.GetQueryInt("NodeID"); var contentIdCollection = TranslateUtils.StringCollectionToIntList(Body.GetQueryString("ContentIDCollection")); var displayAttributes = TranslateUtils.StringCollectionToStringList(Body.GetQueryString("DisplayAttributes")); var isPeriods = Body.GetQueryBool("isPeriods"); var startDate = Body.GetQueryString("startDate"); var endDate = Body.GetQueryString("endDate"); var checkedState = ETriStateUtils.GetEnumType(Body.GetQueryString("checkedState")); ExportContentExcel(nodeId, contentIdCollection, displayAttributes, isPeriods, startDate, endDate, checkedState, out fileName); } else if (_exportType == ExportTypeChannel) { var nodeIdList = TranslateUtils.StringCollectionToIntList(Body.GetQueryString("ChannelIDCollection")); fileName = ExportChannel(nodeIdList); } else if (_exportType == ExportTypeSingleTableStyle) { var tableStyle = ETableStyleUtils.GetEnumType(Body.GetQueryString("TableStyle")); var tableName = Body.GetQueryString("TableName"); var relatedIdentity = Body.GetQueryInt("RelatedIdentity"); fileName = ExportSingleTableStyle(tableStyle, tableName, relatedIdentity); } if (isExport) { var link = new HyperLink(); var filePath = PathUtils.GetTemporaryFilesPath(fileName); link.NavigateUrl = ActionsDownload.GetUrl(PublishmentSystemInfo.Additional.ApiUrl, filePath); link.Text = "下载"; var successMessage = "成功导出文件! " + ControlUtils.GetControlRenderHtml(link); SuccessMessage(successMessage); } else { FailMessage("导出失败,所选条件没有匹配内容,请重新选择条件导出内容"); } } catch (Exception ex) { var failedMessage = "文件导出失败!<br/><br/>原因为:" + ex.Message; FailMessage(ex, failedMessage); } } }