by1455的自留地

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
第十三周

Alert Module中有一些Web application的年代久远,只是简单维持,根本无法加减半分。只好另想他法
例如,名为HRIS的loutsNotes Application. 是一个基于LN 6.0的应用。
下图

 
节略后的html

<HTML>
<!-- Lotus-Domino (Release 5.0.8 - June 18, 2001 on Windows NT/Intel) -->
<HEAD>
<TITLE>HRIS Pending Approval Summary for myname</TITLE><style type="text/css"> A:link {font-family: Arial; font-size:8pt;color:blue;text-decoration:underline;} A:visited {font-family: Arial; font-size:8pt;color:blue;text-decoration:underline;} A:hover {font-family: Arial; font-size:8pt;color:red; text-decoration:underline;} </style>
</HEAD>

..................

<BODY TEXT="000000" BGCOLOR="FFFFFF">

<FORM>

..................

<INPUT NAME="Leave" TYPE=hidden VALUE="0">
<INPUT NAME="Claims" TYPE=hidden VALUE="0">
<INPUT NAME="Training" TYPE=hidden VALUE="0">
<INPUT NAME="ShortName" TYPE=hidden VALUE="myname">
<INPUT NAME="FullName" TYPE=hidden VALUE="Yi BAO/ITD/JTC">
<INPUT NAME="server" TYPE=hidden VALUE="DMNAPP1">
<INPUT NAME="LeaveDb" TYPE=hidden VALUE="HRES/SAPLeave.nsf">
<INPUT NAME="ClaimDb" TYPE=hidden VALUE="HRES/SAPClaim.nsf">
<INPUT NAME="TrainingDb" TYPE=hidden VALUE="HRES/SAPTraining.nsf">
<INPUT NAME="ApprMailInDb" TYPE=hidden VALUE="Mail/HRISApproval.nsf">
<INPUT NAME="PlatinumURL" TYPE=hidden VALUE="http://platinum.jtc.gov.sg/platinumweb/common/frame.asp?">
<INPUT NAME="ChangeDB" TYPE=hidden VALUE="ChangePass.nsf"></FORM>
</BODY>
</HTML>

直接在alert.aspx 中加入对HRIS的处理会破坏整个模块的结构,一旦HRIS升级又要修改。
因此单独用一个hris.aspx对HRIS的网页处理,当然也是XML+XSLT结构
以下是部分代码

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim url As String = Request("url")
    
        Dim errstr As String = String.Empty
        Dim buffer As String = ""

        buffer = GetFilefromURL(url)


        Dim bufferRegex As Regex = New Regex("</TABLE[^>]*>([\s\S]*?)</FORM>", RegexOptions.IgnoreCase)
        Dim m As Match = bufferRegex.Match(buffer)

        buffer = m.Groups(1).Value

        buffer = Replace(buffer, "TYPE=hidden", "")
        buffer = Replace(buffer, "type=hidden", "")
        buffer = Replace(buffer, ">", "/>")
        buffer = "<?xml version=""1.0"" encoding=""utf-8"" ?>" + vbCrLf + "<HRIS>" + vbCrLf + buffer + vbCrLf + "</HRIS>"


        Response.Write(buffer)
        Response.End()
       

 


    End Sub

    Function right(ByVal str As String, ByVal index As Integer) As String
        Return Str.Substring(Str.Length - index)
    End Function

    Function left(ByVal str As String, ByVal index As Integer) As String
        Return Str.Substring(1, index)
    End Function

   
    Function GetFilefromURL(ByVal url As String) As String

        Dim buffer As String = ""

        Try

            Dim myrequest As System.Net.WebRequest = System.Net.WebRequest.Create(url)
            Dim myCredential As System.Net.NetworkCredential = System.Net.CredentialCache.DefaultCredentials
            Dim myproxy As New WebProxy()
            myrequest.Proxy = myproxy
            myrequest.Credentials = System.Net.CredentialCache.DefaultCredentials

            myrequest.Timeout = 15000 ' 20 seconds

            Dim myresponse As System.Net.WebResponse = myrequest.GetResponse

            Dim myStream As Stream = myresponse.GetResponseStream()

            Dim encode As System.Text.Encoding = System.Text.Encoding.GetEncoding("utf-8")


            Dim Readstream As New System.IO.StreamReader(myStream, encode)
            Dim read(256) As Char
            Dim count As Integer = Readstream.Read(read, 0, 256)
            buffer = count.ToString()
            While count > 0
                Dim str As New String(read, 0, count)
                count = Readstream.Read(read, 0, 256)
                buffer = buffer + str
            End While

            Readstream.Close()
            myresponse.Close()


        Catch ex As Exception
            buffer = ex.ToString

        End Try

        Return buffer
    End Function

posted on 2007-12-04 17:41  by1455  阅读(742)  评论(0编辑  收藏  举报