从Powerbuilder访问网站并上传/映射文件以进行文件对象控制

时间:2014-12-11 06:39:16

标签: internet-explorer ole powerbuilder

我可以浏览网址,登录并转到特定网址。现在我已经达到了文件上传水平。有人能帮助我吗?

变量类型将作为'文件',如何在PB中传递文件路径和名称。以下是我的剧本

 IE = CREATE OLEObject
 IE.ConnectToNewObject("InternetExplorer.Application")

 IE.left=200
 IE.top=200
 IE.height=400
 IE.width=400
 IE.menubar=1
 IE.toolbar=1
 IE.statusBar=1
 IE.navigate("http://www.xyz.in/index.php")

 IE.visible=1
 SetForegroundWindow( IE.HWND )

 DO WHILE IE.Busy
  Yield ()
 LOOP

 li_form_ctr = IE.Document.Forms.Length
 if li_form_ctr = 1 then
   li_form_ctr = li_form_ctr - 1
   IE.Document.Forms[li_form_ctr].Elements.username.Value = 'Test'
   IE.Document.Forms[li_form_ctr].Elements.password.Value = 'test@123'
   ls_OldURL = IE.LocationURL
   IE.Document.Forms[li_form_ctr].Elements.submit.Click()
 else
  return
 end if   
DO WHILE IE.Busy
 Yield ()
LOOP
if ls_OldURL = IE.LocationURL then
   messagebox("Error","Either User Name/Password Wrong")
else
  IE.navigate("http://www.xyz.in/upload_ecr_latest.php")
  DO WHILE IE.Busy
    Yield ()
  LOOP
  sleep(2)
  li_form_ctr = 0
  li_form_ctr = IE.Document.Forms.Length
  if li_form_ctr = 1 then
     li_form_ctr = li_form_ctr - 1
     IE.Document.Forms[li_form_ctr].Elements.month.Value = '08'
     IE.Document.Forms[li_form_ctr].Elements.year.Value = '2014'
     IE.Document.Forms[li_form_ctr].Elements.ecr = "D:\temp\xyz.txt"  -- This one is Not working
     ls_OldURL = IE.LocationURL
     IE.Document.Forms[li_form_ctr].Elements.upload.Click()
   else
      return
  end if       
end if  

纳拉亚纳

1 个答案:

答案 0 :(得分:0)

看起来你正在与控件进行同步类型的通信,这显然适用于这种情况,但我不知道它是否适用于文件上传。

我认为您需要做的是继承“inet”对象,并使用“internetresult”来创建自己的后代,您可以使用navigatecomplete等事件获取结果,这些事件将包含您可以使用的参数包含实际有效载荷数据。

如果你需要澄清,请告诉我,但如果你研究inet,internetobject我认为你会弄清楚。您可以在OLE对象上获得所需的事件,但我不确定,从来没有这样做过。