TheSwamp

Code Red => .NET => Topic started by: gswang on October 22, 2019, 09:02:23 PM

Title: Can ResultBuffer data save to binary file?
Post by: gswang on October 22, 2019, 09:02:23 PM
I want to save ResultBuffer data to sql server database, how can do it? Thanks.
Title: Re: Can ResultBuffer data save to binary file?
Post by: MickD on October 22, 2019, 09:50:07 PM
You need to extract the data from the result buffer into a data set that can be used for an SQL query or perhhaps straight to a DataSet which can be saved to the sql server database.

short example of an insert query

1. get result buffer data into variables (not really necessary but makes things easier to understand)
2. get connection to sql server db
3. build sql query with data variables, something like:
Code - C#: [Select]
  1. string qry = "INSERT INTO mytable_name (column1, column2) VALUES (variable1, variable2)";
  2.  
4. run the query command

this is a big topic but pretty easy once you get the hang of it, setting up your db and connection is the hardest and there are many tools to test queries etc.

hth
Title: Re: Can ResultBuffer data save to binary file?
Post by: It's Alive! on October 24, 2019, 09:03:48 PM
Hi,
There’s a couple of projects you might be able to draw inspiration from.

SqliteLsp unpacks result buffers that are sent to Sqlite

And Store File(s) in a DWG https://www.theswamp.org/index.php?topic=26687.0
Has a function ResultBufferToStream

Then you can use a BLOB for your sql data type
Title: Re: Can ResultBuffer data save to binary file?
Post by: Keith Brown on October 25, 2019, 08:44:45 AM
I put all of my data into a class with serializable fields and properties.  The class has a ToResultBuffer function that saves the data to a result buffer.  The class will also load the result buffer into the fields and properties.  I can also serialize the class to json and zip it up into a result buffer when the data becomes to cumbersome to separate and is just data and not autocad information such as hard pointers and world points.


I also take the serialized json string and push to a database and save it there.  Our web app can deserialize the data and present it in its native form for manipulation on the web which can then by synced back down to the dwg items.


So far its working out pretty good.
Title: Re: Can ResultBuffer data save to binary file?
Post by: Jeff H on October 25, 2019, 12:50:39 PM
I put all of my data into a class with serializable fields and properties.  The class has a ToResultBuffer function that saves the data to a result buffer.  The class will also load the result buffer into the fields and properties.  I can also serialize the class to json and zip it up into a result buffer when the data becomes to cumbersome to separate and is just data and not autocad information such as hard pointers and world points.


I also take the serialized json string and push to a database and save it there.  Our web app can deserialize the data and present it in its native form for manipulation on the web which can then by synced back down to the dwg items.


So far its working out pretty good.
*Like*
I mean like a thumbs up like, not like a like?