Admin Service in ApiService und ApiStreamService ausgelagert
This commit is contained in:
49
Service/ServiceImplementations/ApiServiceImp.cs
Normal file
49
Service/ServiceImplementations/ApiServiceImp.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
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 ApiServiceImp : IApiService
|
||||
{
|
||||
public ApiResponse<string> Test()
|
||||
{
|
||||
return ApiResponse<string>.SuccessResponse( "Api Service Test erfolgreich!");
|
||||
}
|
||||
|
||||
public ApiResponse<decimal> GetGkvAbrechnungSumme(AdminServiceSumReqDC request)
|
||||
{
|
||||
if (request == null)
|
||||
{
|
||||
throw new ArgumentException("request darf nicht null sein");
|
||||
}
|
||||
|
||||
if(!Utils.TryParseISO8601(request.Start, out var start))
|
||||
{
|
||||
throw new ArgumentException("start entspricht nicht ISO8601 Norm.");
|
||||
}
|
||||
|
||||
if (!Utils.TryParseISO8601(request.End, out var end))
|
||||
{
|
||||
throw new ArgumentException("end entspricht nicht ISO8601 Norm.");
|
||||
}
|
||||
|
||||
var sum = DAOFactory.ScriptDAO.GetGkvSumByDateRange(start, end);
|
||||
|
||||
return ApiResponse<decimal>.SuccessResponse(sum ?? 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Service/ServiceImplementations/ApiStreamServiceImp.cs
Normal file
38
Service/ServiceImplementations/ApiStreamServiceImp.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user