Inventory Web Page - 'Native' embedded DLL  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Inventory Web Page - 'Native' embedded DLL  Topic is solved

Postby pricerc » Tue Nov 30, 2021 12:01 pm

I have a new Inventory Web Browser plugin based on Microsoft.WebView2 (chrome) instead of IE.

It's working well, except that it has a native DLL that it seems needs to be available to the plugin at compile-time.

If the DLL is in the Jiwa folder, or I put it into the "compiler" and "runtime" folders, then the plugin runs, but I can't add it to the "embedded assemblies" list, because it's not a .NET assembly.

I've attached it as a document and have this code to copy it to the compile-time and run-time plugin folders, which seems to do the trick:
Code: Select all
    Public Sub SetupBeforeHandlers(ByVal JiwaForm As IJiwaForm, ByVal Plugin As Plugin.Plugin) Implements IJiwaFormPlugin.SetupBeforeHandlers
        For Each doc As Documents.Document In Plugin.Documents ' should only be one
            ' grab the native DLL and put it into the runtime folder.
            If doc.PhysicalFileName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) Then
                Dim dllName As String = IO.Path.Combine(Plugin.CompilationFolder, doc.PhysicalFileName)
                If Not My.Computer.FileSystem.FileExists(dllName) OrElse My.Computer.FileSystem.GetFileInfo(dllName).CreationTime < Plugin.LastWriteDateTime Then
                    My.Computer.FileSystem.WriteAllBytes(dllName, doc.FileBinary, False)
                End If

                dllName = IO.Path.Combine(Plugin.RuntimeFolder, doc.PhysicalFileName)
                If Not My.Computer.FileSystem.FileExists(dllName) OrElse My.Computer.FileSystem.GetFileInfo(dllName).CreationTime < Plugin.LastWriteDateTime Then
                    My.Computer.FileSystem.WriteAllBytes(dllName, doc.FileBinary, False)
                End If

            End If
        Next
    End Sub


Is there a better way?


edited subject to be more useful to other punters.
Last edited by pricerc on Tue Nov 30, 2021 2:51 pm, edited 1 time in total.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Re: 'Native' embedded DLL

Postby pricerc » Tue Nov 30, 2021 12:04 pm

For completeness, here's the plugin.

Free to a good home.

I'm not sure if you need the actual runtime installed for it to work: https://go.microsoft.com/fwlink/p/?LinkId=2124703
Attachments
Plugin AERP - Inventory Web Tab.xml
Inventory Web Browser Plugin
(555.11 KiB) Downloaded 963998 times
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Re: 'Native' embedded DLL

Postby Mike.Sheen » Tue Nov 30, 2021 12:24 pm

pricerc wrote:For completeness, here's the plugin.

Free to a good home.

I'm not sure if you need the actual runtime installed for it to work: https://go.microsoft.com/fwlink/p/?LinkId=2124703



Cool - thanks for that.

We also came across this problem on DEV-8922 which uses a Chromium browser to embed Power BI reports / dashboards inside Jiwa. We did that because getting the Microsoft Web Browser control to play nice with auth flows was impossible.

We also arrived at the same solution - attach the required dependencies as documents and extract them if not present.

However, I notice you're not explicitly reading the documents. We added some optimisations a while back to not load the documents of a plugin in DEV-7217 - so in your SetupBeforeHandlers where you extract the documents to the file system, you'll be wanting to do this first:
Code: Select all
Plugin.Documents.Read(Plugin.RecID);


You can see how we do that in DEV-8922 - it has a link to the plugin we developed to download.

I notice your plugin references Jiwa version 7.2.1.0 - the optimisation to not load documents of plugins was implemented in 7.2.0 SR2 - so you'll definitely be impacted by that - I'm actually a little puzzled that didn't trip you up!
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: 'Native' embedded DLL

Postby pricerc » Tue Nov 30, 2021 1:10 pm

Mike.Sheen wrote:I'm actually a little puzzled that didn't trip you up!


hmmm. As am I. Now that you mention it. I have encountered that problem previously.

I'll add it to my 'todo' list to find out why.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Re: 'Native' embedded DLL

Postby pricerc » Tue Nov 30, 2021 1:22 pm

Mike.Sheen wrote:We also came across this problem on DEV-8922 which uses a Chromium browser


I actually looked at the CEF, but it seemed more work than using Edge/WebView2.

I did find https://www.teamdev.com/dotnetbrowser, which is at least an all-managed solution, but they're asking for more than I thought it was worth for my purposes (although with the two days it took me to complete my two hour project, it may have been worth it...)
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Re: 'Native' embedded DLL

Postby pricerc » Tue Nov 30, 2021 2:33 pm

pricerc wrote:
Mike.Sheen wrote:I'm actually a little puzzled that didn't trip you up!


hmmm. As am I. Now that you mention it. I have encountered that problem previously.

I'll add it to my 'todo' list to find out why.


found it.

Plugin documents are read with the plugin... from ILSpy:
Code: Select all
// JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin
...

public override void Read(string RecID)
{
...
      OnReadStart();
      Clear();
      _Documents.DocumentTypes.Read();
      _Notes.NoteTypeCollection.Read();
      text = "SELECT TOP 1 ...  FROM SY_Plugin  WHERE SY_Plugin.RecID = @RecID";

      ...

      PluginFormCollection.Read();
      BusinessLogicCollection.Read();
      ReferenceCollection.Read();
      CustomFieldCollection.Read();
      SystemSettingCollection.Read();
      ExecutionScheduleCollection.Read();
      Documents.Read(base.RecID);
      Notes.Read(base.RecID);
      ImageCollection.Read();
      PluginReferenceCollection.Read();
      EmbeddedReferenceCollection.Read();
      OnReadEnd();

...
}
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Re: Inventory Web Page - 'Native' embedded DLL

Postby pricerc » Tue Nov 30, 2021 2:54 pm

And because I was avoiding doing some other work, I did this, too.

Combining what I learnt for the inventory one with the standard sample 'web browser'.

Even the print button works.

Just needs someone enthusiastic to add forward, back, refresh and 'recent items' support, and you'll be able to use Jiwa as your web browser !
Attachments
Plugin AERP - Web Browser.xml
(558.23 KiB) Downloaded 1471040 times
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Re: 'Native' embedded DLL

Postby Mike.Sheen » Tue Nov 30, 2021 3:35 pm

pricerc wrote:found it.

Plugin documents are read with the plugin... from ILSpy:
Code: Select all
// JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin
...

public override void Read(string RecID)
{
...
      OnReadStart();
      Clear();
      _Documents.DocumentTypes.Read();
      _Notes.NoteTypeCollection.Read();
      text = "SELECT TOP 1 ...  FROM SY_Plugin  WHERE SY_Plugin.RecID = @RecID";

      ...

      PluginFormCollection.Read();
      BusinessLogicCollection.Read();
      ReferenceCollection.Read();
      CustomFieldCollection.Read();
      SystemSettingCollection.Read();
      ExecutionScheduleCollection.Read();
      Documents.Read(base.RecID);
      Notes.Read(base.RecID);
      ImageCollection.Read();
      PluginReferenceCollection.Read();
      EmbeddedReferenceCollection.Read();
      OnReadEnd();

...
}


I see what's happening now... we'll only do the full read if the plugin hasn't been compiled before and needs to be - So I guess that actually is good enough in your case, as you only need to be able to see the documents once to deploy to the file system - subsequent times after that the plugin will have an empty documents collection... but won't care because the files you need are already on the filesystem.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Inventory Web Page - 'Native' embedded DLL

Postby Mike.Sheen » Wed Dec 01, 2021 2:07 pm

FYI This WebView2 works fine on my Windows 10 machine, but Windows Server 2019 I get the error:

---------------------------
Error
---------------------------
Error : Couldn't find a compatible Webview2 Runtime installation to host WebViews.

Module : MoveNext
---------------------------
OK
---------------------------

I think the WebView requires the runtime to be installed - I found that over here : https://developer.microsoft.com/en-us/m ... /webview2/ but haven't managed to find one matching the version of your plugin, Ryan - did you get your embedded assemblies and WebView2Loader.dll from a nuget package?
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Inventory Web Page - 'Native' embedded DLL

Postby pricerc » Wed Dec 01, 2021 3:16 pm

Mike.Sheen wrote:I think the WebView requires the runtime to be installed - I found that over here : https://developer.microsoft.com/en-us/m ... /webview2/ but haven't managed to find one matching the version of your plugin, Ryan - did you get your embedded assemblies and WebView2Loader.dll from a nuget package?


Yes - the Microsoft WebView2 package - https://www.nuget.org/packages/Microsof ... .0.1020.30

But they're supposed to (as I understood the documentation, which is typically vague) rely on the runtime which I left a link to in the plugin description.
Last edited by pricerc on Wed Dec 01, 2021 3:19 pm, edited 1 time in total.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests