Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic SaveToString() produces different results (Read 1294 times)
dsmyth
YaBB Newbies
*
Offline



Posts: 9
Joined: Mar 13th, 2006
SaveToString() produces different results
Mar 23rd, 2007 at 8:37am
Print Post  
Hi,

I create a collection of diagrams that are saved to a database table using the SaveToString() method. The table which the diagrams are stored in has a many to many relationship with another table.

I want to use the HashCode of the string produced by SaveToString() as the primary key to the Diagram table, the idea behind this is I can check to see if the diagram is already stored. However....

What I'm finding is the SaveToString() for the same diagram is producing a different string. For example the diagram is built and SaveToString() is called, if the same diagram is then rebuilt and SaveToString() is called a different string is returned.

This might be due to a time stamp in the string.... so can any tell me what I can use as a primary key in my table.

How can I rebuild a diagram in my application in such a way that I can check to see if the diagram has been changed, or not, from the same diagram stored in the database.

Thanks
(Sorry I am using version 4.0.3.30672)
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SaveToString() produces different results
Reply #1 - Mar 23rd, 2007 at 9:28am
Print Post  
Hi,

We had this problem some time ago when we tried to compare files in one of our Nunit test methods. Flowchart.NET's binary serialization uses Hashtables to build a graph of all objects that should be serialized - including brushes, pens, fonts, etc. We have found that the Keys and Values collections of Hashtable instances are enumerated in different order even if the tables contain the same objects. So the objects' binary contents appear in different order too when saved in a file.

You might try building a hash from the string returned by XlmWriter. The order in which objects are saved in XML format should be the same every time. There is a timestamp field in the headers for some image formats, so you might need to disable XmlWriter.Options.WriteImages.

Stoyan
  
Back to top
 
IP Logged
 
dsmyth
YaBB Newbies
*
Offline



Posts: 9
Joined: Mar 13th, 2006
Re: SaveToString() produces different results
Reply #2 - Mar 23rd, 2007 at 10:24am
Print Post  
Thanks Stoyo for the feedback, I looked at the API of v4.3 and saw the XMLWriter, which looked to be a potential solution to the problem.

Unfortunately time is against me at the moment, release end of next week, and there isn't enough time to update to the new DLL version.

I have a solution though, the diagram is build from XML elements that represent tables/arrows in the diagram. Instead of saving the string from SaveToString(), I'll save that XML instead.

Thanks Stovo. Hopefully this post will serve someone else.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint