/// <summary> /// Invoke middleware actions /// </summary> /// <param name="context">HTTP context</param> /// <param name="webHelper">Web helper</param> /// <returns>Task</returns> public async Task Invoke(Microsoft.AspNetCore.Http.HttpContext context, IWebHelper webHelper) { //判断数据库是否已安装和配置,如果没有,那么跳转至Install页面中 if (!MainDataSettingsHelper.DatabaseIsInstalled()) { var installUrl = $"{webHelper.GetTenantLocation()}install"; if (!webHelper.GetThisPageUrl(false).StartsWith(installUrl, StringComparison.InvariantCultureIgnoreCase)) { //重定向 context.Response.Redirect(installUrl); return; } } //如果已安装则进入下一个中间件 await _next(context); }
public async Task Invoke(HttpContext context, IWebHelper webHelper) { //TODO test. ensure that no guest record is created //判断数据库是否已经完成安装与配置 if (MainDataSettingsHelper.DatabaseIsInstalled()) { //未完成则继续等待 var keepAliveUrl = $"{webHelper.GetTenantLocation()}keepalive/index"; if (webHelper.GetThisPageUrl(false).StartsWith(keepAliveUrl, StringComparison.InvariantCultureIgnoreCase)) { return; } } //进入下一个中间件 await _next(context); }
/// <summary> /// 获取Logo的URL地址 /// </summary> /// <param name="pluginDescriptor">Plugin descriptor</param> /// <param name="webHelper">Web helper</param> /// <returns>Logo URL</returns> public static string GetLogoUrl(this PluginDescriptor pluginDescriptor, IWebHelper webHelper) { Check.NotNull(pluginDescriptor, nameof(pluginDescriptor)); Check.NotNull(webHelper, nameof(webHelper)); if (pluginDescriptor.OriginalAssemblyFile == null || pluginDescriptor.OriginalAssemblyFile.Directory == null) { return(null); } var pluginDirectory = pluginDescriptor.OriginalAssemblyFile.Directory; var logoExtension = SupportedLogoImageExtensions.FirstOrDefault(ext => File.Exists(Path.Combine(pluginDirectory.FullName, "logo." + ext))); if (string.IsNullOrWhiteSpace(logoExtension)) { return(null); //No logo file was found with any of the supported extensions. } var logoUrl = $"{webHelper.GetTenantLocation()}plugins/{pluginDirectory.Name}/logo.{logoExtension}"; return(logoUrl); }