简体   繁体   English

进度条MVC 4将上传的文件保存到数据库

[英]Progress bar MVC 4 Save uploaded file to Database

I'm Writing application where I must upload CSV file to blob -azure cloud- then I show the file content to a user to get some configuration like Columns Names, types and select Columns to be Inserted into the database. 我正在编写应用程序,必须将CSV文件上传到blob -azure cloud-,然后向用户显示文件内容,以获取一些配置(如列名称,类型和选择要插入数据库的列)。

My Question : I get the file from the cloud as a stream I want make progress bar work while Saving to Database, any ideas about how to do that ?! 我的问题:我想以流的形式从云中获取文件,我希望在保存到数据库时使进度条正常工作,有关如何执行此操作的任何想法?

Thanks in Participation. 感谢参与。

I tried using session variable and Ajax Jquery to read get the percentage but it is not working in debugging time. 我尝试使用会话变量和Ajax Jquery读取获取百分比,但它在调试时不起作用。

In order to show the progress of an upload I would suggest using a third party library that has this functionality 为了显示上传的进度,我建议使用具有此功能的第三方库

Here is an example of such a plugin: http://blueimp.github.io/jQuery-File-Upload/ I've used this previously and it works well. 这是一个这样的插件的示例: http : //blueimp.github.io/jQuery-File-Upload/我以前使用过它,并且效果很好。

Concerning this: 关于此:

I want make progress bar work while Saving to Database 我想在保存到数据库的同时使进度条工作

I'm assuming this is a very big file, a small file of just a few thousand lines could probably be saved without the user noticing a delay (once it is uploaded) and you probably don't need to worry about showing a progress bar as it will be done almost instantly. 我假设这是一个很大的文件,可能会保存一个只有几千行的小文件,而无需用户注意延迟(一旦上传),您可能不必担心显示进度栏因为它将几乎立即完成。

If this is not the case I would probably try to do something along the lines of the upload returning a unique ID to the client for the file they uploaded and then this id is used to make a separate AJAX query where you return the progress to the end user. 如果不是这种情况,我可能会尝试执行上载操作,为客户端上传的文件返回唯一ID,然后使用该ID进行单独的AJAX查询,在此将进度返回到最终用户。

The idea would be 这个想法是

  1. Send file to server and show upload progress 将文件发送到服务器并显示上传进度
  2. Store file in database 将文件存储在数据库中
  3. return an Id in the file in the upload request 在上传请求中的文件中返回ID
  4. As you read through the file store the progress of the process on the file in the database 当您阅读文件时,将过程进度存储在数据库中的文件上
  5. Make a separate interface available where you can post the id of a file and get the progress returned to you. 提供一个单独的界面,您可以在其中发布文件ID,并将进度返回给您。
  6. Query this separate interface and display results. 查询该单独的界面并显示结果。
  7. When file is completely processed, forward user to a View containing the results using Javascript 文件完全处理后,使用Javascript将用户转发到包含结果的视图

I used SignalR to update ProgressBar and it is Working Fine, check this link for More Information. 我使用SignalR更新了ProgressBar,并且工作正常,请查看此链接以获取更多信息。

http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/introduction-to-signalr http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/introduction-to-signalr

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM