Skip to content

Commit

Permalink
Refactor permission set and update label names for clarity; streamlin…
Browse files Browse the repository at this point in the history
…e file handling procedures
  • Loading branch information
IceOnly committed Dec 17, 2024
1 parent 3f8fff0 commit 82fe7b9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ permissionset 9452 "File System - Objects"

Permissions =
table "File Account" = X,
table "File System Connector" = X,
table "File System Connector Logo" = X,
table "File Account Content" = X,
table "File Account Scenario" = X,
table "File Scenario" = X;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,18 @@ page 9451 "File Account Wizard"
AccountWasRegistered: Boolean;
ConnectorSucceeded: Boolean;
CustomDimensions: Dictionary of [Text, Text];
CTHLbl: Label '%1 account has been setup.', Locked = true;
CTILbl: Label '%1 account has failed to setup. Error: %2', Locked = true;
TelemetryAccountRegisteredLbl: Label '%1 account has been setup.', Locked = true;
TelemetryAccountFailedtoRegisterLbl: Label '%1 account has failed to setup. Error: %2', Locked = true;
begin
ConnectorSucceeded := TryRegisterAccount(AccountWasRegistered);
CustomDimensions.Add('Category', FileCategoryLbl);

if AccountWasRegistered then begin
FeatureTelemetry.LogUptake('0000CTF', 'File Access', Enum::"Feature Uptake Status"::"Set up");
Telemetry.LogMessage('0000CTH', StrSubstNo(CTHLbl, Rec.Connector), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, CustomDimensions);
Telemetry.LogMessage('0000CTH', StrSubstNo(TelemetryAccountRegisteredLbl, Rec.Connector), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, CustomDimensions);
NextStep(false);
end else begin
Telemetry.LogMessage('0000CTI', StrSubstNo(CTILbl, Rec.Connector, GetLastErrorCallStack()), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, CustomDimensions);
Telemetry.LogMessage('0000CTI', StrSubstNo(TelemetryAccountFailedtoRegisterLbl, Rec.Connector, GetLastErrorCallStack()), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, CustomDimensions);
NextStep(true);
end;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ codeunit 9454 "File System"
/// </summary>
/// <param name="Path">Start path of the dialog.</param>
/// <returns>Returns the selected Folder.</returns>
procedure SelectFolderUI(Path: Text): Text
procedure SelectAndGetFolderPath(Path: Text): Text
var
DefaultSelectFolderUILbl: Label 'Select a folder';
DefaultSelectFolderLbl: Label 'Select a folder';
begin
exit(SelectFolderUI(Path, DefaultSelectFolderUILbl));
exit(SelectAndGetFolderPath(Path, DefaultSelectFolderLbl));
end;

/// <summary>
Expand All @@ -187,9 +187,9 @@ codeunit 9454 "File System"
/// <param name="Path">Start path of the dialog.</param>
/// <param name="DialogTitle">Title of the selection dialog.</param>
/// <returns>Returns the selected Folder.</returns>
procedure SelectFolderUI(Path: Text; DialogTitle: Text): Text
procedure SelectAndGetFolderPath(Path: Text; DialogTitle: Text): Text
begin
exit(FileSystemImpl.SelectFolderUI(Path, DialogTitle));
exit(FileSystemImpl.SelectAndGetFolderPath(Path, DialogTitle));
end;

/// <summary>
Expand All @@ -198,11 +198,11 @@ codeunit 9454 "File System"
/// <param name="Path">Start path.</param>
/// <param name="FileFilter">A filter string that applies only on files not on folders.</param>
/// <returns>Returns the path of the selected file.</returns>
procedure SelectFileUI(Path: Text; FileFilter: Text): Text
procedure SelectAndGetFilePath(Path: Text; FileFilter: Text): Text
var
DefaultSelectFileUILbl: Label 'Select a file';
begin
exit(SelectFileUI(Path, FileFilter, DefaultSelectFileUILbl));
exit(SelectAndGetFilePath(Path, FileFilter, DefaultSelectFileUILbl));
end;

/// <summary>
Expand All @@ -212,9 +212,9 @@ codeunit 9454 "File System"
/// <param name="FileFilter">A filter string that applies only on files not on folders.</param>
/// <param name="DialogTitle">Title of the selection dialog.</param>
/// <returns>Returns the path of the selected file.</returns>
procedure SelectFileUI(Path: Text; FileFilter: Text; DialogTitle: Text): Text
procedure SelectAndGetFilePath(Path: Text; FileFilter: Text; DialogTitle: Text): Text
begin
exit(FileSystemImpl.SelectFileUI(Path, FileFilter, DialogTitle));
exit(FileSystemImpl.SelectAndGetFilePath(Path, FileFilter, DialogTitle));
end;

/// <summary>
Expand All @@ -223,11 +223,11 @@ codeunit 9454 "File System"
/// <param name="Path">Start path of the dialog.</param>
/// <param name="FileExtension">The file extension without dot (like pdf or txt).</param>
/// <returns>Returns the selected file path.</returns>
procedure SaveFileUI(Path: Text; FileExtension: Text): Text
procedure SaveFile(Path: Text; FileExtension: Text): Text
var
DefaultSaveFileUITitleLbl: Label 'Save as';
DefaultSaveFileTitleLbl: Label 'Save as';
begin
exit(SaveFileUI(Path, FileExtension, DefaultSaveFileUITitleLbl));
exit(SaveFile(Path, FileExtension, DefaultSaveFileTitleLbl));
end;

/// <summary>
Expand All @@ -237,9 +237,9 @@ codeunit 9454 "File System"
/// <param name="FileExtension">The file extension without dot (like pdf or txt).</param>
/// <param name="DialogTitle">Title of the selection dialog.</param>
/// <returns>Returns the selected file path.</returns>
procedure SaveFileUI(Path: Text; FileExtension: Text; DialogTitle: Text): Text
procedure SaveFile(Path: Text; FileExtension: Text; DialogTitle: Text): Text
begin
exit(FileSystemImpl.SaveFileUI(Path, FileExtension, DialogTitle));
exit(FileSystemImpl.SaveFile(Path, FileExtension, DialogTitle));
end;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,80 +37,80 @@ codeunit 9455 "File System Impl."

procedure ListFiles(Path: Text; FilePaginationData: Codeunit "File Pagination Data"; var FileAccountContent: Record "File Account Content" temporary)
begin
CheckPath(Path);
CheckInitialization();
CheckPath(Path);
FileSystemConnector.ListFiles(CurrFileAccount."Account Id", Path, FilePaginationData, FileAccountContent);
end;

procedure GetFile(Path: Text; Stream: InStream)
begin
CheckPath(Path);
CheckInitialization();
CheckPath(Path);
FileSystemConnector.GetFile(CurrFileAccount."Account Id", Path, Stream);
end;

procedure CreateFile(Path: Text; Stream: InStream)
begin
CheckPath(Path);
CheckInitialization();
CheckPath(Path);
FileSystemConnector.CreateFile(CurrFileAccount."Account Id", Path, Stream);
end;

procedure CopyFile(SourcePath: Text; TargetPath: Text)
begin
CheckInitialization();
CheckPath(SourcePath);
CheckPath(TargetPath);
CheckInitialization();
FileSystemConnector.CopyFile(CurrFileAccount."Account Id", SourcePath, TargetPath);
end;

procedure MoveFile(SourcePath: Text; TargetPath: Text)
begin
CheckInitialization();
CheckPath(SourcePath);
CheckPath(TargetPath);
CheckInitialization();
FileSystemConnector.MoveFile(CurrFileAccount."Account Id", SourcePath, TargetPath);
end;

procedure FileExists(Path: Text): Boolean
begin
CheckPath(Path);
CheckInitialization();
CheckPath(Path);
exit(FileSystemConnector.FileExists(CurrFileAccount."Account Id", Path));
end;

procedure DeleteFile(Path: Text)
begin
CheckPath(Path);
CheckInitialization();
CheckPath(Path);
FileSystemConnector.DeleteFile(CurrFileAccount."Account Id", Path);
end;

procedure ListDirectories(Path: Text; FilePaginationData: Codeunit "File Pagination Data"; var FileAccountContent: Record "File Account Content" temporary)
begin
CheckPath(Path);
CheckInitialization();
CheckPath(Path);
FileSystemConnector.ListDirectories(CurrFileAccount."Account Id", Path, FilePaginationData, FileAccountContent);
end;

procedure CreateDirectory(Path: Text)
begin
CheckPath(Path);
CheckInitialization();
CheckPath(Path);
FileSystemConnector.CreateDirectory(CurrFileAccount."Account Id", Path);
end;

procedure DirectoryExists(Path: Text): Boolean
begin
CheckPath(Path);
CheckInitialization();
CheckPath(Path);
exit(FileSystemConnector.DirectoryExists(CurrFileAccount."Account Id", Path));
end;

procedure DeleteDirectory(Path: Text)
begin
CheckPath(Path);
CheckInitialization();
CheckPath(Path);
FileSystemConnector.DeleteDirectory(CurrFileAccount."Account Id", Path);
end;

Expand All @@ -137,13 +137,13 @@ codeunit 9455 "File System Impl."
ParentPath := Path.Substring(1, Path.LastIndexOf(PathSeparator()));
end;

procedure SelectFolderUI(Path: Text; DialogTitle: Text): Text
procedure SelectAndGetFolderPath(Path: Text; DialogTitle: Text): Text
var
FileAccountContent: Record "File Account Content";
StorageBrowser: Page "Storage Browser";
begin
CheckPath(Path);
CheckInitialization();
CheckPath(Path);

StorageBrowser.SetPageCaption(DialogTitle);
StorageBrowser.SetFileAccount(CurrFileAccount);
Expand All @@ -158,13 +158,13 @@ codeunit 9455 "File System Impl."
exit(CombinePath(FileAccountContent."Parent Directory", FileAccountContent.Name));
end;

procedure SelectFileUI(Path: Text; FileFilter: Text; DialogTitle: Text): Text
procedure SelectAndGetFilePath(Path: Text; FileFilter: Text; DialogTitle: Text): Text
var
FileAccountContent: Record "File Account Content";
StorageBrowser: Page "Storage Browser";
begin
CheckPath(Path);
CheckInitialization();
CheckPath(Path);

StorageBrowser.SetPageCaption(DialogTitle);
StorageBrowser.SetFileAccount(CurrFileAccount);
Expand All @@ -179,15 +179,15 @@ codeunit 9455 "File System Impl."
exit(CombinePath(FileAccountContent."Parent Directory", FileAccountContent.Name));
end;

procedure SaveFileUI(Path: Text; FileExtension: Text; DialogTitle: Text): Text
procedure SaveFile(Path: Text; FileExtension: Text; DialogTitle: Text): Text
var
StorageBrowser: Page "Storage Browser";
FileName, FileNameWithExtension : Text;
PleaseProvideFileExtensionErr: Label 'Please provide a valid file extension.';
FileNameTok: Label '%1.%2', Locked = true;
begin
CheckPath(Path);
CheckInitialization();
CheckPath(Path);

if FileExtension = '' then
Error(PleaseProvideFileExtensionErr);
Expand Down

0 comments on commit 82fe7b9

Please sign in to comment.