From 3c062a4e22c2eda2a854df8d76ac71deb46af1a3 Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Mon, 12 Jan 2026 16:53:47 +0100 Subject: [PATCH] Folder + bisschen Logik --- .../GeneratedAiEnhancedService.cs | 63 +++++++++++ .../AI/AiPromptbausteinComplexTreeView.xaml | 1 + .../Detail/AI/AiPromptbausteinPromptView.xaml | 1 + BeWo/ViewModel/AiPromptbausteinFolderVM.cs | 22 +++- .../AiPromptbausteinFolderListVM.cs | 1 + .../AiPromptbausteinComplexTreeViewModel.cs | 49 ++++++--- Data/Access/SearchDAO.cs | 13 +++ Data/Data.csproj | 4 + Data/Entities/AiPromptbausteinFolder.cs | 36 ++++++ Data/Mappings/AiPromptbausteinFolder.hbm.xml | 34 ++++++ ...ges_2026-01-09 AI Promptbausteinprompt.txt | 8 +- ...ges_2026-01-12 AI Promptbausteinfolder.txt | 23 ++++ ...bausteinFolderDC_AiPromptbausteinFolder.cs | 59 ++++++++++ ...bausteinPromptDC_AiPromptbausteinPrompt.cs | 4 +- Service/DCEntityMapper/MapperFactory.cs | 2 + Service/Plugins/AiPromptbausteineService.cs | 104 ++++++++++++++++++ Service/Service.csproj | 1 + .../Enhanced/IAiEnhancedService.cs | 35 ++++++ .../Enhanced/AiEnhancedServiceImp.cs | 22 ++++ Shared/BeWoEntityEnums.cs | 3 +- .../DataContracts/AiPromptbausteinFolderDC.cs | 17 ++- 21 files changed, 473 insertions(+), 29 deletions(-) create mode 100644 Data/Entities/AiPromptbausteinFolder.cs create mode 100644 Data/Mappings/AiPromptbausteinFolder.hbm.xml create mode 100644 Model/Changes_2026-01-12 AI Promptbausteinfolder.txt create mode 100644 Service/DCEntityMapper/AiPromptbausteinFolderDC_AiPromptbausteinFolder.cs diff --git a/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs b/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs index b82dca612..f172b1c6d 100644 --- a/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs +++ b/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs @@ -95,6 +95,34 @@ namespace BeWo.ServiceProxy [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteineBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] void DeleteAiPromptbausteine(System.Collections.Generic.Dictionary oid2version); + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/GetAiPromptbausteinFolder", ReplyAction="http://tempuri.org/IAiEnhancedService/GetAiPromptbausteinFolderResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/GetAiPromptbausteinFolderBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] + System.Collections.Generic.List GetAiPromptbausteinFolder(BS.Shared.AiActionType aiActionType); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/InsertAiPromptbausteinFolder", ReplyAction="http://tempuri.org/IAiEnhancedService/InsertAiPromptbausteinFolderResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/InsertAiPromptbausteinFolderBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] + System.Collections.Generic.List InsertAiPromptbausteinFolder(System.Collections.Generic.List folders); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/InsertAiPromptbausteinPrompt", ReplyAction="http://tempuri.org/IAiEnhancedService/InsertAiPromptbausteinPromptResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/InsertAiPromptbausteinPromptBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] + System.Collections.Generic.List InsertAiPromptbausteinPrompt(System.Collections.Generic.List prompts); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteinFolder", ReplyAction="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteinFolderResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteinFolderBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] + System.Collections.Generic.List UpdateAiPromptbausteinFolder(System.Collections.Generic.List folders); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteinPrompt", ReplyAction="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteinPromptResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteinPromptBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] + System.Collections.Generic.List UpdateAiPromptbausteinPrompt(System.Collections.Generic.List prompts); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteinFolder", ReplyAction="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteinFolderResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteinFolderBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] + void DeleteAiPromptbausteinFolder(System.Collections.Generic.Dictionary oid2version); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteinPrompt", ReplyAction="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteinPromptResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteinPromptBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] + void DeleteAiPromptbausteinPrompt(System.Collections.Generic.Dictionary oid2version); + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/ExecuteAiFunctionServiceRecordDocumentation" + "", ReplyAction="http://tempuri.org/IAiEnhancedService/ExecuteAiFunctionServiceRecordDocumentation" + "Response")] @@ -232,6 +260,41 @@ namespace BeWo.ServiceProxy base.Channel.DeleteAiPromptbausteine(oid2version); } + public System.Collections.Generic.List GetAiPromptbausteinFolder(BS.Shared.AiActionType aiActionType) + { + return base.Channel.GetAiPromptbausteinFolder(aiActionType); + } + + public System.Collections.Generic.List InsertAiPromptbausteinFolder(System.Collections.Generic.List folders) + { + return base.Channel.InsertAiPromptbausteinFolder(folders); + } + + public System.Collections.Generic.List InsertAiPromptbausteinPrompt(System.Collections.Generic.List prompts) + { + return base.Channel.InsertAiPromptbausteinPrompt(prompts); + } + + public System.Collections.Generic.List UpdateAiPromptbausteinFolder(System.Collections.Generic.List folders) + { + return base.Channel.UpdateAiPromptbausteinFolder(folders); + } + + public System.Collections.Generic.List UpdateAiPromptbausteinPrompt(System.Collections.Generic.List prompts) + { + return base.Channel.UpdateAiPromptbausteinPrompt(prompts); + } + + public void DeleteAiPromptbausteinFolder(System.Collections.Generic.Dictionary oid2version) + { + base.Channel.DeleteAiPromptbausteinFolder(oid2version); + } + + public void DeleteAiPromptbausteinPrompt(System.Collections.Generic.Dictionary oid2version) + { + base.Channel.DeleteAiPromptbausteinPrompt(oid2version); + } + public BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords.AiFunctionDocResponse ExecuteAiFunctionServiceRecordDocumentation(BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords.AiFunctionDocRequest request) { return base.Channel.ExecuteAiFunctionServiceRecordDocumentation(request); diff --git a/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml b/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml index a74102692..6f1743f0d 100644 --- a/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml +++ b/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml @@ -96,6 +96,7 @@ TreeViewItem.Selected="treeView_Selected"> diff --git a/BeWo/View/Detail/AI/AiPromptbausteinPromptView.xaml b/BeWo/View/Detail/AI/AiPromptbausteinPromptView.xaml index 78b233e11..1536a8086 100644 --- a/BeWo/View/Detail/AI/AiPromptbausteinPromptView.xaml +++ b/BeWo/View/Detail/AI/AiPromptbausteinPromptView.xaml @@ -54,6 +54,7 @@ _IsExpanded; - set => SetProperty(ref _IsExpanded, value, nameof(IsExpanded), () => DataContract.IsExpanded); + set => SetProperty(ref _IsExpanded, value, nameof(IsExpanded)); } public AiActionType ActionType @@ -99,10 +99,15 @@ namespace BeWo.ViewModel } } - public bool CanAdd + public bool CanAddFolder { - get => DataContract.CanAdd; - set => DataContract.CanAdd = value; + get => DataContract.CanAddFolder; + set => DataContract.CanAddFolder = value; + } + public bool CanAddPrompt + { + get => DataContract.CanAddPrompt; + set => DataContract.CanAddPrompt = value; } public bool CanEdit { @@ -110,6 +115,15 @@ namespace BeWo.ViewModel set => DataContract.CanEdit = value; } + public bool IsNewFeature + { + get => DataContract.IsNewFeature; + } + public bool IsEnabled + { + get => !IsNewFeature; + } + public AiPromptbausteinFolderVM Parent { get; set; } public FontWeight FontWeight => !IsNew && ParentFolderOid is null ? FontWeights.SemiBold : FontWeights.Medium; diff --git a/BeWo/ViewModel/ListViewModel/AiPromptbausteinFolderListVM.cs b/BeWo/ViewModel/ListViewModel/AiPromptbausteinFolderListVM.cs index a86318d12..50ce106b5 100644 --- a/BeWo/ViewModel/ListViewModel/AiPromptbausteinFolderListVM.cs +++ b/BeWo/ViewModel/ListViewModel/AiPromptbausteinFolderListVM.cs @@ -15,6 +15,7 @@ namespace BeWo.ViewModel.ListViewModel foreach (var vm in VMList) { vm.Parent = parent; + vm.ParentFolderOid = parent?.DataContract?.Oid; } } diff --git a/BeWo/ViewModel/View/Administration/AiPromptbausteinComplexTreeViewModel.cs b/BeWo/ViewModel/View/Administration/AiPromptbausteinComplexTreeViewModel.cs index daeb18ca6..513124955 100644 --- a/BeWo/ViewModel/View/Administration/AiPromptbausteinComplexTreeViewModel.cs +++ b/BeWo/ViewModel/View/Administration/AiPromptbausteinComplexTreeViewModel.cs @@ -134,14 +134,31 @@ namespace BeWo.ViewModel.View.Administration var actions = new List>(); - //if (toadd_dcs.Any()) - // actions.Add(x => x.CreateAiPromptbausteineTree(toadd_dcs.ToList())); + if (toadd_folder.Any()) + actions.Add(x => x.InsertAiPromptbausteinFolder(toadd_folder_dcs.ToList())); - //if (toupdate_dcs.Any()) - // actions.Add(x => x.UpdateAiPromptbausteineTree(toupdate_dcs.ToList())); + if (toadd_prompts.Any()) + actions.Add(x => x.InsertAiPromptbausteinPrompt(toadd_prompts.ToList())); - //if (todelete.Any()) - // actions.Add(x => x.DeleteAiPromptbausteineTree(todelete.ToDictionary(x1 => x1.Oid.Value, x2 => x2.Version.Value))); + if (toupdate_folder_dcs.Any()) + { + foreach (var folder_dc in toupdate_folder_dcs) + { + folder_dc.SubPrompts = null; + folder_dc.SubFolders = null; + } + + actions.Add(x => x.UpdateAiPromptbausteinFolder(toupdate_folder_dcs.ToList())); + } + + if (toupdate_prompt.Any()) + actions.Add(x => x.UpdateAiPromptbausteinPrompt(toupdate_prompt.ToList())); + + if (todelete_folder.Any()) + actions.Add(x => x.DeleteAiPromptbausteinFolder(todelete_folder.ToDictionary(x1 => x1.Oid.Value, x2 => x2.Version.Value))); + + if (todelete_prompt.Any()) + actions.Add(x => x.DeleteAiPromptbausteinPrompt(todelete_prompt.ToDictionary(x1 => x1.Oid.Value, x2 => x2.Version.Value))); ServiceFacade.DoMultipleAiEnhancedServicesAsync(actions, () => { @@ -150,11 +167,14 @@ namespace BeWo.ViewModel.View.Administration } internal void ReloadVMList() { - var folders_dc = PredefinedAiPromptbausteinFolders.CreateSubTree(AiActionType); + ServiceFacade.DoAiEnhancedServiceAsnyc( + req => req.GetAiPromptbausteinFolder(AiActionType), + callback => + { + Folders = new AiPromptbausteinFolderListVM(callback); - Folders = new AiPromptbausteinFolderListVM(folders_dc); - - FirePropertyChanged(nameof(Folders)); + FirePropertyChanged(nameof(Folders)); + }); } public void UpdateVMList(AiPromptbausteinTreeListVM new_list) { @@ -212,8 +232,11 @@ namespace BeWo.ViewModel.View.Administration new_vm.Creator = CurrentEmployee; new_vm.Parent = sel_folder; - new_vm.CanAdd = true; + new_vm.ParentFolderOid = sel_folder?.DataContract?.Oid; + new_vm.CanAddFolder = true; + new_vm.CanAddPrompt = true; new_vm.CanEdit = true; + new_vm.ActionType = AiActionType; var vm = new AiPromptbausteinFolderViewModel(new_vm, true); @@ -265,7 +288,7 @@ namespace BeWo.ViewModel.View.Administration bool canOpenAddFolderDialog() { - return SelectedFolder?.CanAdd ?? true; + return SelectedFolder?.CanAddFolder ?? true; } bool canOpenEditFolderDialog() { @@ -355,7 +378,7 @@ namespace BeWo.ViewModel.View.Administration bool canOpenAddPromptDialog() { - return SelectedFolder?.CanAdd ?? false; + return SelectedFolder?.CanAddPrompt ?? false; } bool canOpenEditPromptDialog() { diff --git a/Data/Access/SearchDAO.cs b/Data/Access/SearchDAO.cs index e15ac8c6c..0fde40303 100644 --- a/Data/Access/SearchDAO.cs +++ b/Data/Access/SearchDAO.cs @@ -2778,6 +2778,19 @@ WHERE sc.Billable = 1 and sr.StartDate >= '{0:yyyy-MM-dd}' and sr.StartDate < '{ return criteria.List(); } + public IEnumerable GetOwnActiveRootAiPromptbausteineFolders(AiActionType? aiActionType = null) + { + var criteria = CreateCriteriaIsActive() + .Add(Restrictions.IsNull(nameof(AiPromptbausteinFolder.ParentFolderOid))); + + if (aiActionType is AiActionType actionType) + { + criteria.Add(Restrictions.Eq(nameof(AiPromptbausteinFolder.ActionType), actionType)); + } + + return criteria.List(); + } + public IEnumerable GetActiveRootAiPromptbausteine(AiActionType? aiActionType = null) { var criteria = CreateCriteriaIsActive() diff --git a/Data/Data.csproj b/Data/Data.csproj index 0a234e403..464bc8609 100644 --- a/Data/Data.csproj +++ b/Data/Data.csproj @@ -239,6 +239,7 @@ + @@ -868,6 +869,9 @@ Designer + + Designer + Designer diff --git a/Data/Entities/AiPromptbausteinFolder.cs b/Data/Entities/AiPromptbausteinFolder.cs new file mode 100644 index 000000000..865cd693b --- /dev/null +++ b/Data/Entities/AiPromptbausteinFolder.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; + +using BS.Shared; +using BS.Shared.Core; + +namespace BeWo.Data.Entities +{ + public class AiPromptbausteinFolder : BeWoEntityBase + { + public AiPromptbausteinFolder() + { + _Tid = TableID.AiPromptbausteinFolder; + } + + public virtual string Title { get; set; } + + public virtual string Description { get; set; } + + public virtual long? ParentFolderOid { get; set; } + + public virtual long? CreatorOid { get; set; } + + public virtual bool IsPublic { get; set; } + + public virtual int Position { get; set; } + + public virtual bool IsExpanded { get; set; } + + public virtual AiActionType ActionType { get; set; } + + public virtual IList SubFolders { get; set; } = new List(); + + public virtual IList SubPrompts { get; set; } = new List(); + } +} diff --git a/Data/Mappings/AiPromptbausteinFolder.hbm.xml b/Data/Mappings/AiPromptbausteinFolder.hbm.xml new file mode 100644 index 000000000..39f90c933 --- /dev/null +++ b/Data/Mappings/AiPromptbausteinFolder.hbm.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Model/Changes_2026-01-09 AI Promptbausteinprompt.txt b/Model/Changes_2026-01-09 AI Promptbausteinprompt.txt index 7cceda01a..2520dd4ec 100644 --- a/Model/Changes_2026-01-09 AI Promptbausteinprompt.txt +++ b/Model/Changes_2026-01-09 AI Promptbausteinprompt.txt @@ -9,17 +9,19 @@ CREATE TABLE `AiPromptbausteinPrompt` ( `IsActive` tinyint DEFAULT NULL, `SystemEntryID` int DEFAULT NULL, `Title` varchar(255), -`Description` varchar(255), +`Description` mediumtext, `ParentFolderOid` bigint DEFAULT NULL, `CreatorOid` bigint, `IsPublic` tinyint, `Position` int, -`Prompt` varchar(255), +`Prompt` mediumtext, `ShowPrompt` tinyint, `ShowPromptByTenant` tinyint, `IsOwnsoftPrompt` tinyint, `OwnsoftRefLink` varchar(255), PRIMARY KEY (`Oid`), KEY `FK_AIPROMPTBAUSTEINPROMPT_EMPLOYEE_IDX` (`CreatorOid`), -CONSTRAINT `FK_AIPROMPTBAUSTEINPROMPT_EMPLOYEE` FOREIGN KEY (`CreatorOid`) REFERENCES `employee` (`Oid`) +KEY `FK_AIPROMPTBAUSTEINPROMPT_PARENT_IDX` (`ParentFolderOid`), +CONSTRAINT `FK_AIPROMPTBAUSTEINPROMPT_EMPLOYEE` FOREIGN KEY (`CreatorOid`) REFERENCES `employee` (`Oid`), +CONSTRAINT `FK_AIPROMPTBAUSTEINPROMPT_PARENT` FOREIGN KEY (`ParentFolderOid`) REFERENCES `aipromptbausteinfolder` (`Oid`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1; diff --git a/Model/Changes_2026-01-12 AI Promptbausteinfolder.txt b/Model/Changes_2026-01-12 AI Promptbausteinfolder.txt new file mode 100644 index 000000000..3a1ae9b99 --- /dev/null +++ b/Model/Changes_2026-01-12 AI Promptbausteinfolder.txt @@ -0,0 +1,23 @@ +CREATE TABLE `AiPromptbausteinFolder` ( +`Oid` bigint NOT NULL AUTO_INCREMENT, +`InsTs` datetime DEFAULT NULL, +`InsUser` varchar(256) DEFAULT NULL, +`Notice` varchar(1024) DEFAULT NULL, +`Tid` int DEFAULT NULL, +`UdpUser` varchar(256) DEFAULT NULL, +`Version` bigint DEFAULT NULL, +`IsActive` tinyint DEFAULT NULL, +`SystemEntryID` int DEFAULT NULL, +`Title` varchar(255), +`Description` mediumtext, +`ParentFolderOid` bigint DEFAULT NULL, +`CreatorOid` bigint DEFAULT NULL, +`IsPublic` tinyint, +`Position` int, +`ActionType` int, +PRIMARY KEY (`Oid`), +KEY `FK_AIPROMPTBAUSTEINFOLDER_EMPLOYEE_IDX` (`CreatorOid`), +KEY `FK_AIPROMPTBAUSTEINFOLDER_PARENT_IDX` (`ParentFolderOid`), +CONSTRAINT `FK_AIPROMPTBAUSTEINFOLDER_EMPLOYEE` FOREIGN KEY (`CreatorOid`) REFERENCES `employee` (`Oid`), +CONSTRAINT `FK_AIPROMPTBAUSTEINFOLDER_PARENT` FOREIGN KEY (`ParentFolderOid`) REFERENCES `aipromptbausteintree` (`Oid`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1; \ No newline at end of file diff --git a/Service/DCEntityMapper/AiPromptbausteinFolderDC_AiPromptbausteinFolder.cs b/Service/DCEntityMapper/AiPromptbausteinFolderDC_AiPromptbausteinFolder.cs new file mode 100644 index 000000000..f34008740 --- /dev/null +++ b/Service/DCEntityMapper/AiPromptbausteinFolderDC_AiPromptbausteinFolder.cs @@ -0,0 +1,59 @@ +using System.Collections.Generic; +using System.Linq; + +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.Service.ServiceImplementations; +using BS.Shared; +using BS.Shared.Core; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Feature.AI; + +namespace BeWo.Service.DCEntityMapper +{ + public class AiPromptbausteinFolderDC_AiPromptbausteinFolder : BeWoDataContract_BeWoEntityBase + { + public override AiPromptbausteinFolderDC MergeWithDC(AiPromptbausteinFolder pEntity, AiPromptbausteinFolderDC pDataContract) + { + base.MergeWithDC(pEntity, pDataContract); + + pDataContract.Title = pEntity.Title; + pDataContract.Description = pEntity.Description; + pDataContract.ParentFolderOid = pEntity.ParentFolderOid; + pDataContract.IsPublic = pEntity.IsPublic; + pDataContract.Position = pEntity.Position; + pDataContract.IsExpanded = pEntity.IsExpanded; + pDataContract.ActionType = pEntity.ActionType; + pDataContract.SubFolders = MapperFactory.AiPromptbausteinFolder.MapToNewDCs(pEntity.SubFolders); + pDataContract.SubPrompts = MapperFactory.AiPromptbausteinPrompt.MapToNewDCs(pEntity.SubPrompts); + + if (pEntity.CreatorOid is long oid) + pDataContract.Creator = new EmployeeServiceImp().GetActiveCompactEmployeeWithOid(oid); + + return pDataContract; + } + + public override AiPromptbausteinFolder MergeWithEntity(AiPromptbausteinFolderDC pDataContract, AiPromptbausteinFolder pEntity) + { + base.MergeWithDC(pEntity, pDataContract); + + pEntity.Title = pDataContract.Title; + pEntity.Description = pDataContract.Description; + pEntity.CreatorOid = pDataContract.Creator.EmployeeOid; + pEntity.IsPublic = pDataContract.IsPublic; + pEntity.Position = pDataContract.Position; + pEntity.ActionType = pDataContract.ActionType; + + if(pDataContract.ParentFolderOid is long oid && oid >= 0) + pEntity.ParentFolderOid = pDataContract.ParentFolderOid; + + if (pDataContract.SubFolders is object) + MapperFactory.AiPromptbausteinFolder.MergeWithEntitys(pDataContract.SubFolders, pEntity.SubFolders); + + if (pDataContract.SubPrompts is object) + MapperFactory.AiPromptbausteinPrompt.MergeWithEntitys(pDataContract.SubPrompts, pEntity.SubPrompts); + + return pEntity; + } + } +} diff --git a/Service/DCEntityMapper/AiPromptbausteinPromptDC_AiPromptbausteinPrompt.cs b/Service/DCEntityMapper/AiPromptbausteinPromptDC_AiPromptbausteinPrompt.cs index 73dc280fe..e989fb94b 100644 --- a/Service/DCEntityMapper/AiPromptbausteinPromptDC_AiPromptbausteinPrompt.cs +++ b/Service/DCEntityMapper/AiPromptbausteinPromptDC_AiPromptbausteinPrompt.cs @@ -44,8 +44,8 @@ namespace BeWo.Service.DCEntityMapper pEntity.Prompt = pDataContract.Prompt; pEntity.ShowPrompt = pDataContract.ShowPrompt; pEntity.ShowPromptByTenant = pDataContract.ShowPromptByTenant; - pEntity.IsOwnsoftPrompt = pDataContract.IsOwnsoftPrompt; - pEntity.OwnsoftRefLink = pDataContract.OwnsoftRefLink; + //pEntity.IsOwnsoftPrompt = pDataContract.IsOwnsoftPrompt; + //pEntity.OwnsoftRefLink = pDataContract.OwnsoftRefLink; return pEntity; } diff --git a/Service/DCEntityMapper/MapperFactory.cs b/Service/DCEntityMapper/MapperFactory.cs index 2ea0de5b9..59d231d55 100644 --- a/Service/DCEntityMapper/MapperFactory.cs +++ b/Service/DCEntityMapper/MapperFactory.cs @@ -818,6 +818,8 @@ namespace BeWo.Service.DCEntityMapper public static AiModelDC_AiModel AiModel { get; } = new AiModelDC_AiModel(); public static AiConfigDC_AiConfig AiConfig { get; } = new AiConfigDC_AiConfig(); public static AiPromptbausteinTreeDC_AiPromptbaustein AiPromptbausteinTree { get; } = new AiPromptbausteinTreeDC_AiPromptbaustein(); + public static AiPromptbausteinFolderDC_AiPromptbausteinFolder AiPromptbausteinFolder { get; } = new AiPromptbausteinFolderDC_AiPromptbausteinFolder(); + public static AiPromptbausteinPromptDC_AiPromptbausteinPrompt AiPromptbausteinPrompt { get; } = new AiPromptbausteinPromptDC_AiPromptbausteinPrompt(); public static AiPromptbausteinTreeDC_AiPromptbausteinTree AiPromptbausteinTreeTree { get; } = new AiPromptbausteinTreeDC_AiPromptbausteinTree(); public static AddressDC_Address Address { get; } = new AddressDC_Address(); public static GkvAbrechnungLightDC_GkvAbrechnungLight GkvAbrechnungLight { get; } = new GkvAbrechnungLightDC_GkvAbrechnungLight(); diff --git a/Service/Plugins/AiPromptbausteineService.cs b/Service/Plugins/AiPromptbausteineService.cs index 9c3852718..48f6f6399 100644 --- a/Service/Plugins/AiPromptbausteineService.cs +++ b/Service/Plugins/AiPromptbausteineService.cs @@ -144,5 +144,109 @@ namespace BeWo.Service.Plugins aiPromptbausteinListe.Add(aiPromptbaustein); } + + + public IEnumerable GetAiPromptbausteinFolder(AiActionType aiActionType) + { + var own_bib = PredefinedAiPromptbausteinFolders.CreateOwnBibNode(aiActionType); + var shared_bib = PredefinedAiPromptbausteinFolders.CreateSharedBibNode(aiActionType); + var public_bib = PredefinedAiPromptbausteinFolders.CreatePublicBibNode(aiActionType); + + var own = DAOFactory.SearchDAO.GetOwnActiveRootAiPromptbausteineFolders(aiActionType); + var own_dcs = MapperFactory.AiPromptbausteinFolder.MapToNewDCs(own); + + foreach (var dc in own_dcs) + { + initOwnFolder(dc); + } + + own_bib.SubFolders.AddRange(own_dcs); + + return new List() { + own_bib, shared_bib, public_bib + }; + } + private void initOwnFolder(AiPromptbausteinFolderDC folder) + { + folder.CanAddFolder = true; + folder.CanAddPrompt = true; + folder.CanEdit = true; + + foreach (var prompt in folder.SubPrompts) + { + prompt.CanEdit = true; + } + + foreach (var next_folder in folder.SubFolders) + { + initOwnFolder(next_folder); + } + } + + public IEnumerable InsertAiPromptbausteinFolder(IEnumerable folders) + { + var entities = MapperFactory.AiPromptbausteinFolder.MapToNewEntities(folders); + + DAOFactory.GenericDAO.Insert(entities); + + return null; + } + + public IEnumerable InsertAiPromptbausteinPrompt(IEnumerable prompts) + { + var entities = MapperFactory.AiPromptbausteinPrompt.MapToNewEntities(prompts); + + DAOFactory.GenericDAO.Insert(entities); + + return null; + } + + public IEnumerable UpdateAiPromptbausteinFolder(IEnumerable folders) + { + var originale = DAOFactory.GenericDAO.LoadByIDs(folders.Select(sc => sc.Oid.Value)); + var folders2 = folders.ToList(); + MapperFactory.AiPromptbausteinFolder.MergeWithEntitys(folders2, originale); + + DAOFactory.GenericDAO.Update(originale); + + return null; + } + + public IEnumerable UpdateAiPromptbausteinPrompt(IEnumerable prompts) + { + var originale = DAOFactory.GenericDAO.LoadByIDs(prompts.Select(sc => sc.Oid.Value)); + var prompts2 = prompts.ToList(); + MapperFactory.AiPromptbausteinPrompt.MergeWithEntitys(prompts2, originale); + + DAOFactory.GenericDAO.Update(originale); + + return null; + } + + public void DeleteAiPromptbausteinFolder(Dictionary oid2version) + { + var originale = DAOFactory.GenericDAO.LoadByIDs(oid2version.Select(e => e.Key)); + originale.DoForEach(or => MapperFactory.AiPromptbausteinFolder.ConcurrencyCheck(oid2version[or.Oid.Value], or)); + + + DAOFactory.GenericDAO.SetActivationType(originale, BS.Shared.ActivationTypeId.Deleted); + } + private void delete_folder_rec(AiPromptbausteinFolder folder) + { + foreach (var sub_folder in folder.SubFolders) + { + delete_folder_rec(sub_folder); + } + + DAOFactory.GenericDAO.SetActivationType(folder, BS.Shared.ActivationTypeId.Deleted); + } + + public void DeleteAiPromptbausteinPrompt(Dictionary oid2version) + { + var originale = DAOFactory.GenericDAO.LoadByIDs(oid2version.Select(e => e.Key)); + originale.DoForEach(or => MapperFactory.AiPromptbausteinPrompt.ConcurrencyCheck(oid2version[or.Oid.Value], or)); + + DAOFactory.GenericDAO.SetActivationType(originale, BS.Shared.ActivationTypeId.Deleted); + } } } diff --git a/Service/Service.csproj b/Service/Service.csproj index 6001ebc85..741db7bf6 100644 --- a/Service/Service.csproj +++ b/Service/Service.csproj @@ -242,6 +242,7 @@ + diff --git a/Service/ServiceContracts/Enhanced/IAiEnhancedService.cs b/Service/ServiceContracts/Enhanced/IAiEnhancedService.cs index fb5533bd1..15ec41a4a 100644 --- a/Service/ServiceContracts/Enhanced/IAiEnhancedService.cs +++ b/Service/ServiceContracts/Enhanced/IAiEnhancedService.cs @@ -112,6 +112,41 @@ namespace BeWo.Service.ServiceContracts.Enhanced [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineRemove)] void DeleteAiPromptbausteine(Dictionary oid2version); + [FaultContract(typeof(BeWoFault))] + [OperationContract] + [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineView)] + IEnumerable GetAiPromptbausteinFolder(AiActionType aiActionType); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineAdd)] + IEnumerable InsertAiPromptbausteinFolder(IEnumerable folders); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineAdd)] + IEnumerable InsertAiPromptbausteinPrompt(IEnumerable prompts); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineEdit)] + IEnumerable UpdateAiPromptbausteinFolder(IEnumerable folders); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineEdit)] + IEnumerable UpdateAiPromptbausteinPrompt(IEnumerable prompts); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineRemove)] + void DeleteAiPromptbausteinFolder(Dictionary oid2version); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineRemove)] + void DeleteAiPromptbausteinPrompt(Dictionary oid2version); + [FaultContract(typeof(BeWoFault))] [OperationContract] [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineView)] diff --git a/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs b/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs index 97cadd33c..cd93bbe3a 100644 --- a/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs +++ b/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs @@ -7,6 +7,7 @@ using BS.Shared; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Feature.AI; using BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords; +using System; using System.Collections.Generic; using System.ServiceModel; @@ -80,6 +81,27 @@ namespace BeWo.Service.ServiceImplementations.Enhanced public void DeleteAiPromptbausteine(Dictionary oid2version) => GetAiPromptbausteineService().DeleteAiPromptbausteine(oid2version); + public IEnumerable GetAiPromptbausteinFolder(AiActionType aiActionType) + => GetAiPromptbausteineService().GetAiPromptbausteinFolder(aiActionType); + + public IEnumerable InsertAiPromptbausteinFolder(IEnumerable folders) + => GetAiPromptbausteineService().InsertAiPromptbausteinFolder(folders); + + public IEnumerable InsertAiPromptbausteinPrompt(IEnumerable prompts) + => GetAiPromptbausteineService().InsertAiPromptbausteinPrompt(prompts); + + public IEnumerable UpdateAiPromptbausteinFolder(IEnumerable folders) + => GetAiPromptbausteineService().UpdateAiPromptbausteinFolder(folders); + + public IEnumerable UpdateAiPromptbausteinPrompt(IEnumerable prompts) + => GetAiPromptbausteineService().UpdateAiPromptbausteinPrompt(prompts); + + public void DeleteAiPromptbausteinFolder(Dictionary oid2version) + => GetAiPromptbausteineService().DeleteAiPromptbausteinFolder(oid2version); + + public void DeleteAiPromptbausteinPrompt(Dictionary oid2version) + => GetAiPromptbausteineService().DeleteAiPromptbausteinPrompt(oid2version); + private AiPromptbausteineService GetAiPromptbausteineService() { return new AiPromptbausteineService(); diff --git a/Shared/BeWoEntityEnums.cs b/Shared/BeWoEntityEnums.cs index f9ca9e1d8..497fb194f 100644 --- a/Shared/BeWoEntityEnums.cs +++ b/Shared/BeWoEntityEnums.cs @@ -194,7 +194,8 @@ namespace BS.Shared Person2Team = 184, AiPromptbaustein = 185, AiPromptbausteinTree = 186, - AiPromptbausteinPrompt = 187 + AiPromptbausteinPrompt = 187, + AiPromptbausteinFolder = 188 } public enum SystemEntryID diff --git a/Shared/DataContracts/AiPromptbausteinFolderDC.cs b/Shared/DataContracts/AiPromptbausteinFolderDC.cs index 71e3cc090..7efd05809 100644 --- a/Shared/DataContracts/AiPromptbausteinFolderDC.cs +++ b/Shared/DataContracts/AiPromptbausteinFolderDC.cs @@ -20,8 +20,10 @@ namespace BS.Shared.DataContracts [DataMember] public List SubFolders { get; set; } [DataMember] public List SubPrompts { get; set; } - [DataMember] public bool CanAdd { get; set; } + [DataMember] public bool CanAddFolder { get; set; } + [DataMember] public bool CanAddPrompt { get; set; } [DataMember] public bool CanEdit { get; set; } + [DataMember] public bool IsNewFeature { get; set; } } public static class PredefinedAiPromptbausteinFolders @@ -46,7 +48,7 @@ namespace BS.Shared.DataContracts }; } - private static AiPromptbausteinFolderDC CreateOwnBibNode(AiActionType aiActionType) + public static AiPromptbausteinFolderDC CreateOwnBibNode(AiActionType aiActionType) { return new AiPromptbausteinFolderDC() { @@ -58,12 +60,12 @@ namespace BS.Shared.DataContracts SubPrompts = new List(), Title = AiPromptbausteineTexts.OwnBibNodeTitle, Version = 1, - CanAdd = true, + CanAddFolder = true, IsExpanded = true, }; } - private static AiPromptbausteinFolderDC CreateSharedBibNode(AiActionType aiActionType) + public static AiPromptbausteinFolderDC CreateSharedBibNode(AiActionType aiActionType) { return new AiPromptbausteinFolderDC() { @@ -76,10 +78,11 @@ namespace BS.Shared.DataContracts Title = AiPromptbausteineTexts.SharedBibNodeTitle, Version = 1, IsExpanded = true, + IsNewFeature =true }; } - private static AiPromptbausteinFolderDC CreatePublicBibNode(AiActionType aiActionType) + public static AiPromptbausteinFolderDC CreatePublicBibNode(AiActionType aiActionType) { return new AiPromptbausteinFolderDC() { @@ -92,6 +95,7 @@ namespace BS.Shared.DataContracts Title = AiPromptbausteineTexts.PublicBibNodeTitle, Version = 1, IsExpanded = true, + IsNewFeature = true }; } @@ -107,7 +111,8 @@ namespace BS.Shared.DataContracts SubPrompts = new List(), Title = "Beispiel Ordner", Version = 1, - CanAdd = true, + CanAddFolder = true, + CanAddPrompt = true, CanEdit = true }; }