/// <summary> /// Bietet die geforderte Datei zum Download an. /// </summary> /// <param name="file"></param> private void DownloadFile(HttpRequest request, HttpResponse response, ModuleConfig cfg, string file, bool asAttachment) { // Ermitteln des Filewappers der entsprechenden Datei. ConfigAgent cfgAgent = new ConfigAgent(cfg); FileWrapper dwnFile = cfgAgent.RootDirectory.GetFile(file); if (dwnFile != null) { response.CacheControl = "public"; response.Cache.SetCacheability(HttpCacheability.Private); if (asAttachment) { response.AddHeader("Content-Disposition", "attachment; filename=" + dwnFile.FileName); } response.AddHeader("Content-Length", dwnFile.FileSize.ToString()); String mimeType = dwnFile.MimeType; if (mimeType != null) { response.ContentType = mimeType; } response.TransmitFile(dwnFile.PhysicalPath); if (!Portal.API.Statistics.StatisticHelper.IsBot(request)) { // In der Statistik zwischenspeichern. Statistic FbStatistic = new Statistic(cfgAgent.PhysicalRoot); FbStatistic.DownloadFile(file); } } else { throw new FileNotFoundException(); } }
/// <summary> /// Bietet die geforderte Datei zum Download an. /// </summary> /// <param name="file"></param> private void DownloadFile(HttpRequest request, HttpResponse response, ModuleConfig cfg, string file, bool asAttachment) { // Ermitteln des Filewappers der entsprechenden Datei. ConfigAgent cfgAgent = new ConfigAgent(cfg); FileWrapper dwnFile = cfgAgent.RootDirectory.GetFile(file); if (dwnFile != null) { response.CacheControl = "public"; response.Cache.SetCacheability(HttpCacheability.Private); if (asAttachment) response.AddHeader("Content-Disposition", "attachment; filename=" + dwnFile.FileName); response.AddHeader("Content-Length", dwnFile.FileSize.ToString()); String mimeType = dwnFile.MimeType; if (mimeType != null) response.ContentType = mimeType; response.TransmitFile(dwnFile.PhysicalPath); if(!Portal.API.Statistics.StatisticHelper.IsBot(request)) { // In der Statistik zwischenspeichern. Statistic FbStatistic = new Statistic(cfgAgent.PhysicalRoot); FbStatistic.DownloadFile(file); } } else throw new FileNotFoundException(); }
public void Process(HttpRequest request, HttpResponse response, string moduleType, string ModuleReference) { string fileName = Portal.API.Config.GetModuleDataPhysicalPath(moduleType) + "Module_" + ModuleReference + ".config"; ModuleConfig cfg = ReadModuleConfig(fileName); String file = HttpContext.Current.Server.UrlDecode(request.QueryString["File"]); // Soll der Download als Attachment ausgeführt werden? bool asAttachment = true; asAttachment = (0 != Convert.ToInt32(request.QueryString["Att"])); DownloadFile(request, response, cfg, file, asAttachment); }
protected void SaveLB_Click(object sender, System.EventArgs e) { FileBrowser.ModuleConfig cfg = (FileBrowser.ModuleConfig)ReadConfig(typeof(FileBrowser.ModuleConfig)); if (cfg == null) { cfg = new ModuleConfig(); } cfg.VirtualRoot = VirtualRootEdit.Text; cfg.SortProperty = (SortProperty)Enum.Parse(typeof(SortProperty), SortPropertyCombo.SelectedValue); cfg.SortDirectionAsc = SortDirCheck.Checked; WriteConfig(cfg); RedirectBack(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig)); if (cfg == null) cfg = new ModuleConfig(); VirtualRootEdit.Text = cfg.VirtualRoot; SortPropertyCombo.Items.Add(new ListItem(Portal.API.Language.GetText(Portal.API.Module.GetModuleControl(this), "Name"), SortProperty.Name.ToString())); SortPropertyCombo.Items.Add(new ListItem(Portal.API.Language.GetText(Portal.API.Module.GetModuleControl(this), "Description"), SortProperty.Description.ToString())); SortPropertyCombo.Items.Add(new ListItem(Portal.API.Language.GetText(Portal.API.Module.GetModuleControl(this), "Date"), SortProperty.ModDate.ToString())); SortPropertyCombo.SelectedValue = cfg.SortProperty.ToString(); SortDirCheck.Checked = cfg.SortDirectionAsc; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig)); if (cfg == null) { cfg = new ModuleConfig(); } VirtualRootEdit.Text = cfg.VirtualRoot; SortPropertyCombo.Items.Add(new ListItem(Portal.API.Language.GetText(Portal.API.Module.GetModuleControl(this), "Name"), SortProperty.Name.ToString())); SortPropertyCombo.Items.Add(new ListItem(Portal.API.Language.GetText(Portal.API.Module.GetModuleControl(this), "Description"), SortProperty.Description.ToString())); SortPropertyCombo.Items.Add(new ListItem(Portal.API.Language.GetText(Portal.API.Module.GetModuleControl(this), "Date"), SortProperty.ModDate.ToString())); SortPropertyCombo.SelectedValue = cfg.SortProperty.ToString(); SortDirCheck.Checked = cfg.SortDirectionAsc; } }
/// <summary> /// Konstruktor. /// </summary> public ConfigAgent(Portal.Modules.FileBrowser.ModuleConfig config) { this.config = config; ResetData(); }