public ActionResult Download(int id) { var response = _secureFileService.Get(id); if (response.Status == 200) { return(new FilePathResult(new FileInfo(response.Part.FullPath).FullName, response.Part.MimeType()) { FileDownloadName = response.Part.FileName() }); } return(response.ToActionResult()); }
public static IDictionary <string, string> GetParameters( HttpRequestBase request, ISecureFileService secureFileService, IOrchardServices orchard ) { var parameters = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); if (request != null) { if (request.QueryString != null) { foreach (string key in request.QueryString) { if (key == null) { continue; } parameters[key] = request.QueryString[key]; } } if (request.Form != null) { foreach (string key in request.Form) { if (key == null) { continue; } if (!key.Equals("__requestverificationtoken", StringComparison.OrdinalIgnoreCase)) { parameters[key] = request.Form[key]; } } } } // handle input file int inputFileId; if (parameters.ContainsKey(Common.InputFileIdName) && int.TryParse(parameters[Common.InputFileIdName], out inputFileId)) { var response = secureFileService.Get(inputFileId); if (response.Status == 200) { parameters[Common.InputFilePath] = response.Part.FullPath; parameters[Common.InputFileName] = response.Part.FileName(); parameters[Common.InputFileTitleName] = response.Part.Title(); } else { parameters[Common.InputFilePath] = response.Message; parameters[Common.InputFileName] = response.Message; parameters[Common.InputFileTitleName] = response.Message; } } else { parameters[Common.InputFileIdName] = "0"; } AddOrchardVariables(parameters, orchard, request); return(parameters); }
public static IDictionary <string, string> GetParameters( HttpRequestBase request, ISecureFileService secureFileService, IOrchardServices orchard ) { var parameters = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); if (request != null) { if (request.QueryString != null) { foreach (string key in request.QueryString) { parameters[key] = request.QueryString[key]; } } if (request.Form != null) { foreach (string key in request.Form) { if (!key.Equals("__requestverificationtoken", StringComparison.OrdinalIgnoreCase)) { parameters[key] = request.Form[key]; } } } } if (!parameters.ContainsKey("user")) { var defaultUser = ConfigurationManager.AppSettings["default-user"]; if (!string.IsNullOrEmpty(defaultUser)) { parameters["user"] = defaultUser; } } if (!parameters.ContainsKey("password")) { var defaultPassword = ConfigurationManager.AppSettings["default-password"]; if (!string.IsNullOrEmpty(defaultPassword)) { parameters["password"] = defaultPassword; } } // handle input file int inputFileId; if (parameters.ContainsKey(Common.InputFileIdName) && int.TryParse(parameters[Common.InputFileIdName], out inputFileId)) { var response = secureFileService.Get(inputFileId); if (response.Status == 200) { parameters[Common.InputFilePath] = response.Part.FullPath; parameters[Common.InputFileName] = response.Part.FileName(); parameters[Common.InputFileTitleName] = response.Part.Title(); } else { parameters[Common.InputFilePath] = response.Message; parameters[Common.InputFileName] = response.Message; parameters[Common.InputFileTitleName] = response.Message; } } else { parameters[Common.InputFileIdName] = "0"; } parameters["Orchard.User"] = orchard.WorkContext.CurrentUser?.UserName; parameters["Orchard.Email"] = orchard.WorkContext.CurrentUser?.Email; return(parameters); }