Laden der Kunden Dlls im PluginLoader überarbeitet

This commit is contained in:
Christian
2023-09-25 19:03:08 +02:00
parent efcb086faf
commit 0820bbdae9
14 changed files with 170 additions and 225 deletions

View File

@@ -56,13 +56,7 @@ namespace ReportingService.Plugins
private static DefaultReportCreator CreateReportCreator()
{
var reportCreator = PluginLoader.FindClass<DefaultReportCreator>();
reportCreator.Tenant = PluginLoader.Tenant;
#if DEBUG
reportCreator.ReportPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"bin\" + PluginLoader.Tenant + "_reports.dll");
#else
reportCreator.ReportPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Customer\" + PluginLoader.Tenant + "_reports.dll");
#endif
return reportCreator;
}
}

View File

@@ -175,92 +175,19 @@ namespace ReportingService.ServiceImplementations
private static AbstractReportCreator GetReportCreator()
{
var derTenant = MultitenancyOperationContextExt.Current.Tenant;
AbstractReportCreator creator = null;
#if DEBUG
//Kundennummern zum Testen nur noch in PluginLoader eintragen:
derTenant = PluginLoader.Tenant;
var customerDllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"bin\" + derTenant + "_reports.dll");
#else
var customerDllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Customer\" + derTenant + "_reports.dll");
#endif
if (File.Exists(customerDllPath))
{
var allTypes = Assembly.LoadFrom(customerDllPath).GetTypes();
var reportCreator = allTypes.FirstOrDefault(i => typeof(AbstractReportCreator).IsAssignableFrom(i));
if (reportCreator != null)
{
creator = Activator.CreateInstance(reportCreator) as AbstractReportCreator;
}
}
if (creator == null)
creator = new DefaultReportCreator();
creator.Tenant = derTenant;
creator.ReportPath = customerDllPath;
AbstractReportCreator creator = PluginLoader.FindClass<DefaultReportCreator>();
#if DEBUG
creator.TempPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"demo\temp");
#else
creator.TempPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, derTenant + @"\temp");
creator.TempPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PluginLoader.Tenant + @"\temp");
#endif
return creator;
}
private static AbstractReportCreator GetReportCreator(string tenant)
{
AbstractReportCreator creator = null;
#if DEBUG
//Kundennummern zum Testen nur noch in PluginLoader eintragen:
tenant = PluginLoader.Tenant;
// Ist "C:\Users\lyndo\BeWo\BeWoPlanerMobil\bin\2387527289_reports.dll"
// statt "C:\Users\lyndo\BeWo\Host\bin\2387527289_reports.dll"
var path = @"..\Host\";
var customerDllPath = Path.Combine(path, @"bin\" + tenant + "_reports.dll");// Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"bin\" + tenant + "_reports.dll");
#else
var customerDllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Customer\" + tenant + "_reports.dll");
#endif
if (File.Exists(customerDllPath))
{
var allTypes = Assembly.LoadFrom(customerDllPath).GetTypes();
var reportCreator = allTypes.FirstOrDefault(i => typeof(AbstractReportCreator).IsAssignableFrom(i));
if (reportCreator != null)
{
creator = Activator.CreateInstance(reportCreator) as AbstractReportCreator;
}
}
if (creator == null)
{
creator = new DefaultReportCreator();
}
creator.Tenant = tenant;
creator.ReportPath = customerDllPath;
#if DEBUG
creator.TempPath = Path.Combine(path, @"demo\temp");
#else
creator.TempPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, tenant + @"\temp");
#endif
return creator;
}
private static BeWoEntityBase LoadToBargeldkasseRelatedObject(TableID pObjectTid, long pObjectOid)
{
switch (pObjectTid)
@@ -316,7 +243,7 @@ namespace ReportingService.ServiceImplementations
// Zum Test im MoK
public MemoryStream CreateKilometerauswertungForAllCustomersForWebVersion(List<long> customerOids, DateTime rangeDate, string tenant)
{
var reportCreator = GetReportCreator(tenant);
var reportCreator = GetReportCreator();
var report = reportCreator.CreateKilometerauswertungForAllCustomers(customerOids, null, new DateTime(rangeDate.Year, rangeDate.Month, 1), new DateTime(rangeDate.Year, rangeDate.Month, 1).AddMonths(1).AddDays(-1));
@@ -325,7 +252,7 @@ namespace ReportingService.ServiceImplementations
public MemoryStream CreateMedikamentenlistenReport(long mvlOid, string tenant)
{
var reportCreator = GetReportCreator(tenant);
var reportCreator = GetReportCreator();
var report = reportCreator.CreateMediVerordListenReport(mvlOid);