Gkv Summen Abfrage fertig - SQL Statements als einzelne File für bessere Lesbarkeit
- Einfach als Embedded Ressource beim Build Vorgang wählen und durch SearchDAO.LoadSQLStatement verwenden
This commit is contained in:
@@ -17,6 +17,7 @@ using BeWo.ViewModel;
|
||||
using BeWo.ViewModel.ListViewModel;
|
||||
|
||||
using BS.Shared;
|
||||
using BS.Shared.AppSender;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.GkvAbrechnung;
|
||||
@@ -56,6 +57,12 @@ namespace BeWo.View.Detail.Accounting
|
||||
_NewGkvAbrechnungPopUpView.CreateButtonClicked += NewGkvAbrechnungPopUpViewCreateButtonClicked;
|
||||
|
||||
_Viewmodel.DateTimeSpanFilter = yearMonthFilter.FilterSpan;
|
||||
|
||||
var req = new GkvClientSumRequestJson();
|
||||
req.GkvSecretKey = "DfDGNGn72PKfSYxSUsmRdzuBtpR9novewlmYU3gsjiFgSkaZZeylUXlbO42cWNqiKgLdMUFtWUNZT962F1raQDR7HGUzCNYsFeC";
|
||||
req.Tenant = "demo";
|
||||
|
||||
var res = AppRequestSender.Send<GkvClientSumRequestJson, GkvClientSumResponseJson>(req, "http://localhost:3777/Host/GkvAbrechnungClient.aspx");
|
||||
}
|
||||
|
||||
public DownloadLinkEngine DownloadLinkEngine { get; set; }
|
||||
|
||||
@@ -12,5 +12,7 @@
|
||||
<add key="SendMailModuleGkvTestSmtpPassword" value="JJVjJntw2yaRDAxInotF" />
|
||||
<add key="SendMailModuleGkvTestSender" value="noreply@bewoplaner.de" />
|
||||
<add key="SendMailModuleGkvTestReceiver" value="dakota.exchange@ownsoft.de" />
|
||||
|
||||
<add key="GkvSecretKey" value="DfDGNGn72PKfSYxSUsmRdzuBtpR9novewlmYU3gsjiFgSkaZZeylUXlbO42cWNqiKgLdMUFtWUNZT962F1raQDR7HGUzCNYsFeC" />
|
||||
</appSettings>
|
||||
</configuration>
|
||||
@@ -46,11 +46,13 @@
|
||||
<HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DakotaReaderUnitTest.cs" />
|
||||
<Compile Include="GkvObjectUnitTest.cs" />
|
||||
<Compile Include="GkvSumServer.cs" />
|
||||
<Compile Include="MailUnitTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
37
DakotaUnitTest/GkvSumServer.cs
Normal file
37
DakotaUnitTest/GkvSumServer.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using BS.Shared.AppSender;
|
||||
using BS.Shared.DataContracts.GkvAbrechnung;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DakotaUnitTest
|
||||
{
|
||||
[TestClass]
|
||||
public class GkvSumServer
|
||||
{
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Test()
|
||||
{
|
||||
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
||||
|
||||
|
||||
var req = new GkvClientSumRequestJson();
|
||||
req.GkvSecretKey = ConfigurationManager.AppSettings.Get("GkvSecretKey");
|
||||
req.Tenant = "5000000000";
|
||||
|
||||
var res = AppRequestSender.Send<GkvClientSumRequestJson, GkvClientSumResponseJson>(req, "https://app5.bewoplaner.de/service/GkvAbrechnungClient.aspx");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,108 +19,108 @@ using NHibernate.Cfg;
|
||||
|
||||
namespace BeWo.Data
|
||||
{
|
||||
public class ASPHibernateSessionManager : IHttpModule
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
public class ASPHibernateSessionManager : IHttpModule
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public void Init(HttpApplication context)
|
||||
{
|
||||
context.AcquireRequestState += (s, e) =>
|
||||
{
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
|
||||
public void Init(HttpApplication context)
|
||||
{
|
||||
context.AcquireRequestState += (s, e) =>
|
||||
{
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
|
||||
|
||||
if(ShouldConfigureHibernateSession(context))
|
||||
{
|
||||
// TEST FOR DEVEXPRESS. PROBLEMS WITH THIS MODULE WHEN USING AJAX!
|
||||
if(HttpContext.Current.Session == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ShouldConfigureHibernateSession(context))
|
||||
{
|
||||
// TEST FOR DEVEXPRESS. PROBLEMS WITH THIS MODULE WHEN USING AJAX!
|
||||
if (HttpContext.Current.Session == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
if(!ConfigureHibernateSession(context))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// ---------------------------------------------------------------
|
||||
if (!ConfigureHibernateSession(context))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// throw new Exception("Could not configure database. No tenant parameter found");
|
||||
var userLoaded = TryAuthenticateWithRequestParams(context);
|
||||
// throw new Exception("Could not configure database. No tenant parameter found");
|
||||
var userLoaded = TryAuthenticateWithRequestParams(context);
|
||||
|
||||
if(!userLoaded)
|
||||
{
|
||||
userLoaded = TryAuthenticateWithLoginForm(context);
|
||||
}
|
||||
|
||||
if(!userLoaded)
|
||||
{
|
||||
userLoaded = TryAuthenticateWithGkv(context);
|
||||
}
|
||||
if (!userLoaded)
|
||||
{
|
||||
userLoaded = TryAuthenticateWithLoginForm(context);
|
||||
}
|
||||
|
||||
if(!userLoaded && !(SessionFacade.LoggedInUser?.Oid is null))
|
||||
{
|
||||
SessionFacade.LoggedInUser = DAOFactory.GenericDAO.LoadByID<ApplicationUser>(SessionFacade.LoggedInUser.Oid.Value);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!userLoaded)
|
||||
{
|
||||
userLoaded = TryAuthenticateWithGkv(context);
|
||||
}
|
||||
|
||||
context.EndRequest += (s, e) =>
|
||||
{
|
||||
if(HttpContext.Current.Items["hibernateSession"] != null)
|
||||
{
|
||||
((ISession) HttpContext.Current.Items["hibernateSession"]).Close();
|
||||
}
|
||||
};
|
||||
}
|
||||
if (!userLoaded && !(SessionFacade.LoggedInUser?.Oid is null))
|
||||
{
|
||||
SessionFacade.LoggedInUser = DAOFactory.GenericDAO.LoadByID<ApplicationUser>(SessionFacade.LoggedInUser.Oid.Value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private static bool ShouldConfigureHibernateSession(HttpApplication context)
|
||||
{
|
||||
if (string.IsNullOrEmpty(context.Request.FilePath))
|
||||
return false;
|
||||
context.EndRequest += (s, e) =>
|
||||
{
|
||||
if (HttpContext.Current.Items["hibernateSession"] != null)
|
||||
{
|
||||
((ISession)HttpContext.Current.Items["hibernateSession"]).Close();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (context.Request.FilePath.IndexOf("GkvAbrechnungServer.aspx") >= 0)
|
||||
return false;
|
||||
private static bool ShouldConfigureHibernateSession(HttpApplication context)
|
||||
{
|
||||
if (string.IsNullOrEmpty(context.Request.FilePath))
|
||||
return false;
|
||||
|
||||
if (context.Request.FilePath.IndexOf("Admin.aspx") >= 0)
|
||||
return false;
|
||||
if (context.Request.FilePath.IndexOf("GkvAbrechnungServer.aspx") >= 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
if (context.Request.FilePath.IndexOf("Admin.aspx") >= 0)
|
||||
return false;
|
||||
|
||||
private static bool ConfigureHibernateSession(HttpApplication context)
|
||||
{
|
||||
var lTenant = GetTenant(context);
|
||||
|
||||
if(!string.IsNullOrEmpty(lTenant))
|
||||
{
|
||||
SessionFacade.Tenant = lTenant;
|
||||
}
|
||||
else
|
||||
{
|
||||
lTenant = SessionFacade.Tenant;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(string.IsNullOrEmpty(lTenant))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var sessionFactory = new Configuration().Configure(context.Server.MapPath(@"Multitenancy\" + lTenant + ".config")).BuildSessionFactory();
|
||||
|
||||
XmlConfigurator.Configure();
|
||||
if(HttpContext.Current.Items.Contains("hibernateSession"))
|
||||
{
|
||||
HttpContext.Current.Items.Remove("hibernateSession");
|
||||
}
|
||||
private static bool ConfigureHibernateSession(HttpApplication context)
|
||||
{
|
||||
var lTenant = GetTenant(context);
|
||||
|
||||
HttpContext.Current.Items.Add("hibernateSession", sessionFactory.OpenSession());
|
||||
if (!string.IsNullOrEmpty(lTenant))
|
||||
{
|
||||
SessionFacade.Tenant = lTenant;
|
||||
}
|
||||
else
|
||||
{
|
||||
lTenant = SessionFacade.Tenant;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
if (string.IsNullOrEmpty(lTenant))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var sessionFactory = new Configuration().Configure(context.Server.MapPath(@"Multitenancy\" + lTenant + ".config")).BuildSessionFactory();
|
||||
|
||||
XmlConfigurator.Configure();
|
||||
if (HttpContext.Current.Items.Contains("hibernateSession"))
|
||||
{
|
||||
HttpContext.Current.Items.Remove("hibernateSession");
|
||||
}
|
||||
|
||||
HttpContext.Current.Items.Add("hibernateSession", sessionFactory.OpenSession());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String GetTenant(HttpApplication context)
|
||||
{
|
||||
{
|
||||
var lTenant = String.Empty;
|
||||
|
||||
String token = context.Request.Params["token"];
|
||||
@@ -140,201 +140,198 @@ namespace BeWo.Data
|
||||
lTenant = context.Request.Params["k"];
|
||||
|
||||
return lTenant;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryAuthenticateWithRequestParams(HttpApplication context)
|
||||
{
|
||||
string lUserName = null;
|
||||
string lPassword = null;
|
||||
private static bool TryAuthenticateWithRequestParams(HttpApplication context)
|
||||
{
|
||||
string lUserName = null;
|
||||
string lPassword = null;
|
||||
|
||||
//if (!context.Request.Params.AllKeys.Contains("tenant"))
|
||||
// return false;
|
||||
var lTenant = GetTenant(context);
|
||||
//if (!context.Request.Params.AllKeys.Contains("tenant"))
|
||||
// return false;
|
||||
var lTenant = GetTenant(context);
|
||||
|
||||
if (!string.IsNullOrEmpty(lTenant))
|
||||
{
|
||||
if (context.Request.Params.AllKeys.Contains("token"))
|
||||
{
|
||||
lUserName = GetLoginInfoFromToken(context.Request.Params["token"])["user"];
|
||||
lPassword = GetLoginInfoFromToken(context.Request.Params["token"])["password"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lUserName = context.Request.Params["username"];
|
||||
lPassword = context.Request.Params["token"];
|
||||
}
|
||||
|
||||
if (!BS.Shared.Core.Utils.IsAnyNullOrEmpty(lUserName, lPassword))
|
||||
{
|
||||
var ip = context.Request.UserHostAddress;
|
||||
|
||||
var lUser = DAOFactory.UserDAO.FindUserByLoginName(lUserName, ip);
|
||||
|
||||
if (lUser != null && lUser.CheckRC2Password(lPassword))
|
||||
{
|
||||
SessionFacade.LoggedInUser = lUser;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool TryAuthenticateWithLoginForm(HttpApplication context)
|
||||
{
|
||||
var name = context.Request.Params["ctl00$tb_login"];
|
||||
var password = context.Request.Params["ctl00$tb_password"];
|
||||
|
||||
if (!BS.Shared.Core.Utils.IsAnyNullOrEmpty(name, password))
|
||||
{
|
||||
ApplicationUser user = DAOFactory.UserDAO.FindUserByLoginName(name);
|
||||
|
||||
if (user != null && DAOFactory.UserDAO.CheckPassword(user, password))
|
||||
{
|
||||
SessionFacade.LoggedInUser = user;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool TryAuthenticateWithGkv(HttpApplication context)
|
||||
{
|
||||
if (context.Request.FilePath.IndexOf("GkvAbrechnungClient.aspx") == -1)
|
||||
return false;
|
||||
|
||||
// Eigene IP
|
||||
var clientip = GetIP(true);
|
||||
|
||||
// App 8 IP
|
||||
var appsettingip = System.Configuration.ConfigurationManager.AppSettings["App8IpAddress"];
|
||||
|
||||
// Summen Server
|
||||
var appsettingip2 = System.Configuration.ConfigurationManager.AppSettings["ServerSumIpAddress"];
|
||||
|
||||
if (appsettingip != clientip && appsettingip2 != clientip)
|
||||
return false;
|
||||
|
||||
if(appsettingip == clientip)
|
||||
if (!string.IsNullOrEmpty(lTenant))
|
||||
{
|
||||
var useroidstr = context.Request.Params["useroid"];
|
||||
|
||||
if (!long.TryParse(useroidstr, out long useroid))
|
||||
return false;
|
||||
|
||||
SessionFacade.LoggedInUser = DAOFactory.GenericDAO.LoadByID<ApplicationUser>(useroid);
|
||||
}
|
||||
if (context.Request.Params.AllKeys.Contains("token"))
|
||||
{
|
||||
lUserName = GetLoginInfoFromToken(context.Request.Params["token"])["user"];
|
||||
lPassword = GetLoginInfoFromToken(context.Request.Params["token"])["password"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SessionFacade.LoggedInUser = DAOFactory.UserDAO.GetBSUser("BSAdmin", "xyz");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
lUserName = context.Request.Params["username"];
|
||||
lPassword = context.Request.Params["token"];
|
||||
}
|
||||
|
||||
private static string GetIP(bool CheckForward = false)
|
||||
{
|
||||
// https://stackoverflow.com/a/13249280
|
||||
if (!BS.Shared.Core.Utils.IsAnyNullOrEmpty(lUserName, lPassword))
|
||||
{
|
||||
var ip = context.Request.UserHostAddress;
|
||||
|
||||
string ip = null;
|
||||
if (CheckForward)
|
||||
{
|
||||
ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
|
||||
}
|
||||
var lUser = DAOFactory.UserDAO.FindUserByLoginName(lUserName, ip);
|
||||
|
||||
if (string.IsNullOrEmpty(ip))
|
||||
{
|
||||
ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
|
||||
}
|
||||
else
|
||||
{ // Using X-Forwarded-For last address
|
||||
ip = ip.Split(',')
|
||||
.Last()
|
||||
.Trim();
|
||||
}
|
||||
if (lUser != null && lUser.CheckRC2Password(lPassword))
|
||||
{
|
||||
SessionFacade.LoggedInUser = lUser;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return ip;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> GetLoginInfoFromToken(string token)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(token))
|
||||
{
|
||||
return new Dictionary<string, string>();
|
||||
}
|
||||
private static bool TryAuthenticateWithLoginForm(HttpApplication context)
|
||||
{
|
||||
var name = context.Request.Params["ctl00$tb_login"];
|
||||
var password = context.Request.Params["ctl00$tb_password"];
|
||||
|
||||
string decodedToken;
|
||||
if (!BS.Shared.Core.Utils.IsAnyNullOrEmpty(name, password))
|
||||
{
|
||||
ApplicationUser user = DAOFactory.UserDAO.FindUserByLoginName(name);
|
||||
|
||||
token = token.Replace(' ', '+');
|
||||
token = token.Trim(',');
|
||||
if (user != null && DAOFactory.UserDAO.CheckPassword(user, password))
|
||||
{
|
||||
SessionFacade.LoggedInUser = user;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
decodedToken = DecryptString(HttpUtility.UrlDecode(token));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
decodedToken = DecryptString(token);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (decodedToken.Split(';')[2].Split('=')[0].Equals("myToken"))
|
||||
{
|
||||
var b = decodedToken.Split(';');
|
||||
private static bool TryAuthenticateWithGkv(HttpApplication context)
|
||||
{
|
||||
if (context.Request.FilePath.IndexOf("GkvAbrechnungClient.aspx") == -1)
|
||||
return false;
|
||||
|
||||
var a = DecryptString(new Regex(@"[\=]{1}").Split(b[2], 2)[1]);
|
||||
decodedToken += ";" + a;
|
||||
}
|
||||
if (!IsRequestIPValid("App8IpAddress"))
|
||||
return false;
|
||||
|
||||
var Params = decodedToken.Split(';');
|
||||
var useroidstr = context.Request.Params["useroid"];
|
||||
|
||||
return Params.Select(item => item.Split('=')).Where(a => a[0].Equals("tenant") || a[0].Equals("password") || a[0].Equals("user")).ToDictionary(a => a[0], a => a[1]);
|
||||
}
|
||||
if (!long.TryParse(useroidstr, out long useroid))
|
||||
return false;
|
||||
|
||||
private static string DecryptString(string strToDecrypt)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(strToDecrypt))
|
||||
{
|
||||
return "Beim Decodieren ist leider ein Fehler aufgetreten.";
|
||||
}
|
||||
SessionFacade.LoggedInUser = DAOFactory.GenericDAO.LoadByID<ApplicationUser>(useroid);
|
||||
|
||||
strToDecrypt = strToDecrypt.Replace(' ', '+');
|
||||
return true;
|
||||
}
|
||||
|
||||
if(strToDecrypt.Contains(","))
|
||||
{
|
||||
strToDecrypt = strToDecrypt.Split(',')[0];
|
||||
}
|
||||
public static bool IsRequestIPValid(string appsetting)
|
||||
{
|
||||
var clientip = GetRequestIP(true);
|
||||
var appsettingip = System.Configuration.ConfigurationManager.AppSettings[appsetting];
|
||||
|
||||
byte[] _Rc2IV = { 35, 138, 177, 253, 227, 63, 2, 27 };
|
||||
byte[] _Rc2Key = { 174, 130, 219, 185, 185, 221, 96, 50, 37, 212, 81, 121, 71, 206, 130, 153 };
|
||||
var lRc2CSP = new RC2CryptoServiceProvider();
|
||||
var lDecryptor = lRc2CSP.CreateDecryptor(_Rc2Key, _Rc2IV);
|
||||
#if DEBUG
|
||||
if (clientip == "::1")
|
||||
return true;
|
||||
#endif
|
||||
|
||||
strToDecrypt = strToDecrypt.Replace(' ', '+');
|
||||
strToDecrypt = strToDecrypt.Trim(',');
|
||||
return clientip == appsettingip;
|
||||
}
|
||||
|
||||
using (var msDecrypt = new MemoryStream(Convert.FromBase64String(strToDecrypt)))
|
||||
{
|
||||
using (var csDecrypt = new CryptoStream(msDecrypt, lDecryptor, CryptoStreamMode.Read))
|
||||
{
|
||||
var bytes = new List<byte>();
|
||||
int b;
|
||||
private static string GetRequestIP(bool CheckForward = false)
|
||||
{
|
||||
// https://stackoverflow.com/a/13249280
|
||||
|
||||
do
|
||||
{
|
||||
b = csDecrypt.ReadByte();
|
||||
string ip = null;
|
||||
if (CheckForward)
|
||||
{
|
||||
ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
|
||||
}
|
||||
|
||||
if(b != -1)
|
||||
{
|
||||
bytes.Add(Convert.ToByte(b));
|
||||
}
|
||||
if (string.IsNullOrEmpty(ip))
|
||||
{
|
||||
ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
|
||||
}
|
||||
else
|
||||
{ // Using X-Forwarded-For last address
|
||||
ip = ip.Split(',')
|
||||
.Last()
|
||||
.Trim();
|
||||
}
|
||||
|
||||
} while (b != -1);
|
||||
return ip;
|
||||
}
|
||||
|
||||
return Encoding.UTF8.GetString(bytes.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private static Dictionary<string, string> GetLoginInfoFromToken(string token)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(token))
|
||||
{
|
||||
return new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
string decodedToken;
|
||||
|
||||
token = token.Replace(' ', '+');
|
||||
token = token.Trim(',');
|
||||
|
||||
try
|
||||
{
|
||||
decodedToken = DecryptString(HttpUtility.UrlDecode(token));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
decodedToken = DecryptString(token);
|
||||
}
|
||||
|
||||
if (decodedToken.Split(';')[2].Split('=')[0].Equals("myToken"))
|
||||
{
|
||||
var b = decodedToken.Split(';');
|
||||
|
||||
var a = DecryptString(new Regex(@"[\=]{1}").Split(b[2], 2)[1]);
|
||||
decodedToken += ";" + a;
|
||||
}
|
||||
|
||||
var Params = decodedToken.Split(';');
|
||||
|
||||
return Params.Select(item => item.Split('=')).Where(a => a[0].Equals("tenant") || a[0].Equals("password") || a[0].Equals("user")).ToDictionary(a => a[0], a => a[1]);
|
||||
}
|
||||
|
||||
private static string DecryptString(string strToDecrypt)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(strToDecrypt))
|
||||
{
|
||||
return "Beim Decodieren ist leider ein Fehler aufgetreten.";
|
||||
}
|
||||
|
||||
strToDecrypt = strToDecrypt.Replace(' ', '+');
|
||||
|
||||
if (strToDecrypt.Contains(","))
|
||||
{
|
||||
strToDecrypt = strToDecrypt.Split(',')[0];
|
||||
}
|
||||
|
||||
byte[] _Rc2IV = { 35, 138, 177, 253, 227, 63, 2, 27 };
|
||||
byte[] _Rc2Key = { 174, 130, 219, 185, 185, 221, 96, 50, 37, 212, 81, 121, 71, 206, 130, 153 };
|
||||
var lRc2CSP = new RC2CryptoServiceProvider();
|
||||
var lDecryptor = lRc2CSP.CreateDecryptor(_Rc2Key, _Rc2IV);
|
||||
|
||||
strToDecrypt = strToDecrypt.Replace(' ', '+');
|
||||
strToDecrypt = strToDecrypt.Trim(',');
|
||||
|
||||
using (var msDecrypt = new MemoryStream(Convert.FromBase64String(strToDecrypt)))
|
||||
{
|
||||
using (var csDecrypt = new CryptoStream(msDecrypt, lDecryptor, CryptoStreamMode.Read))
|
||||
{
|
||||
var bytes = new List<byte>();
|
||||
int b;
|
||||
|
||||
do
|
||||
{
|
||||
b = csDecrypt.ReadByte();
|
||||
|
||||
if (b != -1)
|
||||
{
|
||||
bytes.Add(Convert.ToByte(b));
|
||||
}
|
||||
|
||||
} while (b != -1);
|
||||
|
||||
return Encoding.UTF8.GetString(bytes.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,8 @@ using static System.String;
|
||||
using Appointment = BeWo.Data.Entities.Appointment;
|
||||
using Login = BeWo.Data.Entities.Login;
|
||||
using Resource = BeWo.Data.Entities.Resource;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
|
||||
namespace BeWo.Data.Access
|
||||
{
|
||||
@@ -34,6 +36,24 @@ namespace BeWo.Data.Access
|
||||
{
|
||||
private static readonly Regex RecurrenceIdRegex = new Regex("(Id=\\\"[a-z0-9-]+\\\")");
|
||||
|
||||
private string LoadSQLStatement(string statementName)
|
||||
{
|
||||
string sqlStatement = string.Empty;
|
||||
|
||||
string namespacePart = "BeWo.Data.Access.Sqls";
|
||||
string resourceName = namespacePart + "." + statementName;
|
||||
|
||||
using (Stream stm = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
|
||||
{
|
||||
if (stm != null)
|
||||
{
|
||||
sqlStatement = new StreamReader(stm).ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
return sqlStatement;
|
||||
}
|
||||
|
||||
public IEnumerable<ValueListEntry> FindValueListEntry(ValueListEntryType pType)
|
||||
{
|
||||
return CreateCriteria<ValueListEntry>().Add(Restrictions.Eq(ValueListEntry.PropertyName_Type, pType)).AddOrder(Order.Asc(ValueListEntry.PropertyName_Value)).List<ValueListEntry>();
|
||||
@@ -1792,6 +1812,18 @@ WHERE sc.Billable = 1 and sr.StartDate >= '{0:yyyy-MM-dd}' and sr.StartDate < '{
|
||||
return lCriteria.List<GkvTransferProtokoll>();
|
||||
}
|
||||
|
||||
public decimal? GetGkvSumByDateRange(DateTime? start, DateTime? end)
|
||||
{
|
||||
var sql = LoadSQLStatement("GetGkvSumByDateRange.sql");
|
||||
|
||||
var rtn = Session.CreateSQLQuery(sql)
|
||||
.SetParameter(0, start ?? DateTime.MinValue)
|
||||
.SetParameter(1, end ?? DateTime.MaxValue)
|
||||
.UniqueResult<decimal>();
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
public IEnumerable<InvoiceBase> GetInvoiceBases(DateTime? startDate, DateTime? endDate, long costBearerOid, String invoiceId)
|
||||
{
|
||||
var lCriteria = CreateCriteriaIsActive<InvoiceBase>();
|
||||
|
||||
12
Data/Access/Sqls/GetGkvSumByDateRange.sql
Normal file
12
Data/Access/Sqls/GetGkvSumByDateRange.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
SELECT SUM(a1.Betrag)
|
||||
FROM gkvtransferprotokoll AS t1
|
||||
JOIN gkvabrechnung a1
|
||||
ON a1.Oid = t1.GkvAbrechnungOid
|
||||
WHERE t1.ErstelltAm > ?
|
||||
AND t1.ErstelltAm < ?
|
||||
AND t1.Oid = (
|
||||
SELECT MIN(Oid)
|
||||
FROM gkvtransferprotokoll AS t2
|
||||
WHERE t1.GkvAbrechnungOid = t2.GkvAbrechnungOid
|
||||
GROUP BY t2.GkvAbrechnungOid
|
||||
)
|
||||
@@ -699,6 +699,7 @@
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Access\Sqls\GetGkvSumByDateRange.sql" />
|
||||
<Content Include="ICD10\icd10.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data;
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.ServiceImplementations;
|
||||
using BS.Shared;
|
||||
@@ -19,6 +20,13 @@ using System.Web.UI.WebControls;
|
||||
|
||||
namespace Host
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Stellt einen Entpunkt für Clients dar.
|
||||
/// z.B. app2,app3,app4,...
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public partial class GkvAbrechnungClient : Page
|
||||
{
|
||||
private readonly string INVALID_INPUT = "Bad Request";
|
||||
@@ -74,8 +82,11 @@ namespace Host
|
||||
|
||||
private void ClientResult(GkvClientResultRequestDC req)
|
||||
{
|
||||
if (!SessionFacade.IsUserLoggedIn())
|
||||
SendErrorResponse(INVALID_INPUT + " 4");
|
||||
|
||||
if (req.ResultDCs is null || !req.ResultDCs.Any())
|
||||
SendInvalidInputResponse();
|
||||
SendErrorResponse(INVALID_INPUT + " 5");
|
||||
|
||||
// Response
|
||||
var response = new GkvResponseDC(false);
|
||||
@@ -102,24 +113,22 @@ namespace Host
|
||||
|
||||
private void ClientSum(GkvClientSumRequestJson req)
|
||||
{
|
||||
if (req.Tenant is null)
|
||||
SendInvalidInputResponse();
|
||||
|
||||
if (req.Start > req.End)
|
||||
SendInvalidInputResponse();
|
||||
SendErrorResponse(INVALID_INPUT + " 4");
|
||||
|
||||
if (!ASPHibernateSessionManager.IsRequestIPValid("GkvSumServerIPAdress"))
|
||||
SendErrorResponse(INVALID_INPUT + " 5");
|
||||
|
||||
// Response
|
||||
var response = new GkvClientSumResponseJson();
|
||||
|
||||
try
|
||||
{
|
||||
var service = new AccountingServiceImp();
|
||||
var sum = DAOFactory.SearchDAO.GetGkvSumByDateRange(req.Start, req.End);
|
||||
|
||||
var invoices = service.GetCompactGkvAbrechnungByTransferDateRange(req.Start, req.End);
|
||||
|
||||
if(invoices is object && invoices.Count > 0)
|
||||
if(sum is decimal s)
|
||||
{
|
||||
response.CompactGkvAbrechnungen = invoices.ToArray();
|
||||
response.Sum = s;
|
||||
response.Success = true;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -18,6 +18,13 @@ using Page = System.Web.UI.Page;
|
||||
|
||||
namespace Host
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Stellt einen Entpunkt für Server dar.
|
||||
/// Hier: app8
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public partial class GkvAbrechnungServer : Page
|
||||
{
|
||||
public const int PROCESS_WAITFOREXIT_MS = 10 * 1000;
|
||||
|
||||
@@ -245,7 +245,7 @@
|
||||
<add key="DakotaPath" value="C:\Program Files (x86)\ITSG\dakotale\dakota30.exe" />
|
||||
<add key="GkvSecretKey" value="DfDGNGn72PKfSYxSUsmRdzuBtpR9novewlmYU3gsjiFgSkaZZeylUXlbO42cWNqiKgLdMUFtWUNZT962F1raQDR7HGUzCNYsFeC" />
|
||||
<add key="App8IpAddress" value="88.198.50.220" />
|
||||
<add key="ServerSumIpAddress" value="88.198.50.220" />
|
||||
<add key="GkvSumServerIPAdress" value="88.198.50.220" />
|
||||
|
||||
<add key="SendMailModuleSmtpServer" value="mail.ownsoft.de" />
|
||||
<add key="SendMailModuleGkvEnabled" value="true" />
|
||||
|
||||
@@ -813,34 +813,6 @@ namespace BeWo.Service.ServiceImplementations
|
||||
|
||||
return dcs;
|
||||
}
|
||||
public List<CompactGkvAbrechnungDC> GetCompactGkvAbrechnungByTransferDateRange(DateTime? start, DateTime? end)
|
||||
{
|
||||
try
|
||||
{
|
||||
var entities = DAOFactory.SearchDAO.GetGkvTransferProtokollByDateRange(start, end);
|
||||
|
||||
var filter = entities.Where(x => x.SentDakotaSuccess);
|
||||
|
||||
var oids = filter.Select(x => x.GkvAbrechnungOid).Distinct();
|
||||
|
||||
if (!oids.Any())
|
||||
return null;
|
||||
|
||||
var list = new List<GkvAbrechnung>();
|
||||
|
||||
foreach (var oid in oids)
|
||||
{
|
||||
var abrechnung = DAOFactory.GenericDAO.LoadByID<GkvAbrechnung>(oid);
|
||||
list.Add(abrechnung);
|
||||
}
|
||||
|
||||
return MapperFactory.CompactGkvAbrechnungDC_GkvAbrechnung.MapToNewDCs(list);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Utils.CreateBeWoFaultException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public GkvAbrechnungCreateResponseDC CreateNewGkvAbrechnung(GkvAbrechnungCreateRequestDC request)
|
||||
{
|
||||
|
||||
@@ -38,13 +38,14 @@ namespace BS.Shared.AppSender
|
||||
}
|
||||
}
|
||||
|
||||
public static Res Send<Req, Res>(Req request, string url, string tenant) where Req : AppRequestDC where Res : AppResponseDC
|
||||
public static Res Send<Req, Res>(Req request, string url, string tenant = null) where Req : AppRequestDC where Res : AppResponseDC
|
||||
{
|
||||
request.Tenant = tenant;
|
||||
if (tenant != null)
|
||||
request.Tenant = tenant;
|
||||
|
||||
var data = JsonConvert.SerializeObject(request);
|
||||
|
||||
var response_app8_str = Send(url, data, tenant);
|
||||
var response_app8_str = Send(url, data, request.Tenant);
|
||||
|
||||
if (string.IsNullOrEmpty(response_app8_str))
|
||||
return null;
|
||||
@@ -101,7 +102,7 @@ namespace BS.Shared.AppSender
|
||||
|
||||
response = await client.UploadStringTaskAsync(url, "POST", dataString);
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace BS.Shared.DataContracts.GkvAbrechnung
|
||||
|
||||
}
|
||||
|
||||
[JsonProperty("gkvinvoices")]
|
||||
[DataMember] public CompactGkvAbrechnungDC[] CompactGkvAbrechnungen { get; set; }
|
||||
[JsonProperty("sum")]
|
||||
[DataMember] public decimal Sum { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user