diff --git a/BeWo/BeWoApp.xaml.cs b/BeWo/BeWoApp.xaml.cs index 50bd7b37d..30aec748f 100644 --- a/BeWo/BeWoApp.xaml.cs +++ b/BeWo/BeWoApp.xaml.cs @@ -49,8 +49,8 @@ namespace BeWo public static LoginControl LoginControl; public static MainControl MainControl; - public static string ShortVersion = "3.21"; - public static string Version = "Version 3.21.3 (GKV Test)"; + public static string ShortVersion = "3.22"; + public static string Version = "Version 3.22.3 (GKV Test)"; public static int RenderTier = 0; diff --git a/Data/Security/UserRightHelper.cs b/Data/Security/UserRightHelper.cs index 76675b11e..322adc57c 100644 --- a/Data/Security/UserRightHelper.cs +++ b/Data/Security/UserRightHelper.cs @@ -12,22 +12,25 @@ namespace BeWo.Data.Security { public class UserRightHelper { - public static ApplicationUser GetLoggedInUser() - { + public static readonly string BASE_VERSION = "1.0"; - if (LoggedInUserOperationContextExt.Current != null && - LoggedInUserOperationContextExt.Current.User != null) - { - return LoggedInUserOperationContextExt.Current.User; - } - else - { - return SessionFacade.LoggedInUser; - } + public static ApplicationUser GetLoggedInUser() + { + return LoggedInUserOperationContextExt.Current?.User ?? SessionFacade.LoggedInUser; + + //if (LoggedInUserOperationContextExt.Current != null && + // LoggedInUserOperationContextExt.Current.User != null) + //{ + // return LoggedInUserOperationContextExt.Current.User; + //} + //else + //{ + // return SessionFacade.LoggedInUser; + //} - return null; - } + //return null; + } public static bool LoggedInUserHasRight(UserRightType right) { @@ -102,14 +105,14 @@ namespace BeWo.Data.Security var version = GetBeWoVersion(GetLoggedInUser().LoginName); CheckRightVersion(version, groupDC); } - + public static void CheckRightVersion(String version, UserDC userDC) - { + { foreach (var ug in userDC.UserGroups) { CheckRightVersion(version, ug); } - + } public static void CheckRightVersion(String version, UserGroupDC ug) @@ -123,7 +126,7 @@ namespace BeWo.Data.Security ug.Rights.Add(r); } } - + } public static bool IsCorrectVersion(UserRightType r, string version) @@ -155,7 +158,26 @@ namespace BeWo.Data.Security { return "3.21"; } - return "1.0"; + + var rights_3_22 = new List { + UserRightType.WohnheimView_Wohneinheit_Belegung_Create, + UserRightType.WohnheimView_Wohneinheit_Belegung_Delete, + UserRightType.WohnheimView_Wohneinheit_Belegung_Edit, + UserRightType.WohnheimView_Wohneinheit_Belegung_View, + UserRightType.WohnheimView_Wohneinheit_Create, + UserRightType.WohnheimView_Wohneinheit_Delete, + UserRightType.WohnheimView_Wohneinheit_Edit, + UserRightType.WohnheimView_Wohneinheit_View, + UserRightType.Customer_Falldaten_Edit, + UserRightType.Customer_Falldaten_View + }; + + if (rights_3_22.Contains(r)) + { + return "3.22"; + } + + return BASE_VERSION; } } } diff --git a/Shared/Core/EnumTranslations.cs b/Shared/Core/EnumTranslations.cs index 6926916c5..0244fba0c 100644 --- a/Shared/Core/EnumTranslations.cs +++ b/Shared/Core/EnumTranslations.cs @@ -626,6 +626,8 @@ namespace BS.Shared.Core { var dict = new Dictionary(); + dict.Add(UserRightType.CreateAll, Translator.Translate("Alles anlegen")); + dict.Add(UserRightType.AccountingTransactionView_Create, Translator.Translate("Finanzen anlegen")); dict.Add(UserRightType.AccountingTransactionView_Delete, Translator.Translate("Finanzen löschen")); dict.Add(UserRightType.AccountingTransactionView_Edit, Translator.Translate("Finanzen ändern")); @@ -694,16 +696,19 @@ namespace BS.Shared.Core dict.Add(UserRightType.PersonView_Edit, Translator.Translate("Personen ändern")); dict.Add(UserRightType.PersonView_View, Translator.Translate("Personen ansehen")); dict.Add(UserRightType.Person_FamilyView, Translator.Translate("Personen Familienangehörige ansehen")); + dict.Add(UserRightType.GroupOfPeopleView_Edit, Translator.Translate("Gruppen bearbeiten")); dict.Add(UserRightType.GroupOfPeopleView_Create, Translator.Translate("Gruppen anlegen")); dict.Add(UserRightType.GroupOfPeopleView_Delete, Translator.Translate("Gruppen löschen")); dict.Add(UserRightType.AdditionalService_View, Translator.Translate("Ergänzende Dienste ansehen")); dict.Add(UserRightType.AdditionalService_Edit, Translator.Translate("Ergänzende Dienste bearbeiten")); dict.Add(UserRightType.OvertimeView, Translator.Translate("Überstundenverwaltung")); + dict.Add(UserRightType.QueryView_Create, Translator.Translate("Auswertungen anlegen")); dict.Add(UserRightType.QueryView_Delete, Translator.Translate("Auswertungen löschen")); dict.Add(UserRightType.QueryView_Edit, Translator.Translate("Auswertungen ändern")); dict.Add(UserRightType.QueryView_View, Translator.Translate("Auswertungen ansehen (Berichte, Stundenübersicht, Hilfeplanübersicht)")); + dict.Add(UserRightType.Analysis_Settlement_View, Translator.Translate("Finanzen Spitzabrechnung erstellen")); dict.Add(UserRightType.Analysis_EmployeeOverviewAll_View, "Auswertungen für alle " + Translator.Translate("MitarbeiterPlural") + " erstellen"); dict.Add(UserRightType.Analysis_ServiceOverview_View, Translator.Translate("Auswertungen->Quittierungsbelege")); @@ -714,18 +719,20 @@ namespace BS.Shared.Core dict.Add(UserRightType.Analysis_Auslastung_View, "Auswertungen->" + Translator.Translate("MitarbeiterPlural") + "auslastung"); dict.Add(UserRightType.Analysis_AuslastungAllEmployee_View, "Auswertungen->" + Translator.Translate("MitarbeiterPlural") + "auslastung für alle " + Translator.Translate("MitarbeiterPlural")); dict.Add(UserRightType.Analysis_AuslastungTeam_View, "Auswertungen->" + Translator.Translate("MitarbeiterPlural") + "auslastung für alle Teams"); + dict.Add(UserRightType.Kilometerauswertung_View, "Auswertungen->Kilometerauswertung (für alle " + Translator.Translate("MitarbeiterPlural") + ")"); dict.Add(UserRightType.KilometerauswertungEigene_View, Translator.Translate("Auswertungen->Kilometerauswertung (nur eigene)")); dict.Add(UserRightType.BewertungAuswertung_View, Translator.Translate("Auswertungen->Bewertung")); dict.Add(UserRightType.PivotTabelleAnsehen, Translator.Translate("Auswertungen->Pivot Tabelle")); dict.Add(UserRightType.DienstplanungAnsehen, Translator.Translate("Auswertungen->Dienstplanung")); dict.Add(UserRightType.AbwesenheitsPlanungAnsehen, Translator.Translate("Auswertungen->Urlaubsplanung")); + dict.Add(UserRightType.ResourceBookingView_Create, Translator.Translate("Ressourcen anlegen")); dict.Add(UserRightType.ResourceBookingView_Delete, Translator.Translate("Ressourcen löschen")); dict.Add(UserRightType.ResourceBookingView_Edit, Translator.Translate("Ressourcen ändern")); dict.Add(UserRightType.ResourceBookingView_View, Translator.Translate("Ressourcen ansehen")); dict.Add(UserRightType.ResourceBookingView_AllowEditResourcesFromOtherEmployees, "Ressourcen anderer " + Translator.Translate("MitarbeiterPlural") + " ändern"); - dict.Add(UserRightType.CreateAll, Translator.Translate("Alles anlegen")); + dict.Add(UserRightType.ServiceRecordView_Create, Translator.Translate("Zeiterfassung anlegen")); dict.Add(UserRightType.ServiceRecordView_Delete, Translator.Translate("Zeiterfassung löschen")); dict.Add(UserRightType.ServiceRecordView_Edit, Translator.Translate("Zeiterfassung ändern")); diff --git a/TranslationUnitTest/EnumTranslationTest.cs b/TranslationUnitTest/EnumTranslationTest.cs index bca3e9a0a..742d60131 100644 --- a/TranslationUnitTest/EnumTranslationTest.cs +++ b/TranslationUnitTest/EnumTranslationTest.cs @@ -1,4 +1,5 @@ -using BS.Shared; +using BeWo.Data.Security; +using BS.Shared; using BS.Shared.Core; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; @@ -10,13 +11,228 @@ namespace TranslationUnitTest public class EnumTranslationTest { public Dictionary Dict { get; set; } + public List UserRightTypesVersion1dot0 { get; set; } [TestInitialize] public void Init() { Dict = EnumTranslations.UserRightType2Translations; - } + UserRightTypesVersion1dot0 = new List() { + UserRightType.None, + UserRightType.DeleteAll, + UserRightType.CreateAll, + UserRightType.EditAll, + UserRightType.ViewAll, + UserRightType.ServiceRecordView_View, +UserRightType.ServiceRecordView_Edit, +UserRightType.ServiceRecordView_Create, +UserRightType.ServiceRecordView_Delete, +UserRightType.AccountingTransactionView_View, +UserRightType.AccountingTransactionView_Edit, +UserRightType.AccountingTransactionView_Create, +UserRightType.AccountingTransactionView_Delete, +UserRightType.ResourceBookingView_View, +UserRightType.ResourceBookingView_Edit, +UserRightType.ResourceBookingView_Create, +UserRightType.ResourceBookingView_Delete, +UserRightType.QueryView_View, +UserRightType.QueryView_Edit, +UserRightType.QueryView_Create, +UserRightType.QueryView_Delete, +UserRightType.SupportConceptView_View, +UserRightType.SupportConceptView_Edit, +UserRightType.SupportConceptView_Create, +UserRightType.SupportConceptView_Delete, +UserRightType.CustomerView_View, +UserRightType.CustomerView_Edit, +UserRightType.CustomerView_Create, +UserRightType.CustomerView_Delete, +UserRightType.OrganisationView_View, +UserRightType.OrganisationView_Edit, +UserRightType.OrganisationView_Create, +UserRightType.OrganisationView_Delete, +UserRightType.PersonView_View, +UserRightType.PersonView_Edit, +UserRightType.PersonView_Create, +UserRightType.PersonView_Delete, +UserRightType.EmployeeView_View, +UserRightType.EmployeeView_Edit, +UserRightType.EmployeeView_Create, +UserRightType.EmployeeView_Delete, +UserRightType.TeamView_ViewAll, +UserRightType.TeamView_Edit, +UserRightType.TeamView_Create, +UserRightType.TeamView_Delete, +UserRightType.UserView_View, +UserRightType.UserView_Edit, +UserRightType.UserView_Create, +UserRightType.UserView_Delete, +UserRightType.UserGroupView_View, +UserRightType.UserGroupView_Edit, +UserRightType.UserGroupView_Create, +UserRightType.UserGroupView_Delete, +UserRightType.AdministrationView_View, +UserRightType.AdministrationView_Edit, +UserRightType.AdministrationView_Create, +UserRightType.AdministrationView_Delete, +UserRightType.Employee_ShowFinance, +UserRightType.Analysis_Settlement_View, +UserRightType.Analysis_EmployeeOverviewAll_View, +UserRightType.Analysis_ServiceOverview_View, +UserRightType.Analysis_SupportConceptOverviewAll_View, +UserRightType.UserView_AllowChangePassword, +UserRightType.OrganisationView_AllowEditCostBearer, +UserRightType.ServiceRecord_AllowChangeWithin24Hours, +UserRightType.ServiceRecord_AllowCreateServiceRecordsForAllClients, +UserRightType.SupportConcept_ViewAllSupportConcepts, +UserRightType.SupportConcept_AllowGoalOrientedSupportConcepts, +UserRightType.Customer_ViewMyCustomers, +UserRightType.Analysis_AllowFLSOverviewForCostbearer, +UserRightType.SupportConceptView_AllowArchiving, +UserRightType.Person_AllowArchiving, +UserRightType.Customer_AllowArchiving, +UserRightType.ServiceRecord_AllowCreationForOtherEmployees, +UserRightType.ResourceBookingView_AllowEditResourcesFromOtherEmployees, +UserRightType.ServiceRecord_AllowEditAfterMaxDaysInNextMonth, +UserRightType.AssessmentSheet_View, +UserRightType.AssessmentSheet_Edit, +UserRightType.AssessmentSheet_Create, +UserRightType.AssessmentSheet_Delete, +UserRightType.ServiceRecord_AllowCreateMoreFLSThanApproved, +UserRightType.Analysis_AuslastungAllEmployee_View, +UserRightType.Analysis_AuslastungTeam_View, +UserRightType.Analysis_Auslastung_View, +UserRightType.Analysis_AllowFLSOverviewForTeam, +UserRightType.Analysis_AllowFLSOverviewForAllTeams, +UserRightType.ServiceRecord_AllowCreateOverlappingFLS, +UserRightType.ServiceRecord_AllowCreationForOtherTeamMember, +UserRightType.BookServiceRecordOutOfSupportConcept, +UserRightType.BookServiceRecordAfterSettlementInvoice, +UserRightType.Organisation_AllowArchiving, +UserRightType.ServiceRecord_ShowHistory, +UserRightType.ServiceRecord_AllowCreateOverlappingFLSForEmployee, +UserRightType.ServiceRecord_AllowCreatingGroupBooking, +UserRightType.ServiceRecord_AllowCreatingMultiBooking, +UserRightType.TeamView_ViewMyTeams, +UserRightType.Customer_ViewMyTeams, +UserRightType.SupportConcept_ViewMyTeams, +UserRightType.Employee_AllowEditExtendedProperties, +UserRightType.Employee_AllowEditContracts, +UserRightType.Employee_AllowEditOwnEmployees, +UserRightType.Employee_AllowArchiving, +UserRightType.User_AllowOrderLicense, +UserRightType.Employee_AllowViewOwnEmployees, +UserRightType.Employee_AllowViewOwnTeam, +UserRightType.Employee_ViewNotizen, +UserRightType.Employee_EditNotizen, +UserRightType.Employee_DeleteNotizen, +UserRightType.GroupOfPeopleView_Edit, +UserRightType.GroupOfPeopleView_Create, +UserRightType.GroupOfPeopleView_Delete, +UserRightType.AdditionalService_View, +UserRightType.OvertimeView, +UserRightType.Mitarbeiterstundenkonto_ViewSelf, +UserRightType.Mitarbeiterstundenkonto_ViewAll, +UserRightType.Mitarbeiterstundenkonto_ViewTeams, +UserRightType.Auswertungen_BerichteAnsehen, +UserRightType.Auswertungen_StundenuebersichtAnsehen, +UserRightType.Auswertungen_HilfeplanuebersichtAnsehen, +UserRightType.Support_View, +UserRightType.SupportConcept_AllowEditGoals, +UserRightType.SupportConcept_AllowEditTasks, +UserRightType.ServiceRecord_AllowEditForOtherEmployees, +UserRightType.KalenderAnsehen, +UserRightType.KalenderMitarbeitertermineAnsehen, +UserRightType.KalenderMitarbeitertermineAnlegen, +UserRightType.KalenderMitarbeitertermineAendern, +UserRightType.KalenderKliententermineAlleAnsehen, +UserRightType.KalenderKliententermineAnlegen, +UserRightType.KalenderKliententermineAendern, +UserRightType.KalenderRessourcentermineAnsehen, +UserRightType.KalenderRessourcentermineAnlegen, +UserRightType.KalenderRessourcentermineAendern, +UserRightType.KalenderRessourcentermineAndererAendern, +UserRightType.KalenderInZeiterfassungUebernehmen, +UserRightType.AllowChangeOwnPassword, +UserRightType.TextbausteineAlleAnsehen, +UserRightType.TextbausteineNurEigeneAnsehen, +UserRightType.TextbausteineAlleBearbeiten, +UserRightType.TextbausteineNurEigeneBearbeiten, +UserRightType.BargeldverwaltungAnsehen, +UserRightType.BargeldverwaltungNurEigeneAnsehen, +UserRightType.BargeldverwaltungBearbeiten, +UserRightType.BargeldverwaltungAnlegen, +UserRightType.BargeldverwaltungLoeschen, +UserRightType.SupportConceptAllowReactivation, +UserRightType.CustomerAllowReactivation, +UserRightType.OrganisationAllowReactivation, +UserRightType.PersonAllowReactivation, +UserRightType.EmployeeAllowReactivation, +UserRightType.ServiceRecordAllowRebooking, +UserRightType.CostbearerAllowChange, +UserRightType.ServiceRecordAllowEditAfterMindays, +UserRightType.DocumentsAllowViewAll, +UserRightType.DocumentsDownloadAll, +UserRightType.DocumentsEditFolders, +UserRightType.DocumentsUploadAll, +UserRightType.DocumentsDeleteAll, +UserRightType.Customer_ViewMedication, +UserRightType.Customer_ViewDiagnosis, +UserRightType.Customer_ViewNotizen, +UserRightType.Customer_EditNotizen, +UserRightType.Customer_DeleteNotizen, +UserRightType.WohnheimView_View, +UserRightType.WohnheimView_Edit, +UserRightType.WohnheimView_Create, +UserRightType.WohnheimView_Delete, +UserRightType.Wohnheim_AllowArchiving, +UserRightType.Betreuungsschluessel_View, +UserRightType.Betreuungsschluessel_Edit, +UserRightType.Betreuungsschluessel_Delete, +UserRightType.Betreuungsschluessel_Create, +UserRightType.Jahresbericht, +UserRightType.DokumenteFinanzen, +UserRightType.DokumenteKlienten, +UserRightType.DokumenteMitarbeiter, +UserRightType.DokumenteOrganisationen, +UserRightType.DokumentePersonen, +UserRightType.DokumenteHilfeplaene, +UserRightType.DokumenteTeams, +UserRightType.BargeldverwaltungFinanzenAnsehen, +UserRightType.BargeldverwaltungFinanzenAnlegen, +UserRightType.BargeldverwaltungFinanzenBearbeiten, +UserRightType.BargeldverwaltungFinanzenLoeschen, +UserRightType.ChatSettings, +UserRightType.ChatAdminSettings, +UserRightType.Kilometerauswertung_View, +UserRightType.BewertungAuswertung_View, +UserRightType.BewertenInZeiterfassung, +UserRightType.PivotTabelleAnsehen, +UserRightType.DienstplanungAnsehen, +UserRightType.AbwesenheitsPlanungAnsehen, +UserRightType.KilometerauswertungEigene_View, +UserRightType.VertretungenView_View, +UserRightType.CustomerTeam_View, +UserRightType.CustomerTeam_Edit, +UserRightType.CustomerTeam_Delete, +UserRightType.CustomerTeam_Create, +UserRightType.Person_FamilyView, +UserRightType.Customer_Anonymization, +UserRightType.Customer_Full_Delete, +UserRightType.Person_Full_Delete, +UserRightType.Employee_Full_Delete, +UserRightType.Employee_Anonymization, +UserRightType.Termine_IntervalDelete, +UserRightType.ServiceRecord_AllowCreateAfterEmployeeSignature, +UserRightType.ServiceRecord_AllowEditAfterEmployeeSignature, +UserRightType.ServiceRecord_AllowDeleteAfterEmployeeSignature, +UserRightType.ConfirmationReceiptSignatures_Delete, +UserRightType.Signature_ProvideSingleSignature, +UserRightType.Signature_ProvideMonthlySignature, +UserRightType.Signature_ProvideMonthlySignatureByProxy, + }; + } [TestMethod] public void DictionaryCreation() @@ -42,5 +258,24 @@ namespace TranslationUnitTest Assert.Fail($"UserRight \"{item}\" hat keine Übersetzung in {nameof(EnumTranslations.UserRightType2Translations)}"); } } + + [TestMethod] + public void UserRightHelperComplete() + { + foreach (UserRightType item in Enum.GetValues(typeof(UserRightType))) + { + var has_base_version = UserRightHelper.GetRightVersion(item) == UserRightHelper.BASE_VERSION; + + if (!has_base_version) + continue; + + var is_base_version = UserRightTypesVersion1dot0.Contains(item); + + if (is_base_version) + continue; + + Assert.Fail($"UserRight \"{item}\" hat keine Versionierung in {nameof(UserRightHelper.GetRightVersion)} ({nameof(UserRightHelper)})"); + } + } } } diff --git a/TranslationUnitTest/TranslationUnitTest.csproj b/TranslationUnitTest/TranslationUnitTest.csproj index cd2306083..2512f3ca2 100644 --- a/TranslationUnitTest/TranslationUnitTest.csproj +++ b/TranslationUnitTest/TranslationUnitTest.csproj @@ -56,6 +56,10 @@ + + {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE} + Data + {2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4} Shared