views:

30

answers:

1

Hey guys

I'm trying to upload images (byte arrays) from the client to a database - this works like a charm.

The thing is, I'd like to show the progress of this operation to the user, but the DomainDataSource object doesn't provide any sort of progress-event.

If I call SubmitChanges for each entity it somehow starts to overlap and things get pretty messy, so the following doesn't work.

foreach(T entity in entities)
{
    myDomainDataSource.DataView.Add(entity);
    myDomainDataSource.SubmitChanges();
}

Anyone got an idea how to show the user the upload progress of those images?

+1  A: 

You'll need to upload your images in chunks... which you often need to do anyway, as a single image may run the request limit for the maximum request size.

Once you use a chunked uploading approach, then you can show progress based on how much of the image has been uploaded.

I demonstrated this at TechEd Australia... while this was in 2007, and the code is old, it should largely work, or serve as a starting point. The sample demonstrated how you can use Silverlight to augment ajax to do a multi-file upload. See http://www.nikhilk.net/Entry.aspx?id=169 for a description of the samples. Maybe it helps...

NikhilK
Thanks for the sample - the problem is, I'd like to use the Domain Service approach - so I'd have to add (to the datacontext) and later submit the whole image entity (basically an object which represents a database table that contains image-name, image-type, image-data and a few other properties / columns).
Dänu
Use an Invoke method on a DomainService. Uploading a stream of bytes doesn't lend itself well to an insert/update CRUD method.
NikhilK