Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix errors and warning #180

Merged
merged 8 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions businessCentral/app/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
"${CodeCop}",
"${UICop}",
"${PerTenantExtensionCop}",
"${analyzerfolder}BusinessCentral.LinterCop.dll"
"${analyzerFolder}BusinessCentral.LinterCop.dll"
],
"al.ruleSetPath": "./.vscode/custom.ruleset.json",
"CRS.FileNamePattern": "<ObjectNameShort>.<ObjectTypeShortPascalCase>.al",
"CRS.FileNamePatternExtensions": "<ObjectNameShort>.<ObjectTypeShortPascalCase>.al",
"CRS.FileNamePatternPageCustomizations": "<ObjectNameShort>.<ObjectTypeShortPascalCase>.al",
"CRS.RemovePrefixFromFilename": true
"CRS.RemovePrefixFromFilename": true,
"linterCop.repositories": [
{
"url": "https://github.com/StefanMaron/BusinessCentral.LinterCop",
"shortName": "BcLntr",
"fileName": "BusinessCentral.LinterCop.dll"
}
]
}
24 changes: 24 additions & 0 deletions businessCentral/app/permissions/Api.PermissionSet.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. See LICENSE in the project root for license information.
permissionset 82563 "ADLSE - API"
{
/// <summary>
/// The permission set to be used when using the API.
/// </summary>
Access = Public;
Assignable = true;
Caption = 'ADLS - Api', MaxLength = 30;

Permissions = tabledata "ADLSE Table" = RMI,
tabledata "ADLSE Setup" = R,
tabledata "ADLSE Current Session" = R,
tabledata "ADLSE Run" = R,
tabledata "ADLSE Field" = RI,
page "ADLSE Table API" = X,
page "ADLSE Setup API v11" = X,
page "ADLSE CurrentSession API" = X,
page "ADLSE Run API" = X,
page "ADLSE Field API" = X,
codeunit "ADLSE External Events Helper" = X,
codeunit "ADLSE External Events" = X;
}
17 changes: 15 additions & 2 deletions businessCentral/app/permissions/Execute.PermissionSet.al
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ permissionset 82561 "ADLSE - Execute"
/// </summary>
Access = Public;
Assignable = true;
Caption = 'Azure Data Lake Storage - Execute';
Caption = 'ADLS - Execute', MaxLength = 30;

Permissions = tabledata "ADLSE Setup" = RM,
tabledata "ADLSE Table" = RM,
Expand All @@ -17,5 +17,18 @@ permissionset 82561 "ADLSE - Execute"
tabledata "ADLSE Table Last Timestamp" = RIMD,
tabledata "ADLSE Run" = RIMD,
tabledata "ADLSE Enum Translation" = RIMD,
tabledata "ADLSE Enum Translation Lang" = RIMD;
tabledata "ADLSE Enum Translation Lang" = RIMD,
codeunit "ADLSE UpgradeTagNewCompanySubs" = X,
codeunit "ADLSE Upgrade" = X,
codeunit "ADLSE Util" = X,
codeunit ADLSE = X,
codeunit "ADLSE CDM Util" = X,
codeunit "ADLSE Communication" = X,
codeunit "ADLSE Session Manager" = X,
codeunit "ADLSE Http" = X,
codeunit "ADLSE Gen 2 Util" = X,
codeunit "ADLSE Execute" = X,
codeunit "ADLSE Execution" = X,
report "ADLSE Seek Data" = X,
xmlport "BC2ADLS Export" = X;
}
17 changes: 15 additions & 2 deletions businessCentral/app/permissions/Setup.PermissionSet.al
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,26 @@ permissionset 82560 "ADLSE - Setup"
/// </summary>
Access = Public;
Assignable = true;
Caption = 'Azure Data Lake Storage - Setup';
Caption = 'ADLS - Setup', MaxLength = 30;

Permissions = tabledata "ADLSE Setup" = RIMD,
tabledata "ADLSE Table" = RIMD,
tabledata "ADLSE Field" = RIMD,
tabledata "ADLSE Deleted Record" = RD,
tabledata "ADLSE Current Session" = R,
tabledata "ADLSE Table Last Timestamp" = RID,
tabledata "ADLSE Run" = RD;
tabledata "ADLSE Run" = RD,
tabledata "ADLSE Enum Translation" = RIMD,
tabledata "ADLSE Enum Translation Lang" = RIMD,
codeunit "ADLSE Clear Tracked Deletions" = X,
codeunit "ADLSE Credentials" = X,
codeunit "ADLSE Setup" = X,
codeunit "ADLSE Installer" = X,
page "ADLSE Setup Tables" = X,
page "ADLSE Setup Fields" = X,
page "ADLSE Setup" = X,
page "ADLSE Run" = X,
page "ADLSE Enum Translations" = X,
page "ADLSE Enum Translations Lang" = X,
xmlport "BC2ADLS Import" = X;
}
2 changes: 2 additions & 0 deletions businessCentral/app/src/BC2ADLSExport.xmlport.al
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ xmlport 82561 "BC2ADLS Export"
Caption = 'BC2ADLS Export';
UseRequestPage = false;
Direction = Export;
Permissions = tabledata "ADLSE Field" = r,
tabledata "ADLSE Table" = r;

schema
{
Expand Down
2 changes: 2 additions & 0 deletions businessCentral/app/src/BC2ADLSImport.xmlport.al
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ xmlport 82560 "BC2ADLS Import"
Caption = 'BC2ADLS Import';
UseRequestPage = false;
Direction = Import;
Permissions = tabledata "ADLSE Field" = rmi,
tabledata "ADLSE Table" = rmid;

schema
{
Expand Down
2 changes: 2 additions & 0 deletions businessCentral/app/src/CDMFormat.Enum.al
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ enum 82562 "ADLSE CDM Format"
Access = Internal;
Extensible = false;

#pragma warning disable LC0045
value(0; Csv)
{
Caption = 'CSV';
}
#pragma warning restore LC0045

value(1; Parquet)
{
Expand Down
6 changes: 3 additions & 3 deletions businessCentral/app/src/CDMUtil.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ codeunit 82566 "ADLSE CDM Util" // Refer Common Data Model https://docs.microsof
FieldDataTypeCannotBeChangedErr: Label 'The data type for the field %1 in the entity %2 cannot be changed.', Comment = '%1: field name, %2: entity name';
RepresentsTableTxt: Label 'Represents the table %1', Comment = '%1: table caption';
ManifestNameTxt: Label '%1-manifest', Comment = '%1: name of manifest';
EntityPathTok: Label '%1.cdm.json/%1', Comment = '%1: Entity';
EntityPathTok: Label '%1.cdm.json/%1', Comment = '%1: Entity', Locked = true;
UnequalAttributeCountErr: Label 'Unequal number of attributes';
MismatchedValueInAttributeErr: Label 'The attribute value for %1 at index %2 is different. First: %3, Second: %4', Comment = '%1 = field, %2 = index, %3 = value of the first, %4 = value of the second';

Expand Down Expand Up @@ -111,7 +111,7 @@ codeunit 82566 "ADLSE CDM Util" // Refer Common Data Model https://docs.microsof
Token.Add(NameValue);
end;

local procedure CreateAttributes(TableID: Integer; FieldIdList: List of [Integer]) Result: JsonArray;
local procedure CreateAttributes(TableID: Integer; FieldIdList: List of [Integer]) Result: JsonArray
var
ADLSESetup: Record "ADLSE Setup";
ADLSEUtil: Codeunit "ADLSE Util";
Expand Down Expand Up @@ -174,7 +174,7 @@ codeunit 82566 "ADLSE CDM Util" // Refer Common Data Model https://docs.microsof
FieldTable: Record Field;
begin
if FieldTable.Get(TableId, FieldId) then
exit(fieldTable.IsPartOfPrimaryKey);
exit(FieldTable.IsPartOfPrimaryKey);
end;

local procedure CreateAttributeJson(Name: Text; DataFormat: Text; DisplayName: Text; AppliedTraits: JsonArray; MaximumLength: Integer; IsPrimaryKeyFieldParameter: Boolean) Attribute: JsonObject
Expand Down
4 changes: 3 additions & 1 deletion businessCentral/app/src/ClearTrackedDeletions.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ codeunit 82573 "ADLSE Clear Tracked Deletions"
var
TrackedDeletedRecordsRemovedMsg: Label 'Representations of deleted records that have been exported previously have been deleted.';

[InherentPermissions(PermissionObjectType::TableData, Database::"ADLSE Table", 'r')]
[InherentPermissions(PermissionObjectType::TableData, Database::"ADLSE Deleted Record", 'rd')]
local procedure ClearTrackedDeletedRecords()
var
ADLSETable: Record "ADLSE Table";
Expand All @@ -29,7 +31,7 @@ codeunit 82573 "ADLSE Clear Tracked Deletions"
ADLSEDeletedRecord.SetRange("Table ID", ADLSETable."Table ID");
ADLSEDeletedRecord.SetFilter("Entry No.", '<=%1', ADLSETableLastTimestamp.GetDeletedLastEntryNo(ADLSETable."Table ID"));
if not ADLSEDeletedRecord.IsEmpty() then
ADLSEDeletedRecord.DeleteAll();
ADLSEDeletedRecord.DeleteAll(false);

ADLSETableLastTimestamp.SaveDeletedLastEntryNo(ADLSETable."Table ID", 0);
until ADLSETable.Next() = 0;
Expand Down
8 changes: 4 additions & 4 deletions businessCentral/app/src/Communication.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ codeunit 82562 "ADLSE Communication"
CorpusJsonPathTxt: Label '/%1', Comment = '%1 = name of the blob', Locked = true;
CannotAddedMoreBlocksErr: Label 'The number of blocks that can be added to the blob has reached its maximum limit.';
SingleRecordTooLargeErr: Label 'A single record payload exceeded the max payload size. Please adjust the payload size or reduce the fields to be exported for the record.';
DeltasFileCsvTok: Label '/deltas/%1/%2.csv', Comment = '%1: Entity, %2: File identifier guid';
DeltasFileCsvTok: Label '/deltas/%1/%2.csv', Comment = '%1: Entity, %2: File identifier guid', Locked = true;
ExportOfSchemaNotPerformendTxt: Label 'Please export the schema first before trying to export the data.';
EntitySchemaChangedErr: Label 'The schema of the table %1 has changed. %2', Comment = '%1 = Entity name, %2 = NotAllowedOnSimultaneousExportTxt';
CdmSchemaChangedErr: Label 'There may have been a change in the tables to export. %1', Comment = '%1 = NotAllowedOnSimultaneousExportTxt';
MSFabricUrlTxt: Label 'https://onelake.dfs.fabric.microsoft.com/%1/%2.Lakehouse/Files', Locked = true, Comment = '%1: Workspace name, %2: Lakehouse Name';
MSFabricUrlGuidTxt: Label 'https://onelake.dfs.fabric.microsoft.com/%1/%2/Files', Locked = true, Comment = '%1: Workspace name, %2: Lakehouse Name';
ResetTableExportTxt: Label '/reset/%1.txt', Locked = true, comment = '%1 = Table name';
ResetTableExportTxt: Label '/reset/%1.txt', Locked = true, Comment = '%1 = Table name';

procedure SetupBlobStorage()
var
Expand Down Expand Up @@ -224,7 +224,7 @@ codeunit 82562 "ADLSE Communication"
LastTimestampExported := LastFlushedTimeStamp;

Payload.Append(RecordPayLoad);
LastRecordOnPayloadTimeStamp := RecordTimestamp;
LastRecordOnPayloadTimeStamp := RecordTimeStamp;
end;

[TryFunction]
Expand Down Expand Up @@ -327,7 +327,7 @@ codeunit 82562 "ADLSE Communication"
if ManifestJsonsNeedsUpdate then begin
// Expected that multiple sessions that export data from different tables will be competing for writing to
// manifest. Semaphore applied.
ADLSESetup.LockTable(true);
ADLSESetup.ReadIsolation := IsolationLevel::UpdLock;
ADLSESetup.GetSingleton();

UpdateManifest(GetBaseUrl() + StrSubstNo(CorpusJsonPathTxt, DataCdmManifestNameTxt), 'data', ADLSESetup.DataFormat);
Expand Down
6 changes: 5 additions & 1 deletion businessCentral/app/src/Credentials.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ codeunit 82565 "ADLSE Credentials"
[NonDebuggable]
procedure IsClientIDSet(): Boolean
begin
exit(GetClientId() <> '');
exit(GetClientID() <> '');
end;

[NonDebuggable]
Expand All @@ -100,17 +100,21 @@ codeunit 82565 "ADLSE Credentials"
begin
if not IsolatedStorage.Contains(KeyName, IsolatedStorageDataScope()) then
exit('');
#pragma warning disable LC0043
IsolatedStorage.Get(KeyName, IsolatedStorageDataScope(), Secret);
#pragma warning restore LC0043
end;

[NonDebuggable]
local procedure SetSecret(KeyName: Text; Secret: Text)
begin
#pragma warning disable LC0043
if EncryptionEnabled() then begin
IsolatedStorage.SetEncrypted(KeyName, Secret, IsolatedStorageDataScope());
exit;
end;
IsolatedStorage.Set(KeyName, Secret, IsolatedStorageDataScope());
#pragma warning restore LC0043
end;

[NonDebuggable]
Expand Down
14 changes: 11 additions & 3 deletions businessCentral/app/src/CurrentSession.Table.al
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma warning disable LC0015
table 82565 "ADLSE Current Session"
#pragma warning restore
{
Access = Internal;
Caption = 'ADLSE Current Session';
DataClassification = SystemMetadata;
DataPerCompany = false;

Expand Down Expand Up @@ -48,6 +51,7 @@ table 82565 "ADLSE Current Session"
InsertFailedErr: Label 'Could not start the export as there is already an active export running for the table %1. If this is not so, please stop all exports and try again.', Comment = '%1 = table caption';
CouldNotStopSessionErr: Label 'Could not delete the export table session %1 for table on company %2.', Comment = '%1: session id, %2: company name';

[InherentPermissions(PermissionObjectType::TableData, Database::"ADLSE Current Session", 'i')]
procedure Start(ADLSETableID: Integer)
var
ADLSEUtil: Codeunit "ADLSE Util";
Expand All @@ -57,10 +61,11 @@ table 82565 "ADLSE Current Session"
Rec."Session ID" := SessionId();
Rec."Session Unique ID" := GetActiveSessionIDForSession(SessionId());
Rec."Company Name" := CopyStr(CompanyName(), 1, 30);
if not Rec.Insert() then
if not Rec.Insert(true) then
Error(InsertFailedErr, ADLSEUtil.GetTableCaption(ADLSETableID));
end;

[InherentPermissions(PermissionObjectType::TableData, Database::"ADLSE Current Session", 'rd')]
procedure Stop(ADLSETableID: Integer; EmitTelemetry: Boolean; TableCaption: Text)
var
ADLSEExecution: Codeunit "ADLSE Execution";
Expand All @@ -69,7 +74,7 @@ table 82565 "ADLSE Current Session"
if not Rec.Get(ADLSETableID, CompanyName()) then
exit;
CustomDimensions.Add('Entity', TableCaption);
if not Rec.Delete() then
if not Rec.Delete(true) then
ADLSEExecution.Log('ADLSE-036', StrSubstNo(CouldNotStopSessionErr, Rec."Session ID", CompanyName()), Verbosity::Error, CustomDimensions)
else
ADLSEExecution.Log('ADLSE-039', 'Session ended and was removed', Verbosity::Normal, CustomDimensions);
Expand All @@ -81,6 +86,7 @@ table 82565 "ADLSE Current Session"
Error(ExportDataInProgressErr);
end;

[InherentPermissions(PermissionObjectType::TableData, Database::"ADLSE Current Session", 'r')]
procedure AreAnySessionsActive() AnyActive: Boolean
begin
Rec.SetRange("Company Name", CopyStr(CompanyName(), 1, 30));
Expand All @@ -93,12 +99,14 @@ table 82565 "ADLSE Current Session"
until Rec.Next() = 0;
end;

[InherentPermissions(PermissionObjectType::TableData, Database::"ADLSE Current Session", 'd')]
procedure CleanupSessions()
begin
Rec.SetRange("Company Name", CopyStr(CompanyName(), 1, 30));
Rec.DeleteAll(false);
end;

[InherentPermissions(PermissionObjectType::TableData, Database::"ADLSE Current Session", 'rd')]
procedure CancelAll()
var
ADLSEUtil: Codeunit "ADLSE Util";
Expand All @@ -109,7 +117,7 @@ table 82565 "ADLSE Current Session"
Session.StopSession(Rec."Session ID", StrSubstNo(SessionTerminatedMsg, ADLSEUtil.GetTableCaption(Rec."Table ID")));
until Rec.Next() = 0;

Rec.DeleteAll();
Rec.DeleteAll(false);
end;

local procedure IsSessionActive(): Boolean
Expand Down
6 changes: 6 additions & 0 deletions businessCentral/app/src/CurrentSessionAPI.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ page 82571 "ADLSE CurrentSession API"
{
Editable = false;
}
#pragma warning disable LC0016
field(systemRowVersion; Rec.SystemRowVersion)
{
Editable = false;
}
#pragma warning restore
field(lastModifiedDateTime; Rec.SystemModifiedAt)
{
Editable = false;
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions businessCentral/app/src/DeletedRecord.Table.al
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma warning disable LC0015
table 82563 "ADLSE Deleted Record"
#pragma warning restore
{
Access = Internal;
Caption = 'ADLSE Deleted Record';
DataClassification = SystemMetadata;

fields
Expand Down
Loading
Loading