protected Task PrepareTenantUrlWarningModel(IList <SystemWarningModel> models) { if (models == null) { throw new ArgumentNullException(nameof(models)); } //check whether current tenant URL matches the tenant`s configured URL var currentTenantUrl = _tenantContext.CurrentTenant.Url; if (!string.IsNullOrEmpty(currentTenantUrl) && (currentTenantUrl.Equals(_webHelper.GetLocation(false), StringComparison.InvariantCultureIgnoreCase) || currentTenantUrl.Equals(_webHelper.GetLocation(true), StringComparison.InvariantCultureIgnoreCase))) { models.Add(new SystemWarningModel { Level = SystemWarningLevel.Pass, Text = "Specified tenant URL matches this tenant URL" }); return(Task.CompletedTask); } models.Add(new SystemWarningModel { Level = SystemWarningLevel.Fail, Text = $"Specified tenant URL ({currentTenantUrl}) doesn't match this tenant URL ({_webHelper.GetLocation(false)})" }); return(Task.CompletedTask); }
/// <summary> /// Get picture (thumb) URL /// </summary> /// <param name="thumbFileName">Filename</param> /// <param name="location">Location URL; null to use determine the current tenant location automatically</param> /// <returns>Local picture thumb path</returns> protected virtual string GetThumbUrl(string thumbFileName, string location = null) { location = !string.IsNullOrEmpty(location) ? location : _webHelper.GetLocation(); var url = location + "images/thumbs/"; url = url + thumbFileName; return(url); }
public async Task ExecuteAsync(CancellationToken cancellationToken) { var keepAliveUrl = $"{_webHelper.GetLocation()}{HttpDefaults.KeepAlivePath}"; using (var wc = new WebClient()) { await wc.DownloadStringTaskAsync(keepAliveUrl); } }
public void Execute() { string url = _webHelper.GetLocation() + "keepalive/index"; using (var wc = new WebClient()) { wc.DownloadString(url); } }
public async Task Invoke(HttpContext context, IWebHelper webHelper) { if (!DataSettingsManager.DatabaseIsInstalled) { var keepAliveUrl = $"{webHelper.GetLocation()}{HttpDefaults.KeepAlivePath}"; if (webHelper.GetThisPageUrl(false).StartsWith(keepAliveUrl, StringComparison.InvariantCultureIgnoreCase)) { return; } } await _next(context); }
public FaviconModel PrepareFaviconModel() { var model = new FaviconModel(); var faviconFileName = "favicon.ico"; var localFaviconPath = System.IO.Path.Combine(_httpContext.Request.PhysicalApplicationPath, faviconFileName); if (!File.Exists(localFaviconPath)) { return(model); } model.FaviconUrl = _webHelper.GetLocation() + faviconFileName; return(model); }
public async Task Invoke(HttpContext context, IWebHelper webHelper) { if (!DataSettingsManager.DatabaseIsInstalled) { var installUrl = $"{webHelper.GetLocation()}{HttpDefaults.InstallPath}"; if (!webHelper.GetThisPageUrl(false) .StartsWith(installUrl, StringComparison.InvariantCultureIgnoreCase)) { //redirect context.Response.Redirect(installUrl); return; } } await _next(context); }
/// <summary> /// Setting menu /// </summary> /// <param name="rootNode">Current menu node</param> public void ManageSiteMap(SiteMapNode rootNode) { var isPermit = _permissionService.Authorize(StandardPermissionProvider.ManagePlugins); var pluginMainMenu = new SiteMapNode { Title = "License Manager", Url = _webHelper.GetLocation() + "License/Configure", Visible = isPermit, SystemName = "license.mgr", IconClass = "fa fa-key" }; var settingNode = rootNode.ChildNodes.FirstOrDefault(node => node.SystemName.Equals("Configuration")); settingNode?.ChildNodes.Add(pluginMainMenu); }
protected void InstallTenants() { var url = _webHelper.GetLocation(false); var tenants = new List <Tenant> { new Tenant { Name = "Tenant", Url = url, SslEnabled = false, Hosts = "site.com,www.site.com", DisplayOrder = 1, } }; _tenantRepository.Insert(tenants); }
public void ManageSiteMap(SiteMapNode rootNode) { var canManagePlugin = _permissionService.Authorize(StandardPermissionProvider.ManagePlugins); var pluginMainMenu = new SiteMapNode { Title = "API Settings", Url = _webHelper.GetLocation() + "ApiSettings/Index", Visible = canManagePlugin, SystemName = "api.settings", IconClass = "glyphicon glyphicon-send" }; var settingNode = rootNode.ChildNodes.FirstOrDefault(node => node.SystemName.Equals("Configuration")); settingNode?.ChildNodes.Add(pluginMainMenu); }
public virtual ActionResult BackupFiles(DataSourceRequest command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } var backupFiles = _maintenanceService.GetAllBackupFiles().ToList(); var gridModel = new DataSourceResult { Data = backupFiles.Select(p => new { p.Name, Length = string.Format("{0:F2} Mb", p.Length / 1024f / 1024f), Link = _webHelper.GetLocation(false) + "Administration/db_backups/" + p.Name }), Total = backupFiles.Count }; return(Json(gridModel)); }
public virtual string GetDefaultPictureUrl(int targetSize = 0, PictureType defaultPictureType = PictureType.Entity) { string defaultImageFileName; switch (defaultPictureType) { /*从设定中获取默认头像和实体默认图片名*/ case PictureType.Avatar: defaultImageFileName = _settingService.GetSettingByKey("Media.Customer.DefaultAvatarImageName", "default-avatar.jpg"); break; case PictureType.Entity: default: defaultImageFileName = _settingService.GetSettingByKey("Media.DefaultImageName", "default-image.png"); break; } var filePath = GetPictureLocalPath(defaultImageFileName); if (!File.Exists(filePath)) { return(""); } if (targetSize == 0) { var url = _webHelper.GetLocation() + "Content/Images/" + defaultImageFileName; return(url); } else { string fileExtension = Path.GetExtension(filePath); string thumbFileName = string.Format("{0}_{1}{2}", Path.GetFileNameWithoutExtension(filePath), targetSize, fileExtension);//生成目标尺寸图片的存储路径 var thumbFilePath = GetThumbLocalPath(thumbFileName); if (!GeneratedThumbExists(thumbFilePath, thumbFileName)) { using (var b = new Bitmap(filePath)) { using (var destStream = new MemoryStream()) { var newSize = CalculateDimensions(b.Size, targetSize); ImageBuilder.Current.Build(b, destStream, new ResizeSettings { Width = newSize.Width, Height = newSize.Height, Scale = ScaleMode.Both, Quality = _mediaSettings.DefaultImageQuality }); var destBinary = destStream.ToArray(); SaveThumb(thumbFilePath, thumbFileName, "", destBinary); } } } var url = GetThumbUrl(thumbFileName); return(url); } }
public void Can_get_appLocation_without_ssl() { _webHelper.GetLocation(false).ShouldEqual("http://www.Example.com/"); }