1. Drew Buchanan
  2. PowerBuilder
  3. Thursday, 12 December 2019 16:04 PM UTC

I have a .NET assembly that I've generated from NVOs. One of the methods I need to call accepts a BLOB of a DataWindow state (calls datastore.setfullstate(BLOB), then performs validation on datastore).

How would one go about generating a byte array that this method could accept? I've tried just passing a tab-delimited string of the contents of my .NET DataTable object which I converted to a byte array using System.Text.Encoding.Unicode.GetBytes(BLOB), but that did not work.

Thanks

 

ETA: The .NET Assembly was created with PowerBuilder 2017 R3 and migrating to PB19 is not an option for our shop at this time.

Kevin Ridley Accepted Answer Pending Moderation
  1. Thursday, 12 December 2019 21:31 PM UTC
  2. PowerBuilder
  3. # 1

Just so I understand, you have a PB client that you want to communicate with the .NET assembly?  If I'm understanding you correctly I'd suggest this.  Since you created the .NET assembly from PB nvo's, change the current method to accept JSON instead of a BLOB.  Then from the PB client, you can do DW/DS.ExportJSON method, and then in the .NET assembly use ImportJSON.  If you don't want to change that method, just create a new one that takes JSON as I mentioned, then do GetFullState on that and pass the blob to the other method.  I don't really use the .NET functionality at this point, so not sure if the .NET assemblies support the GetFullState/SetFullState, but if not, the JSON should work.  Check the help file for the ExportJSON syntax to get the full state, not just plain JSON.

 

Kevin

Comment
  1. Drew Buchanan
  2. Thursday, 12 December 2019 21:37 PM UTC
I should have been more clear. I've exported PowerBuilder NVOs to a .NET dll that I'm attempting to use from within a C# project.
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Thursday, 12 December 2019 21:44 PM UTC
From what I remember a C# project cannot call those old .NET DLLs, but I could be wrong. But just to clarify, there is no such restriction on the new C# projects of PB 2019 since it is native C#. In fact, in PowerBuilder 2019 R2 we enhanced the .NET DataStore to inherit from an iList so the DataWindow can directly pass back n' forth to other lists you may have in other C# code.
  1. Helpful
  1. Kevin Ridley
  2. Thursday, 12 December 2019 23:52 PM UTC
Is the C# project using Appeon or not? If not, you will have to use standard JSON. You can still modify your .NET assembly to import the JSON as I mentioned before. You obviously won't have the state information and you will have to recreate that to do your update. If your client is Appeon, again like I said you can export the full state JSON and import it in your .NET assembly. Hope that makes sense.
  1. Helpful
There are no comments made yet.
Ricardo Jasso Accepted Answer Pending Moderation
  1. Thursday, 12 December 2019 22:48 PM UTC
  2. PowerBuilder
  3. # 2

Drew,

From PB2017 documentation about SetFullState:

"Applies the contents of a DataWindow blob retrieved by GetFullState to a DataWindow or DataStore."

"GetFullState retrieves the entire state of a DataWindow or DataStore into a blob, including the DataWindow object specification, the data buffers, and the status flags. When you use SetFullState to apply the blob created by GetFullState to another DataWindow, the target DataWindow has enough information to recreate the source DataWindow."

I think it would be difficult to recreate, with another language, what SetFullState needs, which is the product of GetFullState. Surely, a simple tab-delimited string of the contents of the .NET DataTable won't do. You're still missing the DataWindow object specification which could result in a daunting task to recreate. These functions were created for a PB distributed application in mind, that is, a PB client and a PB server.

I'd suggest you create an interface in your NVO to receive just a string of data which can be imported to the DataWindow using the ImportString method.

Regards,

Ricardo

 

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.