How to save/load a chart template from a database ?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Yann
Newbie
Newbie
Posts: 2
Joined: Thu Mar 23, 2006 12:00 am

How to save/load a chart template from a database ?

Post by Yann » Thu Dec 07, 2006 5:36 pm

Hello,

I would like to know what is the best practice for saving/loading a chart template into a Database field (Sql Server in the case in point). What type of field use in the Db (varbinary ?).
I've done some tests but if the save job work good the load one always throw a exception because of a Truncate stream when using TeeChart.Import.Load().

The Load code :

Code: Select all

System.IO.MemoryStream _stream = new System.IO.MemoryStream(GraphLayout);
this.tChart1.Import.Template.Load(_stream);
where GraphLayout is a Byte[] array readed from the db.

The Save code:

Code: Select all

System.IO.MemoryStream _stream = new System.IO.MemoryStream();
this.tChart1.Export.Template.Save(_stream);
GraphLayout = _stream.GetBuffer();

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Dec 11, 2006 11:48 am

Hi jfb,

Have you tried setting stream's position to zero before loading it into the chart? For example:

Code: Select all

System.IO.MemoryStream _stream = new System.IO.MemoryStream(GraphLayout);
_stream.Position = 0;
this.tChart1.Import.Template.Load(_stream); 
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Yann
Newbie
Newbie
Posts: 2
Joined: Thu Mar 23, 2006 12:00 am

Post by Yann » Tue Dec 12, 2006 9:51 am

Thanks for your response,

I've done the stream position setting to 0 but the problem still occur.
I think there is a problem with the Export.Template.Save() method, I've notice that some times I catch the Exception below when trying to save the chart (ten file or stream) :

(translation from French, may be some some differences in real english message).
The 'TextContrast' property accessor on object 'System.Drawing.Graphics' has thrown a exception : 'invalid parameter'

à System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component)
à Steema.TeeChart.Export.TemplateExport.SerializeProperty(String Title, Object value, PropertyDescriptor i, SerializationInfo info)
à Steema.TeeChart.Export.TemplateExport.SerializeObject(String Prefix, Object value, SerializationInfo info)
à Steema.TeeChart.Export.TemplateExport.SerializeProperty(String Title, Object value, PropertyDescriptor i, SerializationInfo info)
à Steema.TeeChart.Export.TemplateExport.SerializeObject(String Prefix, Object value, SerializationInfo info)
à Steema.TeeChart.Export.TemplateExport.SerializeProperty(String Title, Object value, PropertyDescriptor i, SerializationInfo info)
à Steema.TeeChart.Export.TemplateExport.SerializeObject(String Prefix, Object value, SerializationInfo info)
à Steema.TeeChart.Export.TemplateExport.Serialize(SerializationInfo info, StreamingContext context)
à Steema.TeeChart.Chart.GetObjectData(SerializationInfo info, StreamingContext context)
à System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
à System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
à System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
à System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
à System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
à Steema.TeeChart.Export.TemplateExport.Serialize(Stream stream)
à Steema.TeeChart.Export.TemplateExport.Save(Stream stream)
à Steema.TeeChart.Export.TemplateExport.Save(String FileName)



May be it could be related to this post from Adrian
http://www.teechart.net/support/viewtop ... plate+save

Yann.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Dec 12, 2006 10:05 am

Hi Yann,

Yes, it seems to be the same issue as you pointed. It is already a high priority item on our defect list to be investigated fixed for the next releases.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply