public static string GetFileHtmlWithoutCount(SiteInfo siteInfo, string fileUrl, Dictionary <string, string> attributes, string innerXml, bool isStlEntity) { if (siteInfo != null) { var retval = string.Empty; if (!string.IsNullOrEmpty(fileUrl)) { if (isStlEntity) { retval = ApiRouteActionsDownload.GetUrl(ApiManager.OuterApiUrl, siteInfo.Id, fileUrl); } else { var stlAnchor = new HtmlAnchor(); ControlUtils.AddAttributesIfNotExists(stlAnchor, attributes); stlAnchor.HRef = ApiRouteActionsDownload.GetUrl(ApiManager.OuterApiUrl, siteInfo.Id, fileUrl); stlAnchor.InnerHtml = string.IsNullOrEmpty(innerXml) ? PageUtils.GetFileNameFromUrl(fileUrl) : innerXml; retval = ControlUtils.GetControlRenderHtml(stlAnchor); } } return(retval); } return(string.Empty); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } _exportType = AuthRequest.GetQueryString("ExportType"); if (!IsPostBack) { var fileName = string.Empty; try { if (_exportType == ExportTypeSingleTableStyle) { var tableName = AuthRequest.GetQueryString("TableName"); fileName = ExportSingleTableStyle(tableName); } var link = new HyperLink(); var filePath = PathUtils.GetTemporaryFilesPath(fileName); link.NavigateUrl = ApiRouteActionsDownload.GetUrl(ApiManager.InnerApiUrl, filePath); link.Text = "下载"; var successMessage = "成功导出文件! " + ControlUtils.GetControlRenderHtml(link); SuccessMessage(successMessage); } catch (Exception ex) { var failedMessage = "文件导出失败!<br/><br/>原因为:" + ex.Message; FailMessage(ex, failedMessage); } } }
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(DdlCheckedState.SelectedValue)); var link = new HyperLink { NavigateUrl = ApiRouteActionsDownload.GetUrl(PageUtility.InnerApiUrl, filePath), Text = "下载" }; var successMessage = "成功导出文件! " + ControlUtils.GetControlRenderHtml(link); SuccessMessage(successMessage); BtnSubmit.Visible = false; } catch (Exception ex) { var failedMessage = "文件导出失败!<br/><br/>原因为:" + ex.Message; FailMessage(ex, failedMessage); } }
public static string GetFileHtmlWithoutCount(SiteInfo siteInfo, string fileUrl, NameValueCollection attributes, string innerHtml, bool isStlEntity, bool isLower, bool isUpper) { if (siteInfo == null || string.IsNullOrEmpty(fileUrl)) { return(string.Empty); } string retVal; if (isStlEntity) { retVal = ApiRouteActionsDownload.GetUrl(ApiManager.ApiUrl, siteInfo.Id, fileUrl); } else { var stlAnchor = new HtmlAnchor(); ControlUtils.AddAttributesIfNotExists(stlAnchor, attributes); stlAnchor.HRef = ApiRouteActionsDownload.GetUrl(ApiManager.ApiUrl, siteInfo.Id, fileUrl); stlAnchor.InnerHtml = string.IsNullOrEmpty(innerHtml) ? PageUtils.GetFileNameFromUrl(fileUrl) : innerHtml; if (isLower) { stlAnchor.InnerHtml = stlAnchor.InnerHtml.ToLower(); } if (isUpper) { stlAnchor.InnerHtml = stlAnchor.InnerHtml.ToUpper(); } retVal = ControlUtils.GetControlRenderHtml(stlAnchor); } return(retVal); }
public NameValueCollection Backup(int siteId, string backupType, string userKeyPrefix) { //返回“运行结果”和“错误信息”的字符串数组 NameValueCollection retval; var request = new RequestImpl(Request); try { var eBackupType = EBackupTypeUtils.GetEnumType(backupType); var siteInfo = SiteManager.GetSiteInfo(siteId); var filePath = PathUtility.GetBackupFilePath(siteInfo, eBackupType); DirectoryUtils.CreateDirectoryIfNotExists(filePath); FileUtils.DeleteFileIfExists(filePath); if (eBackupType == EBackupType.Templates) { BackupUtility.BackupTemplates(siteId, filePath, request.AdminName); } else if (eBackupType == EBackupType.ChannelsAndContents) { BackupUtility.BackupChannelsAndContents(siteId, filePath, request.AdminName); } else if (eBackupType == EBackupType.Files) { BackupUtility.BackupFiles(siteId, filePath, request.AdminName); } else if (eBackupType == EBackupType.Site) { BackupUtility.BackupSite(siteId, filePath, request.AdminName); } string resultString = $"任务完成,备份地址:<br /><strong> {filePath} </strong> <a href='{ApiRouteActionsDownload.GetUrl(ApiManager.InnerApiUrl, 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); }
public static string GetFileHtmlWithCount(SiteInfo siteInfo, int channelId, int contentId, string fileUrl, NameValueCollection attributes, string innerHtml, bool isStlEntity) { var retval = string.Empty; if (!string.IsNullOrEmpty(fileUrl)) { if (isStlEntity) { retval = ApiRouteActionsDownload.GetUrl(ApiManager.ApiUrl, siteInfo.Id, channelId, contentId, fileUrl); } else { var stlAnchor = new HtmlAnchor(); ControlUtils.AddAttributesIfNotExists(stlAnchor, attributes); stlAnchor.HRef = ApiRouteActionsDownload.GetUrl(ApiManager.ApiUrl, siteInfo.Id, channelId, contentId, fileUrl); stlAnchor.InnerHtml = string.IsNullOrEmpty(innerHtml) ? PageUtils.GetFileNameFromUrl(fileUrl) : innerHtml; retval = ControlUtils.GetControlRenderHtml(stlAnchor); } } 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.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString()) { var targetChannelId = contextInfo.ContentInfo.SourceId; var targetSiteId = StlChannelCache.GetSiteId(targetChannelId); var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId); var targetNodeInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId); var targetContentInfo = ContentManager.GetContentInfo(targetSiteInfo, targetNodeInfo, contextInfo.ContentInfo.ReferenceId); if (targetContentInfo != null && targetContentInfo.ChannelId > 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 = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Id); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Id); } } else if (StringUtils.EqualsIgnoreCase(Title, attributeName))//内容标题 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.Title; } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Title); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Title); } } else if (StringUtils.EqualsIgnoreCase(FullTitle, attributeName))//内容标题全称 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.Title; } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Title); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Title); } } else if (StringUtils.EqualsIgnoreCase(NavigationUrl, attributeName))//内容链接地址 { if (contextInfo.ContentInfo != null) { parsedContent = PageUtility.GetContentUrl(pageInfo.SiteInfo, contextInfo.ContentInfo, pageInfo.IsLocal); } else { var nodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId); parsedContent = PageUtility.GetContentUrl(pageInfo.SiteInfo, nodeInfo, contextInfo.ContentId, pageInfo.IsLocal); } } else if (StringUtils.EqualsIgnoreCase(ImageUrl, attributeName))//内容图片地址 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.ImageUrl); } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.ImageUrl); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.ImageUrl); } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } } else if (StringUtils.EqualsIgnoreCase(VideoUrl, attributeName))//内容视频地址 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.VideoUrl); } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.VideoUrl); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.VideoUrl); } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } } else if (StringUtils.EqualsIgnoreCase(FileUrl, attributeName))//内容附件地址 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.FileUrl); } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.FileUrl); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.FileUrl); } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } } else if (StringUtils.EqualsIgnoreCase(DownloadUrl, attributeName))//内容附件地址(可统计下载量) { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.FileUrl); } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.FileUrl); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.FileUrl); } if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = ApiRouteActionsDownload.GetUrl(pageInfo.ApiUrl, pageInfo.SiteId, contextInfo.ChannelId, contextInfo.ContentId, parsedContent); } } else if (StringUtils.EqualsIgnoreCase(AddDate, attributeName))//内容添加日期 { if (contextInfo.ContentInfo != null) { parsedContent = DateUtils.Format(contextInfo.ContentInfo.AddDate, string.Empty); } } else if (StringUtils.EqualsIgnoreCase(LastEditDate, attributeName))//替换最后修改日期 { if (contextInfo.ContentInfo != null) { parsedContent = DateUtils.Format(contextInfo.ContentInfo.LastEditDate, string.Empty); } } else if (StringUtils.EqualsIgnoreCase(Content, attributeName))//内容正文 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.Content); } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.Content); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.Content); } parsedContent = ContentUtility.TextEditorContentDecode(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal); } else if (StringUtils.EqualsIgnoreCase(Group, attributeName))//内容组别 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.GroupNameCollection; } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.ContentGroupNameCollection); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, ContentAttribute.GroupNameCollection); } } else if (StringUtils.EqualsIgnoreCase(Tags, attributeName))//标签 { if (contextInfo.ContentInfo != null) { parsedContent = contextInfo.ContentInfo.Tags; } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Tags); parsedContent = StlContentCache.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 = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId)); //addUserName = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.AddUserName); addUserName = StlContentCache.GetValue(tableName, contextInfo.ContentId, ContentAttribute.AddUserName); } if (!string.IsNullOrEmpty(addUserName)) { parsedContent = addUserName; } } else if (StringUtils.StartsWithIgnoreCase(attributeName, StlParserUtility.ItemIndex) && contextInfo.ItemContainer?.ContentItem != null) { parsedContent = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.ContentItem.ItemIndex, attributeName, contextInfo).ToString(); } else { int contentChannelId; if (contextInfo.ContentInfo != null) { contentChannelId = contextInfo.ContentInfo.ChannelId; if (contextInfo.ContentInfo.ContainsKey(attributeName)) { parsedContent = contextInfo.ContentInfo.GetString(attributeName); } } else { var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, contextInfo.ChannelId); //contentChannelId = DataProvider.ContentDao.GetChannelId(tableName, contextInfo.ContentId); contentChannelId = StlContentCache.GetChannelId(tableName, contextInfo.ContentId); tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contentChannelId)); //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, attributeName); parsedContent = StlContentCache.GetValue(tableName, contextInfo.ContentId, attributeName); } if (!string.IsNullOrEmpty(parsedContent)) { var channelInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, contentChannelId); var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, channelInfo); var relatedIdentities = TableStyleManager.GetRelatedIdentities(channelInfo); var styleInfo = TableStyleManager.GetTableStyleInfo(tableName, attributeName, relatedIdentities); //styleInfo.IsVisible = false 表示此字段不需要显示 styleInfo.TableStyleId = 0 不能排除,因为有可能是直接辅助表字段没有添加显示样式 parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, ",", pageInfo.SiteInfo, styleInfo, string.Empty, null, string.Empty, true); } } } catch { // ignored } } parsedContent = parsedContent.Replace(ContentUtility.PagePlaceHolder, string.Empty); 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 == ExportTypeRelatedField) { var relatedFieldId = Body.GetQueryInt("RelatedFieldID"); fileName = ExportRelatedField(relatedFieldId); } else if (_exportType == ExportTypeContentZip) { var channelId = Body.GetQueryInt("channelId"); 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(channelId, contentIdCollection, isPeriods, startDate, endDate, checkedState, out fileName); } else if (_exportType == ExportTypeContentAccess) { var channelId = Body.GetQueryInt("channelId"); 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(channelId, contentIdCollection, displayAttributes, isPeriods, startDate, endDate, checkedState, out fileName); } else if (_exportType == ExportTypeContentExcel) { var channelId = Body.GetQueryInt("channelId"); 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(channelId, contentIdCollection, displayAttributes, isPeriods, startDate, endDate, checkedState, out fileName); } else if (_exportType == ExportTypeChannel) { var channelIdList = TranslateUtils.StringCollectionToIntList(Body.GetQueryString("ChannelIDCollection")); fileName = ExportChannel(channelIdList); } else if (_exportType == ExportTypeSingleTableStyle) { var tableName = Body.GetQueryString("TableName"); var relatedIdentity = Body.GetQueryInt("RelatedIdentity"); fileName = ExportSingleTableStyle(tableName, relatedIdentity); } if (isExport) { var link = new HyperLink(); var filePath = PathUtils.GetTemporaryFilesPath(fileName); link.NavigateUrl = ApiRouteActionsDownload.GetUrl(PageUtility.InnerApiUrl, filePath); link.Text = "下载"; var successMessage = "成功导出文件! " + ControlUtils.GetControlRenderHtml(link); SuccessMessage(successMessage); } else { FailMessage("导出失败,所选条件没有匹配内容,请重新选择条件导出内容"); } } catch (Exception ex) { var failedMessage = "文件导出失败!<br/><br/>原因为:" + ex.Message; FailMessage(ex, failedMessage); } } }