Author Topic: Can ResultBuffer data save to binary file?  (Read 3642 times)

0 Members and 1 Guest are viewing this topic.

gswang

  • Newt
  • Posts: 117
Can ResultBuffer data save to binary file?
« on: October 22, 2019, 09:02:23 PM »
I want to save ResultBuffer data to sql server database, how can do it? Thanks.

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Can ResultBuffer data save to binary file?
« Reply #1 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
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: Can ResultBuffer data save to binary file?
« Reply #2 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

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: Can ResultBuffer data save to binary file?
« Reply #3 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.
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

Jeff H

  • Needs a day job
  • Posts: 6144
Re: Can ResultBuffer data save to binary file?
« Reply #4 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?