Files
BeWoPlaner/Service/ServiceImplementations/ApiStreamServiceImp.cs
2025-05-27 10:32:21 +02:00

55 lines
1.7 KiB
C#

using BeWo.Data.Access;
using BeWo.Service.ServiceContracts;
using BS.Shared.Core;
using BS.Shared.DataContracts.AdminService;
using BS.Shared.DataContracts.MikePHPContracts;
using DevExpress.Pdf.Native.BouncyCastle.Ocsp;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Threading.Tasks;
namespace BeWo.Service.ServiceImplementations
{
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
public class ApiStreamServiceImp : IApiStreamService
{
public Stream Download()
{
string filename = "xrechnung.pdf";
string filePath = Path.Combine(@"C:\Users\ownSoft\Desktop\XRechnung\", filename);
if (!File.Exists(filePath))
throw new FileNotFoundException("Datei nicht gefunden");
// Setze die Header
WebOperationContext.Current.OutgoingResponse.ContentType = "application/pdf";
WebOperationContext.Current.OutgoingResponse.Headers.Add(
"Content-Disposition", $"attachment; filename=\"{filename}\"");
return new FileStream(filePath, FileMode.Open, FileAccess.Read);
}
public Stream DownloadReport()
{
string filename = "xrechnung.pdf";
string filePath = Path.Combine(@"C:\Users\ownSoft\Desktop\XRechnung\", filename);
if (!File.Exists(filePath))
throw new FileNotFoundException("Datei nicht gefunden");
// Setze die Header
WebOperationContext.Current.OutgoingResponse.ContentType = "application/pdf";
WebOperationContext.Current.OutgoingResponse.Headers.Add(
"Content-Disposition", $"attachment; filename=\"{filename}\"");
return new FileStream(filePath, FileMode.Open, FileAccess.Read);
}
}
}