当前位置: 首页 > news >正文

信誉好的低价网站建设广州网络营销

信誉好的低价网站建设,广州网络营销,公司网站维护一般需要做什么,学做网站需要什么软件使用《VB.net webbrowser 如何实现自定义下载 IDownloadManager》中的控件ExtendedWebBrowser(下载控件),并扩展了NewWindow2。 使用ExtendedWebBrowser_1过程中,遇到很多问题,花了几天时间,终于解决了所有…

 使用《VB.net webbrowser 如何实现自定义下载 IDownloadManager》中的控件ExtendedWebBrowser(下载控件),并扩展了NewWindow2。

使用ExtendedWebBrowser_1过程中,遇到很多问题,花了几天时间,终于解决了所有问题。

问题1:接管了下载后,发现大文件下载,主程序会阻塞。

        一开始,以为是在写文件时因为IO响应导致阻塞,改用异步写,等等...尝试,发现阻塞依然,看过《C# 用FileStream.WriteAsync 异步读文件,调用线程还是被阻塞了》等文章后,问题依然未能解决。

        最后尝试主程序不写文件(就是接管下载后,在OnDataAvailable中对接收数据不操作),不做任何操作,阻塞依然存在。阻塞会导致下载中断,而且这种情况与下载文件大小无关,即使很小几M的文件也会发生。

        苦思中,记起以前写一个延时函数时,为了不阻塞而加入了Application.DoEvents()语句,于是在最频繁操作的OnDataAvailable中加入Application.DoEvents()语句,问题终于得到完满解决。

问题2:写文件

        一开始,是主程序写文件,遇到太多麻烦,在解决问题1中,发现接管了下载后,其实IE是有在后台进程中将文件下载到IE缓冲区的,OnProgress第一次便是返回IE缓冲区中下载的文件名,于是便改用:等下载完后从IE缓冲区复制文件。(貌似IE原有下载器也是这样干的?)

问题3:对于会弹出新窗口的下载,在进行第二次下载时,没有触发下载。

        因为主程序中接管弹出窗口的Extendedwebbrowser_2一直没关闭(IE中下载窗口是立即关闭的),并且发现,在NewWindow2中将弹出下载转到Extendedwebbrowser_2触发下载时,Extendedwebbrowser_2并没有触发DocumentCompleted,估计就是这里导致第二次下载时不能触发。
       解决办法:在下载完后,Extendedwebbrowser_2加载空白页"about:blank",问题解决。
 

下面是IWebBrowserDownloadManager接口完整代码:

Imports Remotion.Dms.Clients.Windows.WebBrowserControl
Imports System.IONamespace MyDownloadmanager                         '定义接口,以实现接口引用 2023.10.27Public Class MyDownloadmanagerImplements IWebBrowserDownloadManagerDim INetCacheFile As String'一些状态的判定(True、False),其中的一种状态(True或False)必须放在接口内进行设定,'不能全部都靠通过外部进程来设定,外部进程只进行其中一种状态的改变就好,否则因为轮询时间差而导致不同步引发非预期结果发生。'例如:AfterLoadBlank#Region "增加属性,将接口的数据传递出去以及传进来"#Region "可读写属性"Private _ContinueDownload As Boolean = TruePublic Property ContinueDownload() As BooleanGetReturn _ContinueDownloadEnd GetSet(ByVal value As Boolean)_ContinueDownload = valueEnd SetEnd PropertyPrivate _DownloadDir As String = ""Public Property DownloadDir() As StringGetReturn _DownloadDirEnd GetSet(ByVal value As String)_DownloadDir = valueEnd SetEnd PropertyPrivate _AttchmentFilename As String = ""Public Property AttchmentFilename() As StringGetReturn _AttchmentFilenameEnd GetSet(ByVal value As String)_AttchmentFilename = valueEnd SetEnd Property'对于会弹出新窗口的下载,因为程序中接管的webbrowser一直没关闭,’在下载完后,需要加载一次新页(在这里加载空白页"about:blank"),‘否则可能无法进行下一次下载。Private _AfterLoadBlank As Boolean = FalsePublic Property AfterLoadBlank() As Boolean    GetReturn _AfterLoadBlankEnd GetSet(ByVal value As Boolean)_AfterLoadBlank = valueEnd SetEnd Property#End Region#Region "ReadOnly Property"Dim _DownloadFileName As String = ""Public ReadOnly Property DownloadFileName() As StringGetReturn _DownloadFileNameEnd GetEnd PropertyPrivate _totalSize As IntegerPublic ReadOnly Property GetTotalSize() As IntegerGetReturn _totalSizeEnd GetEnd PropertyPrivate _currentValue As IntegerPublic ReadOnly Property GetCurrentValue() As IntegerGetReturn _currentValueEnd GetEnd PropertyPrivate _success As BooleanPublic ReadOnly Property GetSuccess() As BooleanGetReturn _successEnd GetEnd PropertyPrivate _statusText As StringPublic ReadOnly Property GetStatusText() As StringGetReturn _statusTextEnd GetEnd PropertyPrivate _isAborted As BooleanPublic ReadOnly Property GetisAborted() As BooleanGetReturn _isAbortedEnd GetEnd PropertyPrivate _IsDownloadCompleted As Boolean = False'下载开始时,设置为false,下载结束或退出时,设置为TruePublic ReadOnly Property IsDownloadCompleted() As Boolean    GetReturn _IsDownloadCompletedEnd GetEnd PropertyPrivate _OnStartDownloading As Boolean = False'下载开始时,设置为false,下载结束或退出时,设置为TruePublic ReadOnly Property OnStartDownloading() As Boolean    GetReturn _OnStartDownloadingEnd GetEnd Property#End Region#End Region#Region "接口函数"Public Sub OnAborted() Implements Remotion.Dms.Clients.Windows.WebBrowserControl.IWebBrowserDownloadManager.OnAbortedWriteRunLog("OnAborted")_isAborted = True_IsDownloadCompleted = True_OnStartDownloading = FalseEnd SubPublic Function OnDataAvailable(ByVal buffer() As Byte, ByVal bytesAvailable As Integer) As Boolean Implements Remotion.Dms.Clients.Windows.WebBrowserControl.IWebBrowserDownloadManager.OnDataAvailable_currentValue += bytesAvailable'需要加这行,否则可能下载时发生阻塞,导致下载中断,而且这种情况与下载文件大小无关,即使很小几M的文件也会发生。Application.DoEvents()      Return _ContinueDownloadEnd Function'在下载完后,需要加载一次新页(在这里加载空白页"about:blank"),否则可能无法进行下一次下载。Public Sub OnDownloadCompleted(ByVal success As Boolean, ByVal statusText As String) Implements Remotion.Dms.Clients.Windows.WebBrowserControl.IWebBrowserDownloadManager.OnDownloadCompleted_isAborted = False_IsDownloadCompleted = True_OnStartDownloading = False_AfterLoadBlank = True_success = success_statusText = statusText_AttchmentFilename = ""WriteRunLog("OnDownloadCompleted:" + success.ToString + "      " + statusText)If success ThenIf String.IsNullOrEmpty(INetCacheFile) ThenWriteRunLog("没有找到IE缓冲区文件!文件 " + _DownloadFileName + " 下载失败!")ElseFile.Copy(INetCacheFile, _DownloadFileName, overwrite:=True)      '从IE缓冲区复制文件WriteRunLog("找到IE缓冲区文件: " + INetCacheFile + ",复制到:" + _DownloadFileName)End IfEnd IfEnd SubPublic Function OnProgress(ByVal currentValue As Integer, ByVal totalSize As Integer, ByVal statusText As String) As Boolean Implements Remotion.Dms.Clients.Windows.WebBrowserControl.IWebBrowserDownloadManager.OnProgress_totalSize = totalSize'从第一次OnProgress中获取下载文件名If String.IsNullOrEmpty(_DownloadFileName) Then      _DownloadFileName = MyGetFileName(statusText)If String.IsNullOrEmpty(_DownloadFileName) Then_DownloadFileName = "TmpFile"End IfIf Directory.Exists(_DownloadDir) Then_DownloadFileName = _DownloadDir + "\" + _DownloadFileNameEnd IfEnd IfIf String.IsNullOrEmpty(INetCacheFile) ThenIf InStr(statusText, "Windows\INetCache") > 0 Then  '查找IE缓冲区文件 保存路径、文件名INetCacheFile = statusText'WriteRunLog("OnProgress找到IE缓冲区文件: " + INetCacheFile)End IfEnd IfSystem.Windows.Forms.Application.DoEvents()Return _ContinueDownloadEnd FunctionPublic Function OnStartDownload(ByVal uri As System.Uri) As Boolean Implements Remotion.Dms.Clients.Windows.WebBrowserControl.IWebBrowserDownloadManager.OnStartDownload_currentValue = 0_OnStartDownloading = True_ContinueDownload = True_IsDownloadCompleted = FalseINetCacheFile = ""_DownloadFileName = ""WriteRunLog("OnStartDownload :" + uri.ToString)Return TrueEnd Function'OnStartDownload:http://115.1.115.15:9080/FrntMonitor/servlet/com.icbc.cte.cs.servlet.CSReqServlet'1、第一次获得文件名   OnProgress:0 totalSize:0 statusText: C:\Users\gdzs-liyh\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5\0F2VEW6C\statatmdev[2].xls'2、第二次获得下载链接 OnProgress:3483 totalSize:0 statusText:(OnStartDownload中的网址:http://115.1.115.15:9080/FrntMonitor/servlet/com.icbc.cte.cs.servlet.CSReqServlet)'3483就是在这时候读取的数据大小。'OnProgress:3483 totalSize:0 statusText: C:\Users\gdzs-liyh\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5\0F2VEW6C\statatmdev[2].xls'OnDataAvailable:38281  (这个就是文件的实际大小)(可能文件小,此时文件已经下载到缓存:C:\Users\gdzs-liyh\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5\0F2VEW6C\statatmdev[2].xls)'OnProgress:38281 totalSize:0 statusText:(OnStartDownload中的网址)'OnDownloadCompleted'================================='OnStartDownload :http://115.96.14.11/kjbbs/UpLoadFile/2010-7/20107214401523292.doc'1、第一次获得文件名   OnProgress:0 totalSize:0 statusText :http://115.96.14.11/kjbbs/UpLoadFile/2010-7/20107214401523292.doc'2、第二次获得下载链接 OnProgress:119296 totalSize:119296 statusText :http://115.96.14.11/kjbbs/UpLoadFile/2010-7/20107214401523292.doc'OnProgress:119296 totalSize:119296 statusText :C:\Users\gdzs-liyh\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5\5Q44G40U\20107214401523292.doc'OnProgress:119296 totalSize:119296 statusText :http://115.96.14.11/kjbbs/UpLoadFile/2010-7/20107214401523292.doc'OnDataAvailable:119296  (可能文件小,此时文件已经下载到缓存:C:\Users\gdzs-liyh\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5\0F2VEW6C\statatmdev[2].xls)'OnDownloadCompleted#End RegionShared Sub WriteRunLog(ByVal MyMsg As String)'Using w As StreamWriter = File.AppendText("RunLog.txt")Dim w As StreamWriterIf File.Exists("RunLog.txt") ThenIf My.Computer.FileSystem.GetFileInfo("RunLog.txt").Length > 10485760 Then  '2017.5.4 文件大于10M,清0w = File.CreateText("RunLog.txt")w.Write("文件大于10M,置0从头开始!")w.Write(Chr(9))Elsew = File.AppendText("RunLog.txt")End IfElsew = File.CreateText("RunLog.txt")End Ifw.Write(Now)w.Write(Chr(9))     '插入Tab键w.WriteLine(MyMsg)w.Flush()w.Close()'End UsingEnd SubPublic Function MyGetFileName(ByVal inStr As String) As String'获取文件名, '文件夹名、文件名不能包含下列字符\/:*?"<>|Dim ss As Stringss = System.IO.Path.GetFileName(inStr)Dim n = InStrRev(ss, "=")If n < ss.Length Thenss = ss.Substring(n)End IfMyGetFileName = ss.Replace("\", "").Replace("/", "").Replace(":", "").Replace("*", "").Replace("?", "").Replace(Chr(34), "").Replace("<", "").Replace(">", "").Replace("|", "")If InStrRev(MyGetFileName, "[") > 1 And InStrRev(MyGetFileName, "[") < InStrRev(MyGetFileName, "]") Then    '将 21018102002617385797[1] 中的 [1] 去掉MyGetFileName = Left(MyGetFileName, InStrRev(MyGetFileName, "[") - 1) + Mid(MyGetFileName, InStrRev(MyGetFileName, "]") + 1)End IfMyGetFileName = _AttchmentFilename + MyGetFileNameEnd FunctionEnd ClassEnd Namespace


文章转载自:
http://dinncokingwana.tqpr.cn
http://dinncofetation.tqpr.cn
http://dinncoaton.tqpr.cn
http://dinncoapoenzyme.tqpr.cn
http://dinncodispassionate.tqpr.cn
http://dinncotersanctus.tqpr.cn
http://dinncoalbanian.tqpr.cn
http://dinncoflashboard.tqpr.cn
http://dinncosternutation.tqpr.cn
http://dinncodisassimilation.tqpr.cn
http://dinncomonarchial.tqpr.cn
http://dinncoburthen.tqpr.cn
http://dinncoglycosyl.tqpr.cn
http://dinncoducky.tqpr.cn
http://dinncopurchaseless.tqpr.cn
http://dinncojackscrew.tqpr.cn
http://dinncoblende.tqpr.cn
http://dinncosolacet.tqpr.cn
http://dinncoimprudence.tqpr.cn
http://dinncoscreed.tqpr.cn
http://dinncotriglot.tqpr.cn
http://dinncotraditionally.tqpr.cn
http://dinncocorpselike.tqpr.cn
http://dinncoantienzymic.tqpr.cn
http://dinncopreconize.tqpr.cn
http://dinncopalafitte.tqpr.cn
http://dinncobush.tqpr.cn
http://dinncowhaup.tqpr.cn
http://dinncoeuphemism.tqpr.cn
http://dinncobryozoan.tqpr.cn
http://dinncobraciola.tqpr.cn
http://dinncoaccessional.tqpr.cn
http://dinncokintal.tqpr.cn
http://dinncoqueer.tqpr.cn
http://dinncosnackette.tqpr.cn
http://dinncoconceptive.tqpr.cn
http://dinncoinveigh.tqpr.cn
http://dinncocontrariant.tqpr.cn
http://dinncoplausible.tqpr.cn
http://dinncofoliole.tqpr.cn
http://dinncopatency.tqpr.cn
http://dinncojockeyship.tqpr.cn
http://dinncoconflux.tqpr.cn
http://dinncodogtrot.tqpr.cn
http://dinncoaar.tqpr.cn
http://dinncochlorodyne.tqpr.cn
http://dinncoswiz.tqpr.cn
http://dinncomaxilliped.tqpr.cn
http://dinnconegrohead.tqpr.cn
http://dinncoupend.tqpr.cn
http://dinncobioplasm.tqpr.cn
http://dinncononboarding.tqpr.cn
http://dinncodescension.tqpr.cn
http://dinncohumoresque.tqpr.cn
http://dinncokerr.tqpr.cn
http://dinncodepurge.tqpr.cn
http://dinncoinsipidness.tqpr.cn
http://dinncoreassemble.tqpr.cn
http://dinncohieroglyphologist.tqpr.cn
http://dinncodisemboguement.tqpr.cn
http://dinncodisapprovingly.tqpr.cn
http://dinncoantismog.tqpr.cn
http://dinncoquorum.tqpr.cn
http://dinncoyourselves.tqpr.cn
http://dinncoargand.tqpr.cn
http://dinncoguiltiness.tqpr.cn
http://dinncorefloat.tqpr.cn
http://dinncointrigue.tqpr.cn
http://dinncodirham.tqpr.cn
http://dinncoasteroidal.tqpr.cn
http://dinncocmyk.tqpr.cn
http://dinncounsccur.tqpr.cn
http://dinncopolychaete.tqpr.cn
http://dinncocornus.tqpr.cn
http://dinncopolite.tqpr.cn
http://dinncoorthopteron.tqpr.cn
http://dinncodeaminase.tqpr.cn
http://dinncoincapability.tqpr.cn
http://dinncovahine.tqpr.cn
http://dinncobiotron.tqpr.cn
http://dinncoschizophrenia.tqpr.cn
http://dinncojaponic.tqpr.cn
http://dinncoornithologic.tqpr.cn
http://dinncotenderness.tqpr.cn
http://dinncobissel.tqpr.cn
http://dinncoaerobody.tqpr.cn
http://dinncopecorino.tqpr.cn
http://dinncoreckling.tqpr.cn
http://dinncofrazzled.tqpr.cn
http://dinncodecillion.tqpr.cn
http://dinncoforbore.tqpr.cn
http://dinncogod.tqpr.cn
http://dinncomania.tqpr.cn
http://dinncowinningness.tqpr.cn
http://dinncocum.tqpr.cn
http://dinncoprequisite.tqpr.cn
http://dinncomirdita.tqpr.cn
http://dinncooutvote.tqpr.cn
http://dinncodrakestone.tqpr.cn
http://dinncogoldbug.tqpr.cn
http://www.dinnco.com/news/153674.html

相关文章:

  • 三网合一网站建设系统 价格西安疫情最新消息
  • 绵阳建设网站营销策划机构
  • 珠海seo网站建设百度地图人工电话
  • 搭建网站大概需要多少钱百度获客平台怎么收费的
  • 营销导向企业网站策划百度seo推广价格
  • 百度推广渠道商深圳网站营销seo费用
  • 建设企业网站所遵循的一般原则优化营商环境的意义
  • 做音乐网站建设的开发平台滕州seo
  • 南阳网网站建设软件定制开发平台
  • 网站建设与管理难学吗医院营销策略的具体方法
  • 公司制作网站怎么做的在线排名优化
  • 网站做多个产品软文免费发布平台
  • xml做网站源码河北企业网站建设
  • 什么网站可以兼职做平面设计今日头条荆州新闻
  • wordpress分类不显示讯展网站优化推广
  • 做垃圾网站培训seo哪家学校好
  • 从百万到千万 网站怎么优化网上国网app推广
  • 广告平台投放广告百度推广优化技巧
  • 网站做好了前端 后端怎么做百度移动权重
  • 建设的网站优秀企业网站欣赏
  • 怎么样自学做网站世界疫情最新数据
  • 怎么发布网站优秀的营销策划案例
  • html对于网站今日国际新闻头条15条
  • 新浪博客怎么给自己网站做链接吗手机版百度一下
  • 企业seo策划方案优化案例关键词排名优化公司外包
  • dede网站搬家发布信息的免费平台
  • 响应式网站写法贵阳网站建设
  • 河南手机网站建设价格明细表厦门关键词优化报价
  • 网站上怎么做图片变换动图下载班级优化大师app
  • 西安做营销型网站建设济南百度推广公司电话