Files
BeWoPlaner/Service/Plugins/PluginLoader.cs

507 lines
25 KiB
C#

using System;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Reflection;
using BeWo.Data;
using BS.Shared.Core;
namespace BeWo.Service.Plugins
{
public class PluginLoader
{
public static String Tenant
{
get
{
#if DEBUG
var t = "demo";
t = "irgendwaswasesnichtgibt";
//t = "5473568546"; //Interner Chat
//t = "2356097460"; // Lebenshilfe Würzburg
//t = "1234567890"; // Präsentationsdatenbank
//t = "5687373602"; // LH Duisburg
//t = "5509064354"; // LH Duisburg Service Plus
//t = "5620636022"; // GPZ Biberach
//t = "8562233401"; // Sozialwirkstatt Schmitz
//t = "1076891970"; // Assistenza
//t = "0216265667"; // LH Hannover
//t = "1774789565"; // LH Essen
//t = "9342168675"; // ABC Betreuungen - jetzt Schubkraft
//t = "1193188501"; // Aids Hilfe Dortmund
//t = "7860351957"; // SKF Alsdorf
//t = "3311520228"; // Die Düne
//t = "1352143437"; // Sewo
//t = "7107514623"; // BeWo Neuss
//t = "9098141768"; // Fib e.V. Marburg
//t = "1505148718"; // VSD Hamm
//t = "5926081834"; // Spektrum
//t = "1378137009"; // BeWo Direkt+
//t = "3010479871"; // Aachener Verein
//t = "3849764093"; // Club 74
//t = "5805202339"; // Wegweiser Betreuungsdienst
//t = "2301474784"; // Hauskrankenpflege Leiendecker
//t = "8243565510"; // Der Karren
//t = "7709306800"; // Der Karren SBD
//t = "2499262621"; // HPH Bersenbrück
//t = "4950382346"; // Holsinger
//t = "5973016645"; // Verein Lebensgestaltung Hanau
//t = "7375324044"; // Diakonie KK Kleve
//t = "1441747891"; // BeWo Mobil Köln
//t = "5120047701"; // Trialog
//t = "3629696651"; // Soziale Dienste Niederrhein (SDN)
//t = "9893557471"; // Caritas Frankfurt
//t = "2918696314"; // Caritas Frankfurt 2
//t = "6923790936"; // Integra e.V.
//t = "2392153512"; // Christopherus Haus
//t = "9495336024"; // VKM Aachen
//t = "5237724939"; // Indro ABW
//t = "7635986435"; // Köln Ring
//t = "4074176860"; // Soziale Dienstleistung Gessner
//t = "2542550178"; // LWVEingliederungshilfe
//t = "3963982016"; // Convoi
//t = "1600408120"; // BeWo Amrath
//t = "3886054624"; // Brücke ABW
//t = "2028095630"; // Integra Heinsberg
//t = "5351926758"; // Viva a Vida
//t = "2215396183"; // Diakonie Remscheid Lennep
//t = "5157599087"; // SHG Schwerte
//t = "4526293996"; // Fortis
//t = "3647969417"; // Caritas Bottrop
//t = "3057313346"; // SSB Mainz
//t = "6246287823"; // BeWo Alsdorf
//t = "1420341656"; // Vibb Essen
//t = "4941141927"; // Signcom
//t = "8897605322"; // SPZ Ratingen
//t = "6483870127"; // Wigonetz
//t = "9482484652"; // Blömeling und Teckhaus
//t = "8001550599"; // Biallas BeWo
//t = "7282396774"; // Caritas Unna
//t = "6884855402"; // IBP
//t = "4867997795"; // ADiK Kleve
//t = "3184859776"; // Sergej Becker
//t = "7752610643"; // BWK Gbr
//t = "3785623125"; // Betreuwo
//t = "7130228334"; // LH Borken
//t = "4209820830"; // VKM Hamm
//t = "5700328131"; // Betreutes Wohnen St. Ludgerus Essen-Werden
//t = "1907984777"; // Soziale Dienste Katrin Schmidt
//t = "9033246467"; // SKM Menden
//t = "9290510010"; // Soziale Dienste Schilling (ehemals BeWo Schilling)
//t = "5251218094"; // KOMO e.V.
//t = "3529871747"; // Talis GmbH (vorher Vivat gemeinnützige GmbH, Projekt VivatgGmbHReports)
//t = "8561513464"; // Caritasverband Wuppertal/Solingen
//t = "2727001973"; // SD Julia Schönberg
//t = "5653806613"; // Feid und Kollegen
//t = "3830114427"; // FiZ Familie im Zentrum Hof
//t = "7138297573"; // Tagwerk betreutes wohnen
//t = "1008896531"; // BeWo Auxilio
//t = "9383760246"; // Die Kette
//t = "5915565037"; // Lebenshilfe Remscheid
//t = "3350425974"; // BeWo Rückenwind
//t = "9447917179"; // LH Rodenkirchen
//t = "4690407894"; // Bleib im Leben
//t = "2509786400"; // LH Stade
//t = "8677523325"; // BeWo Richartz
//t = "1765854593"; // Mein Betreutes Wohnen
//t = "6802909544"; // Lebenshilfe Coburg
//t = "9417634361"; // Synprax
//t = "5761861730"; // Lebenshilfe Warendorf
//t = "6712648331"; // BeWo Färber
//t = "4982295287"; // ASB Hamm
//t = "3890031575"; // Die Wohnhelfer Kuhrau
//t = "3536719736"; // BeWo Stefanie Schäfer (BeWoKerpen)
//t = "7739670213"; // SPZ Leverkusen
//t = "3341456098"; // Hilfe Daheim (früher BeWo Schillinger)
//t = "4271389563"; // Komm Mit
//t = "5430005891"; // Marienhospital Eickel
//t = "3265049248"; // Gerdas Pflegedienst
//t = "1549622397"; // Kontakt und Krisenhilfe
//t = "4782194565"; // Skm Rheydt
//t = "7535795843"; // Sozialwerk Dürener Christen
//t = "6388340414"; // Weitblick
//t = "0288588964"; // BeWo Marin
//t = "8872796313"; // WMB
//t = "6297638711"; // ASB Bergisch Gladbach
//t = "5553641242"; // RheinSupport (ehem. Aids und Drogenberatung)
//t = "1218057423"; // LH Koblenz
//t = "3517812158"; // Haus Theresia
//t = "7058292376"; // BeWo Heinsberg
//t = "3227700467"; // Psychosozialer Trägerverein
//t = "4378753169"; // Die Wohnhelfer Köln
//t = "2214258555"; // Betreuungsbüro Baak
//t = "4525013596"; // Hph Bersenbrück Freizeit und Reisen
//t = "1609455614"; // Hph Bersenbrück Aph
//t = "7852961459"; // B&B Betreutes Wohnen
//t = "8719930557"; // Lebenshilfe Rhein-Sieg
//t = "8947336185"; // Lebenshilfe Ahrweiler
//t = "5712358157"; // FINDUS
//t = "8828216586"; // Caritas Aachen
//t = "7062943632"; // ABW Elsebrock
//t = "3956369664"; // LH Wetterau
//t = "3984525482"; // API Berlin
//t = "9975231461"; // Selwo
//t = "8181286349"; // BeWo am Rhein
//t = "4595275645"; // Eigenständig
//t = "7912635399"; // Prof. Dr. Eggers Stiftung
//t = "3549726254"; // Socia
//t = "1992495802"; // Monvita
//t = "7381352241"; // Ressource e.V.
//t = "3607551608"; // Betreuungsbüro Scholz
//t = "3104936392"; // B.A.P. Bielefelder Ambulante Pflege
//t = "1106039294"; // Hph Bersenbrück ATZ
//t = "5562845955"; // Praunheimer Werkstätten
//t = "4801617798"; // Severin
//t = "1172092025"; // Flingern
//t = "3852198843"; // LH Mannheim
//t = "9800364930"; // BeWo Leverkusen
//t = "4439874912"; // BeWo Sahin
t = "1873138856"; // BUG e.V.
//t = "6463422907"; // Caritas Leverkusen
//t = "6149463003"; // Diakonisches Werk Bad Windsheim Neustadt a. d. Aisch
//t = "6548202677"; // VKM Aachen SBD
//t = "7803602698"; // Taubblindendienst
//t = "5518600303"; // Wetterleuchten e.V.
//t = "4096649015"; // AWO Dortmund
//t = "3614251071"; // Pusteblume
//t = "7755740484"; // Sawo
//t = "8275654834"; // Twg Jonathan
//t = "6586058528"; // Freundeskreis Suchtkrankenhilfe e.V. (FFS)
//t = "2632162696"; // Hand in Hand (ehemals Pro BeWo Düren)
//t = "6340891020"; // Caritas Ahlen
//t = "3659854106"; // alpha e.V.
//t = "5809130435"; // Lebenshilfe Kusel
//t = "3367947706"; // PaS Mönchengladbach
//t = "2331203795"; // BeWo für dich
//t = "5426234256"; // SKM Leverkusen
//t = "4137042939"; // MLG Lebengestalten / Haus Müllestumpe
//t = "5260936181"; // LORI
//t = "1931553444"; // HIBA
//t = "7185338722"; // BeWo Walz & Paiva
//t = "3196643272"; // Betreutes Wohnen Lisa Wöll
//t = "3432911735"; // Caritas Günzburg - Neu Ulm
//t = "2591682148"; // Humanitas
//t = "9805564204"; // LeWo Aachen
//t = "7215356798"; // Triathlon
//t = "3664416736"; // LH Mönchengladbach
//t = "4290816992"; // BeWo im flow
//t = "3612443220"; // ABW Weeger
//t = "6265842607"; // BeWo Dienstleistungen Pougin und Klaasen
//t = "9273332501"; // Pflegedienst Wessel
//t = "4693476852"; // HSH Netzwerk
//t = "3884496709"; // Wahl e.V.
//t = "9883255779"; // VKM Menden (mobil GmbH)
//t = "9556218062"; // Diakonie Landshut
//t = "2279593936"; // Diakonie Mülheim
//t = "3623837005"; // Betreuwo Wesel
//t = "8407321888"; // AWO Wesel
//t = "8454426692"; // Mit-Menschen Wuppertal
//t = "0629004412"; // BeWo-Colonia Basaran (Projekt
//t = "7668701607"; // Wohnstätten Essen
//t = "3833058951"; // Aids Hilfe Duisburg (Self)
//t = "9463879250"; // ABW Dziallas und Muhrin
//t = "7964339639"; // Lebenshilfe Trier
//t = "1477928721"; // ASB Regionalverband Rhein-Erft/Dueren e.V.
//t = "6178990609"; // Johannes-Diakonie Mosbach
//t = "7185105541"; // Nous GmbH
//t = "5022131330"; // Tabula Rasa
//t = "4189934785"; // Landshuter Netzwerke
//t = "7584236951"; // Aachener Betreuungsbüro Kirschbaum und Manz GbR
//t = "3678599942"; // VKM Rietberg
t = "4069072369"; // BeWo Dreilich&Pastor (Projekt TranskulturellesBBPastor)
//t = "4160851689"; // BeWo Dreilich&Pastor (Dreilich)
//t = "9970072066"; // Bussmannshof
//t = "2993745954"; // Kollegium für freie Jugendarbeit und Berufsbildung e.V.
//t = "5495240031"; // Christian Luft
//t = "6922762575"; // BHS Solingen
//t = "3472573348"; // ASB Mönchengladbach
//t = "8831599797"; // SeHT Münster
//t = "7817461089"; // FAB e.V. (Familienarbeit und Beratung e.V.)
//t = "5207911843"; // Pro Balance
//t = "8619663355"; // HSH Cologne
//t = "1652658918"; // LH Frankfurt Oder
//t = "7696927868"; // Kuhring Betreuung
//t = "6251348980"; // BeWo Gün
//t = "6782533512"; // LH Dorsten
//t = "5890882255"; // Fortis Nova
//t = "2422863972"; // Diakonisches Werk Mülheim (Therapeutische Wohngemeinschaft)
//t = "2141858509"; // INKOMM GmbH
//t = "8975059766"; // Quer-Fällt-Ein
//t = "8928179244"; // ASB Ruhr e.V. Regionalverband
//t = "4423043131"; // Die Perspektive e.V.
//t = "5263375280"; // LH Wolfsburg
//t = "4900722829"; // Evangelische Kirchengemeinde Bottrop
//t = "9853685258"; // Input
//t = "7622428090"; // Freie gemeinnützige Beratungsstelle für Psychotherapie e.V. (BfpDus) (Panama)
//t = "0206140343"; // Lebenswelt Gabriel
//t = "6916712798"; // LH Rodenkirchen Bewo
//t = "6255521162"; // KCM GmbH
//t = "2697528233"; // Diakonisches Werk Wesel
//t = "2547623489"; // Sprungbrett
//t = "5076807716"; // Psychosoziale Hilfen Bochum e.V.
//t = "1601313225"; // Bella Donna
//t = "5098825926"; // SAB GmbH
//t = "7808149226"; // BeWo Flex
//t = "7419804320"; // Gender Bewo
//t = "4500422855"; // BeWo Nordeifel
//t = "3565931805"; // Betreuungsbüro Frank Röhrig
//t = "4152581290"; // MVZ Medikus GmbH (Stoffwechsel Betreutes wohnen)
//t = "4529320405"; // BeWo Stelzel
//t = "2594047883"; // KOMM Ambulante Dienste e. V.
//t = "1558685648"; // KIMM
//t = "3460972350"; // Caritas Kleve I
//t = "2623845876"; // Passgenau Hildesheim
//t = "4368361336"; // Kompass BeWo Wesel
//t = "3257905806"; // Diakonisches Werk Herne
//t = "2535794597"; // Mobilo Ambulant
//t = "7114701269"; // Die Brücke Hilfe und Halt
//t = "6447060239"; // Empathie Fachassistenz
//t = "6919016656"; // Leben und Wohnen Christian Wilke
//t = "8281327384"; // Caritasverband Düren-Jülich e.V. (Eingliederungshilfe)
//t = "6023735102"; // Kölner BeWo (Selbstbestimmt Leben)
//t = "2998118179"; // BeWo Plus
//t = "9254115251"; // Praunheimer Werkstätten 2.DB
//t = "5880845152"; // Bewegt Systemische Beratung und Begleitung (Kathrin Lilly)
//t = "5798370140"; // Team Pfeil
//t = "8242644560"; // Bewolonia - Fr. Sultan Schulz
//t = "4817284046"; // Verein für Sozialmedizin Stade e.V.
//t = "6323001211"; // ASB Faßbacher Hof gGmbH
//t = "9389386079"; // VARO Sozialagentur
//t = "7951718431"; // Ambulant Betreutes Wohnen Astrid Pulm
//t = "5850903700"; // Alzey Teilhabe
//t = "5929601293"; // Lebenshilfe Duisburg Frühförderung (Projekt heißt LebenshilfeDuisburgAtz)
//t = "6860475645"; // Lebenshilfe Duisburg ATZ (Projekt heißt LebenshilfeDuisburgAtz6860475645)
//t = "9678360705"; // Lebenshilfe Duisburg HPTG (Projekt heißt LebenshilfeDuisburgHPTG)
//t = "4823067940"; // Die Kette 2
//t = "8283849714"; // Forum e.V. (proviel GmbH)
//t = "3915346496"; // Sprungbrett 2. DB (Haus Theresia)
//t = "2387527289"; // Lebenshilfe Duisburg HPFH
//t = "2314784470"; // Lebenshilfe Duisburg BeWo
//t = "5595701056"; // Domiziel Ansbach
//t = "9430188510"; // Pro INTEGRA
//t = "4820371076"; // Zuhause Wohnen Iris Thimm
//t = "1078667960"; // FAM Rhein-Sieg Gbr
//t = "9388871209"; // Sozialwerk Aachener Christen e.V.
//t = "1566251835"; // Sicherleben Michael Voß
//t = "4947061147"; // Diakonisches Werk Passau
//t = "9064234785"; // BeWo Rimbach
//t = "9433783300"; // Wichernhaus gGmbH
//t = "6282665941"; // Diakonisches Werk Regensburg
//t = "7712740386"; // Heimstatt St. Marien e.V. (Carl-Sonnenscheinhaus)
//t = "5537187628"; // Verband Ev. Kirchengemeinden Dorsten
//t = "8375099271"; // Neustart - Ambulant Betreutes Wohnen
//t = "5478434972"; // LebensWert - Kai Lippel
//t = "5381886394"; // PZDDuesseldorf
//t = "3640152169"; // Claudia Charisius
//t = "3536079480"; // Behindertenhilfe Menden
//t = "5427523619"; // Christopherus-Haus Familienhilfe
//t = "8251343124"; // Rat Plus Tat
//t = "6819347851"; // Awo Kreisverband Plön
//t = "2385915144"; // AKGG GmbHd
//t = "8002913382"; // AKGG GmbH (MID)
//t = "5155880294"; // BHV Bergische Hauspflege
//t = "8366649557"; // Münchner Aids-Hilfe e.V.
//t = "2976949196"; // WHB Refrath gGmbH
//t = "3563903598"; // ABW Münster
//t = "1344064965"; // ABW Klaßen
//t = "3625103678"; // Pro Hilfe GbR | MID
//t = "6028314513"; // Grundstein e.V.
//t = "6178735147"; // Ilka Link ivi. - ambulante Hilfen, Beratung & Therapie
//t = "9416221963"; // Übergangshilfe Unna e.V.
//t = "1316958991"; // Aidshilfe Essen
//t = "3718732195"; // Diakonie Remscheid Lennep (Jobfit)
//t = "4858885375"; // BewoTrio
//t = "9734214365"; // Wegfinder Rhein-Ruhr
//t = "1011478760"; // Autismus Köln/Bonn e.V.
//t = "8184278271"; // Ambulant Betreutes Wohnen Stephan Schillings
//t = "2576513996"; // TRIAS Ambulante Sozialarbeit Schön + Schön-Uhlmann GbR
//t = "9518001524"; // Sozialpädagogische Praxis Astrid Schnödewind
//t = "1048483934"; // Frauenhaus e.V. EWFRA - Wohnprojekt für Frauen
//t = "4293131072"; // ASB Rhein-Erft/Düren e.V. Schulbegleitung
//t = "2221228727"; // Autismus Leben gGmbH
//t = "5065709552"; // Biotop e.V.
//t = "9094672461"; // Transkulturelles Betreuungsbüro (Toprak GmbH)
//t = "9008813932"; // Aids Hilfe Giessen
//t = "4052216789"; // Perspektiven e.V.
//t = "7663765314"; // Christina Frommen (Frommen BeWo)
//t = "5462295916"; // BeWo Dellbrueck
//t = "2120989920"; // Sozialbüro Schüßler und Wilckens GbR
//t = "9815376800"; // Haus Dülken GmbH + Co. KG
//t = "6917917884"; // AMBEWO Müller/Gerhards
//t = "5240630948"; // Caritasverband der Diözese Rottenburg-Stuttgart e.V. - Rechtsträger der Caritas Heilbronn Hohenlohe e.V. (Projekt heißt CaritasHeilbronnHohenlohe)
//t = "7748694330"; // Caritasverband der Diözese Rottenburg-Stuttgart e.V. als Rechtsträger der Caritas Ludwigsburg-Waiblingen-Enz (Projekt heißt CaritasLudwigsburgWaiblingenEnz)
//t = "5578206856"; // SHK Service GmbH
//t = "1508800817"; // Behindert na und e.V.
//t = "4351087063"; // MOBILE e.V. - Selbstbestimmtes Leben
//t = "1262219859"; // Psychosoziale Projekte Saarpfalz
//t = "2986016022"; // Ev Verein für Wohnraumhilfe Frankfurt a.M.
//t = "2181497347"; // BetreuungsserviceFuerAlltagUndWohnen (BAW Aachen)
//t = "5433105975"; // aha e.V.
//t = "7396826106"; // SKF Sozialdienst katholischer Frauen e.V. Leverkusen
//t = "4748304562"; // BeWo Darmstadt
//t = "5315865694"; // Wismarer Werkstätten GmbH
//t = "6971328056"; // SKM Krefeld
//t = "4199238586"; // MeZ Menden;
//t = "3226307161"; // Roman Roger Puth
//t = "3522103738"; // AWO Münsterland-Recklinghausen
//t = "5592509446"; // Kontakt Verein für psychosoziale Hilfen e.V
//t = "5344902949"; // SHK Service GmbH SBD
//t = "1422963536"; // Malteser-Johanniter-Johanneshaus gGmbH
//t = "5433105975"; // aha e.V.
//t = "1701920223"; // SKFM Monheim
//t = "5484692276"; // SPEKTRUM GmbH
//t = "4434019324"; // FENIX Soziale Dienste
//t = "6219220038"; // SKM Kreis Viersen e.V.
//t = "1372050368"; // Petra Wagner Matthes
return t;
#else
if (MultitenancyOperationContextExt.Current != null)
return MultitenancyOperationContextExt.Current.Tenant;
return SessionFacade.Tenant;
#endif
}
}
public static String CustomerPluginPath()
{
var path = ConfigurationManager.AppSettings.Get("PluginPath");
if (path != null)
{
return Path.Combine(path, Tenant + "_reports.dll");
}
#if DEBUG
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"bin\" + Tenant + "_reports.dll");
#else
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Customer\" + Tenant + "_reports.dll");
#endif
}
public static T FindClass<T>() where T : new()
{
var t = FindClass<T>(null, null);
if (t == null)
{
t = new T();
}
return t;
}
public static T FindClass<T>(string specificId)
{
return FindClass<T>(specificId, null);
}
public static T FindClass<T>(string specificId, string typename)
{
Type[] lAllTypes = null;
var type = typeof(T);
if (Tenant != null)
{
if (File.Exists(CustomerPluginPath()))
lAllTypes = Assembly.LoadFrom(CustomerPluginPath()).GetTypes();
}
T result = default(T);
if (lAllTypes != null)
result = FindClass<T>(lAllTypes, specificId, typename);
return result;
}
public static T FindClass<T>(Type[] lAllTypes, string specificId, string typename)
{
T result = default(T);
if (!string.IsNullOrEmpty(specificId) && !string.IsNullOrEmpty(typename))
{
var cbSpecific = lAllTypes
.Where(i => typeof(T).IsAssignableFrom(i))
.FirstOrDefault(t => t.GetCustomAttributes(typeof(IDSpecificClassAttribute), true)
.ToList()
.Exists(i =>
{
var attr = (IDSpecificClassAttribute)i;
if (attr.Identifiers != null)
return attr.Identifiers.Contains(specificId);
if (!String.IsNullOrEmpty(attr.Identifier))
return attr.Identifier.Equals(specificId);
return false;
}
) && t.FullName == typename);
if (cbSpecific != null)
result = (T)Activator.CreateInstance(cbSpecific);
}
if (!string.IsNullOrEmpty(typename))
{
var cbSpecific = lAllTypes.FirstOrDefault(t => t.FullName == typename);
if (cbSpecific != null)
result = (T)Activator.CreateInstance(cbSpecific);
}
if (!string.IsNullOrEmpty(specificId))
{
var cbSpecific = lAllTypes
.Where(i => typeof(T).IsAssignableFrom(i))
.FirstOrDefault(t => t.GetCustomAttributes(typeof(IDSpecificClassAttribute), true)
.ToList()
.Exists(i =>
{
var attr = (IDSpecificClassAttribute)i;
if (attr.Identifiers != null)
return attr.Identifiers.Contains(specificId);
if (!String.IsNullOrEmpty(attr.Identifier))
return attr.Identifier.Equals(specificId);
return false;
}
));
if (cbSpecific != null)
result = (T)Activator.CreateInstance(cbSpecific);
if (result == null)
{
foreach (var iType in lAllTypes)
if (typeof(T).IsAssignableFrom(iType))
if (iType.Name == specificId)
result = (T)Activator.CreateInstance(iType);
}
}
if (result == null)
{
var list2 = lAllTypes.Where(t => typeof (T).IsAssignableFrom(t)).ToList();
var list = list2.Where(t => t.GetCustomAttributes(typeof (IgnoreAutoPluginAttribute), true).Length == 0).ToList();
if (list.Count == 1)
result = (T)Activator.CreateInstance(list[0]);
else if (list.Count > 1)
{
foreach (var type in list)
{
var attrs = type.GetCustomAttributes(typeof(IDSpecificClassAttribute), true);
if (attrs.Length == 0)
return (T)Activator.CreateInstance(type);
}
result = (T)Activator.CreateInstance(list[0]);
}
}
return result;
}
}
}