public IHttpActionResult Enable(string pluginId) { try { var request = new RequestImpl(); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.PluginsPermissions.Add)) { return(Unauthorized()); } var pluginInfo = PluginManager.GetPluginInfo(pluginId); if (pluginInfo != null) { pluginInfo.IsDisabled = !pluginInfo.IsDisabled; DataProvider.PluginDao.UpdateIsDisabled(pluginId, pluginInfo.IsDisabled); PluginManager.ClearCache(); request.AddAdminLog(!pluginInfo.IsDisabled ? "禁用插件" : "启用插件", $"插件:{pluginId}"); } CacheUtils.ClearAll(); CacheDbUtils.Clear(); return(Ok()); } catch (Exception ex) { return(InternalServerError(ex)); } }
public void BtnReload_Click(object sender, EventArgs e) { CacheUtils.ClearAll(); CacheDbUtils.Clear(); AddScript(AlertUtils.Success("插件重新加载成功", "插件重新加载成功,系统需要重载页面", "重新载入", "window.top.location.reload(true);")); }
protected void btn_Clear_Click(object sender, System.EventArgs e) { if (CacheUtils.ClearAll() > 0) { base.Response.Redirect(base.Request.RawUrl); } }
public NameValueCollection CreateSiteByOnlineTemplateName(int siteId, bool isImportContents, bool isImportTableStyles, string onlineTemplateName, string onlineTemplateUrl, string userKeyPrefix, string administratorName) { var cacheTotalCountKey = userKeyPrefix + CacheTotalCount; var cacheCurrentCountKey = userKeyPrefix + CacheCurrentCount; var cacheMessageKey = userKeyPrefix + CacheMessage; CacheUtils.Insert(cacheTotalCountKey, "4"); //存储需要的页面总数 CacheUtils.Insert(cacheCurrentCountKey, "0"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, string.Empty); //存储消息 //返回“运行结果”、“错误信息”及“执行JS脚本”的字符串数组 NameValueCollection retval; try { CacheUtils.Insert(cacheCurrentCountKey, "1"); CacheUtils.Insert(cacheMessageKey, "开始下载模板压缩包,可能需要几分钟,请耐心等待..."); var filePath = PathUtility.GetSiteTemplatesPath($"T_{onlineTemplateName}.zip"); FileUtils.DeleteFileIfExists(filePath); //var downloadUrl = OnlineTemplateManager.GetDownloadUrl(onlineTemplateName); var downloadUrl = OnlineTemplateManager.GetDownloadUrlByUrl(onlineTemplateUrl); WebClientUtils.SaveRemoteFileToLocal(downloadUrl, filePath); CacheUtils.Insert(cacheCurrentCountKey, "2"); CacheUtils.Insert(cacheMessageKey, "模板压缩包下载成功,开始解压缩,可能需要几分钟,请耐心等待..."); var siteTemplateDir = $"T_{onlineTemplateName}"; var directoryPath = PathUtility.GetSiteTemplatesPath(siteTemplateDir); DirectoryUtils.DeleteDirectoryIfExists(directoryPath); ZipUtils.ExtractZip(filePath, directoryPath); CacheUtils.Insert(cacheCurrentCountKey, "3"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, "模板压缩包解压成功,正在导入数据..."); //存储消息 SiteTemplateManager.Instance.ImportSiteTemplateToEmptySite(siteId, siteTemplateDir, isImportContents, isImportTableStyles, administratorName); CreateManager.CreateByAll(siteId); CacheUtils.Insert(cacheCurrentCountKey, "4"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, "创建成功!"); //存储消息 var siteInfo = SiteManager.GetSiteInfo(siteId); retval = AjaxManager.GetWaitingTaskNameValueCollection($"站点 <strong>{siteInfo.SiteName}<strong> 创建成功!", string.Empty, $"top.location.href='{PageUtils.GetMainUrl(siteId)}';"); } 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.ClearAll(); return(retval); }
public static void SyncDatabase() { CacheUtils.ClearAll(); CreateSiteServerTables(); SyncContentTables(); UpdateConfigVersion(); }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } CacheUtils.ClearAll(); CacheDbUtils.Clear(); PageUtils.Redirect(PageUtils.GetSettingsUrl(nameof(PageUtilityCache), null)); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageType = AuthRequest.GetQueryInt("pageType"); if (AuthRequest.IsQueryExists("delete")) { var pluginId = AuthRequest.GetQueryString("pluginId"); PluginManager.Delete(pluginId); AuthRequest.AddAdminLog("删除插件", $"插件:{pluginId}"); CacheUtils.ClearAll(); CacheDbUtils.Clear(); AddScript(AlertUtils.Success("插件删除成功", "插件删除成功,系统需要重载页面", "重新载入", "window.top.location.reload(true);")); } if (AuthRequest.IsQueryExists("enable")) { var pluginId = AuthRequest.GetQueryString("pluginId"); PluginManager.UpdateDisabled(pluginId, false); AuthRequest.AddAdminLog("启用插件", $"插件:{pluginId}"); CacheUtils.ClearAll(); CacheDbUtils.Clear(); AddScript(AlertUtils.Success("插件启用成功", "插件启用成功,系统需要重载页面", "重新载入", "window.top.location.reload(true);")); } else if (AuthRequest.IsQueryExists("disable")) { var pluginId = AuthRequest.GetQueryString("pluginId"); PluginManager.UpdateDisabled(pluginId, true); AuthRequest.AddAdminLog("禁用插件", $"插件:{pluginId}"); CacheUtils.ClearAll(); CacheDbUtils.Clear(); AddScript(AlertUtils.Success("插件禁用成功", "插件禁用成功,系统需要重载页面", "重新载入", "window.top.location.reload(true);")); } if (Page.IsPostBack) { return; } VerifySystemPermissions(ConfigManager.PluginsPermissions.Management); }
public static void SyncDatabase() { CacheUtils.ClearAll(); foreach (var provider in DataProvider.AllProviders) { if (string.IsNullOrEmpty(provider.TableName) || provider.TableColumns == null || provider.TableColumns.Count <= 0) { continue; } if (!DataProvider.DatabaseDao.IsTableExists(provider.TableName)) { DataProvider.DatabaseDao.CreateSystemTable(provider.TableName, provider.TableColumns); } else { DataProvider.DatabaseDao.AlterSystemTable(provider.TableName, provider.TableColumns); } } var tableNameList = DataProvider.TableDao.GetTableNameListCreatedInDb(); foreach (var tableName in tableNameList) { if (!DataProvider.DatabaseDao.IsTableExists(tableName)) { DataProvider.DatabaseDao.CreateSystemTable(tableName, DataProvider.ContentDao.TableColumns); } else { DataProvider.DatabaseDao.AlterSystemTable(tableName, DataProvider.ContentDao.TableColumns); } } var configInfo = DataProvider.ConfigDao.GetConfigInfo(); if (configInfo == null) { configInfo = new ConfigInfo(true, Version, DateTime.Now, string.Empty); DataProvider.ConfigDao.Insert(configInfo); } else { configInfo.DatabaseVersion = Version; configInfo.IsInitialized = true; configInfo.UpdateDate = DateTime.Now; DataProvider.ConfigDao.Update(configInfo); } DataProvider.TableDao.CreateAllTableCollectionInfoIfNotExists(); }
public IHttpActionResult Main() { var request = new AuthenticatedRequest(); if (!request.IsAdminLoggin) { return(Unauthorized()); } CacheUtils.ClearAll(); CacheDbUtils.Clear(); return(Ok(new {})); }
public NameValueCollection CreateSiteBySiteTemplateDir(int siteId, bool isImportContents, bool isImportTableStyles, string siteTemplateDir, bool isUseTables, string userKeyPrefix, string administratorName) { var cacheTotalCountKey = userKeyPrefix + CacheTotalCount; var cacheCurrentCountKey = userKeyPrefix + CacheCurrentCount; var cacheMessageKey = userKeyPrefix + CacheMessage; CacheUtils.Insert(cacheTotalCountKey, "3"); //存储需要的页面总数 CacheUtils.Insert(cacheCurrentCountKey, "0"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, string.Empty); //存储消息 //返回“运行结果”、“错误信息”及“执行JS脚本”的字符串数组 NameValueCollection retval; try { CacheUtils.Insert(cacheCurrentCountKey, "1"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, "正在创建站点..."); //存储消息 var siteInfo = SiteManager.GetSiteInfo(siteId); CacheUtils.Insert(cacheCurrentCountKey, "2"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, "正在导入数据..."); //存储消息 SiteTemplateManager.Instance.ImportSiteTemplateToEmptySite(siteId, siteTemplateDir, isUseTables, isImportContents, isImportTableStyles, administratorName); CreateManager.CreateAll(siteId); CacheUtils.Insert(cacheCurrentCountKey, "3"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, "创建成功!"); //存储消息 retval = AjaxManager.GetWaitingTaskNameValueCollection( $"站点 <strong>{siteInfo.SiteName}<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.ClearAll(); return(retval); }
public IHttpActionResult Reload() { try { var request = new RequestImpl(); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.PluginsPermissions.Add)) { return(Unauthorized()); } CacheUtils.ClearAll(); CacheDbUtils.Clear(); return(Ok()); } catch (Exception ex) { return(InternalServerError(ex)); } }
public NameValueCollection CreateSite(int siteId, string userKeyPrefix, string administratorName) { var cacheTotalCountKey = userKeyPrefix + CacheTotalCount; var cacheCurrentCountKey = userKeyPrefix + CacheCurrentCount; var cacheMessageKey = userKeyPrefix + CacheMessage; CacheUtils.Insert(cacheTotalCountKey, "2"); //存储需要的页面总数 CacheUtils.Insert(cacheCurrentCountKey, "0"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, string.Empty); //存储消息 //返回“运行结果”、“错误信息”及“执行JS脚本”的字符串数组 NameValueCollection retval; try { CacheUtils.Insert(cacheCurrentCountKey, "1"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, "正在创建站点..."); //存储消息 var siteInfo = SiteManager.GetSiteInfo(siteId); CacheUtils.Insert(cacheCurrentCountKey, "2"); //存储当前的页面总数 CacheUtils.Insert(cacheMessageKey, "创建成功!"); //存储消息 retval = AjaxManager.GetWaitingTaskNameValueCollection( $"站点 <strong>{siteInfo.SiteName}<strong> 创建成功!", string.Empty, $"top.location.href='{PageUtils.GetMainUrl(siteId)}';"); } 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.ClearAll(); return(retval); }
public IHttpActionResult Delete(string pluginId) { try { var request = new RequestImpl(); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.PluginsPermissions.Add)) { return(Unauthorized()); } PluginManager.Delete(pluginId); request.AddAdminLog("删除插件", $"插件:{pluginId}"); CacheUtils.ClearAll(); CacheDbUtils.Clear(); return(Ok()); } catch (Exception ex) { return(InternalServerError(ex)); } }
public static void RecoverySite(int siteId, bool isDeleteChannels, bool isDeleteTemplates, bool isDeleteFiles, bool isZip, string path, bool isOverride, bool isUseTable, string administratorName) { var importObject = new ImportObject(siteId, administratorName); var siteInfo = SiteManager.GetSiteInfo(siteId); var siteTemplatePath = path; if (isZip) { //解压文件 siteTemplatePath = PathUtils.GetTemporaryFilesPath(EBackupTypeUtils.GetValue(EBackupType.Site)); DirectoryUtils.DeleteDirectoryIfExists(siteTemplatePath); DirectoryUtils.CreateDirectoryIfNotExists(siteTemplatePath); ZipUtils.ExtractZip(path, siteTemplatePath); } var siteTemplateMetadataPath = PathUtils.Combine(siteTemplatePath, DirectoryUtils.SiteTemplates.SiteTemplateMetadata); if (isDeleteChannels) { var channelIdList = ChannelManager.GetChannelIdList(ChannelManager.GetChannelInfo(siteId, siteId), EScopeType.Children, string.Empty, string.Empty, string.Empty); foreach (var channelId in channelIdList) { DataProvider.ChannelDao.Delete(siteId, channelId); } } if (isDeleteTemplates) { var templateInfoList = DataProvider.TemplateDao.GetTemplateInfoListBySiteId(siteId); foreach (var templateInfo in templateInfoList) { if (templateInfo.IsDefault == false) { DataProvider.TemplateDao.Delete(siteId, templateInfo.Id); } } } if (isDeleteFiles) { DirectoryUtility.DeleteSiteFiles(siteInfo); } //导入文件 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); //导入站点设置 var configurationFilePath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.FileConfiguration); importObject.ImportConfiguration(configurationFilePath); //导入栏目及内容 var siteContentDirectoryPath = PathUtils.Combine(siteTemplateMetadataPath, DirectoryUtils.SiteTemplates.SiteContent); importObject.ImportChannelsAndContents(0, siteContentDirectoryPath, isOverride); //导入表样式及清除缓存 if (isUseTable) { importObject.ImportTableStyles(tableDirectoryPath); } importObject.RemoveDbCache(); CacheUtils.ClearAll(); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } if (Body.IsQueryExists("delete")) { var pluginId = Body.GetQueryString("pluginId"); PluginManager.Delete(pluginId); Body.AddAdminLog("删除插件", $"插件:{pluginId}"); CacheUtils.ClearAll(); CacheDbUtils.Clear(); AddScript(AlertUtils.Success("插件删除成功", "插件删除成功,系统需要重载页面", "重新载入", "window.top.location.reload();")); } if (Body.IsQueryExists("enable")) { var pluginId = Body.GetQueryString("pluginId"); PluginManager.UpdateDisabled(pluginId, false); Body.AddAdminLog("启用插件", $"插件:{pluginId}"); CacheUtils.ClearAll(); CacheDbUtils.Clear(); AddScript(AlertUtils.Success("插件启用成功", "插件启用成功,系统需要重载页面", "重新载入", "window.top.location.reload();")); } else if (Body.IsQueryExists("disable")) { var pluginId = Body.GetQueryString("pluginId"); PluginManager.UpdateDisabled(pluginId, true); Body.AddAdminLog("禁用插件", $"插件:{pluginId}"); CacheUtils.ClearAll(); CacheDbUtils.Clear(); AddScript(AlertUtils.Success("插件禁用成功", "插件禁用成功,系统需要重载页面", "重新载入", "window.top.location.reload();")); } if (Page.IsPostBack) { return; } PageType = Body.GetQueryInt("type", 1); VerifyAdministratorPermissions(ConfigManager.Permissions.Plugins.Management); var listEnabled = new List <PluginInfo>(); var listDisabled = new List <PluginInfo>(); var listError = new List <PluginInfo>(); foreach (var pluginInfo in PluginManager.AllPluginInfoList) { if (pluginInfo.Plugin == null) { CountError++; listError.Add(pluginInfo); } else { if (pluginInfo.IsDisabled) { CountDisabled++; listDisabled.Add(pluginInfo); } else { CountEnabled++; listEnabled.Add(pluginInfo); } } } RptEnabled.DataSource = listEnabled; RptEnabled.ItemDataBound += RptRunnable_ItemDataBound; RptEnabled.DataBind(); RptDisabled.DataSource = listDisabled; RptDisabled.ItemDataBound += RptRunnable_ItemDataBound; RptDisabled.DataBind(); RptError.DataSource = listError; RptError.ItemDataBound += RptError_ItemDataBound; RptError.DataBind(); }