Save / Load a report to / from a database.

Stimulsoft Reports.Flex discussion
Felipe
Posts: 5
Joined: Tue Jan 18, 2011 9:23 am
Location: Recife - PE / Brazil

Save / Load a report to / from a database.

Post by Felipe »

I want to save a report to my database and then recover it to show on design or view mode.

A example code I tried but didnt work:

Code: Select all

var reportString:String = report.saveReportToString();

//save reportString to my database.

//In another moment I recover the String from my database.

report.loadReportFromString(reportString);
But when I try the method loadReportFromString my flash builder shows the message "The file you choose is not inside a project, so many Flash Builder features will be disabled" and the exception "Error #1063: Incompatibilidade de contagem do argumento Stimulsoft_Replace.Components::StiImage(). Esperado 1, obtido 0.)"

It's the wrong way to do that? There is something I'm missing?
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Save / Load a report to / from a database.

Post by Vladimir »

Hello,

Please try the following code for testing:

Code: Select all

var reportString:String = report.saveReportToString();
report.loadReportFromString(reportString);
If this code does not work, please send us your report for testing.


Also, for storage in a database is better to use the packed format:

Code: Select all

var reportString:String = report.savePackedReportToString();

// Save reportString to database.

report.loadPackedReportFromString(reportString);
Thank you.
Felipe
Posts: 5
Joined: Tue Jan 18, 2011 9:23 am
Location: Recife - PE / Brazil

Save / Load a report to / from a database.

Post by Felipe »

Your code gives the same error than mine. I've tried using the first and the second code.

My code is basically this:

Code: Select all

            protected function titlewindow1_creationCompleteHandler(event:FlexEvent):void
            {				
				var report:StiReport = new StiReport();
				
				if(!insert)
				{
					report.loadPackedReportFromString(entity.ReportXML);
				}
				
				designer.report = report;
			}

			protected function stidesignerfx1_saveReportHandler(event:StiDesignerEvent):void
			{
				var reportXML:String  = designer.report.savePackedReportToString();
				
				save(reportXML);
			}

            
I have this componente designer:StiDesignerFx named "designer" and on my window creation if it's an update request (that's the reason to if(!insert)) load the ReportXML from entity (an entity gotten from the database) and then I charge it to the component StiDesignerFx "designer" 's report. The method save(reportXML:String) saves de String to the database.

Is there any chance the error is a mistake of mine in any other part of this code?
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Save / Load a report to / from a database.

Post by Vladimir »

Hello,

Perhaps the problem is in the report. Please send us your report for analysis: the result of the saveReportToString() or savePackedReportToString() functions, as well as a report taken from the database (entity.ReportXML property).

Thank you.
Felipe
Posts: 5
Joined: Tue Jan 18, 2011 9:23 am
Location: Recife - PE / Brazil

Save / Load a report to / from a database.

Post by Felipe »

I'm using a simple report just for test. There are just a Text and a RectaglePrimitive but I'm sending it anyway.

The packed and no-packed report XML (using savePackedReportToString and saveReportToString):

Code: Select all

H4sIAG+1X6MEC9VY23LiOBB9z1d4/cziC/fEeIrrztZOZlOBzTxM7YNiBKgiLJcspsJ+/baEbAvb
IWQmU1tbQGG1Tgt399FpmeDD845a3zBPCYuHttd0bQvHEVuReDO092L9a9+2UoHiFaIsxkP7gFP7
Q3gVLARZYE4QJf9gXloAJQklERLKAsB7nDAu7PDKsoIpiaQd8YMlDgksWBhs6x6vYQnbIukf+DC0
Bd9j5SX9kECPKMWpFbF9LIa2K2GfSCo0zjGAC7bn0evQBwQBPNLXgfeYqmguAMpIYU5F4h7tgVPE
qMZ3aFP8pldaSq8kMZ5OkbzWyfHrkgPwMWNPO8SfHMPCV5iHn6FqN1/da3j9fePdLBglq5s5oim+
aWf2wNHg3Jfv02341e90rvVHYpQxg0zYLoGlY5EH0q4NRIEXAnFxx0gs7jjZEUG+5bEBPXZ7mrK1
aB6T1yxWbkqSVV11Klr1qahPx/GeKYFl73EEfN5QHLaa3YYrPw03cMqTpuNHuFVOSVxa7xY9L4D+
ofLPBicAEhsAPTABn9EOh3XZCRw1ZWIlCzJm+bZTmuNw8y/NghHDfISX7Lc9WYXz1qw/afem40Gr
Px9M5oPptD9qdWa9Xsd3fW8UOGUPc7Ul2pwuv2SMLkliGAOnLiZjfhavTif9C+lQcdRkaP8wGTy3
2W60mv5/zYZqav7vXKhGZMwu8bPItEBe63p23lzPH9A7U/Pc6zOqV0ucNiiIB7zR3+e5M3uOMH1A
dI9P737OYhGOZD9teMAONbyIc3xD4lRSqqF5dzT8BGKqSr0rFxdbsha3bAW/DIqRD84TDO4iXG5J
CotayBI4FRZXSvFL4KjJMjov7LH0hakM/DNRPf51QqtMGIa81JXuVp3R/O5+B7+FYLsFgQQtwUVy
ODdc0uS6zX7Db3bP03PCKOMhML9hufAGsDKYkAtVoyIVLzD4E14LI6h8+BMIXFOm95VWstmasRTj
N5Je3X4HZsthLMQBCqY0TbbYA8VvVWNlTIybzEYGvWvylB/7nKId5zalaYstxqI4faryj/vT2bwz
m026QBJ3NPXGLcUSf+qN5pP2+JQlNQzJ9c1rqFdF346FVWfl01K+VEZl/4hlZUK/1xwEjmEwMV/I
SmxD35M7phhf5Tu+5pxfqUEl/8EXJDCXe/vC406O17LRe0k2zjeQ4PedTMfxN9W1Xq9/RoZGaQJE
uJcPPqFqoIFjmt7WkccURU+VfqysZ7rxkqM4TdSmu6QT513w7OmN8RElm3gHiFDKTeCcmC7QLJXB
9z783e6pIAnFcxQJkFzJ9VNLWc+c79j7D5iLIlTY+4FzajJkQEVZOqm91ksDJ2esfo5Vm8c7Pgar
5151qbTr/NM0PCPATscPx38WQj3y5XHStF/luxGCQGl4vJYiVtgMzF5sGXcMy2QLFMGr0HN8F96e
Zw2ufffaa1uj22yVDGN4cQxxvuKlMYWXUjs06A36636EB2v/sYOhY3o+anWwj/EaoVU3c8+kUfvq
DmYGl+mdRvwVExFOoIhkh6EGaQZT9gKmEwc5kC3E+BMn/Bd4/9cmDBIAAA==

Code: Select all


  
    
    
    
    
    
  
  
    
      
      None;[0:0:0];1;Solid;False;4;[0:0:0]
      [255:255:255]
      
        
          
          3.6,0.6,0,0
          
          0,0
          0,0
          StartPointPrimitive1
          
          
          F3E8C47DB938F9CF9DD8A35E7752021A
          
          
        
        
          
          10.4,3.2,0,0
          
          0,0
          0,0
          EndPointPrimitive2
          
          
          F3E8C47DB938F9CF9DD8A35E7752021A
          
          
        
        
          
          None;[0:0:0];1;Solid;False;4;[0:0:0]
          [0:255:255:255]
          4.6,1.2,4.6,1.2
          
          Arial,10
          
          0,0,0,0
          0,0
          0,0
          Text1
          
          
          0
          
          This is a test report!
          [0:0:0]
          
          
        
        
          
          True
          3.6,0.6,6.8,2.6
          255, 0, 0
          F3E8C47DB938F9CF9DD8A35E7752021A
          
          True
          0,0
          0,0
          RectanglePrimitive1
          
          
          True
          0
          5
          Solid
          
          
          True
        
      
      
      B8DEF5EEC68F90AD1B38A35E2D1AFC4B
      
      1,1,1,1
      Page1
      
      27.9
      21.6
      
      
      
      
        Arial,10
        
          False
          
          None;Black;1;Solid;False;4;Black
          Transparent
          0,0,0,0
          Left
          
          
          0,0
          0,0
          1
          
          
          
          Top
        
        [0:0:0]
      
    
  
  
  EngineV2
  Report
  
  1/20/2011 9:20:14 AM
  1/20/2011 9:20:14 AM
  a9798f8ce9f2b5e77512a35e2eefaad6
  Report
  Centimeters
  

And the ones recovered from the database:

Code: Select all

H4sIAG+1X6MEC9VY23LiOBB9z1d4/cziC/fEeIrrztZOZlOBzTxM7YNiBKgiLJcspsJ+/baEbAvb
IWQmU1tbQGG1Tgt399FpmeDD845a3zBPCYuHttd0bQvHEVuReDO092L9a9+2UoHiFaIsxkP7gFP7
Q3gVLARZYE4QJf9gXloAJQklERLKAsB7nDAu7PDKsoIpiaQd8YMlDgksWBhs6x6vYQnbIukf+DC0
Bd9j5SX9kECPKMWpFbF9LIa2K2GfSCo0zjGAC7bn0evQBwQBPNLXgfeYqmguAMpIYU5F4h7tgVPE
qMZ3aFP8pldaSq8kMZ5OkbzWyfHrkgPwMWNPO8SfHMPCV5iHn6FqN1/da3j9fePdLBglq5s5oim+
aWf2wNHg3Jfv02341e90rvVHYpQxg0zYLoGlY5EH0q4NRIEXAnFxx0gs7jjZEUG+5bEBPXZ7mrK1
aB6T1yxWbkqSVV11Klr1qahPx/GeKYFl73EEfN5QHLaa3YYrPw03cMqTpuNHuFVOSVxa7xY9L4D+
ofLPBicAEhsAPTABn9EOh3XZCRw1ZWIlCzJm+bZTmuNw8y/NghHDfISX7Lc9WYXz1qw/afem40Gr
Px9M5oPptD9qdWa9Xsd3fW8UOGUPc7Ul2pwuv2SMLkliGAOnLiZjfhavTif9C+lQcdRkaP8wGTy3
2W60mv5/zYZqav7vXKhGZMwu8bPItEBe63p23lzPH9A7U/Pc6zOqV0ucNiiIB7zR3+e5M3uOMH1A
dI9P737OYhGOZD9teMAONbyIc3xD4lRSqqF5dzT8BGKqSr0rFxdbsha3bAW/DIqRD84TDO4iXG5J
CotayBI4FRZXSvFL4KjJMjov7LH0hakM/DNRPf51QqtMGIa81JXuVp3R/O5+B7+FYLsFgQQtwUVy
ODdc0uS6zX7Db3bP03PCKOMhML9hufAGsDKYkAtVoyIVLzD4E14LI6h8+BMIXFOm95VWstmasRTj
N5Je3X4HZsthLMQBCqY0TbbYA8VvVWNlTIybzEYGvWvylB/7nKId5zalaYstxqI4faryj/vT2bwz
m026QBJ3NPXGLcUSf+qN5pP2+JQlNQzJ9c1rqFdF346FVWfl01K+VEZl/4hlZUK/1xwEjmEwMV/I
SmxD35M7phhf5Tu+5pxfqUEl/8EXJDCXe/vC406O17LRe0k2zjeQ4PedTMfxN9W1Xq9/RoZGaQJE
uJcPPqFqoIFjmt7WkccURU+VfqysZ7rxkqM4TdSmu6QT513w7OmN8RElm3gHiFDKTeCcmC7QLJXB
9z783e6pIAnFcxQJkFzJ9VNLWc+c79j7D5iLIlTY+4FzajJkQEVZOqm91ksDJ2esfo5Vm8c7Pgar
5151qbTr/NM0PCPATscPx38WQj3y5XHStF/luxGCQGl4vJYiVtgMzF5sGXcMy2QLFMGr0HN8F96e
Zw2ufffaa1uj22yVDGN4cQxxvuKlMYWXUjs06A36636EB2v/sYOhY3o+anWwj/EaoVU3c8+kUfvq
DmYGl+mdRvwVExFOoIhkh6EGaQZT9gKmEwc5kC3E+BMn/Bd4/9cmDBIAAA==

Code: Select all


  
    
    
    
    
    
  
  
    
      
      None;[0:0:0];1;Solid;False;4;[0:0:0]
      [255:255:255]
      
        
          
          3.6,0.6,0,0
          
          0,0
          0,0
          StartPointPrimitive1
          
          
          F3E8C47DB938F9CF9DD8A35E7752021A
          
          
        
        
          
          10.4,3.2,0,0
          
          0,0
          0,0
          EndPointPrimitive2
          
          
          F3E8C47DB938F9CF9DD8A35E7752021A
          
          
        
        
          
          None;[0:0:0];1;Solid;False;4;[0:0:0]
          [0:255:255:255]
          4.6,1.2,4.6,1.2
          
          Arial,10
          
          0,0,0,0
          0,0
          0,0
          Text1
          
          
          0
          
          This is a test report!
          [0:0:0]
          
          
        
        
          
          True
          3.6,0.6,6.8,2.6
          255, 0, 0
          F3E8C47DB938F9CF9DD8A35E7752021A
          
          True
          0,0
          0,0
          RectanglePrimitive1
          
          
          True
          0
          5
          Solid
          
          
          True
        
      
      
      B8DEF5EEC68F90AD1B38A35E2D1AFC4B
      
      1,1,1,1
      Page1
      
      27.9
      21.6
      
      
      
      
        Arial,10
        
          False
          
          None;[0:0:0];1;Solid;False;4;[0:0:0]
          [0:255:255:255]
          0,0,0,0
          Left
          
          
          0,0
          0,0
          1
          
          
          
          Top
        
        [0:0:0]
      
    
  
  
  EngineV2
  Report
  
  1/20/2011 1:53:31 AM
  1/20/2011 1:53:31 AM
  a9798f8ce9f2b5e77512a35e2eefaad6
  Report
  Centimeters
  
On debbug mode I noticed that the exception appears inside the static function convertXMLNodeToObject from StiSerializePropertyHelper.as when it reads the property from a node named Image and componentClass named StiImage.

Code: Select all

                var property: StiSerializeProperty = getPropertyByName(propertiesCollection, propertyElement.nodeName);
				
				if (property != null)
				{
					if (isList) type = property.value.getType();
					
					if (isKey || isList)
					{
						var componentClass: Class = StiComponentType.getFlexComponentClass(type);
						var component: * = new componentClass();
						component.parent = object;
						component.properties = propertyElement;
						object[property.name] = component;
					}
Exactly this line:

Code: Select all

var component: * = new componentClass();
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Save / Load a report to / from a database.

Post by Vladimir »

Hello,

We could not reproduce this error.
Please tell us, what version of our product are you using? Judging by the a saved report, an error occurs when saving Watermark Image. This problem was fixed in newer versions.

Thank you.
Felipe
Posts: 5
Joined: Tue Jan 18, 2011 9:23 am
Location: Recife - PE / Brazil

Save / Load a report to / from a database.

Post by Felipe »

You were right. I was using an old version. I updated it but unfortunately it keeps on the same error =(
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Save / Load a report to / from a database.

Post by Vladimir »

Hello,

To what version you upgraded? In the latest prerelease build this report should be loaded without any errors.

If an update to the latest prerelease build does not solve the problem, please try to correct the report (remove the saved Image from Watermark):

Code: Select all


  
    
    
    
    
    
  
  
    
      
      None;[0:0:0];1;Solid;False;4;[0:0:0]
      [255:255:255]
      
        
          
          3.6,0.6,0,0
          
          0,0
          0,0
          StartPointPrimitive1
          
          
          F3E8C47DB938F9CF9DD8A35E7752021A
          
          
        
        
          
          10.4,3.2,0,0
          
          0,0
          0,0
          EndPointPrimitive2
          
          
          F3E8C47DB938F9CF9DD8A35E7752021A
          
          
        
        
          
          None;[0:0:0];1;Solid;False;4;[0:0:0]
          [0:255:255:255]
          4.6,1.2,4.6,1.2
          
          Arial,10
          
          0,0,0,0
          0,0
          0,0
          Text1
          
          
          0
          
          This is a test report!
          [0:0:0]
          
          
        
        
          
          True
          3.6,0.6,6.8,2.6
          255, 0, 0
          F3E8C47DB938F9CF9DD8A35E7752021A
          
          True
          0,0
          0,0
          RectanglePrimitive1
          
          
          True
          0
          5
          Solid
          
          
          True
        
      
      
      B8DEF5EEC68F90AD1B38A35E2D1AFC4B
      
      1,1,1,1
      Page1
      
      27.9
      21.6
      
      
      
      
        Arial,10
        [0:0:0]
      
    
  
  
  EngineV2
  Report
  
  1/20/2011 1:53:31 AM
  1/20/2011 1:53:31 AM
  a9798f8ce9f2b5e77512a35e2eefaad6
  Report
  Centimeters
  
Thank you.
Felipe
Posts: 5
Joined: Tue Jan 18, 2011 9:23 am
Location: Recife - PE / Brazil

Save / Load a report to / from a database.

Post by Felipe »

Now I'm using the 2010.3 version.

When I removed the Image tag it worked. Thank you!
Andrew
Posts: 4104
Joined: Fri Jun 09, 2006 3:58 am

Save / Load a report to / from a database.

Post by Andrew »

Ok!

Thank you.
Locked