From b7b0c08e502b3076a3135e1c385850c4ee0e00c2 Mon Sep 17 00:00:00 2001 From: Kasper Lind Date: Thu, 12 Nov 2026 09:48:45 +0100 Subject: [PATCH] Add SpencerMetrics integration components - Created "PVS SM Count Summary Buffer" table to store summary data. - Implemented "PVS SM Counter Entries" page for displaying counter entries. - Developed "PVS SM Counter Entry" table for individual counter records. - Added "PVS SM Counts Sum By UOM" query for aggregating counts by UOM. - Introduced "PVS SM Assign To Job Costing" page for assigning counts to job costing entries. - Created "PVS SM Counter Worker" codeunit for processing counter data. - Developed "PVS SM Session Manager" codeunit for managing session states. - Implemented "PVS SM Api Client" codeunit for handling API interactions. - Added "PVS SM Timer AddIn" control add-in for timer functionality. - Extended "PVS SF Electronic Ticket" page to include SpencerMetrics count summary. - Extended "PVS Job Sheet" table to include SpencerMetrics key. --- .../.vscode/settings.json | 7 + .../Logo/PV_logo_240x240px.png | Bin 0 -> 16632 bytes .../Permissions/PVSSMFULL.PermissionSet.al | 36 +++ .../PrintVis SpencerMetrics/app.json | 44 ++++ .../src/API/PVSSMOrderSheetAPI.Page.al | 34 +++ .../CostCenter/PVSSMCostCenterSetup.Page.al | 88 +++++++ .../CostCenter/PVSSMCostCenterSetup.Table.al | 70 ++++++ .../SessionLog/PVSSMSessionEventType.Enum.al | 16 ++ .../SessionLog/PVSSMSessionLog.Page.al | 52 ++++ .../SessionLog/PVSSMSessionLog.Table.al | 73 ++++++ .../PVSSMSessionParameter.Table.al | 33 +++ .../Configuration/Setup/PVSSMSetup.Page.al | 33 +++ .../Configuration/Setup/PVSSMSetup.Table.al | 43 ++++ .../src/Core/PVSSMEventHandler.Codeunit.al | 97 ++++++++ .../src/Core/PVSSMEvents.Codeunit.al | 17 ++ .../src/Core/PVSSMInstall.Codeunit.al | 30 +++ .../Entries/PVSSMCountFactBox.Page.al | 83 +++++++ .../Entries/PVSSMCountSummaryBuffer.Table.al | 41 +++ .../Entries/PVSSMCounterEntries.Page.al | 96 ++++++++ .../Entries/PVSSMCounterEntry.Table.al | 122 +++++++++ .../Entries/PVSSMCountsSumByUOM.Query.al | 16 ++ .../PVSSMAssignToJobCosting.Page.al | 116 +++++++++ .../PVSSMCounterWorker.Codeunit.al | 91 +++++++ .../PVSSMSessionManager.Codeunit.al | 215 ++++++++++++++++ .../PVSSMElectronicTicket.PageExt.al | 32 +++ .../PVSSMSheet.TableExt.al | 35 +++ .../src/Services/PVSSMApiClient.Codeunit.al | 233 ++++++++++++++++++ .../PVSSMTimerAddIn.ControlAddin.al | 15 ++ .../src/Utilities/TimerAddIn/timer.js | 65 +++++ 29 files changed, 1833 insertions(+) create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/.vscode/settings.json create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/Logo/PV_logo_240x240px.png create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/Permissions/PVSSMFULL.PermissionSet.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/app.json create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/API/PVSSMOrderSheetAPI.Page.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/CostCenter/PVSSMCostCenterSetup.Page.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/CostCenter/PVSSMCostCenterSetup.Table.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionLog/PVSSMSessionEventType.Enum.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionLog/PVSSMSessionLog.Page.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionLog/PVSSMSessionLog.Table.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionParameter/PVSSMSessionParameter.Table.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/Setup/PVSSMSetup.Page.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/Setup/PVSSMSetup.Table.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Core/PVSSMEventHandler.Codeunit.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Core/PVSSMEvents.Codeunit.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Core/PVSSMInstall.Codeunit.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCountFactBox.Page.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCountSummaryBuffer.Table.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCounterEntries.Page.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCounterEntry.Table.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCountsSumByUOM.Query.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/PVSSMAssignToJobCosting.Page.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/PVSSMCounterWorker.Codeunit.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/PVSSMSessionManager.Codeunit.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/PrintVisIntegration/PVSSMElectronicTicket.PageExt.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/PrintVisIntegration/PVSSMSheet.TableExt.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Services/PVSSMApiClient.Codeunit.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Utilities/TimerAddIn/PVSSMTimerAddIn.ControlAddin.al create mode 100644 Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Utilities/TimerAddIn/timer.js diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/.vscode/settings.json b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/.vscode/settings.json new file mode 100644 index 0000000..1c72724 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "al.codeAnalyzers": [ + "${PerTenantExtensionCop}", + "${CodeCop}", + "${UICop}" + ] +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/Logo/PV_logo_240x240px.png b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/Logo/PV_logo_240x240px.png new file mode 100644 index 0000000000000000000000000000000000000000..fd61b39c5ef32624af02ab16508cb92e169dec55 GIT binary patch literal 16632 zcmdtKcQl+~_cr=yQG@6aVS*r{jNXY}qD1dx^xk`o5d=XHL=S?9=)DJFA|pifn&^q% zdpURBcD{Ai_x;xU&-v$@6^wB|`?|LDXb_zc6fbe}GXqL-slbUIuEaqL!}CTnH;y3u`VvXE!h!g2bi# z+z^(I)?P3RYg>C43C8V~4n~;0l?0={fErxQP1f4ZUMaxCT01~p$1=dtQpAc;N)jgS zCkg~OTYDj3e$GxVo}zvdjQ@};3f}+yn41yyk0D-;5{%M+ZwNC`djgYn^{|Esa0zl+ z^6(45ghaS_1o`+yL^xo)a2{c9xG*;lA19BXC_h}3mlyW07bCcvhn0<}mYl-B?gf66 zV6^k{auem|_VxAU^5x@l^|0mU5fKsLhVyds@^XR^oSyzJUI;%<7f+^tOOUhnwDhod z^Rjn!f&G<;uyFPEl3)Zg{pS*#-Toui#q(d=1U8J@58=km!v+7lq<;@oQ~RHXIy?Vo zw5ON654g*}=KH@D?5X4LX3ec-?dj_6VQDSzW9{O_^zWNlS^no*H*XK8f2`EXlH1zJ z+8GS<1QX-=&#m0-T)kX9?Ogv4>-f)~|Far5QCSabgqN#_j;pKFzYprkzoo!rW&a+G z2#ihN-o?t**Ym;ON&V{@YdM6M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u@1}zTDfIndtaj474z_~r3ob;MqBzbYK*&9S1~6t@l?fv3T`?bVfS>`qC46tdJF#hLF9R#jm3LZx1S 0) then + CounterEntry.DeleteAll(); + end; + end; + } + + action("Session Log") + { + Caption = 'Session Log'; + Image = Log; + RunObject = page "PVS SM Session Log"; + RunPageLink = "Cost Center" = field("Cost Center"); + ToolTip = 'View session start/stop history for this cost center'; + } + } + } +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/CostCenter/PVSSMCostCenterSetup.Table.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/CostCenter/PVSSMCostCenterSetup.Table.al new file mode 100644 index 0000000..63cf800 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/CostCenter/PVSSMCostCenterSetup.Table.al @@ -0,0 +1,70 @@ +namespace PrintVis.SpencerMetrics.Configuration; + +table 80290 "PVS SM Cost Center Setup" +{ + Caption = 'SpencerMetrics Cost Center Setup'; + DataClassification = CustomerContent; + + fields + { + field(1; "Cost Center"; Code[20]) + { + Caption = 'Cost Center'; + NotBlank = true; + TableRelation = "PVS Cost Center".Code; + ToolTip = 'The Cost Center code for SpencerMetrics connection'; + } + field(2; "API Key"; Text[50]) + { + Caption = 'API Key'; + ExtendedDatatype = Masked; + ToolTip = 'The SpencerMetrics API Key for this cost center'; + } + field(3; Enabled; Boolean) + { + Caption = 'Enabled'; + Editable = false; + InitValue = false; + ToolTip = 'Set SpencerMetrics Timer On'; + } + field(4; "Interval (ms)"; Integer) + { + Caption = 'Interval (ms)'; + InitValue = 15000; + MinValue = 5000; + ToolTip = 'The interval for the timer to check SpencerMetrics for new counts. It is not recommended to set this less than 15000 (15 seconds)'; + } + field(5; "Session Id"; Integer) + { + Caption = 'Session Id'; + ToolTip = 'The session ID that is running the SpencerMetrics timer'; + } + field(6; "Login Key"; Text[100]) + { + Caption = 'Login Key'; + ExtendedDatatype = Masked; + } + field(7; "Last Heartbeat"; DateTime) + { + Caption = 'Last Heartbeat'; + ToolTip = 'The last heartbeat for the session running the SpencerMetrics timer'; + } + field(8; "Last Error"; Text[2048]) + { + Caption = 'Last Error'; + ToolTip = 'The last error for the session running the SpencerMetrics timer'; + } + field(9; "Job Queue Entry ID"; Guid) + { + Caption = 'Job Queue Entry ID'; + ToolTip = 'The Job Queue Entry ID for the session running the SpencerMetrics timer'; + } + } + + keys { key(Key1; "Cost Center") { Clustered = true; } } + + internal procedure SetLastHeartbeat() + begin + "Last Heartbeat" := CurrentDateTime(); + end; +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionLog/PVSSMSessionEventType.Enum.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionLog/PVSSMSessionEventType.Enum.al new file mode 100644 index 0000000..acec9f4 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionLog/PVSSMSessionEventType.Enum.al @@ -0,0 +1,16 @@ +namespace PrintVis.SpencerMetrics.Configuration; + +enum 80290 "PVS SM Session Event Type" +{ + Caption = 'Session Event Type'; + Access = Internal; + + value(0; Start) + { + Caption = 'Start'; + } + value(1; Stop) + { + Caption = 'Stop'; + } +} diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionLog/PVSSMSessionLog.Page.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionLog/PVSSMSessionLog.Page.al new file mode 100644 index 0000000..43db4d9 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionLog/PVSSMSessionLog.Page.al @@ -0,0 +1,52 @@ +namespace PrintVis.SpencerMetrics.Configuration; + +page 80292 "PVS SM Session Log" +{ + ApplicationArea = All; + Caption = 'SpencerMetrics Session Log'; + Editable = false; + InsertAllowed = false; + ModifyAllowed = false; + DeleteAllowed = false; + PageType = List; + SourceTable = "PVS SM Session Log"; + SourceTableView = sorting("Entry No.") order(descending); + UsageCategory = None; + Extensible = false; + + layout + { + area(Content) + { + repeater(repeater) + { + field("Entry No."; Rec."Entry No.") { } + field("Cost Center"; Rec."Cost Center") { } + field("Job Queue Entry ID"; Rec."Job Queue Entry ID") { } + field("Event Type"; Rec."Event Type") { } + field("Event DateTime"; Rec."Event DateTime") { } + field("Expected End DateTime"; Rec."Expected End DateTime") { } + field("User ID"; Rec."User ID") { } + field(Success; Rec.Success) + { + StyleExpr = SuccessStyle; + } + field("Error Message"; Rec."Error Message") + { + Visible = false; + } + } + } + } + + var + SuccessStyle: Text; + + trigger OnAfterGetRecord() + begin + if Rec.Success then + SuccessStyle := 'Favorable' + else + SuccessStyle := 'Unfavorable'; + end; +} diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionLog/PVSSMSessionLog.Table.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionLog/PVSSMSessionLog.Table.al new file mode 100644 index 0000000..7261a80 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionLog/PVSSMSessionLog.Table.al @@ -0,0 +1,73 @@ +namespace PrintVis.SpencerMetrics.Configuration; + +table 80291 "PVS SM Session Log" +{ + Caption = 'SpencerMetrics Session Log'; + DataClassification = CustomerContent; + DrillDownPageId = "PVS SM Session Log"; + LookupPageId = "PVS SM Session Log"; + Access = Internal; + + fields + { + field(1; "Entry No."; BigInteger) + { + AutoIncrement = true; + Caption = 'Entry No.'; + ToolTip = 'Entry No. for SpencerMetrics Session Log'; + Editable = false; + } + field(2; "Cost Center"; Code[20]) + { + Caption = 'Cost Center'; + ToolTip = 'Cost Center for SpencerMetrics Session Log'; + NotBlank = true; + TableRelation = "PVS Cost Center".Code; + } + field(4; "Event Type"; Enum "PVS SM Session Event Type") + { + Caption = 'Event Type'; + ToolTip = 'Event Type for SpencerMetrics Session Log'; + } + field(5; "Event DateTime"; DateTime) + { + Caption = 'Event DateTime'; + ToolTip = 'Event DateTime for SpencerMetrics Session Log'; + } + field(6; "User ID"; Code[50]) + { + Caption = 'User ID'; + ToolTip = 'User ID for SpencerMetrics Session Log'; + DataClassification = EndUserIdentifiableInformation; + } + field(7; "Error Message"; Text[2048]) + { + Caption = 'Error Message'; + ToolTip = 'Error Message for SpencerMetrics Session Log'; + } + field(8; Success; Boolean) + { + Caption = 'Success'; + ToolTip = 'Success for SpencerMetrics Session Log'; + InitValue = true; + } + field(9; "Expected End DateTime"; DateTime) + { + Caption = 'Expected End DateTime'; + ToolTip = 'Expected End DateTime for SpencerMetrics Session Log'; + } + field(10; "Job Queue Entry ID"; Guid) + { + Caption = 'Job Queue Entry ID'; + ToolTip = 'Job Queue Entry ID for SpencerMetrics Session Log'; + } + } + + keys + { + key(PK; "Entry No.") + { + Clustered = true; + } + } +} diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionParameter/PVSSMSessionParameter.Table.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionParameter/PVSSMSessionParameter.Table.al new file mode 100644 index 0000000..9284d7f --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/SessionParameter/PVSSMSessionParameter.Table.al @@ -0,0 +1,33 @@ +namespace PrintVis.SpencerMetrics.Configuration; + +table 80292 "PVS SM Session Parameter" +{ + Caption = 'SpencerMetrics Session Parameter'; + DataClassification = CustomerContent; + + fields + { + field(1; "Session Id"; Integer) + { + Caption = 'Session Id'; + } + field(2; "Setup Code"; Code[20]) + { + Caption = 'Setup Code'; + } + field(3; "Session Type"; Text[50]) + { + Caption = 'Session Type'; + } + field(4; "Case ID"; Integer) + { + Caption = 'Case ID'; + } + field(5; "Plan ID"; Integer) + { + Caption = 'Plan ID'; + } + } + + keys { key(PK; "Session Id") { Clustered = true; } } +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/Setup/PVSSMSetup.Page.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/Setup/PVSSMSetup.Page.al new file mode 100644 index 0000000..c0d0448 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/Setup/PVSSMSetup.Page.al @@ -0,0 +1,33 @@ +page 80293 "PVS SM Setup" +{ + ApplicationArea = All; + Caption = 'SpencerMetrics Setup'; + InsertAllowed = false; + PageType = List; + SourceTable = "PVS SM Setup"; + UsageCategory = Administration; + layout + { + area(Content) + { + group(API) + { + Caption = 'API'; + field("Base URL"; Rec."Base URL") { } + } + group(Session) + { + Caption = 'Session'; + field("Max Session Duration (min)"; Rec."Max Session Duration (min)") + { + ToolTip = 'Maximum session duration in minutes. 0 means no limit. Default is 8 hours (480 min).'; + } + } + } + } + + trigger OnOpenPage() + begin + Rec.Initialize(); + end; +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/Setup/PVSSMSetup.Table.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/Setup/PVSSMSetup.Table.al new file mode 100644 index 0000000..23d5aad --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Configuration/Setup/PVSSMSetup.Table.al @@ -0,0 +1,43 @@ +table 80293 "PVS SM Setup" +{ + Caption = 'SpencerMetrics Setup'; + DataClassification = CustomerContent; + + fields + { + field(1; "Primary Key"; Code[20]) + { + Caption = 'Primary Key'; + } + field(9; "Base URL"; Text[200]) + { + Caption = 'Base URL'; + InitValue = 'https://clientlogin.spencermetrics.com/api/'; + NotBlank = true; + ToolTip = 'The base URL for SpencerMetrics API endpoints'; + } + field(10; "Max Session Duration (min)"; Integer) + { + Caption = 'Max Session Duration (min)'; + InitValue = 480; + MinValue = 0; + ToolTip = 'Maximum session duration in minutes. 0 means no limit. Default is 8 hours (480 min).'; + } + } + + keys + { + key(Key1; "Primary Key") + { + Clustered = true; + } + } + + internal procedure Initialize() + begin + if not Rec.Get() then begin + Clear(Rec); + Rec.Insert(true); + end; + end; +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Core/PVSSMEventHandler.Codeunit.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Core/PVSSMEventHandler.Codeunit.al new file mode 100644 index 0000000..4795902 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Core/PVSSMEventHandler.Codeunit.al @@ -0,0 +1,97 @@ +namespace PrintVis.SpencerMetrics; + +using PrintVis.SpencerMetrics.CounterManagement; +using Microsoft.Projects.TimeSheet; +using PrintVis.SpencerMetrics.Configuration; + +codeunit 80290 "PVS SM Event Handler" +{ + Access = Internal; + SingleInstance = true; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"PVS Shop Floor Management", 'OnAfterShopFloorUserLogin', '', false, false)] + local procedure ShopFloorManagement_OnAfterShopFloorUserLogin( + var UserRegisterRec: Record "User Time Register"; + var LaborEntryRec: Record "PVS Job Costing Labor Entry") + var + SMCostCenterSetup: Record "PVS SM Cost Center Setup"; + SessionManager: Codeunit "PVS SM Session Manager"; + begin + if SMCostCenterSetup.Get(UserRegisterRec."PVS Login Cost Center") then + SessionManager.Start(SMCostCenterSetup."Cost Center"); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"PVS Shop Floor Management", 'OnAfterShopFloorUserLogout', '', false, false)] + local procedure ShopFloorManagement_OnAfterShopFloorUserLogout( + var in_PrintVisUserRec: Record "PVS User Setup"; + var UserRegisterRec: Record "User Time Register"; + var LaborEntryRec_Start: Record "PVS Job Costing Labor Entry") + var + SMCostCenterSetup: Record "PVS SM Cost Center Setup"; + SessionManager: Codeunit "PVS SM Session Manager"; + begin + if SMCostCenterSetup.Get(UserRegisterRec."PVS Login Cost Center") then + SessionManager.Stop(SMCostCenterSetup."Cost Center"); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"PVS Shop Floor Management", 'OnBeforeReadMachineCounter', '', false, false)] + local procedure ShopFloorManagement_OnBeforeReadMachineCounter( + var in_Journal_EntryRec: Record "PVS Shop Floor Journal Entry"; + Is_Start: Boolean; + var Is_Handled: Boolean) + var + SMCostCenterSetup: Record "PVS SM Cost Center Setup"; + CounterEntry: Record "PVS SM Counter Entry"; + FirstEntryNo: Integer; + StartUOMDeviceStatusTok: Label 'Start UOM', Locked = true; + StopUOMDeviceStatusTok: Label 'Stop UOM', Locked = true; + begin + if not SMCostCenterSetup.Get(in_Journal_EntryRec."Cost Center Code") then + exit; + + if Is_Start then begin + Clear(CounterEntry); + CounterEntry."Cost Center Code" := in_Journal_EntryRec."Cost Center Code"; + CounterEntry."Entry No." := CounterEntry.GetNextEntryNo(in_Journal_EntryRec."Cost Center Code"); + CounterEntry."Case ID" := in_Journal_EntryRec.ID; + CounterEntry."Plan ID" := in_Journal_EntryRec."Plan ID"; + CounterEntry.UOM := in_Journal_EntryRec."UOM"; + CounterEntry."Current Count" := -1; + CounterEntry."Device Status" := StartUOMDeviceStatusTok; + CounterEntry."Include In Job Costing" := true; + CounterEntry.Insert(); + end else begin + CounterEntry.Reset(); + CounterEntry.SetRange("Cost Center Code", in_Journal_EntryRec."Cost Center Code"); + CounterEntry.SetRange("Case ID", in_Journal_EntryRec.ID); + CounterEntry.SetRange("Plan ID", in_Journal_EntryRec."Plan ID"); + CounterEntry.SetRange(UOM, in_Journal_EntryRec."UOM"); + if CounterEntry.FindFirst() then begin + FirstEntryNo := CounterEntry."Entry No."; + CounterEntry.Reset(); + CounterEntry.SetRange("Cost Center Code", in_Journal_EntryRec."Cost Center Code"); + CounterEntry.SetRange("Include In Job Costing", false); + CounterEntry.SetFilter("Entry No.", '>%1', FirstEntryNo); + if CounterEntry.FindSet(true) then + repeat + CounterEntry."Case ID" := in_Journal_EntryRec.ID; + CounterEntry."Plan ID" := in_Journal_EntryRec."Plan ID"; + CounterEntry.UOM := in_Journal_EntryRec.UOM; + in_Journal_EntryRec.Quantity := in_Journal_EntryRec.Quantity + CounterEntry."Difference Count"; + CounterEntry."Include In Job Costing" := true; + CounterEntry.Modify(); + until CounterEntry.Next() = 0; + CounterEntry.Reset(); + CounterEntry.Init(); + CounterEntry."Entry No." := CounterEntry.GetNextEntryNo(in_Journal_EntryRec."Cost Center Code"); + CounterEntry."Case ID" := 0; + CounterEntry."Plan ID" := 0; + CounterEntry.UOM := ''; + CounterEntry."Current Count" := -1; + CounterEntry."Device Status" := StopUOMDeviceStatusTok; + CounterEntry."Include In Job Costing" := true; + CounterEntry.Insert(); + end; + end; + end; +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Core/PVSSMEvents.Codeunit.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Core/PVSSMEvents.Codeunit.al new file mode 100644 index 0000000..116aea9 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Core/PVSSMEvents.Codeunit.al @@ -0,0 +1,17 @@ +namespace PrintVis.SpencerMetrics; + +codeunit 80291 "PVS SM Events" +{ + Access = Public; + + /// + /// Integration event to mock the web request. + /// + /// The service action. + /// The response. + /// The handled flag. + [IntegrationEvent(false, false)] + procedure OnMockWebRequest(in_ServiceAction: Text; var out_Response: Text; var out_Handled: Boolean) + begin + end; +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Core/PVSSMInstall.Codeunit.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Core/PVSSMInstall.Codeunit.al new file mode 100644 index 0000000..abc8823 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Core/PVSSMInstall.Codeunit.al @@ -0,0 +1,30 @@ +codeunit 80292 "PVS SM Install" +{ + Access = Internal; + Subtype = Install; + + + trigger OnInstallAppPerDatabase() + var + MyAppInfo: ModuleInfo; + begin + NavApp.GetCurrentModuleInfo(MyAppInfo); + this.AllowHttpRequests(MyAppInfo.Id); + end; + + + local procedure AllowHttpRequests(in_AppID: Guid) + var + NAVAppSetting: Record "NAV App Setting"; + begin + if NAVAppSetting.Get(in_AppID) then begin + NAVAppSetting."Allow HttpClient Requests" := true; + NAVAppSetting.Modify(); + end else begin + Clear(NAVAppSetting); + NAVAppSetting."App ID" := in_AppID; + NAVAppSetting."Allow HttpClient Requests" := true; + NAVAppSetting.Insert(); + end; + end; +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCountFactBox.Page.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCountFactBox.Page.al new file mode 100644 index 0000000..2cbe3e8 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCountFactBox.Page.al @@ -0,0 +1,83 @@ +namespace PrintVis.SpencerMetrics.CounterManagement; + +using PrintVis.SpencerMetrics.Utilities; + +page 80295 "PVS SM Count FactBox" +{ + ApplicationArea = All; + Caption = 'SpencerMetrics Count Summary'; + Editable = false; + PageType = ListPart; + SourceTable = "PVS SM Count Summary Buffer"; + SourceTableTemporary = true; + + layout + { + area(content) + { + usercontrol(Timer; "PVS SM Timer AddIn") + { + trigger Ready() + begin + CurrPage.Timer.Start(5000); + end; + + trigger OnTick() + begin + this.RefreshLoop(); + end; + } + + repeater(repeater) + { + field(UOM; Rec."UOM") { } + field("Total Difference Count"; Rec."Total Difference Count") { } + } + } + } + + local procedure ResolveContext(): Boolean + var + ShopFloorMgmt: Codeunit "PVS Shop Floor Management"; + begin + CurrentCostCenter := ShopFloorMgmt.User_Get_Current_CostCenter(); + if (CurrentCostCenter = '') then + exit(false); + + exit(ShopFloorMgmt.Find_ActivePlanJournalEntry(CurrentPlan, 0, 0, 0, CurrentCostCenter)); + end; + + local procedure RefreshLoop() + var + SumByUOM: Query "PVS SM Counts Sum By UOM"; + begin + If not this.ResolveContext() then + exit; + + Rec.DeleteAll(); + + SumByUOM.SetFilter(CostCenter, CurrentCostCenter); + SumByUOM.SetRange(CaseID, CurrentPlan.ID); + SumByUOM.SetRange(PlanID, CurrentPlan."Plan ID"); + if not SumByUOM.Open() then + Error('Error opening Query'); + + while SumByUOM.Read() do begin + Clear(Rec); + Rec."Case ID" := CurrentPlan.ID; + Rec."Plan ID" := CurrentPlan."Plan ID"; + Rec."UOM" := SumByUOM.UOM; + Rec."Total Difference Count" := SumByUOM.DifferenceCountSum; + Rec."Cost Center Code" := CurrentCostCenter; + Rec.Insert(); + end; + + SumByUOM.Close(); + + CurrPage.Update(false); + end; + + var + CurrentPlan: Record "PVS Shop Floor Journal Entry"; + CurrentCostCenter: Code[20]; +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCountSummaryBuffer.Table.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCountSummaryBuffer.Table.al new file mode 100644 index 0000000..50c6f4b --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCountSummaryBuffer.Table.al @@ -0,0 +1,41 @@ +namespace PrintVis.SpencerMetrics.CounterManagement; + +table 80295 "PVS SM Count Summary Buffer" +{ + Caption = 'SpencerMetrics Count Summary Buffer'; + DataClassification = CustomerContent; + TableType = Temporary; + + fields + { + field(1; UOM; Code[20]) + { + Caption = 'UOM'; + ToolTip = 'The Unit of Measure for the Count entry.'; + } + field(2; "Total Difference Count"; Integer) + { + Caption = 'Counts'; + ToolTip = 'The total difference count for the Count entry.'; + } + field(3; "Cost Center Code"; Code[20]) + { + Caption = 'Cost Center Code'; + ToolTip = 'The Cost Center Code for the Count entry.'; + } + field(4; "Case ID"; Integer) + { + Caption = 'Case ID'; + ToolTip = 'The Case ID for the Count entry.'; + } + field(5; "Plan ID"; Integer) + { + Caption = 'Plan ID'; + ToolTip = 'The Plan ID for the Count entry.'; + } + } + keys + { + key(PK; "UOM", "Case ID", "Plan ID") { Clustered = true; } + } +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCounterEntries.Page.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCounterEntries.Page.al new file mode 100644 index 0000000..bee680f --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCounterEntries.Page.al @@ -0,0 +1,96 @@ +namespace PrintVis.SpencerMetrics.CounterManagement; + +using PrintVis.SpencerMetrics.Configuration; + +page 80294 "PVS SM Counter Entries" +{ + ApplicationArea = All; + Caption = 'SpencerMetrics Counter Entries'; + InsertAllowed = false; + ModifyAllowed = false; + PageType = List; + SourceTable = "PVS SM Counter Entry"; + UsageCategory = Lists; + + layout + { + area(Content) + { + repeater(repeater) + { + field("Cost Center Code"; Rec."Cost Center Code") { } + field("Entry No."; Rec."Entry No.") { } + field("Current Count"; Rec."Current Count") { } + field("Difference Count"; Rec."Difference Count") { } + field("Current Time"; Rec."Current Time") { } + field("Device Status"; Rec."Device Status") { } + field(Speed; Rec.Speed) { } + field("Include In Job Costing"; Rec."Include In Job Costing") { } + field("Case ID"; Rec."Case ID") { } + field("Plan ID"; Rec."Plan ID") { } + field(UOM; Rec.UOM) { } + } + } + } + + actions + { + area(Processing) + { + action("Cost Center Setup") + { + Caption = 'Cost Center Setup'; + Image = Setup; + RunObject = page "PVS SM Cost Center Setup"; + ToolTip = 'Opens the setup page for SpencerMetrics'; + } + action(Assign) + { + Caption = 'Assign to Job Costing'; + Image = Link; + ToolTip = 'Allows the user to assign SpencerMetrics counts to job costing entries that were missed during shop floor recording'; + + trigger OnAction() + var + ConnectPage: Page "PVS SM Assign To Job Costing"; + ErrorLbl: Label 'Only count entries that have not already been included in a job costing entry can be assigned'; + begin + Rec.TestField("Entry No."); + Rec.TestField("Cost Center Code"); + Rec.TestField("Difference Count"); + if Rec."Include In Job Costing" then + Error(ErrorLbl); + + ConnectPage.SetContext(Rec); + ConnectPage.RunModal(); + end; + } + } + area(Navigation) + { + action(XMLContent) + { + Caption = 'XML Content'; + Image = XMLFile; + ToolTip = 'Displays the XML content of the counter entry'; + + trigger OnAction() + var + XmlContentNotFoundLbl: Label 'No XML content found'; + XMLContent: Text; + begin + XMLContent := Rec.GetXMLContent(); + if (XMLContent = '') then + Message(XmlContentNotFoundLbl) + else + Message(XMLContent); + end; + } + } + area(Promoted) + { + actionref(AssignPromoted; Assign) { } + actionref(XMLContentPromoted; XMLContent) { } + } + } +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCounterEntry.Table.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCounterEntry.Table.al new file mode 100644 index 0000000..dc76b72 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCounterEntry.Table.al @@ -0,0 +1,122 @@ +namespace PrintVis.SpencerMetrics.CounterManagement; + +using System.Reflection; + +table 80294 "PVS SM Counter Entry" +{ + Caption = 'SpencerMetrics Counter Entry'; + DataClassification = CustomerContent; + DrillDownPageId = "PVS SM Counter Entries"; + LookupPageId = "PVS SM Counter Entries"; + + fields + { + field(1; "Cost Center Code"; Code[20]) + { + Caption = 'Cost Center Code'; + TableRelation = "PVs Cost Center"; + ToolTip = 'Cost Center Code for SpencerMetrics'; + } + field(2; "Entry No."; BigInteger) + { + AutoIncrement = true; + Caption = 'Entry No.'; + ToolTip = 'Entry No. for SpencerMetrics'; + Editable = false; + } + field(3; "XML Content"; Blob) + { + Caption = 'XML Content'; + ToolTip = 'XML Content from SpencerMetrics'; + } + field(4; "Current Count"; Integer) + { + Caption = 'Current Count'; + ToolTip = 'Current count from SpencerMetrics'; + } + field(6; "Difference Count"; Integer) + { + Caption = 'Difference Count'; + ToolTip = 'Difference between previous count and current count'; + } + field(7; "Current Time"; DateTime) + { + Caption = 'Current Time'; + ToolTip = 'Current date/time for this SpencerMetrics count'; + } + field(8; "Device Status"; Code[50]) + { + Caption = 'Device Status'; + ToolTip = 'SpencerMetrics device status'; + } + field(9; Speed; Integer) + { + Caption = 'Speed'; + ToolTip = 'Calculated speed of the machine'; + } + field(10; "Include In Job Costing"; Boolean) + { + Caption = 'Included in job costing'; + ToolTip = 'This is checked once the count has been included in a job costing entry'; + } + field(13; "Case ID"; Integer) + { + Caption = 'Case ID'; + ToolTip = 'The Case ID associated with this count'; + } + field(14; "Plan ID"; Integer) + { + Caption = 'Plan ID'; + ToolTip = 'The Plan ID associated with this count'; + } + field(15; UOM; Code[20]) + { + Caption = 'UOM'; + ToolTip = 'The UOM associated with this count'; + } + } + + keys + { + key(PK; "Cost Center Code", "Entry No.") + { + Clustered = true; + } + } + + internal procedure GetNextEntryNo(in_CostCenterCode: Code[20]): BigInteger + var + CounterEntry: Record "PVS SM Counter Entry"; + NextEntryNo: BigInteger; + begin + CounterEntry.Reset(); + CounterEntry.SetRange("Cost Center Code", in_CostCenterCode); + if CounterEntry.FindLast() then + NextEntryNo := CounterEntry."Entry No." + else + NextEntryNo := 0; + + NextEntryNo += 1; + + exit(NextEntryNo); + end; + + internal procedure SetXMLContent(in_XMLContent: Text) + var + OutStream: OutStream; + begin + Clear("XML Content"); + "XML Content".CreateOutStream(OutStream, TextEncoding::UTF8); + OutStream.WriteText(in_XMLContent); + end; + + internal procedure GetXMLContent() XMLContent: Text + var + TypeHelper: Codeunit "Type Helper"; + InStream: InStream; + begin + CalcFields("XML Content"); + "XML Content".CreateInStream(InStream, TextEncoding::UTF8); + exit(TypeHelper.TryReadAsTextWithSepAndFieldErrMsg(InStream, TypeHelper.LFSeparator(), FieldName("XML Content"))); + end; +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCountsSumByUOM.Query.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCountsSumByUOM.Query.al new file mode 100644 index 0000000..c6a8b21 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/Entries/PVSSMCountsSumByUOM.Query.al @@ -0,0 +1,16 @@ +namespace PrintVis.SpencerMetrics.CounterManagement; + +query 80290 "PVS SM Counts Sum By UOM" +{ + elements + { + dataitem(CounterEntry; "PVS SM Counter Entry") + { + filter(CostCenter; "Cost Center Code") { } + filter(CaseID; "Case ID") { } + filter(PlanID; "Plan ID") { } + column(UOM; UOM) { } + column(DifferenceCountSum; "Difference Count") { Method = Sum; } + } + } +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/PVSSMAssignToJobCosting.Page.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/PVSSMAssignToJobCosting.Page.al new file mode 100644 index 0000000..a0ca4c0 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/PVSSMAssignToJobCosting.Page.al @@ -0,0 +1,116 @@ +namespace PrintVis.SpencerMetrics.CounterManagement; + +page 80296 "PVS SM Assign To Job Costing" +{ + ApplicationArea = All; + Caption = 'Assign Count to Job Costing Entry'; + PageType = StandardDialog; + + layout + { + area(content) + { + group(CountInfo) + { + Caption = 'Count'; + field("Count Entry No."; CountEntryNo) + { + Caption = 'Count Entry No.'; + ToolTip = 'The Entry No. of the Count entry that will be added to the Job Costing Entry.'; + Editable = false; + } + field("Count Cost Center"; CountCostCenterTxt) + { + Caption = 'Count Cost Center'; + ToolTip = 'The Cost Center of the Count entry that will be added to the Job Costing Entry.'; + Editable = false; + } + field("Count Quantity"; CountQty) + { + Caption = 'Count Quantity'; + Editable = false; + ToolTip = 'Quantity from the Count entry that will be added to the Job Costing Entry.'; + } + } + + group(JobCosting) + { + Caption = 'Job Costing'; + field(JobCostingEntryNo; JobCostingEntryNo) + { + Caption = 'Job Costing Entry'; + ToolTip = 'Choose a Job Costing Entry with the same Cost Center; entries with Type = Login are excluded.'; + + trigger OnLookup(var Text: Text): Boolean + var + JobCostingEntry: Record "PVS Job Costing Entry"; + ActionChosen: Action; + begin + JobCostingEntry.Reset(); + if CountCostCenterTxt <> '' then + JobCostingEntry.SetRange("Cost Center Code", CountCostCenterTxt); + JobCostingEntry.SetFilter("Costing Type", '%1', JobCostingEntry."Costing Type"::Time); + ActionChosen := PAGE.RunModal(PAGE::"PVS Job Costing - Details", JobCostingEntry); + if ActionChosen = Action::LookupOK then begin + JobCostingEntryNo := JobCostingEntry."Entry No."; + Text := Format(JobCostingEntryNo); + exit(true); + end; + + exit(false); + end; + } + } + } + } + + procedure SetContext(in_CounterEntry: Record "PVS SM Counter Entry") + begin + this.CounterEntry := in_CounterEntry; + end; + + trigger OnOpenPage() + begin + this.CountEntryNo := this.CounterEntry."Entry No."; + this.CountCostCenterTxt := this.CounterEntry."Cost Center Code"; + this.CountQty := this.CounterEntry."Difference Count"; + end; + + trigger OnQueryClosePage(CloseAction: Action): Boolean + var + JobCostingEntry: Record "PVS Job Costing Entry"; + begin + if CloseAction <> Action::OK then + exit(true); + + if JobCostingEntryNo = 0 then + Error(SelectJobCostingEntryErr); + + if not JobCostingEntry.Get(JobCostingEntryNo) then + Error(JobCostingEntryNotFoundErr, JobCostingEntryNo); + + if (CountCostCenterTxt <> '') and (JobCostingEntry."Cost Center Code" <> CountCostCenterTxt) then + Error(CostCenterMismatchErr); + + JobCostingEntry.Validate("Quantity", JobCostingEntry."Quantity" + CountQty); + JobCostingEntry.Modify(true); + + this.CounterEntry.Validate("Include In Job Costing", true); + this.CounterEntry.Validate("Case ID", JobCostingEntry.ID); + this.CounterEntry.Validate("Plan ID", JobCostingEntry."Plan ID"); + this.CounterEntry.Validate(UOM, JobCostingEntry.UOM); + this.CounterEntry.Modify(true); + + exit(true); + end; + + var + CounterEntry: Record "PVS SM Counter Entry"; + CountEntryNo: BigInteger; + CountCostCenterTxt: Code[20]; + CountQty: Integer; + JobCostingEntryNo: Integer; + CostCenterMismatchErr: Label 'Selected Job Costing Entry has a different Cost Center.'; + JobCostingEntryNotFoundErr: Label 'Job Costing Entry %1 was not found.', Comment = '%1 = Job Costing Entry No.'; + SelectJobCostingEntryErr: Label 'Please select a Job Costing Entry before clicking OK.'; +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/PVSSMCounterWorker.Codeunit.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/PVSSMCounterWorker.Codeunit.al new file mode 100644 index 0000000..6d38057 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/PVSSMCounterWorker.Codeunit.al @@ -0,0 +1,91 @@ +namespace PrintVis.SpencerMetrics.CounterManagement; + +using PrintVis.SpencerMetrics.Configuration; +using System.Threading; +using PrintVis.SpencerMetrics.Services; + +codeunit 80293 "PVS SM Counter Worker" +{ + Access = Internal; + TableNo = "Job Queue Entry"; + + trigger OnRun() + var + SMCostCenterSetup: Record "PVS SM Cost Center Setup"; + SessionParameter: Record "PVS SM Session Parameter"; + CostCenterCode: Code[20]; + KeepRunning: Boolean; + Interval: Integer; + MySessionId: Integer; + CostCenterSetupNotFoundErr: Label 'Cost center setup not found for %1', Comment = '%1 = RecordId'; + begin + if not SMCostCenterSetup.Get(Rec."Record ID to Process") then + Error(CostCenterSetupNotFoundErr, Rec."Record ID to Process"); + + CostCenterCode := SMCostCenterSetup."Cost Center"; + MySessionId := SessionId(); + KeepRunning := true; + + Clear(SessionParameter); + SessionParameter."Session Id" := MySessionId; + SessionParameter."Setup Code" := CostCenterCode; + if not SessionParameter.Insert(true) then + SessionParameter.Modify(true); + + SMCostCenterSetup."Session Id" := MySessionId; + SMCostCenterSetup.SetLastHeartbeat(); + SMCostCenterSetup.Modify(); + Commit(); + + if SMCostCenterSetup."Interval (ms)" < 5000 then + Interval := 5000 + else + Interval := SMCostCenterSetup."Interval (ms)"; + + while KeepRunning do begin + SMCostCenterSetup.Get(CostCenterCode); + SMCostCenterSetup.SetLastHeartbeat(); + SMCostCenterSetup.Modify(); + Commit(); + + if ShouldRotateSession(CostCenterCode, Rec.ID) then + if RotateSession(CostCenterCode) then + KeepRunning := false; + + if KeepRunning then begin + this.DoTick(CostCenterCode); + + if not SMCostCenterSetup.Enabled then + KeepRunning := false; + + if KeepRunning then + Sleep(Interval); + end; + end; + end; + + procedure DoTick(in_CostCenter: Code[20]) + var + SpencerMetricsApiClient: Codeunit "PVS SM Api Client"; + begin + SpencerMetricsApiClient.ProcessSpencerMetricsData(in_CostCenter); + end; + + local procedure ShouldRotateSession(in_CostCenter: Code[20]; in_JobQueueEntryId: Guid): Boolean + var + SessionManager: Codeunit "PVS SM Session Manager"; + ExpectedEnd: DateTime; + begin + ExpectedEnd := SessionManager.GetExpectedEndDateTime(in_CostCenter, in_JobQueueEntryId); + if ExpectedEnd = 0DT then + exit(false); + exit(CurrentDateTime() >= ExpectedEnd); + end; + + local procedure RotateSession(in_CostCenter: Code[20]): Boolean + var + SessionManager: Codeunit "PVS SM Session Manager"; + begin + exit(SessionManager.Rotate(in_CostCenter)); + end; +} diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/PVSSMSessionManager.Codeunit.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/PVSSMSessionManager.Codeunit.al new file mode 100644 index 0000000..65a8be8 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/CounterManagement/PVSSMSessionManager.Codeunit.al @@ -0,0 +1,215 @@ +namespace PrintVis.SpencerMetrics.CounterManagement; + +using PrintVis.SpencerMetrics.Configuration; +using System.Threading; + +codeunit 80294 "PVS SM Session Manager" +{ + Access = Internal; + + var + SpencerMetricsLbl: Label 'SpencerMetrics: %1', Comment = '%1 = Error Message', Locked = true; + + procedure Start(in_CostCenter: Code[20]) + var + SMCostCenterSetup: Record "PVS SM Cost Center Setup"; + JobQueueEntry: Record "Job Queue Entry"; + EmptyGuid: Guid; + SessionStartErr: Label 'Failed to start session. %1', Comment = '%1 = Error Message'; + + begin + if not SMCostCenterSetup.Get(in_CostCenter) then + exit; + + if SMCostCenterSetup.Enabled then + exit; + + SMCostCenterSetup.Enabled := true; + SMCostCenterSetup."Last Error" := ''; + SMCostCenterSetup.Modify(true); + Commit(); + + ClearLastError(); + + Clear(JobQueueEntry); + JobQueueEntry.Init(); + JobQueueEntry.ID := CreateGuid(); + JobQueueEntry."Object Type to Run" := JobQueueEntry."Object Type to Run"::Codeunit; + JobQueueEntry."Object ID to Run" := Codeunit::"PVS SM Counter Worker"; + JobQueueEntry."Record ID to Process" := SMCostCenterSetup.RecordId; + JobQueueEntry."Run in User Session" := false; + JobQueueEntry."Record ID to Process" := SMCostCenterSetup.RecordId; + JobQueueEntry.Description := StrSubstNo(SpencerMetricsLbl, in_CostCenter); + if not JobQueueEntry.Insert(true) then begin + SMCostCenterSetup.Enabled := false; + SMCostCenterSetup."Last Error" := StrSubstNo(SessionStartErr, GetLastErrorText()); + SMCostCenterSetup.Modify(true); + Commit(); + LogSessionEvent(in_CostCenter, EmptyGuid, Enum::"PVS SM Session Event Type"::Start, false, SMCostCenterSetup."Last Error"); + exit; + end; + + Codeunit.Run(Codeunit::"Job Queue - Enqueue", JobQueueEntry); + + SMCostCenterSetup.SetLastHeartbeat(); + SMCostCenterSetup."Job Queue Entry ID" := JobQueueEntry.ID; + SMCostCenterSetup."Session Id" := 0; + SMCostCenterSetup.Modify(true); + Commit(); + LogSessionEvent(in_CostCenter, JobQueueEntry.ID, Enum::"PVS SM Session Event Type"::Start, true, ''); + end; + + procedure Stop(in_CostCenter: Code[20]) + var + SMCostCenterSetup: Record "PVS SM Cost Center Setup"; + SessionParameter: Record "PVS SM Session Parameter"; + JobQueueEntry: Record "Job Queue Entry"; + CounterEntry: Record "PVS SM Counter Entry"; + StoppedJobQueueEntryId: Guid; + StopSuccess: Boolean; + ErrorMsg: Text; + begin + if not SMCostCenterSetup.Get(in_CostCenter) then + exit; + + StoppedJobQueueEntryId := SMCostCenterSetup."Job Queue Entry ID"; + StopSuccess := true; + ErrorMsg := ''; + + SMCostCenterSetup.Enabled := false; + SMCostCenterSetup."Last Error" := ''; + + if not IsNullGuid(SMCostCenterSetup."Job Queue Entry ID") then + if JobQueueEntry.Get(SMCostCenterSetup."Job Queue Entry ID") then begin + JobQueueEntry.SetStatus(JobQueueEntry.Status::"On Hold"); + JobQueueEntry.Delete(true); + end; + + if (SMCostCenterSetup."Session Id" <> 0) and SessionParameter.Get(SMCostCenterSetup."Session Id") then + SessionParameter.Delete(); + + SMCostCenterSetup."Session Id" := 0; + Clear(SMCostCenterSetup."Job Queue Entry ID"); + SMCostCenterSetup.Modify(true); + + CounterEntry.Reset(); + CounterEntry.SetRange("Cost Center Code", in_CostCenter); + CounterEntry.SetRange("Include In Job Costing", true); + if CounterEntry.Count() > 0 then + CounterEntry.DeleteAll(); + + CounterEntry.Reset(); + CounterEntry.SetRange("Cost Center Code", in_CostCenter); + CounterEntry.SetFilter("Difference Count", '=0'); + if CounterEntry.Count() > 0 then + CounterEntry.DeleteAll(); + + LogSessionEvent(in_CostCenter, StoppedJobQueueEntryId, Enum::"PVS SM Session Event Type"::Stop, StopSuccess, ErrorMsg); + end; + + procedure Rotate(in_CostCenter: Code[20]): Boolean + var + SMCostCenterSetup: Record "PVS SM Cost Center Setup"; + SessionParameter: Record "PVS SM Session Parameter"; + OldJobQueueEntry: Record "Job Queue Entry"; + NewJobQueueEntry: Record "Job Queue Entry"; + OldSessionId: Integer; + OldJobQueueEntryId: Guid; + EmptyGuid: Guid; + SessionStartErr: Label 'Failed to start rotated session. %1', Comment = '%1 = Error Message'; + begin + if not SMCostCenterSetup.Get(in_CostCenter) then + exit(false); + + if not SMCostCenterSetup.Enabled then + exit(false); + + OldSessionId := SMCostCenterSetup."Session Id"; + OldJobQueueEntryId := SMCostCenterSetup."Job Queue Entry ID"; + + ClearLastError(); + + Clear(NewJobQueueEntry); + NewJobQueueEntry.Init(); + NewJobQueueEntry.ID := CreateGuid(); + NewJobQueueEntry."Object Type to Run" := NewJobQueueEntry."Object Type to Run"::Codeunit; + NewJobQueueEntry."Object ID to Run" := Codeunit::"PVS SM Counter Worker"; + NewJobQueueEntry."Record ID to Process" := SMCostCenterSetup.RecordId; + NewJobQueueEntry."Run in User Session" := false; + NewJobQueueEntry.Description := StrSubstNo(SpencerMetricsLbl, in_CostCenter); + if not NewJobQueueEntry.Insert(true) then begin + SMCostCenterSetup."Last Error" := StrSubstNo(SessionStartErr, GetLastErrorText()); + SMCostCenterSetup.Modify(true); + Commit(); + LogSessionEvent(in_CostCenter, EmptyGuid, Enum::"PVS SM Session Event Type"::Start, false, SMCostCenterSetup."Last Error"); + exit(false); + end; + + Codeunit.Run(Codeunit::"Job Queue - Enqueue", NewJobQueueEntry); + + LogSessionEvent(in_CostCenter, OldJobQueueEntryId, Enum::"PVS SM Session Event Type"::Stop, true, ''); + + if not IsNullGuid(OldJobQueueEntryId) then + if OldJobQueueEntry.Get(OldJobQueueEntryId) then begin + OldJobQueueEntry.SetStatus(OldJobQueueEntry.Status::"On Hold"); + OldJobQueueEntry.Delete(true); + end; + + + if (OldSessionId <> 0) and SessionParameter.Get(OldSessionId) then + SessionParameter.Delete(); + + SMCostCenterSetup.SetLastHeartbeat(); + SMCostCenterSetup."Job Queue Entry ID" := NewJobQueueEntry.ID; + SMCostCenterSetup."Session Id" := 0; + SMCostCenterSetup."Last Error" := ''; + SMCostCenterSetup.Modify(true); + Commit(); + + LogSessionEvent(in_CostCenter, NewJobQueueEntry.ID, Enum::"PVS SM Session Event Type"::Start, true, ''); + + exit(true); + end; + + procedure GetExpectedEndDateTime(in_CostCenter: Code[20]; in_JobQueueEntryId: Guid): DateTime + var + SessionLog: Record "PVS SM Session Log"; + begin + SessionLog.Reset(); + SessionLog.SetRange("Cost Center", in_CostCenter); + SessionLog.SetRange("Job Queue Entry ID", in_JobQueueEntryId); + SessionLog.SetRange("Event Type", Enum::"PVS SM Session Event Type"::Start); + SessionLog.SetRange(Success, true); + if SessionLog.FindLast() then + exit(SessionLog."Expected End DateTime"); + exit(0DT); + end; + + local procedure LogSessionEvent( + in_CostCenter: Code[20]; + in_JobQueueEntryId: Guid; + in_EventType: Enum "PVS SM Session Event Type"; + in_Success: Boolean; + in_ErrorMessage: Text) + var + SessionLog: Record "PVS SM Session Log"; + SMSetup: Record "PVS SM Setup"; + begin + Clear(SessionLog); + SessionLog."Cost Center" := in_CostCenter; + SessionLog."Job Queue Entry ID" := in_JobQueueEntryId; + SessionLog."Event Type" := in_EventType; + SessionLog."Event DateTime" := CurrentDateTime(); + SessionLog."User ID" := CopyStr(UserId(), 1, MaxStrLen(SessionLog."User ID")); + SessionLog.Success := in_Success; + SessionLog."Error Message" := CopyStr(in_ErrorMessage, 1, MaxStrLen(SessionLog."Error Message")); + + if (in_EventType = Enum::"PVS SM Session Event Type"::Start) and in_Success then begin + SMSetup.Get(); + if SMSetup."Max Session Duration (min)" > 0 then + SessionLog."Expected End DateTime" := SessionLog."Event DateTime" + (SMSetup."Max Session Duration (min)" * 60000); + end; + + SessionLog.Insert(true); + end; +} diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/PrintVisIntegration/PVSSMElectronicTicket.PageExt.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/PrintVisIntegration/PVSSMElectronicTicket.PageExt.al new file mode 100644 index 0000000..a5f520c --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/PrintVisIntegration/PVSSMElectronicTicket.PageExt.al @@ -0,0 +1,32 @@ +namespace PrintVis.SpencerMetrics.Integration; + +using PrintVis.SpencerMetrics.Configuration; +using PrintVis.SpencerMetrics.CounterManagement; + +pageextension 80290 "PVS SM Electronic Ticket" extends "PVS SF Electronic Ticket" +{ + layout + { + addbefore(QtyPart) + { + part("PVS SM Count Summary"; "PVS SM Count FactBox") + { + ApplicationArea = All; + Caption = 'SpencerMetrics Count Summary'; + Visible = ShowCountsFactBox; + } + } + } + + var + ShowCountsFactBox: Boolean; + + trigger OnOpenPage() + var + SMCostCenterSetup: Record "PVS SM Cost Center Setup"; + ShopFloorManagement: Codeunit "PVS Shop Floor Management"; + begin + SMCostCenterSetup.SetRange("Cost Center", ShopFloorManagement.User_Get_Current_CostCenter()); + ShowCountsFactBox := not SMCostCenterSetup.IsEmpty; + end; +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/PrintVisIntegration/PVSSMSheet.TableExt.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/PrintVisIntegration/PVSSMSheet.TableExt.al new file mode 100644 index 0000000..a6bf520 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/PrintVisIntegration/PVSSMSheet.TableExt.al @@ -0,0 +1,35 @@ +namespace PrintVis.SpencerMetrics.Integration; + +tableextension 80290 "PVS SM Sheet" extends "PVS Job Sheet" +{ + fields + { + field(80290; "PVS SM Key"; Text[30]) + { + Caption = 'SpencerMetrics Key'; + DataClassification = CustomerContent; + Editable = false; + } + } + + keys + { + key("PVS SM Key"; "PVS SM Key") { } + } + + trigger OnBeforeInsert() + begin + this.GenerateSpencerMetricsKey(Rec); + end; + + trigger OnBeforeModify() + begin + this.GenerateSpencerMetricsKey(Rec); + end; + + local procedure GenerateSpencerMetricsKey(var in_JobSheet: Record "PVS Job Sheet") + begin + in_JobSheet.CalcFields("Order No."); + in_JobSheet."PVS SM Key" := Format(in_JobSheet."Order No.") + '_Se.' + Format(in_JobSheet."Sheet No."); + end; +} diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Services/PVSSMApiClient.Codeunit.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Services/PVSSMApiClient.Codeunit.al new file mode 100644 index 0000000..2034056 --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Services/PVSSMApiClient.Codeunit.al @@ -0,0 +1,233 @@ +namespace PrintVis.SpencerMetrics.Services; + +using PrintVis.SpencerMetrics.CounterManagement; +using PrintVis.SpencerMetrics.Configuration; +using PrintVis.SpencerMetrics; + +codeunit 80295 "PVS SM Api Client" +{ + Access = Internal; + + var + CostCenterSetupNotFoundErr: Label 'Cost Center SpencerMetrics setup not found'; + InvalidJsonResponseErr: Label 'Invalid JSON response'; + InvalidLoginKeyErr: Label 'Unauthorized - invalid login key'; + UnableToProcessRequestErr: Label 'Unable to process request: Error Code = %1', Comment = '%1 = Error Code'; + + procedure ProcessSpencerMetricsData(in_CostCenterCode: Code[20]) + var + SMCostCenterSetup: Record "PVS SM Cost Center Setup"; + CounterEntry: Record "PVS SM Counter Entry"; + SMSetup: Record "PVS SM Setup"; + Prefix, RequestUrl, Response, SubString : Text; + begin + if (in_CostCenterCode = '') then + exit; + + SMSetup.Get(); + SMSetup.TestField("Base URL"); + + if SMCostCenterSetup.Get(in_CostCenterCode) then begin + this.Authenticate(SMSetup."Base URL", SMCostCenterSetup); + + RequestUrl := this.BuildRequestUrl(SMSetup."Base URL", 'getXMLData?ApiSid=' + SMCostCenterSetup."Login Key"); + Response := this.SendGetRequest(RequestUrl, Response); + + if StrLen(Response) >= 5 then + Prefix := CopyStr(Response, 1, 5) + else + Prefix := Response; + + if Prefix = ' '' then + exit(DataText); + if ErrorText <> '' then + exit(ErrorText); + end; + + procedure ParseXMLResponse( + in_ResponseText: Text; + var out_CounterEntry: Record "PVS SM Counter Entry"; + var out_SMCostCenterSetup: Record "PVS SM Cost Center Setup") + var + PrevCounterEntry: Record "PVS SM Counter Entry"; + Hours: Decimal; + ElapsedTime: Duration; + DiffCount, + TotalProductionCounter : Integer; + CounterTxt: Text; + DeviceStatus: Text; + Attribute: XmlAttribute; + XmlDoc: XmlDocument; + Node: XmlNode; + begin + // Parse XML into XmlDocument (static call) + if not XmlDocument.ReadFrom(in_ResponseText, XmlDoc) then begin + out_SMCostCenterSetup."Last Error" := 'Invalid XML.'; + exit; + end; + + // TimeStamp on root + out_CounterEntry."Current Time" := CurrentDateTime(); + + // DeviceStatus on + if XmlDoc.SelectSingleNode('/*[local-name()="JMF"]/*[local-name()="Signal"]/*[local-name()="DeviceInfo"]/@DeviceStatus', Node) then begin + Attribute := Node.AsXmlAttribute(); + DeviceStatus := Attribute.Value; + out_CounterEntry."Device Status" := CopyStr(DeviceStatus, 1, MaxStrLen(out_CounterEntry."Device Status")); + end else + DeviceStatus := ''; + + // TotalProductionCounter on + if XmlDoc.SelectSingleNode('/*[local-name()="JMF"]/*[local-name()="Signal"]/*[local-name()="DeviceInfo"]/@TotalProductionCounter', Node) then begin + Attribute := Node.AsXmlAttribute(); + CounterTxt := Attribute.Value; + if not Evaluate(TotalProductionCounter, CounterTxt) then + TotalProductionCounter := 0; + end else + TotalProductionCounter := 0; + + out_CounterEntry."Current Count" := TotalProductionCounter; + + //Compare against previous record + PrevCounterEntry.Reset(); + PrevCounterEntry.SetRange("Cost Center Code", out_CounterEntry."Cost Center Code"); + if PrevCounterEntry.FindLast() then begin + out_CounterEntry.UOM := PrevCounterEntry.UOM; + out_CounterEntry."Case ID" := PrevCounterEntry."Case ID"; + out_CounterEntry."Plan ID" := PrevCounterEntry."Plan ID"; + if PrevCounterEntry."Current Count" <> -1 then + DiffCount := out_CounterEntry."Current Count" - PrevCounterEntry."Current Count" + else + DiffCount := 0; + out_CounterEntry."Difference Count" := DiffCount; + if PrevCounterEntry."Current Time" = 0DT then + ElapsedTime := out_CounterEntry."Current Time" - out_CounterEntry."Current Time" + else + ElapsedTime := out_CounterEntry."Current Time" - PrevCounterEntry."Current Time"; + + if ElapsedTime = 0 then + out_CounterEntry.Speed := 0 + else begin + Hours := ElapsedTime / (1000 * 60 * 60); + if Hours > 0 then + out_CounterEntry.Speed := Round(DiffCount / Hours, 1); + end; + end; + end; + + local procedure BuildRequestUrl(in_BaseUrl: Text; in_Resource: Text): Text + var + RequestUrl: Text; + begin + RequestUrl := in_BaseUrl; + if not RequestUrl.EndsWith('/') then + RequestUrl := RequestUrl + '/'; + + RequestUrl := RequestUrl + in_Resource; + + exit(RequestUrl); + end; + + procedure SendGetRequest(in_Uri: Text; in_ServiceAction: Text): Text + var + IsHandled: Boolean; + Client: HttpClient; + RequestMessage: HttpRequestMessage; + ResponseMessage: HttpResponseMessage; + Response: Text; + begin + IsHandled := false; + this.MockWebRequest(in_ServiceAction, Response, IsHandled); + if IsHandled then + exit(Response); + + Client.DefaultRequestHeaders().Clear(); + RequestMessage.SetRequestUri(in_Uri); + RequestMessage.Method('GET'); + if Client.Send(RequestMessage, ResponseMessage) then begin + ResponseMessage.Content().ReadAs(Response); + exit(Response); + end else + Error(UnableToProcessRequestErr, ResponseMessage.HttpStatusCode()); + end; + + local procedure MockWebRequest(in_ServiceAction: Text; var out_Response: Text; var out_IsHandled: Boolean) + var + SpencerMetricsEvents: Codeunit "PVS SM Events"; + begin + if in_ServiceAction = '' then + exit; + + SpencerMetricsEvents.OnMockWebRequest(in_ServiceAction, out_Response, out_IsHandled); + end; +} diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Utilities/TimerAddIn/PVSSMTimerAddIn.ControlAddin.al b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Utilities/TimerAddIn/PVSSMTimerAddIn.ControlAddin.al new file mode 100644 index 0000000..5d5daac --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Utilities/TimerAddIn/PVSSMTimerAddIn.ControlAddin.al @@ -0,0 +1,15 @@ +namespace PrintVis.SpencerMetrics.Utilities; + +controladdin "PVS SM Timer AddIn" +{ + HorizontalStretch = false; + RequestedHeight = 1; + RequestedWidth = 1; + Scripts = 'src/Utilities/TimerAddIn/timer.js'; + VerticalStretch = false; + + event Ready(); + event OnTick(); + procedure Start(IntervalMs: Integer) + procedure Stop() +} \ No newline at end of file diff --git a/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Utilities/TimerAddIn/timer.js b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Utilities/TimerAddIn/timer.js new file mode 100644 index 0000000..c37eeea --- /dev/null +++ b/Integrations/SpencerMetrics/PrintVis SpencerMetrics/src/Utilities/TimerAddIn/timer.js @@ -0,0 +1,65 @@ +(function () { + var state = { + interval: 30000, + running: false, + handle: null + }; + + function fireReady() { + try { + Microsoft.Dynamics.NAV.InvokeExtensibilityMethod( + 'Ready', // AL event name in your controladdin + [], // args to AL + false, // runOnServer + function onSuccess() { /* no-op */ }, + function onError(err) { /* optional logging/backoff */ } + ); + } catch (e) { /* ignore */ } + } + + function scheduleNext() { + if (!state.running) return; + state.handle = window.setTimeout(invokeTick, state.interval); + } + + function invokeTick() { + if (!state.running) return; + Microsoft.Dynamics.NAV.InvokeExtensibilityMethod( + 'OnTick', // AL event name + [], // args to AL (add items here if needed) + false, // runOnServer + function onSuccess() { + // AL finished handling the tick → schedule the next one + scheduleNext(); + }, + function onError(err) { + // Optionally implement backoff/retry strategy here + scheduleNext(); // still schedule the next tick + } + ); + } + + // Exposed to AL + window.Start = function (ms) { + if (typeof ms === 'number' && ms > 0) state.interval = ms; + + // restart cleanly + window.Stop(); + state.running = true; + + // fire first tick immediately; subsequent ticks are scheduled after AL completes + invokeTick(); + }; + + // Exposed to AL + window.Stop = function () { + state.running = false; + if (state.handle) { + window.clearTimeout(state.handle); + state.handle = null; + } + }; + + // Announce readiness once the script is loaded + fireReady(); +})(); \ No newline at end of file