Page Index Toggle Pages: [1] 2 3  Send TopicPrint
Very Hot Topic (More than 25 Replies) save and retrieve the node in to database (Read 18608 times)
jithu14
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 1
Joined: Oct 13th, 2009
save and retrieve the node in to database
Oct 13th, 2009 at 7:17pm
Print Post  


  hi,

     Iam using the flowcharter example.Here iam dragging the nodes and I want to save the node information(like nodetext) and i want to retrive the node information in the shapelist.

Can u give any sample for this one.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: save and retrieve the node in to database
Reply #1 - Oct 14th, 2009 at 3:26pm
Print Post  
Hi,

You could add a Diagrams table with "id" and "diagram" fields to hold the fullly saved diagram, and Nodes table with id, text, diagramId fields to contain relational data about nodes. Then if you generate typed data adapters, you could implement saving to database like this:

Code
Select All
protected void btnSave_Click(object sender, EventArgs e)
{
	if (!String.IsNullOrEmpty(tbFileName.Text))
	{
		string diagramId = tbFileName.Text;
		string diagramString = diagramView.Diagram.SaveToString();

		DiagramsTableAdapter diagAdapter = new DiagramsTableAdapter();
		DiagramsSet.DiagramsDataTable diagTable = diagAdapter.GetDataBy(diagramId);
		if (diagTable.Rows.Count == 0)
			diagAdapter.Insert(diagramId, diagramString);
		else
			diagAdapter.UpdateQuery(diagramString, diagramId);

		NodesTableAdapter nodeAdapter = new NodesTableAdapter();
		nodeAdapter.DeleteQuery(diagramId);
		foreach (DiagramNode node in diagramView.Diagram.Nodes)
		{
			ShapeNode shapeNode = node as ShapeNode;
			if (shapeNode == null)
				continue;

			nodeAdapter.Insert(shapeNode.Tag.ToString(), shapeNode.Text, diagramId);
		}
	}
}
 


  
Back to top
 
IP Logged
 
learner123
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 20
Joined: Oct 9th, 2009
Re: save and retrieve the node in to database
Reply #2 - Oct 14th, 2009 at 5:38pm
Print Post  

  Thanks for your reply

         Can i know how it is saving into database.Iam using sqlserver here I want to the details of each node .In your code u didnt mention any sql query
so can you send how to store and retriev the node information so it wil dasplay the flowchart in diagramview based on node information what i saved.

So can u expalin how to use query to insert and  retrieve .
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: save and retrieve the node in to database
Reply #3 - Oct 15th, 2009 at 9:12am
Print Post  
Here is the complete example along with some code to load a diagram and refresh nodes from their db table data:
https://mindfusion.eu/_samples/netdiag_SqlServerStore.zip

You should copy the mindfusion.* assemblies to the bin fodler and the .jar file to the site's folder.
  
Back to top
 
IP Logged
 
bhanuprakash007
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Sep 29th, 2009
Re: save and retrieve the node in to database
Reply #4 - Oct 15th, 2009 at 5:49pm
Print Post  

  Thanks for ur reply

    In this Application you are retrieving the nodes information based on selecting the filename.Now i want to edit the data in a seperate window based on uniqueid.The edit page window should when i clcik on the node means i want to transfer the node uniqueid to the edit page window how can i get the uniqueid for a particular node.Can u please suggest me in this one.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: save and retrieve the node in to database
Reply #5 - Oct 15th, 2009 at 6:13pm
Print Post  
If you are asking how to get an id that's already assigned to the Tag property, you can do that by calling args.getNode().getTag(), e.g.:

Code
Select All
function onNodeDoubleClicked(sender, args)
{
	window.open("editnode.aspx?id="+args.getNode().getTag());
}
 



Then editnode.aspx can access the value through the QueryString collection: string id = Request.QueryString["id"];
  
Back to top
 
IP Logged
 
bhanuprakash007
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Sep 29th, 2009
Re: save and retrieve the node in to database
Reply #6 - Oct 15th, 2009 at 7:27pm
Print Post  

     Hi,


string diagramId = tbFileName.Text;
string diagramString = diagramView.Diagram.SaveToString();

DiagramsTableAdapter diagAdapter = new DiagramsTableAdapter();
DiagramsSet.DiagramsDataTable diagTable = diagAdapter.GetDataBy(diagramId);
if (diagTable.Rows.Count == 0)
diagAdapter.Insert(diagramId, diagramString);

nodeAdapter.Insert(shapeNode.Tag.ToString(), shapeNode.Text, diagramId);


       In this application u r saving the details at server side.But i want store the details in another window when the node is clicked.So i want to transfer the details of Diagram.SaveToString(),Shapenode.text at clientside.So please can u send these syantax at client side
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: save and retrieve the node in to database
Reply #7 - Oct 16th, 2009 at 5:48am
Print Post  
Try to save the string returned by applet.saveToString() and the node's id as variables in the global scope in your main page, and then access them from the other window through the opener property:

// in the main window
diagramString = applet.saveToString();

// in the other window
diagramString = window.opener['diagramString'];
  
Back to top
 
IP Logged
 
bhanuprakash007
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Sep 29th, 2009
Re: save and retrieve the node in to database
Reply #8 - Oct 16th, 2009 at 7:26am
Print Post  
Hi,

  Thanks For your Reply.Iam getting runtime error at this code

diagramString = applet.saveToString();


Here applet object doesn't declare.Can i know how to declare for applet



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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: save and retrieve the node in to database
Reply #9 - Oct 16th, 2009 at 8:02am
Print Post  
var applet = <%=diagramView.AppletElement%>;
  
Back to top
 
IP Logged
 
bhanuprakash007
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Sep 29th, 2009
Re: save and retrieve the node in to database
Reply #10 - Oct 16th, 2009 at 8:17am
Print Post  


     Hi,

          var applet = <%=diagramView.AppletElement%>;  with this one iam getting the errar.Later i changed like this

var applet = <%=diagramView.AppletElement%>.getDiagram();
     diagramString = applet .saveToString();

Now it is getting the diagrastring but it is not saving int to the database remaining values are saving in the database like uniqueid,text but

diagramString = applet.saveToString(); 
is not saving in the database.Iam using sql server 2000 i have taken the datatype for diagramstring as nvarchar with Lentgh 4000.Can u check once this.
i
  
Back to top
 
IP Logged
 
bhanuprakash007
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Sep 29th, 2009
Re: save and retrieve the node in to database
Reply #11 - Oct 16th, 2009 at 9:35am
Print Post  
   
     Hi,

      Iam able to insert the daigramstring in the database.Now Iam getting the errorwhen we are binding the diagramstring to diagramview  at this code .


string diagramString = ds.Tables["Diagram"].Rows[0]["DiagramID"].ToString() ;
                   diagramView.Diagram.LoadFromString(diagramString);

The Error Is:

The magic number in GZip header is not correct. Make sure you are passing in a GZip stream.

Can u please let me know how to handle this error.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: save and retrieve the node in to database
Reply #12 - Oct 16th, 2009 at 10:50am
Print Post  
applet.saveToString() serializes the diagram in binary format, which is different than the .NET's one. You will have to save it in XML format, e.g. try setting the string to applet.getDiagram().saveToString(/*CompressedXml*/ 3, true).
  
Back to top
 
IP Logged
 
bhanuprakash007
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Sep 29th, 2009
Re: save and retrieve the node in to database
Reply #13 - Oct 16th, 2009 at 12:57pm
Print Post  


  hi
      Iam getting the xml file and i want save it in another window so i want to send this daigaram string xml file to another window.But iam getting this error while iam sending this one to another window.Here is the code

var applet = <%= diagramView.AppletElement %>;
var diagram = applet.getDiagram();

// Base64 = 1;
// Xml = 2;
// CompressedXml = 3;
var xml = diagram.saveToString(2, true);
//<%=diagramView.AppletElement%>.getDiagramView().beginEdit(node);
// var diagram = <%=diagramView.AppletElement%>.getDiagram();
// var applet = <%=diagramView.AppletElement%>;
//    var  diagramString = applet.getDiagram().saveToString(/*CompressedXml*/ 3, true);
//var ddlReport = document.getElementById("<%=listFileNames.ClientID%>");
var Text = document.getElementById("txtUniqueid").value;
//var Value = ddlReport.options[ddlReport.selectedIndex].value;



//  myRef = window.open('Windows.aspx?UniqueId=' + document.getElementById("txtUniqueid").value + '?DiagramId= ' + diagramString + '?DiagramFile= ' + Text,'mywin',

//'left=20,top=20,width=500,height=500,toolbar=1,resizable=0');

myRef = window.open('Windows.aspx?UniqueId=' + document.getElementById("txtUniqueid").value + '?DiagramFile= ' + Text + '?DiagramId= ' + xml,'mywin',

'left=20,top=20,width=500,height=500,toolbar=1,resizable=0');


The error is:

A potentially dangerous Request.QueryString value was detected from the client (UniqueId="...one="no"?><Diagram Version="13...").


Can u please suggest in this one
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: save and retrieve the node in to database
Reply #14 - Oct 16th, 2009 at 3:51pm
Print Post  
The saveToString() result could be a very long string, and neither web servers nor browsers like long query strings. Try to save the string in a variable in the global scope of the main page, or in a HIDDEN field. Then you should be able to access it from the second window through window.opener['diagramString'], or if it's in a hidden field through window.opener.document.getElementById(hiddenId).value.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 3 
Send TopicPrint