public object Get(GetFileOrganizationActivity request) { var result = InternalFileOrganizationService.GetResults(new FileOrganizationResultQuery { Limit = request.Limit, StartIndex = request.StartIndex }); return(_resultFactory.GetResult(Request, result)); }
/// <summary> /// Gets the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>System.Object.</returns> public async Task <object> Get(GetDashboardResource request) { if (!_appConfig.HostWebClient() || DashboardUIPath == null) { throw new ResourceNotFoundException(); } var path = request.ResourceName; var contentType = MimeTypes.GetMimeType(path); var basePath = DashboardUIPath; // Bounce them to the startup wizard if it hasn't been completed yet if (!_serverConfigurationManager.Configuration.IsStartupWizardCompleted && Request.RawUrl.IndexOf("wizard", StringComparison.OrdinalIgnoreCase) == -1 && PackageCreator.IsCoreHtml(path)) { // But don't redirect if an html import is being requested. if (path.IndexOf("bower_components", StringComparison.OrdinalIgnoreCase) == -1) { Request.Response.Redirect("index.html?start=wizard#!/wizardstart.html"); return(null); } } var localizationCulture = GetLocalizationCulture(); // Don't cache if not configured to do so // But always cache images to simulate production if (!_serverConfigurationManager.Configuration.EnableDashboardResponseCaching && !contentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase) && !contentType.StartsWith("font/", StringComparison.OrdinalIgnoreCase)) { var stream = await GetResourceStream(basePath, path, localizationCulture).ConfigureAwait(false); return(_resultFactory.GetResult(Request, stream, contentType)); } TimeSpan?cacheDuration = null; // Cache images unconditionally - updates to image files will require new filename // If there's a version number in the query string we can cache this unconditionally if (contentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase) || contentType.StartsWith("font/", StringComparison.OrdinalIgnoreCase) || !string.IsNullOrEmpty(request.V)) { cacheDuration = TimeSpan.FromDays(365); } var cacheKey = (_appHost.ApplicationVersionString + (localizationCulture ?? string.Empty) + path).GetMD5(); // html gets modified on the fly if (contentType.StartsWith("text/html", StringComparison.OrdinalIgnoreCase)) { return(await _resultFactory.GetStaticResult(Request, cacheKey, null, cacheDuration, contentType, () => GetResourceStream(basePath, path, localizationCulture)).ConfigureAwait(false)); } return(await _resultFactory.GetStaticFileResult(Request, _resourceFileManager.GetResourcePath(basePath, path)).ConfigureAwait(false)); }
/// <summary> /// Gets the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>System.Object.</returns> public async Task <object> Get(GetDashboardResource request) { var path = request.ResourceName; path = path.Replace("bower_components" + _appHost.ApplicationVersion, "bower_components", StringComparison.OrdinalIgnoreCase); var contentType = MimeTypes.GetMimeType(path); var basePath = DashboardUIPath; // Bounce them to the startup wizard if it hasn't been completed yet if (!_serverConfigurationManager.Configuration.IsStartupWizardCompleted && path.IndexOf("wizard", StringComparison.OrdinalIgnoreCase) == -1 && GetPackageCreator(basePath).IsCoreHtml(path)) { // But don't redirect if an html import is being requested. if (path.IndexOf("bower_components", StringComparison.OrdinalIgnoreCase) == -1) { Request.Response.Redirect("wizardstart.html"); return(null); } } path = path.Replace("scripts/jquery.mobile-1.4.5.min.map", "thirdparty/jquerymobile-1.4.5/jquery.mobile-1.4.5.min.map", StringComparison.OrdinalIgnoreCase); var localizationCulture = GetLocalizationCulture(); // Don't cache if not configured to do so // But always cache images to simulate production if (!_serverConfigurationManager.Configuration.EnableDashboardResponseCaching && !contentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase) && !contentType.StartsWith("font/", StringComparison.OrdinalIgnoreCase)) { var stream = await GetResourceStream(basePath, path, localizationCulture).ConfigureAwait(false); return(_resultFactory.GetResult(stream, contentType)); } TimeSpan?cacheDuration = null; // Cache images unconditionally - updates to image files will require new filename // If there's a version number in the query string we can cache this unconditionally if (contentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase) || contentType.StartsWith("font/", StringComparison.OrdinalIgnoreCase) || !string.IsNullOrEmpty(request.V)) { cacheDuration = TimeSpan.FromDays(365); } var cacheKey = (_appHost.ApplicationVersion + (localizationCulture ?? string.Empty) + path).GetMD5(); return(await _resultFactory.GetStaticResult(Request, cacheKey, null, cacheDuration, contentType, () => GetResourceStream(basePath, path, localizationCulture)).ConfigureAwait(false)); }
/// <summary> /// 转发信息 /// </summary> /// <param name="url"></param> /// <returns></returns> private async Task <object> DoGet(string url, ImageType?type) { //logger.Info($"{url}"); //if (url.IsWebUrl() != true) // throw new ResourceNotFoundException(); var resp = await imageProxyService.GetImageResponse(url, type ?? ImageType.Backdrop, default); if (!(resp?.ContentLength > 0)) { throw new ResourceNotFoundException(); } return(resultFactory.GetResult(Request, resp.Content, resp.ContentType)); }
/// <summary> Gets the given request. </summary> /// <param name="request"> The request. </param> /// <returns> A Task<object> </returns> public object Get(GetReportDownload request) { if (string.IsNullOrEmpty(request.IncludeItemTypes)) { return(null); } request.DisplayType = "Export"; ReportViewType reportViewType = ReportHelper.GetReportViewType(request.ReportView); var headers = new Dictionary <string, string>(); string fileExtension = "csv"; string contentType = "text/plain;charset='utf-8'"; switch (request.ExportType) { case ReportExportType.CSV: break; case ReportExportType.Excel: contentType = "application/vnd.ms-excel"; fileExtension = "xls"; break; } var filename = "ReportExport." + fileExtension; headers["Content-Disposition"] = string.Format("attachment; filename=\"{0}\"", filename); headers["Content-Encoding"] = "UTF-8"; var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null; ReportResult result = null; switch (reportViewType) { case ReportViewType.ReportData: ReportIncludeItemTypes reportRowType = ReportHelper.GetRowType(request.IncludeItemTypes); ReportBuilder dataBuilder = new ReportBuilder(_libraryManager); QueryResult <BaseItem> queryResult = GetQueryResult(request, user); result = dataBuilder.GetResult(queryResult.Items, request); result.TotalRecordCount = queryResult.TotalRecordCount; break; case ReportViewType.ReportActivities: result = GetReportActivities(request); break; } string returnResult = string.Empty; switch (request.ExportType) { case ReportExportType.CSV: returnResult = new ReportExport().ExportToCsv(result); break; case ReportExportType.Excel: returnResult = new ReportExport().ExportToExcel(result); break; } return(_resultFactory.GetResult(returnResult, contentType, headers)); }
public object Get(GetContentDirectory request) { var xml = ContentDirectory.GetServiceXml(Request.Headers.ToDictionary()); return(_resultFactory.GetResult(Request, xml, XMLContentType)); }
public object Get(GetContentDirectory request) { var xml = ContentDirectory.GetServiceXml(); return(_resultFactory.GetResult(Request, xml, XMLContentType)); }