tags:

views:

47

answers:

2

I have a winform application that uses some referenced web services to get data. The data returned is an array of objects that I loop through and add to a dataSet.

When I call the service, it can often take 2 or 3 minutes to get all the data.

If the user exits the program and comes back later, I don't want them to have to re-download all the data again.

When I run the app in debug mode, there's no persistence of the downloaded information; which worries me.

I'm still in "development mode", so I haven't really put together an installer yet to test if the information stays with the application.

I'm curious about a couple of things:

  1. Does the data stored in the dataset remain after the user exits?
  2. If not, what would you recommend on how to accomplish this?
  3. I've considered XML for storage; is that the best option when you have 9-10 MB of data?
    Edit: Final Outcome: OK - here's the final outcome (thank you everyone for your quick response)

When the application exits, I call a function to save the data. Here's a snippet:

   using System.IO;
   using System.Runtime.Serialization;
   using System.Runtime.Serialization.Formatters.Binary;            
   FileStream fs;
   IFormatter formatter = new BinaryFormatter();
    //activities
    if (actList.Length > 0)
    {
        fs = new FileStream("activities.bin", FileMode.Create, FileAccess.Write, FileShare.None);
        formatter.Serialize(fs, actList);
        fs.Close();
    }
    //users
    if (userList.Length > 0)
    {
        fs = new FileStream("users.bin", FileMode.Create, FileAccess.Write, FileShare.None);
        formatter.Serialize(fs, userList);
        fs.Close();
    }

The userList and actList parameters are List objects that came from the web services call.

another thing I implemented (slightly off topic) is to create an application setting to save when the user last did a download from the web service. It's saved as

Properties.Settings.Default.last_downloaded

If the user clicks the download button, they are prompted with the date they last performed the download and are given a chance to say "no".

Thanks again for your help!

+2  A: 

A .NET object has no persistance unless you write it yourself - for example by serializing to a file in the user's profile (or isolated storage for ClickOnce).

Note: personally, I wouldn't use DataSet at all in this scenario; if you are downloading the data as a list of objects, then just keep them like that - List<T> etc.

Re xml: 9-10Mb is big but not immense. It really depends on the nature of the data and other requirements; unless you are already using web-compression (GZIP etc), you might find that the data transfers quicker with a more compact format, such as csv, or a binary format such as protocol buffers.

Marc Gravell
I'm actually using the dataset as the source of data for a couple of datagridviews and listboxes; is there a way to use the list to populate those things?
JayTee
List<T> can be used just fine as the DataSource for DataGridView and ListBox etc.
Marc Gravell
Strictly speaking, anything that is `IList` or `IListSource` will work - `List<T>` benefits from a `public T this[int]` indexer which provides stronger metadata than just `IList`. But main point: there is no issue using `List<T>`
Marc Gravell
I can only mark 1 as the accepted answer - even though both of you helped out
JayTee
+1  A: 

You need to manually persist any data that you want to save. What you can do is take your Dataset, and, when your application is closing, serialize the dataset to a file. Then when the app opens, if the file exists, deserialize the dataset from that file instead of calling the webservice.

GWLlosa
I can only mark 1 as the accepted answer - even though both of you helped out
JayTee