Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) loadfrom with custom objects (Read 5778 times)
Bjorn
YaBB Newbies
*
Offline


Alfadata Technologies
Corporation

Posts: 33
Location: Alberta
Joined: Aug 14th, 2008
loadfrom with custom objects
Nov 20th, 2008 at 5:32pm
Print Post  
Hello,

I have a product using Flowchart.NET that I have a saved diagram from that product, and I have saved the diagram to a stream, and I load that stream using the NetDiagram product. 

This seems to work fine unless I have custom objects in my original diagram (in my test I used a single custom object whose load and save methods are empty), in which case, the NetDiagram version displays only an empty screen (it doesn't even display the non custom objects anymore).

- I am using Mindfusion.Diagramming.WebForms
2.0.1.19968

Thanks for any help you can provide!
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: loadfrom with custom objects
Reply #1 - Nov 20th, 2008 at 6:14pm
Print Post  
Hi,

Are you using RegisterItemClass to enable serialization of custom objects in the WinForms app? You should now call RegisterItemClass from the web application too, using the same class IDs to enable loading objects from the custom class.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Bjorn
YaBB Newbies
*
Offline


Alfadata Technologies
Corporation

Posts: 33
Location: Alberta
Joined: Aug 14th, 2008
Re: loadfrom with custom objects
Reply #2 - Nov 20th, 2008 at 9:32pm
Print Post  
Hello,

Yes I use the RegisterItemClass from the web application, using the same IDs.

Strangely, though, the RegisterItemClass function works only the the first time the web application is accessed, then fails out saying the key is already registered.  Is this a problem? 

I am doing the RegisterItemClass in the pageload
if !ispostback and in a try catch block since it throws exceptions after the first run.  Will this work, or does the registeritemclass call need to be somewhere else?
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: loadfrom with custom objects
Reply #3 - Nov 21st, 2008 at 7:22am
Print Post  
Hi,

The IDs are saved in a static table in the Diagram class, so you might add Global.asax (using the "Global application class" template from the New Item list) and register the class in Application_Start. Otherwise you might check if ((view.Diagram as IItemFactory).ClsidTable.ContainsKey(...)) before calling the Register method in Form_Load.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Bjorn
YaBB Newbies
*
Offline


Alfadata Technologies
Corporation

Posts: 33
Location: Alberta
Joined: Aug 14th, 2008
Re: loadfrom with custom objects
Reply #4 - Nov 21st, 2008 at 6:02pm
Print Post  
Ok, I have changed the call to use an if statement check rather than a try catch, but it didn't effect the resulting diagram.  It still seems to only display a blank diagram if I have any custom objects in the saved diagram.
  
Back to top
WWW  
IP Logged
 
Bjorn
YaBB Newbies
*
Offline


Alfadata Technologies
Corporation

Posts: 33
Location: Alberta
Joined: Aug 14th, 2008
Re: loadfrom with custom objects
Reply #5 - Nov 21st, 2008 at 6:03pm
Print Post  
Also, I should note that when I use the flowcharter sample for the Flowchart.NET product, (add in the registeritem code) and load the saved diagram, then I do get the expected result.

Thanks again for your help!
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: loadfrom with custom objects
Reply #6 - Nov 21st, 2008 at 6:54pm
Print Post  
Have you added all your custom serialization code to the webforms application? Are you using any Windows Forms specific types as fields in your custom items?
  
Back to top
 
IP Logged
 
Bjorn
YaBB Newbies
*
Offline


Alfadata Technologies
Corporation

Posts: 33
Location: Alberta
Joined: Aug 14th, 2008
Re: loadfrom with custom objects
Reply #7 - Nov 21st, 2008 at 8:14pm
Print Post  
Hello,

Yes, for testing purposes, I have made my custom code very simple (empty) to make sure there aren't any windows specific objects:
Public Class SchematicNote
    Inherits MindFusion.Diagramming.ShapeNode
End Class

This is the same dll reference from both the saving windows application and the loading web application.
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: loadfrom with custom objects
Reply #8 - Nov 22nd, 2008 at 12:26pm
Print Post  
Hi,

Does the original class from the Windows Forms application writes any additional information by overriding the SaveTo method? When loading a file in binary mode, each object should read exactly as many bytes from the stream as it has written there when saving. So you'd have to copy the SaveTo and LoadFrom methods to the ASP.NET class too.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Bjorn
YaBB Newbies
*
Offline


Alfadata Technologies
Corporation

Posts: 33
Location: Alberta
Joined: Aug 14th, 2008
Re: loadfrom with custom objects
Reply #9 - Nov 26th, 2008 at 6:32pm
Print Post  
Hello,

No, I am using the same build of by custom object dll for saving that I am for loading. There should be no extra data saved with the diagram.

I decided that my custom application had to many factors to make a decent test, so i built a test case from your samples, it gave the same result.. Here is what I did:

I took the IconNodes sample from Flowchart.net, and replaced the reference to IconNode with my custom dll that contains this code:
namespace IconNodes {
public class IconNode : ShapeNode {}
}
I took out the parts that assign an icon so my simplified object would work with the application.
Then, I ran the sample, add some squares and save to file.
Then, I used the Flowcharter sample from Netdiagram, and referenced the same custom dll,
added the registeritemclass code to register my class, ran the sample and loaded the file I saved.
It comes up as blank, the squares do not show up. If I use the IconNode sample and load the diagram, they do show up.

Thanks again!
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: loadfrom with custom objects
Reply #10 - Nov 27th, 2008 at 10:07am
Print Post  
Hi,

Try this in ImageMap mode and you will see that the file loads correctly. However, if you need to show it in JavaApplet mode, you will have to create a corresponding Java node class and include it in the applet's JAR file. In that case you will need to implement the SaveToXml and LoadFromXml methods, because the applet communicates with the server through XML.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint