Tag: progress

LINQ to SQL SubmitChangess()进度

我正在使用LINQ to SQL将旧的DBF文件导入MSSQL。 我正在读取所有行并使用ctx.MyTable.InsertOnSubmit(row)将它们添加到数据库 读完阶段完成后,我有大约100 000个待处理插入。 ctx.SubmitChanges()自然需要很长时间。 有没有办法跟踪ctx.submitchanges()进度? ctx.Log可以以某种方式用于此目的吗? 更新 :是否可以使用ctx.GetChangeSet().Inserts.Count并使用Log跟踪插入语句? 将ctx.SubmitChanges()划分为较小的块对我来说不起作用,因为我需要事务,全部或全部。 更新2:我发现了一个很好的类ActionTextWriter,我将尝试计算插入数。 http://damieng.com/blog/2008/07/30/linq-to-sql-log-to-debug-window-file-memory-or-multiple-writers 更新3: 我已经构建了第一个代码原型,它没有进行优化。 它似乎工作:) ctx.Log = new ActionTextWriter(s => { counter += s.Split(‘ ‘).Count(w => w.ToUpper() == “INSERT”); ReportProgress(counter); });

WebClient AsyncUpload进度百分比始终返回50%

我使用Webclient使用异步调用上传数据到服务器, WebClient webClient = new WebClient(); webClient.UploadDataAsync(uri , “PUT”, buffer, userToken); 我已将DatauploadProgress和DatauploadCompleted事件附加到适当的回调函数 // Upload Date Progress webClient.UploadProgressChanged += new UploadProgressChangedEventHandler(UploadProgressCallback); // Upload Date Progress void UploadProgressCallback(object sender, UploadProgressChangedEventArgs e) { // Magic goes here logger.writeToLog(“Percentage =” + e.ProgressPercentage); } e.ProgressPercentage总是返回50 ..无论上传的文件大小是多少(尝试10kb到60mb之间的不同大小)。 函数本身只被调用两次(真的很快),百分比显示50! ..特别是大文件不合逻辑…… e.BytesSent也没有帮助..总是以字节为单位显示文件大小:S(例如:如果文件大小为63,000,我会得到e.BytesSent = 63,000和e.ProgressPercentage= 50 有人能指出问题给我吗?