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 18626 times)
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 #15 - Oct 16th, 2009 at 4:26pm
Print Post  
  hi,

     I want this code at server side.The below code diagramid in xml at client side but i want this code at server side in xml.


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

// Base64 = 1;
// Xml = 2;
// CompressedXml = 3;
var xml = diagram.saveToString(2, true);

Please send me the code
  
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 #16 - Oct 16th, 2009 at 4:42pm
Print Post  
Try this:

string xml = diagramView.Diagram.SaveToString(SaveToStringFormat.Xml);
  
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 #17 - Oct 16th, 2009 at 4:58pm
Print Post  
hi

it is getting syntax error that no overload for method savetostring it is giving.please check once.
  
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 #18 - Oct 16th, 2009 at 5:32pm
Print Post  
hi,

    Thanx for ur support. iam getting and binding the diagramid i.e long string.Now iam facing the problem with uniqueid which is not binding to the node.Below is the code

string id = ds1.Tables["Nodes"].Rows[0]["UniqueId"].ToString();
                       ShapeNode shapeNode = diagramView.Diagram.FindNode(id) as ShapeNode;
                       if (shapeNode != null)


                           shapeNode.Text = ds1.Tables["Nodes"].Rows[0]["Location"].ToString();

I done debugging Iam getting the unique in string 'id'.But it is not binding to the shapenode

i.e   ShapeNode shapeNode = diagramView.Diagram.FindNode(id) as ShapeNode;


Can u Please check once.
  
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 #19 - Oct 16th, 2009 at 5:50pm
Print Post  
The diagram could be empty if this happens in a GET request to the page. Try to first load the diagram nodes using the diagram.LoadFromString method, if that code is not executed in response to a post-back.
  
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 #20 - Oct 16th, 2009 at 6:36pm
Print Post  


     Hi,

        Iam using diagram.Loadfromstring still the uniqueid is not biinding to the node.

SqlCommand SQLcmd = new SqlCommand();
               DataSet ds = new DataSet();
               string query = "Select DiagramId from BOmSystem Where Ltrim(DiagramFile) ='" + diagramId + "'";
               SqlDataAdapter da = new SqlDataAdapter(query, con);
               da.Fill(ds, "Diagram");


               //DiagramTableTableAdapter diagAdapter = new DiagramTableTableAdapter();
               //DiagramsSet.DiagramTableDataTable diagTable = diagAdapter.GetData(diagramId);
               if (ds.Tables["Diagram"].Rows.Count > 0)
               {
                   string diagramString = ds.Tables["Diagram"].Rows[0]["DiagramID"].ToString();
                   diagramView.Diagram.LoadFromString(diagramString);

                   SqlConnection con1 = new SqlConnection(connstr);


                   DataSet ds1 = new DataSet();
                   string query1 = "Select * from BOmSystem Where Ltrim(DiagramFile) ='" + diagramId + "'";
                   SqlDataAdapter da1 = new SqlDataAdapter(query1, con1);
                   da1.Fill(ds1, "Nodes");

                   if (ds1.Tables["Nodes"].Rows.Count > 0)
                   {
                       string id = ds1.Tables["Nodes"].Rows[0]["UniqueId"].ToString();
                       ShapeNode shapeNode = diagramView.Diagram.FindNode(id) as ShapeNode;
                       if (shapeNode != null)


                           shapeNode.Text = ds1.Tables["Nodes"].Rows[0]["Location"].ToString();
                                      



                   }
               }



Still it is not binding iam getting both diagramvviewud and uniqueid.Iam able to bind the diagramviewid to diagram but unable to bind the uniqueid to node.

string id = ds1.Tables["Nodes"].Rows[0]["UniqueId"].ToString();
                       ShapeNode shapeNode = diagramView.Diagram.FindNode(id) as ShapeNode;


can u check once.
  
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 #21 - Oct 19th, 2009 at 6:21am
Print Post  
Hi,

This code doesn't look correct:

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

It tries to load the diagram content from the value used as ID, if the "DiagramID" column is where you store IDs. I suppose you should replace "DiagramID" with the name of the column where you store the saveToString results.

I hope that helps,
Stoyan
  
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 #22 - Oct 19th, 2009 at 6:44am
Print Post  


   hi,

     I have tyaken column name as DiagramID for which we are storing the long string.I done debugging process there iam getting the 2 vaklues i.e Long string and UniqueId.Long string si binding to the Diagram but uniqueid is not binding to the nodes.

So,I think some problem with the binding to the node.

Can u Check once.
  
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 #23 - Oct 19th, 2009 at 7:40am
Print Post  


  HI,

     Here
  string query = "Select DiagramId from BOmSystem Where Ltrim(DiagramFile) ='" + diagramId + "'";


column DiagramId is long string.
and variable diagramid is filename i.e example untitles.fc


SO iam gettiong long string and uniqueid both.But long string is binding to diagramview and uniqueid for the node is not binding i.e the problem.
  
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 #24 - Oct 19th, 2009 at 8:14am
Print Post  
Hi,

So, the DiagramFile column contains diagram IDs, and the DiagramID column contains the diagram data? If you believe that's correct, you might also check whether the diagram loaded from the database is up to date and contains the newly created node. E.g. loop over all items in diagram.Nodes and Debug.Print their tags to see if the new node is there indeed.

Stoyan
  
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 #25 - Oct 19th, 2009 at 9:04am
Print Post  
hi,

can u send me the code for looping the nodes in a duiagram.
  
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 #26 - Oct 19th, 2009 at 10:22am
Print Post  
foreach (DiagramNode node in diagram.Nodes)
     Debug.WriteLine(node.Tag == null ? "null" : node.Tag.ToString());
  
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 #27 - Oct 19th, 2009 at 4:26pm
Print Post  
HI,

  I used your code which u have sent.


if (!String.IsNullOrEmpty(tbFileName.Text))
           {
               string diagramId = tbFileName.Text;



               SqlConnection con = new SqlConnection(connstr);

               SqlCommand SQLcmd = new SqlCommand();
               DataSet ds = new DataSet();
               string query = "Select * from BOmSystem Where Ltrim(DiagramFile) ='" + diagramId + "'";
               SqlDataAdapter da = new SqlDataAdapter(query, con);
               da.Fill(ds, "Diagram");


               //DiagramTableTableAdapter diagAdapter = new DiagramTableTableAdapter();
               //DiagramsSet.DiagramTableDataTable diagTable = diagAdapter.GetData(diagramId);
               if (ds.Tables["Diagram"].Rows.Count > 0)
               {
                   string diagramString = ds.Tables["Diagram"].Rows[0]["DiagramID"].ToString();
                   diagramView.Diagram.LoadFromString(diagramString);
                   foreach (DiagramNode node in diagramView.Diagram.Nodes)
                       Debug.WriteLine(node.Tag == null ? "null" : node.Tag.ToString());


In this iam getting the diagramstring .But the loop is not running I mean node is null. Can u help me on this.
  
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 #28 - Oct 19th, 2009 at 8:08pm
Print Post  
The project you've emailed me saves the diagram in the session upon the first page load:

protected void Page_Load(object sender, EventArgs e)
{
     if (!IsPostBack)
     {
           string diagramString = diagramView.Diagram.SaveToString();
           Session["DiagramId"] = diagramString;
           ...

The diagram is empty at that point. and this is the only assignment to Session["DiagramId"]. Later you are saving this empty diagram into the database, and so FindNode can't find anything after loading it again.

In the else case (when IsPostback is true), you are loading the diagram and losing the data that was posted back. I suppose that code is intended for your auto-refresh feature. If so, you should simply swap the if / else blocks; the diagram should be saved in the session after postback, and loaded from the database in the if (!IsPostBack) case.
  
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 #29 - Oct 20th, 2009 at 5:25am
Print Post  


    Hi,

       The session which i have used for the diagram string  is

Session["DiagramId"] = diagramString;

Here iam using this session in another page.If session is in (postback is true) postaback feature it will save the null.Mainly session iam using for the trabsferring the diagram string from one page to another page.Can you provide the code how to implement the code to transfer the diagram string
from on epage to another page.If possible can u please add in the application and send me the application.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 3 
Send TopicPrint