public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { CacheUtils.Clear(); DbCacheManager.Clear(); PageUtils.Redirect(PageUtils.GetSettingsUrl(nameof(PageCache), null)); } }
public NameValueCollection CreatePublishmentSystem(int publishmentSystemId, bool isUseSiteTemplate, bool isImportContents, bool isImportTableStyles, string siteTemplateDir, bool isUseTables, string userKeyPrefix, string returnUrl, string administratorName) { var cacheTotalCountKey = userKeyPrefix + CacheTotalCount; var cacheCurrentCountKey = userKeyPrefix + CacheCurrentCount; var cacheMessageKey = userKeyPrefix + CacheMessage; CacheUtils.Max(cacheTotalCountKey, "3"); //存储需要的页面总数 CacheUtils.Max(cacheCurrentCountKey, "0"); //存储当前的页面总数 CacheUtils.Max(cacheMessageKey, string.Empty); //存储消息 //返回“运行结果”、“错误信息”及“执行JS脚本”的字符串数组 NameValueCollection retval; try { CacheUtils.Max(cacheCurrentCountKey, "1"); //存储当前的页面总数 CacheUtils.Max(cacheMessageKey, "正在创建站点..."); //存储消息 var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId); CacheUtils.Max(cacheCurrentCountKey, "2"); //存储当前的页面总数 CacheUtils.Max(cacheMessageKey, "正在导入数据..."); //存储消息 if (isUseSiteTemplate && !string.IsNullOrEmpty(siteTemplateDir)) { SiteTemplateManager.Instance.ImportSiteTemplateToEmptyPublishmentSystem(publishmentSystemId, siteTemplateDir, isUseTables, isImportContents, isImportTableStyles, administratorName); } CacheUtils.Max(cacheCurrentCountKey, "3"); //存储当前的页面总数 CacheUtils.Max(cacheMessageKey, "创建成功!"); //存储消息 if (!string.IsNullOrEmpty(returnUrl)) { returnUrl = PageUtils.AddQueryString(StringUtils.ValueFromUrl(returnUrl), "PublishmentSystemID", publishmentSystemId.ToString()); retval = AjaxManager.GetWaitingTaskNameValueCollection( $"站点 <strong>{publishmentSystemInfo.PublishmentSystemName}<strong> 创建成功!", string.Empty, $"location.href='{returnUrl}';"); } else { retval = AjaxManager.GetWaitingTaskNameValueCollection( $"站点 <strong>{publishmentSystemInfo.PublishmentSystemName}<strong> 创建成功!", string.Empty, $"top.location.href='{PageInitialization.GetRedirectUrl()}';"); } } catch (Exception ex) { retval = AjaxManager.GetWaitingTaskNameValueCollection(string.Empty, ex.Message, string.Empty); LogUtils.AddErrorLog(ex); } CacheUtils.Remove(cacheTotalCountKey); //取消存储需要的页面总数 CacheUtils.Remove(cacheCurrentCountKey); //取消存储当前的页面总数 CacheUtils.Remove(cacheMessageKey); //取消存储消息 CacheUtils.Clear(); return(retval); }
public bool IsNeedUpgrade(Page page) { CacheUtils.Clear(); if (BaiRongDataProvider.ConfigDao.GetDatabaseVersion() == AppManager.Version) { page.Response.Write($"<h2>当前版本为“{AppManager.Version}”,数据库版本与系统版本一致,无需升级</h2>"); page.Response.End(); return(false); } return(true); }
public static void RecoverySite(int publishmentSystemId, bool isDeleteChannels, bool isDeleteTemplates, bool isDeleteFiles, bool isZip, string path, bool isOverride, bool isUseTable, string administratorName) { var importObject = new ImportObject(publishmentSystemId); var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId); var siteTemplatePath = path; if (isZip) { //解压文件 siteTemplatePath = PathUtils.GetTemporaryFilesPath(EBackupTypeUtils.GetValue(EBackupType.Site)); DirectoryUtils.DeleteDirectoryIfExists(siteTemplatePath); DirectoryUtils.CreateDirectoryIfNotExists(siteTemplatePath); ZipUtils.UnpackFiles(path, siteTemplatePath); } var siteTemplateMetadataPath = PathUtils.Combine(siteTemplatePath, DirectoryUtils.SiteTemplates.SiteTemplateMetadata); if (isDeleteChannels) { var nodeIdList = DataProvider.NodeDao.GetNodeIdListByParentId(publishmentSystemId, publishmentSystemId); foreach (int nodeId in nodeIdList) { DataProvider.NodeDao.Delete(nodeId); } } if (isDeleteTemplates) { var templateInfoList = DataProvider.TemplateDao.GetTemplateInfoListByPublishmentSystemId(publishmentSystemId); foreach (var templateInfo in templateInfoList) { if (templateInfo.IsDefault == false) { DataProvider.TemplateDao.Delete(publishmentSystemId, templateInfo.TemplateId); } } } if (isDeleteFiles) { DirectoryUtility.DeletePublishmentSystemFiles(publishmentSystemInfo); } //导入文件 importObject.ImportFiles(siteTemplatePath, isOverride); //导入模板 var templateFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileTemplate); importObject.ImportTemplates(templateFilePath, isOverride, administratorName); //导入辅助表 var tableDirectoryPath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.Table); importObject.ImportAuxiliaryTables(tableDirectoryPath, isUseTable); //导入菜单 var menuDisplayFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileMenuDisplay); importObject.ImportMenuDisplay(menuDisplayFilePath, isOverride); //导入标签样式 var tagStyleFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileTagStyle); importObject.ImportTagStyle(tagStyleFilePath, isOverride); //导入固定广告 var adFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileAd); importObject.ImportAd(adFilePath, isOverride); //导入采集规则 var gatherRuleFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileGatherRule); importObject.ImportGatherRule(gatherRuleFilePath, isOverride); //导入提交表单 var inputDirectoryPath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.Input); importObject.ImportInput(inputDirectoryPath, isOverride); //导入站点设置 var configurationFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileConfiguration); importObject.ImportConfiguration(configurationFilePath); //导入内容模型 var contentModelFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileContentModel); importObject.ImportContentModel(contentModelFilePath, true); //导入栏目及内容 var siteContentDirectoryPath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.SiteContent); importObject.ImportChannelsAndContents(0, siteContentDirectoryPath, isOverride); DataProvider.NodeDao.UpdateContentNum(publishmentSystemInfo); //导入表样式及清除缓存 if (isUseTable) { importObject.ImportTableStyles(tableDirectoryPath); } importObject.RemoveDbCache(); CacheUtils.Clear(); }