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

Add functionality to have job queues with different schedules #194

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
1 change: 1 addition & 0 deletions businessCentral/app/permissions/Execute.PermissionSet.al
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ permissionset 82561 "ADLSE - Execute"
tabledata "ADLSE Enum Translation" = RIMD,
tabledata "ADLSE Enum Translation Lang" = RIMD,
tabledata "Deleted Tables Not to Sync" = R,
tabledata "ADLSE Export Category" = R,
codeunit "ADLSE UpgradeTagNewCompanySubs" = X,
codeunit "ADLSE Upgrade" = X,
codeunit "ADLSE Util" = X,
Expand Down
4 changes: 4 additions & 0 deletions businessCentral/app/permissions/Setup.PermissionSet.al
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ permissionset 82560 "ADLSE - Setup"
tabledata "ADLSE Enum Translation" = RIMD,
tabledata "ADLSE Enum Translation Lang" = RIMD,
tabledata "Deleted Tables Not to Sync" = RIMD,
tabledata "ADLSE Export Category" = RIMD,
codeunit "ADLSE Clear Tracked Deletions" = X,
codeunit "ADLSE Credentials" = X,
codeunit "ADLSE Setup" = X,
Expand All @@ -29,5 +30,8 @@ permissionset 82560 "ADLSE - Setup"
page "ADLSE Run" = X,
page "ADLSE Enum Translations" = X,
page "ADLSE Enum Translations Lang" = X,
page "ADLSE Export Categories" = X,
page "ADLSE Assign Export Category" = X,
report "ADLSE Schedule Task Assignment" = X,
xmlport "BC2ADLS Import" = X;
}
29 changes: 29 additions & 0 deletions businessCentral/app/src/AssignExportCategoryDialog.page.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
page 82576 "ADLSE Assign Export Category"
{
ApplicationArea = Basic, Suite;
Caption = 'Assign Export Category';
PageType = StandardDialog;
DataCaptionExpression = '';
ModifyAllowed = false;

layout
{
area(Content)
{
field("Export Category"; ExportCategory)
{
ApplicationArea = Basic, Suite;
Caption = 'Export Catgory';
TableRelation = "ADLSE Export Category".Code;
ToolTip = 'Specifies Unique Code of an Export Category which can be linked to tables which are part of the export to Azure Datalake.';
}
}
}
var
ExportCategory: code[50];

procedure GetExportCategoryCode(): Code[50]
begin
exit(ExportCategory);
end;
}
27 changes: 9 additions & 18 deletions businessCentral/app/src/Execution.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ codeunit 82569 "ADLSE Execution"
[InherentPermissions(PermissionObjectType::TableData, Database::"ADLSE Field", 'r')]
internal procedure StartExport()
var
ADLSESetupRec: Record "ADLSE Setup";
ADLSETable: Record "ADLSE Table";
begin
StartExport(AdlseTable);
end;

[InherentPermissions(PermissionObjectType::TableData, Database::"ADLSE Table", 'r')]
[InherentPermissions(PermissionObjectType::TableData, Database::"ADLSE Field", 'r')]
internal procedure StartExport(var AdlseTable: Record "ADLSE Table")
var
ADLSESetupRec: Record "ADLSE Setup";
ADLSEField: Record "ADLSE Field";
ADLSECurrentSession: Record "ADLSE Current Session";
ADLSESetup: Codeunit "ADLSE Setup";
Expand Down Expand Up @@ -138,23 +146,6 @@ codeunit 82569 "ADLSE Execution"
ADLSEExternalEvents.OnClearSchemaExportedOn(ADLSESetup);
end;

internal procedure ScheduleExport()
var
JobQueueEntry: Record "Job Queue Entry";
ScheduleAJob: Page "Schedule a Job";
Handled: Boolean;
begin
OnBeforeScheduleExport(Handled);
if Handled then
exit;

CreateJobQueueEntry(JobQueueEntry);
ScheduleAJob.SetJob(JobQueueEntry);
Commit(); // above changes go into the DB before RunModal
if ScheduleAJob.RunModal() = Action::OK then
Message(JobScheduledTxt);
end;

local procedure CreateJobQueueEntry(var JobQueueEntry: Record "Job Queue Entry")
var
JobQueueCategory: Record "Job Queue Category";
Expand Down
27 changes: 27 additions & 0 deletions businessCentral/app/src/ExportCategories.Page.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
page 82577 "ADLSE Export Categories"
{
ApplicationArea = Basic, Suite;
Caption = 'Export Catgories';
PageType = List;
SourceTable = "ADLSE Export Category";


layout
{
area(Content)
{
repeater(General)
{
field(Code; Rec.Code)
{
Caption = 'Code';
}
field(Description; Rec.Description)
{
Caption = 'Description';
}
}
}
}
}

30 changes: 30 additions & 0 deletions businessCentral/app/src/ExportCategory.Table.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
table 82570 "ADLSE Export Category"
{
Caption = 'Export Category';
DataClassification = ToBeClassified;
LookupPageId = "ADLSE Export Categories";

Bertverbeek4PS marked this conversation as resolved.
Show resolved Hide resolved
fields
{
field(1; "Code"; Code[50])
{
Caption = 'Code';
DataClassification = CustomerContent;
ToolTip = 'Specifies the Unique Code of a Export Category which can be linked to tables which are part of the export to Azure Datalake.';
}
field(10; Description; Text[250])
{
Caption = 'Description';
DataClassification = CustomerContent;
ToolTip = 'Specifies the Description of the Export Category.';
}
}
keys
{
key(PK; "Code")
{
Clustered = true;
}
}
}

149 changes: 149 additions & 0 deletions businessCentral/app/src/ScheduleTaskAssignment.Report.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
report 82561 "ADLSE Schedule Task Assignment"
{
ApplicationArea = Basic, Suite;
Caption = 'Schedule Export';
ProcessingOnly = true;


dataset
{
dataitem(ADLSETable; "ADLSE Table")
{
RequestFilterFields = ExportCategory;
trigger OnPreDataItem()
var
ADLSEExecution: Codeunit "ADLSE Execution";
begin
ADLSEExecution.StartExport(ADLSETable);
end;
}
}
requestpage
{
SaveValues = true;
layout
{
area(Content)
{
group(Options)
{
Caption = 'Options';
field(JobQueueDescription; Description)
{
ApplicationArea = All;
Caption = 'Description';
ToolTip = 'Specifies the description that is displayed in the job queue.';
}
field(EarliestStartDateTimeControl; EarliestStartDateTime)
{
ApplicationArea = All;
Caption = 'Earliest Start Date / Time ';
ToolTip = 'Specifies the date and time when the job queue must be executed for the first time.';
}
field(NoofMinutesBetweeenRuns; NoofMinutesBetweenRuns)
{
ApplicationArea = All;
Caption = 'No of minutes between runs';
ToolTip = 'Specifies the minimum number of minutes that are to elapse between runs of a job queue entry. The value cannot be less than one minute.';
Bertverbeek4PS marked this conversation as resolved.
Show resolved Hide resolved
}
}

group(Recurrence)
{
grid(Daysgrid)
{
Caption = 'Recurrence';
group(Recurrence1)
{
ShowCaption = false;
field(RunOnMondaysControl; RunOnMondays)
{
ApplicationArea = All;
Caption = 'Run On Mondays';
ToolTip = 'Specifies that the job queue entry runs on Mondays.';
}
field(RunOnTeusdaysControl; RunOnTeusdays)
{
ApplicationArea = All;
Caption = 'Run On Tuesdays';
ToolTip = 'Specifies that the job queue entry runs on Teusdays.';
}
field(RunOnWednesdayControl; RunOnWednesdays)
{
ApplicationArea = All;
Caption = 'Run On Wednesdays';
ToolTip = 'Specifies that the job queue entry runs on Wednesdays.';
}
field(RunOnThursdayControl; RunOnThursdays)
{
ApplicationArea = All;
Caption = 'Run On Thursdays';
ToolTip = 'Specifies that the job queue entry runs on Thursdays.';
}
}
group(Recurrence2)
{
ShowCaption = false;
field(RunOnFridayControl; RunOnFridays)
{
ApplicationArea = All;
Caption = 'Run On Fridays';
ToolTip = 'Specifies that the job queue entry runs on Fridays.';
}
field(RunOnSaturdayControl; RunOnSaturdays)
{
ApplicationArea = All;
Caption = 'Run On Saturdays';
ToolTip = 'Specifies that the job queue entry runs on Saturdays.';
}
field(RunOnSundaysControl; RunOnSundays)
{
ApplicationArea = All;
Caption = 'Run On Sundays';
ToolTip = 'Specifies that the job queue entry runs on Sundays.';
}
}
}
}
}
}
}

var
Description: Text[30];
JobCategoryCodeTxt: Label 'ADLSE', Locked = true;
EarliestStartDateTime: DateTime;
NoofMinutesBetweenRuns: Integer;
RunOnSundays: Boolean;
RunOnMondays: Boolean;
RunOnTeusdays: Boolean;
RunOnWednesdays: Boolean;
RunOnThursdays: Boolean;
RunOnFridays: Boolean;
RunOnSaturdays: Boolean;

procedure CreateJobQueueEntry(var JobQueueEntry: Record "Job Queue Entry")
var
JobQueueCategory: Record "Job Queue Category";
begin
Clear(JobQueueEntry);
JobQueueCategory.InsertRec(JobCategoryCodeTxt, Description);
JobQueueEntry.Init();
JobQueueEntry.Status := JobQueueEntry.Status::"On Hold";
JobQueueEntry.Description := Description;
JobQueueEntry."No. of Minutes between Runs" := NoofMinutesBetweenRuns;
JobQueueEntry."Run on Mondays" := RunOnMondays;
JobQueueEntry."Run on Tuesdays" := RunOnTeusdays;
JobQueueEntry."Run on Wednesdays" := RunOnWednesdays;
JobQueueEntry."Run on Thursdays" := RunOnThursdays;
JobQueueEntry."Run on Fridays" := RunOnFridays;
JobQueueEntry."Run on Saturdays" := RunOnSaturdays;
JobQueueEntry."Run on Sundays" := RunOnSundays;
JobQueueEntry."Object Type to Run" := JobQueueEntry."Object Type to Run"::Report;
JobQueueEntry."Object ID to Run" := Report::"ADLSE Schedule Task Assignment";
JobQueueEntry."Earliest Start Date/Time" := EarliestStartDateTime;
JobQueueEntry."Report Output Type" := JobQueueEntry."Report Output Type"::"None (Processing only)";
JobQueueEntry.Insert(true);
end;
}

44 changes: 42 additions & 2 deletions businessCentral/app/src/Setup.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,27 @@ page 82560 "ADLSE Setup"

trigger OnAction()
var
ADLSEExecution: Codeunit "ADLSE Execution";
JobQueueEntry: Record "Job Queue Entry";
ADLSEScheduleTaskAssignment: Report "ADLSE Schedule Task Assignment";
SavedData: Text;
xmldata: Text;
begin
ADLSEExecution.ScheduleExport();
Bertverbeek4PS marked this conversation as resolved.
Show resolved Hide resolved
JobQueueEntry.SetFilter("User ID", UserId());
JobQueueEntry.SetRange("Object Type to Run", JobQueueEntry."Object Type to Run"::Report);
JobQueueEntry.SetRange("Object ID to Run", Report::"ADLSE Schedule Task Assignment");
JobQueueEntry.SetCurrentKey(SystemCreatedAt);
JobQueueEntry.SetAscending(SystemCreatedAt, false);

if JobQueueEntry.FindFirst() then
SavedData := JobQueueEntry.GetReportParameters();

xmldata := ADLSEScheduleTaskAssignment.RunRequestPage(SavedData);

if xmldata <> '' then begin
ADLSEScheduleTaskAssignment.CreateJobQueueEntry(JobQueueEntry);
JobQueueEntry.SetReportParameters(xmldata);
JobQueueEntry.Modify();
end;
end;
}

Expand Down Expand Up @@ -286,6 +304,28 @@ page 82560 "ADLSE Setup"
Image = Delete;
RunObject = page "Deleted Tables Not To Sync";
}
action("Job Queue")
{
Caption = 'Job Queue';
ApplicationArea = All;
ToolTip = 'Specifies the scheduled Job Queues for the export to Datalake.';
Image = BulletList;
trigger OnAction()
var
JobQueueEntry: Record "Job Queue Entry";
begin
JobQueueEntry.SetFilter("Object ID to Run", '%1|%2', Codeunit::"ADLSE Execution", Report::"ADLSE Schedule Task Assignment");
Page.Run(Page::"Job Queue Entries", JobQueueEntry);
end;
}
action("Export Category")
{
Caption = 'Export Category';
ApplicationArea = All;
ToolTip = 'Specifies the Export Categories available for scheduling the export to Datalake.';
Image = Export;
RunObject = page "ADLSE Export Categories";
}
}
area(Promoted)
{
Expand Down
Loading
Loading