Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Flowchart doesn't restore properly (Read 7140 times)
Seablade
YaBB Newbies
*
Offline



Posts: 9
Location: U.S.
Joined: Aug 12th, 2008
Flowchart doesn't restore properly
Aug 26th, 2008 at 9:20pm
Print Post  
I'm using the trial version 5.x.

Currently I'm using the Diagram.SaveToStream(...) method to save my diagram to the database.

Now, if I go back and restore the diagram from the binary data stored in the database, then add more nodes, then save the diagram again using the Diagram.SaveToStream(...) method, the newly added nodes are missing the next time I try to reload the Diagram and it's back to the way it was the first time I created it.

I'm really at a loss for what's going on here.
Any suggestions would be appreciated.

Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Flowchart doesn't restore properly
Reply #1 - Aug 27th, 2008 at 9:34am
Print Post  
More likely the problem is that the dataset changes are not committed to the database. Are you calling TableAdapter.Update(dataset.table) after adding the new nodes and saving the diagram stream in the dataset?

Stoyan
  
Back to top
 
IP Logged
 
Seablade
YaBB Newbies
*
Offline



Posts: 9
Location: U.S.
Joined: Aug 12th, 2008
Re: Flowchart doesn't restore properly
Reply #2 - Aug 27th, 2008 at 12:17pm
Print Post  
Right now I'm using the Diagram.SaveToStream(...) method to save it and then using the Diagram.LoadFromStream(...) method to load it back. 

I'm not using a DataSet.  I'm using LINQ-SQL to save and load the diagram.  I have compared the two sets of binary data and they are different.  Also, I've noticed that if I save a diagram, then load the diagram then save the diagram, the binary data is different on the second save than from the first save, even though I didn't change anything.

In order to save and restore a diagram what must I do or what else might be the problem?

Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Flowchart doesn't restore properly
Reply #3 - Aug 27th, 2008 at 2:04pm
Print Post  
Could you copy here the code you are using to save the data from the stream into the database?

Stoyan
  
Back to top
 
IP Logged
 
Seablade
YaBB Newbies
*
Offline



Posts: 9
Location: U.S.
Joined: Aug 12th, 2008
Re: Flowchart doesn't restore properly
Reply #4 - Aug 27th, 2008 at 2:12pm
Print Post  
Here's the code I'm using to save to the database and read from the database
dc is a LINQ-SQL DataContext object.
rs is a variable that points to a LINQ generated class for a database table.  The table has several columns including one that is a Varbinary(MAX) that stores the binary representation of the diagram.

Saving a diagram:
....

//Save the diagram changes.
using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) {
    this.Diagram.SaveToStream(ms, true);
    rs.Diagram = ms.ToArray();
}
dc.RS.InsertOnSubmit(rs);
dc.SubmitChanges();

....

Restoring a diagram:
....

using (System.IO.MemoryStream ms = new System.IO.MemoryStream(this.RS.Diagram.ToArray())) {
    this.Diagram.LoadFromStream(ms);
}

....

Thanks,
Mike
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Flowchart doesn't restore properly
Reply #5 - Aug 27th, 2008 at 2:24pm
Print Post  
So InsertOnSubmit and SubmitChanges cause the diagram to be inserted into the table as a new record? Are you sure this.RS points to the latest record when you call LoadFromStream? If your select query returns all copies of the diagram, I suppose the oldest copy will be the current record just after the query has been executed.

Stoyan
  
Back to top
 
IP Logged
 
Seablade
YaBB Newbies
*
Offline



Posts: 9
Location: U.S.
Joined: Aug 12th, 2008
Re: Flowchart doesn't restore properly
Reply #6 - Aug 27th, 2008 at 2:31pm
Print Post  
Yes on both accounts.
The InsertOnSubmit(...) method causes the the values to be submitted when SubmitChanges(...) method is executed.
There is no other record except the one I'm adding.  Prior to making/submitting these changes, I delete the previous table data (including the diagram bytes) and then recreate it and and store the new diagram bytes along with the other data.

Thanks.
  
Back to top
 
IP Logged
 
Seablade
YaBB Newbies
*
Offline



Posts: 9
Location: U.S.
Joined: Aug 12th, 2008
Re: Flowchart doesn't restore properly
Reply #7 - Aug 27th, 2008 at 7:36pm
Print Post  
I have also now discovered that a variety of properties are not serialized properly when you save (or load) a diagram.  One example of such is the text property for a cell in a TableNode object.  When you change the text property, it changes, but when serialized and then deserialized, the text property has reverted to its prior form.

Can this be caused because a previous "diagram" instance is not total replaced when you do a Diagram.LoadFromStream(...)?

Is there a method that can be called on the Diagram to completely clear all information currently loaded so that a new diagram can be loaded?

Thanks.
  
Back to top
 
IP Logged
 
Seablade
YaBB Newbies
*
Offline



Posts: 9
Location: U.S.
Joined: Aug 12th, 2008
Re: Flowchart doesn't restore properly
Reply #8 - Aug 27th, 2008 at 9:22pm
Print Post  
After further testing, I have discovered that if I close my entire application down and then restart it, loading the diagram (without having loaded a previous diagram) the changes that I applied and stored in the database are now apparent.

It seems that the diagram needs to be cleared before changing with a new or different diagram.

Is there such a feature or is this a bug?

Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Flowchart doesn't restore properly
Reply #9 - Aug 28th, 2008 at 8:28am
Print Post  
Internally SaveToStream and LoadFromStream are used in many situations, such as when saving to a file, when copying to the clipboard, by the SaveToString and LoadFromString methods, etc. So it is very unlikely that the problem comes from them. Either you are loading from an older copy of the diagram data, or you are loading it into a Diagram that is not the one displayed by the DiagramView.

Stoyan
  
Back to top
 
IP Logged
 
Seablade
YaBB Newbies
*
Offline



Posts: 9
Location: U.S.
Joined: Aug 12th, 2008
Re: Flowchart doesn't restore properly
Reply #10 - Aug 28th, 2008 at 1:50pm
Print Post  
You know better about the internals of the methods than I do.  Nevertheless, I can only see the updated diagram changes if I close my entire application down and then restart it. 

If I follow these steps listed below with my diagram form up I can reproduce this problem:

1)  Start a new form with the diagram.
2)  Add some TableNodes to the diagram.
3)  Save the diagram.
4)  Load the saved diagram.
5)  Add some more TableNodes.
6)  Save the diagram.
7)  Load the saved diagram.  The previously added (step 5) TableNodes are missing.
8)  Close the entire application and start over, loading the previously created diagram (step 6).  The previously added (step 5) TableNodes are now visible.

Something is amiss here.  It may only be on my end, but it might not be.  It seems that if the Diagram control contained a previous diagram and then a new diagram was loaded, it keeps its previously loaded diagram over the newly loaded diagram.

This is a serious issue for me as I need these diagrams to be displayed properly.

Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Flowchart doesn't restore properly
Reply #11 - Aug 29th, 2008 at 7:21am
Print Post  
Try calling SaveToStream and LoadFromStream on a FileStream object.

If it works, then something is wrong with the database update or query code - you might be getting a cached value, using a dataset returned by old query, or the update hasn't been committed.

If it doesn't work any better with a FileStream, make sure the Diagram object on which you are calling LoadFromStream is the one you are seeing in the DiagramView. E.g. if the code that loads the diagram looks like this

this.diagram = new Diagram();
this.diagram.LoadFromStream(...);

you won't see the loaded diagram unless you also set diagramView.Diagram = this.diagram;

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint