This is a migrated thread and some comments may be shown as answers.

Disconnected API Across a Reboot

1 Answer 29 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Randy
Top achievements
Rank 1
Randy asked on 21 Jul 2011, 01:11 AM

I suspect I know the answer, but I am an optimist. If the program using the disconnected API crashes or is restarted without doing the CopyTo what happens to the data? Is that inforamtion just lost? Is there a way of serializing it to the disk and retrieving it on a relaunched?

I am trying to put together my app so that it would work properly even with a long term internet outage rather than forcing the program to run until it is available again.

Thanks
Randy Miller
TransGuardian

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 22 Jul 2011, 04:43 PM
Hi Randy,

Unfortunately any information from the container would be lost if the application crashes. However, there is a way to serialize the content. Here is some sample code:
ObjectContainer.ChangeSet originalCs = container.GetContent();
 
XmlSerializer serializer = new XmlSerializer(typeof(ObjectContainer.ChangeSet));
MemoryStream stream = new MemoryStream();
serializer.Serialize(stream, originalCs);
 
stream.Seek(0, SeekOrigin.Begin);
ObjectContainer.ChangeSet deserializedCs = (ObjectContainer.ChangeSet) serializer.Deserialize(stream);

Of course, you can use any other type of stream to persist the content. Afterwards you can use the Apply() method of the container to restore the deserialized changeset.
I hope that helps.

All the best,
Alexander
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
General Discussions
Asked by
Randy
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or