Bertverbeek4PS / bc2adls

Exporting data from Dynamics 365 Business Central to Azure data lake storage or MS Fabric lakehouse
MIT License
60 stars 22 forks source link

OnAllExportIsFinished event triggers to fast? #127

Closed WilcoHendriksen closed 5 months ago

WilcoHendriksen commented 6 months ago

In the "ADLSE Execution".StartExport method the OnAllExportIsFinished is added, I think this event is triggered too fast, because the sessionmanager starts background sessions. So they are all "scheduled" but not finished. Maybe its better to call it OnAllExportAreScheduled?

        Message(ExportStartedTxt, Started, Counter);
        if EmitTelemetry then
            Log('ADLSE-001', StrSubstNo(ExportStartedTxt, Started, Counter), Verbosity::Normal);

        ADLSEExternalEvents.OnAllExportIsFinished(ADLSESetupRec);
    end;

I like the idea to have an event when everything is finished. Maybe we could add a RunID in the "ADLSE Run" table, so we can check every x seconds if the scheduled sessions per RunID have been exported successful.

Bertverbeek4PS commented 5 months ago

Sorry for the delay @WilcoHendriksen I have a look into this when all the events are done.

Bertverbeek4PS commented 5 months ago

@WilcoHendriksen I have looked into this. But You cannot create a unique runID or something and put it in the run table or session table. This because the sessions are runned in a new session and you cannot pass the runId to it. Also not with a singleinstance codeunit. Or you have to store it in the isolated storage. But I think that isn't a good practice.

What you can do to query the run table if everything is exported every minute. Or (I added this in a seperate branche) you can query the currentsessions API if that table is empty then everything is exported. You can do it with the do until loop in Power Automate.