Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Schedule Serialization and SaveTo/LoadFrom (Read 3802 times)
fmorgan98
YaBB Newbies
*
Offline


Yes

Posts: 4
Joined: Jun 21st, 2007
Schedule Serialization and SaveTo/LoadFrom
Jun 24th, 2007 at 3:49pm
Print Post  
Hi

I'm trying to create a schedule with my own custom schedule item class.  I started with the tutorial 4 and it seems to work.  But when I go to setting up saving the schedule (ie serialization) as demonstrated in tutorial #9 the saveto/loadfrom overrides don't get invoked.  However, the schedules do get saved and loaded except the "kept" property gets lost?  When I edit a schedule item after its been loaded back in, the "kept" part of it is lost.  When I add a new item its there, but once I save or load its gone!

I don't know what I'm doing wrong.

Here's the saveto/loadfrom code:

Public Overrides Sub SaveTo(ByVal writer As System.IO.BinaryWriter, ByVal context As SerializationContext)

       MyBase.SaveTo(writer, context)

       writer.Write(Kept)
    End Sub

    Public Overrides Sub LoadFrom(ByVal reader As System.IO.BinaryReader, ByVal context As SerializationContext)

       MyBase.LoadFrom(reader, context)

       Kept = reader.ReadBoolean()
    End Sub


Here's the code for the form load event where I register my schedule class.

       Calendar.InteractiveItemType = GetType(MyScheduleClass)

       Schedule.RegisterItemClass(GetType(MyScheduleClass), "MyScheduleClass", 1)


Thanks
Al
  

Looking Glass Roll Eyes
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Schedule Serialization and SaveTo/LoadFrom
Reply #1 - Jun 25th, 2007 at 6:13am
Print Post  
The SaveTo and LoadFrom overloads having BinaryWriter and BinaryReader as their first argument are only invoked during binary serialization. If you save and load to and from a XML file, they won't be used. In order to support the XML serialization too, you have to override the SaveTo and LoadFrom overloads, which receive System.Xml.XmlWriter and System.Xml.XmlReader as first argument. The following code illustrates this:

Code
Select All
    Public Overloads Overrides Sub SaveTo(ByVal writer As System.Xml.XmlWriter, ByVal context As MindFusion.Scheduling.SerializationContext)
	  MyBase.SaveTo(writer, context)
	  writer.WriteElementString("kept", Kept.ToString())
    End Sub

    Public Overloads Overrides Sub LoadFrom(ByVal reader As System.Xml.XmlReader, ByVal context As MindFusion.Scheduling.SerializationContext)
	  MyBase.LoadFrom(reader, context)
	  Kept = Boolean.Parse(reader.ReadElementString("kept"))
    End Sub 


Meppy
  
Back to top
 
IP Logged
 
fmorgan98
YaBB Newbies
*
Offline


Yes

Posts: 4
Joined: Jun 21st, 2007
Re: Schedule Serialization and SaveTo/LoadFrom
Reply #2 - Jun 25th, 2007 at 7:59pm
Print Post  
Hi Meppy

Thanks for the quick response.  I pasted in the saveto/loadfrom with the system.xml...... and put breakpoints on each.  When I run it and save it, they don't get invoked either. 

I'm using the following code to save a schedule

         

Don't those methods get called when you use SaveToDataSource()?

Thanks for your help.

Al
  

Looking Glass Roll Eyes
Back to top
 
IP Logged
 
fmorgan98
YaBB Newbies
*
Offline


Yes

Posts: 4
Joined: Jun 21st, 2007
Re: Schedule Serialization and SaveTo/LoadFrom
Reply #3 - Jun 25th, 2007 at 8:00pm
Print Post  
heres the code

Calendar.SaveToDataSource(ReminderTableAdapter1, _
               StyleTableAdapter1, _
               CustomBrushesTableAdapter1, _
               ContactTableAdapter1, _
               LocationTableAdapter1, _
               ResourceTableAdapter1, _
               TaskTableAdapter1, _
               ItemTableAdapter1, _
               ItemContactsTableAdapter1, _
               ItemResourcesTableAdapter1, _
               RecurrenceTableAdapter1, _
               RecurrenceExceptionTableAdapter1, _
               RecurrenceExceptionsTableAdapter1)
  

Looking Glass Roll Eyes
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Schedule Serialization and SaveTo/LoadFrom
Reply #4 - Jun 26th, 2007 at 5:11am
Print Post  
These methods are only invoked when you are serializing to a XML file, i.e. when you call Schedule.SaveTo and pass ContentType.Xml as the second argument. Anyway, I am afraid custom item serialization is not yet supported when you save and load the schedule to and from a database.

Meppy
  
Back to top
 
IP Logged
 
fmorgan98
YaBB Newbies
*
Offline


Yes

Posts: 4
Joined: Jun 21st, 2007
Re: Schedule Serialization and SaveTo/LoadFrom
Reply #5 - Jun 26th, 2007 at 8:51pm
Print Post  
Hi

Ok.  I guess the work around is to keep track of my own properties by my code and save it as necessary?

Is there a way to have my code called on the appointment load or save?

Al
  

Looking Glass Roll Eyes
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Schedule Serialization and SaveTo/LoadFrom
Reply #6 - Jun 27th, 2007 at 5:00am
Print Post  
I don't think it is currently possible to perform custom item serialization during saving in a database. I will check with our developers whether this feature can be implemented easily and let you know.

Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint