Advertisement
Advertisement
| 04.17.2008 at 10:39AM PDT, ID: 23331841 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: |
Private Declare Function GetForegroundWindow Lib "user32" Alias "GetForegroundWindow" () As Integer
Public Class Window
Public BodyHtml As String
Public LocationName As String
Public Url As String
Public Hwnd As Integer
End Class
Public Class InternetExplorerWindows
Public Shared Function GetWindows() As List(Of Window)
Dim list As New List(Of Window)
For Each window As InternetExplorer In New ShellWindows()
' Skip Windows Explorer instances, since the Document type is IShellFolderViewDual2.
If TypeOf window.Document Is mshtml.HTMLDocument Then
' Get the HTML document represented by the browser's Document property.
Dim doc As mshtml.HTMLDocument = CType(window.Document, mshtml.HTMLDocument)
' Create a class to collect important information to return to the caller
Dim win As New Window()
If doc.getElementById("TargetContent") IsNot Nothing Then
' Get the HTML from the IFrame element, if it exists.
Dim frame As mshtml.HTMLIFrame = CType(doc.getElementById("TargetContent"), mshtml.HTMLIFrame)
Dim windowDocument As mshtml.HTMLDocument = CType(frame.contentWindow, mshtml.HTMLWindow2).document
win.BodyHtml = windowDocument.body.outerHTML
Else
' Get the HTML from the main document.
win.BodyHtml = doc.body.outerHTML
End If
' Store info needed from the Internet Explorer instance.
win.LocationName = window.LocationName
win.Url = window.LocationURL
win.Hwnd = window.HWND
list.Add(win)
End If
Next window
Return list
End Function
End Class
Private Sub hotKey_Pressed(ByVal sender As System.Object, ByVal e As HotKeyPressedEventArgs)
Dim windowList As List(Of Window) = InternetExplorerWindows.GetWindows()
Dim activeHwnd As Integer = GetForegroundWindow()
For Each win As Window In windowList
Dim html As String = win.BodyHtml
Dim id As String = HtmlParser.FindIntegrationID(html)
If id.Length > 0 AndAlso win.Hwnd = activeHwnd Then
txtPropertyValue.Text = id
Dim sURL As String
sURL = constructURL()
OpenBrowser(sURL)
Exit For
End If
Next win
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
Friend Class HtmlParser
'This is the main logic for the PeopleSoft scrape. Parse through the HTML looking for the required data.
' Look for:
' <label for='VOUCHER_PACKSLIP_NO' class='PSEDITBOXLABEL' >Integration ID</label>
' </td>
' </tr>
' <tr>
' <td height='51' colspan='2'></td>
' <td colspan='4' valign='top' align='LEFT'>
' <span class='PSEDITBOX_DISPONLY' >000000010001</span>
Public Shared Function FindIntegrationID(ByVal pageText As String) As String
Dim document As New mshtml.HTMLDocument()
' The HTML document class doesn't have the correct 'write' method,
' so use the IHTMLDocument2 interface.
CType(document, mshtml.IHTMLDocument2).write(pageText)
Dim labelFound As Boolean = False
Dim count As Integer = 0
For Each table As mshtml.HTMLTable In document.getElementsByTagName("table")
If table.className = "PSPAGECONTAINER" Then
' Loop through all the table cells (<td> elements)
For Each cell As mshtml.HTMLTableCell In table.getElementsByTagName("td")
If Not labelFound Then
' Look for the last 'Integration ID' label, since we need the lowest
' level <td> element.
For Each label As mshtml.HTMLLabelElement In cell.getElementsByTagName("label")
If label.innerText = "Integration ID" Then
If count < 4 Then
count += 1
Else
' The right <label> was found, so quit looking, and start looking for the next <span>.
labelFound = True
Exit For
End If
End If
Next label
Else
' The next element that has a <span> child should be the 'Integration ID' value.
For Each span As mshtml.HTMLSpanElement In cell.getElementsByTagName("span")
Return Format(Val(span.innerText), "000000000000")
Next span
End If
Next cell
End If
Next table
Return ""
End Function
End Class
End Class
|