From 47f698636d7580f0f6f5443a2ce06261dd9777dc Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Tue, 3 Dec 2024 11:52:25 -0600 Subject: [PATCH 1/2] add comments --- .../Services/BotSharpConversationSideCar.cs | 16 ++++++++++++++++ .../Services/ConversationStateService.cs | 16 ++++++++++++++++ .../Translation/TranslationService.cs | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/src/Infrastructure/BotSharp.Core.SideCar/Services/BotSharpConversationSideCar.cs b/src/Infrastructure/BotSharp.Core.SideCar/Services/BotSharpConversationSideCar.cs index ec3ad0fe..4ddc3a43 100644 --- a/src/Infrastructure/BotSharp.Core.SideCar/Services/BotSharpConversationSideCar.cs +++ b/src/Infrastructure/BotSharp.Core.SideCar/Services/BotSharpConversationSideCar.cs @@ -1,3 +1,19 @@ +/***************************************************************************** + Copyright 2024 Written by Jicheng Lu. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +******************************************************************************/ + using BotSharp.Core.Infrastructures; namespace BotSharp.Core.SideCar.Services; diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs index 152b74ca..eedcdf9a 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs @@ -1,3 +1,19 @@ +/***************************************************************************** + Copyright 2024 Written by Jicheng Lu. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +******************************************************************************/ + using BotSharp.Abstraction.Conversations.Enums; namespace BotSharp.Core.Conversations.Services; diff --git a/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs b/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs index 453b2277..7b81ac10 100644 --- a/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs +++ b/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs @@ -1,3 +1,19 @@ +/***************************************************************************** + Copyright 2024 Written by Jicheng Lu. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +******************************************************************************/ + using BotSharp.Abstraction.Infrastructures.Enums; using BotSharp.Abstraction.MLTasks; using BotSharp.Abstraction.Options; From e831c810a1a4dad8fd02546f1ec2d1d5a29ba77f Mon Sep 17 00:00:00 2001 From: Jicheng Lu Date: Tue, 3 Dec 2024 18:52:28 -0600 Subject: [PATCH 2/2] init roles --- .../Repositories/Filters/RoleFilter.cs | 5 +++++ .../BotSharp.Core/Roles/Services/RoleService.cs | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Infrastructure/BotSharp.Abstraction/Repositories/Filters/RoleFilter.cs b/src/Infrastructure/BotSharp.Abstraction/Repositories/Filters/RoleFilter.cs index 35e2e1d3..7c6c738a 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Repositories/Filters/RoleFilter.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Repositories/Filters/RoleFilter.cs @@ -15,4 +15,9 @@ public class RoleFilter { return new RoleFilter(); } + + public bool IsInit() + { + return Names.IsNullOrEmpty(); + } } diff --git a/src/Infrastructure/BotSharp.Core/Roles/Services/RoleService.cs b/src/Infrastructure/BotSharp.Core/Roles/Services/RoleService.cs index 8cd7935b..9636fe18 100644 --- a/src/Infrastructure/BotSharp.Core/Roles/Services/RoleService.cs +++ b/src/Infrastructure/BotSharp.Core/Roles/Services/RoleService.cs @@ -39,7 +39,15 @@ public class RoleService : IRoleService public async Task> GetRoles(RoleFilter filter) { var db = _services.GetRequiredService(); + var roles = db.GetRoles(filter); + if (filter.IsInit() && roles.IsNullOrEmpty()) + { + await RefreshRoles(); + await Task.Delay(100); + roles = db.GetRoles(filter); + } + return roles; }