Skip to content

Commit

Permalink
Merge branch 'B97GER-Issue#3114' of https://github.com/BB97GER/BCApps
Browse files Browse the repository at this point in the history
…into B97GER-Issue#3114
  • Loading branch information
BB97GER committed Mar 3, 2025
2 parents fb817cc + 6bd8098 commit 99874a4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ page 7775 "Copilot AI Capabilities"
EnvironmentInformation: Codeunit "Environment Information";
WithinGeo: Boolean;
WithinEUDB: Boolean;
TaskId: Integer;
begin
OnRegisterCopilotCapability();

Expand Down Expand Up @@ -280,7 +281,43 @@ page 7775 "Copilot AI Capabilities"

if EnvironmentInformation.IsSaaSInfrastructure() then begin
CopilotNotifications.ShowBillingInTheFutureNotification();
CopilotNotifications.CheckAIQuotaAndShowNotification();
CurrPage.EnqueueBackgroundTask(TaskId, Codeunit::"Copilot Quota Impl.");
end;
end;

trigger OnPageBackgroundTaskCompleted(TaskId: Integer; Results: Dictionary of [Text, Text])
var
CopilotNotifications: Codeunit "Copilot Notifications";
Value: Text;
CanConsume: Boolean;
HasBilling: Boolean;
QuotaUsedPercentage: Decimal;
CanConsumeLbl: Label 'CanConsume', Locked = true;
HasSetupBillingLbl: Label 'HasSetupBilling', Locked = true;
QuotaUsedPercentageLbl: Label 'QuotaUsedPercentage', Locked = true;
begin
if Results.ContainsKey(CanConsumeLbl) then begin
Results.Get(CanConsumeLbl, Value);
if Evaluate(CanConsume, Value) then;
if not CanConsume then begin
CopilotNotifications.ShowAIQuotaUsedUpNotification();
exit;
end;
end;

if Results.ContainsKey(HasSetupBillingLbl) then begin
Results.Get(HasSetupBillingLbl, Value);
if Evaluate(HasBilling, Value) then;
if HasBilling then
exit;
end;

if Results.ContainsKey(QuotaUsedPercentageLbl) then begin
Results.Get(QuotaUsedPercentageLbl, Value);
if Evaluate(QuotaUsedPercentage, Value) then;
if QuotaUsedPercentage >= 80.0 then
CopilotNotifications.ShowAIQuotaNearlyUsedUpNotification();
exit;
end;
end;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ codeunit 7786 "Copilot Quota Impl."
CapabilityNotRegisteredTelemetryMsg: Label 'Capability "%1" is not registered in the system but is logging usage.', Locked = true;
LoggingUsageTelemetryMsg: Label 'Capability "%1" is logging %2 usage of type %3.', Locked = true;

trigger OnRun()
var
ALCopilotFunctions: DotNet ALCopilotFunctions;
ALCopilotQuotaDetails: Dotnet ALCopilotQuotaDetails;
Results: Dictionary of [Text, Text];
begin
ALCopilotQuotaDetails := ALCopilotFunctions.GetCopilotQuotaDetails();

if IsNull(ALCopilotQuotaDetails) then
exit;

Results.Add('CanConsume', Format(ALCopilotQuotaDetails.CanConsume()));
Results.Add('HasSetupBilling', Format(ALCopilotQuotaDetails.HasSetupBilling()));
Results.Add('QuotaUsedPercentage', Format(ALCopilotQuotaDetails.QuotaUsedPercentage()));

Page.SetBackgroundTaskResult(Results);
end;

procedure LogQuotaUsage(CopilotCapability: Enum "Copilot Capability"; Usage: Integer; CopilotQuotaUsageType: Enum "Copilot Quota Usage Type"; CallerModuleInfo: ModuleInfo)
var
CopilotCapabilityImpl: Codeunit "Copilot Capability Impl";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ page 2515 "AppSource Product List"
Caption = 'Edit User Settings';
RunObject = page "User Settings";
Image = UserSetup;
ToolTip = 'Locale will be used to determine the market and language will be used to determine the language of the app details listed here.';
ToolTip = 'Locale determines the language used for details about the app in Business Central and on AppSource.';
}
}

Expand Down

0 comments on commit 99874a4

Please sign in to comment.