Ria服务:同步DomainDataSource.SubmitChanges()
我正在尝试将图像(字节数组)从客户端上传到数据库 - 这就像一个魅力。
问题是,我想向用户显示此操作的进度,但 DomainDataSource 对象不提供任何类型的进度事件。
如果我为每个实体调用 SubmitChanges,它会以某种方式开始重叠并且事情变得非常混乱,因此以下内容不起作用。
foreach(T entity in entities)
{
myDomainDataSource.DataView.Add(entity);
myDomainDataSource.SubmitChanges();
}
有人知道如何向用户显示这些图像的上传进度吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要分块上传图像......无论如何,您经常需要这样做,因为单个图像可能会运行最大请求大小的请求限制。
使用分块上传方法后,您可以根据已上传的图像量显示进度。
我在 TechEd Australia 上演示了这一点……虽然那是在 2007 年,而且代码很旧,但它应该基本上可以工作,或者可以作为一个起点。该示例演示了如何使用 Silverlight 增强 ajax 来执行多文件上传。请参阅http://www.nikhilk.net/Entry.aspx?id=169 样品的描述。也许这有帮助...
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...