Performance.asp

Use the following sample ASP to test retrieving data for the Performance view.

<%@ EnableSessionState=False Language=VBScript %>

<% option explicit %>

<%

Dim Conn

Dim SQL

Dim R

Dim F

Dim RecsAffected

Dim aConnectionString


aConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _

  & "Data Source=c:\Inetpub\ibd\mdb.mdb"


Set Conn = Server.CreateObject("ADODB.Connection")

Conn.Mode = 3

Conn.ConnectionString = aConnectionString

Conn.CursorLocation = 3

Conn.Open

SQL="SELECT * from perf"

Set R=Server.CreateObject("ADODB.Recordset")




dim v

dim fs

dim ts

dim sReq

Dim aPath 

Dim aLogFile

dim item



aPath = Request.ServerVariables("PATH_TRANSLATED") 

'Response.Write aPath



' strip the file name from the path 

aPath = Left(aPath, instrRev(aPath, "\")) 

' add the log file name

aLogFile = aPath & "\log\perf.log"

set fs = Server.CreateObject("Scripting.FileSystemObject")

set ts = fs.OpenTextFile(aLogFile, 8, True, 0)



'for each item in Request.ServerVariables

  'ts.write item

  'ts.writeline Request.ServerVariables(item)

'next



dim domDoc

dim aFilename

set domDoc = Server.CreateObject("MSXML.DOMDocument")

domDoc.async = false

'domDoc.setProperty("ServerHTTPRequest")=true

domDoc.load(Request)



dim node

dim nodes

dim mainNode

dim mainNodes

dim matchNode

dim matchNodes

dim attribs

dim attrib

dim SQLwhere

Dim root

dim SQLinsert

dim SQLfields

dim SQLvalues

dim sWhere

dim x

dim y

dim sFields

dim sValues



set root = domDoc.documentElement



dim nName

dim inputText

dim data



'inputText = Request.Form("textInput")



nName = root.nodeName



Select Case nName



Case "siebel-xmlext-fields-req"



R.Open SQL, Conn, 3, 1, &H0001

domDoc.save (server.MapPath("init1.xml"))

Response.Write "<?xml version= ""1.0"" encoding=""UTF-8""?>"

Response.Write "<siebel-xmlext-fields-ret>"

For Each F in R.Fields

  Response.Write "<support field='"& F.Name &"'/>"

Next

Response.Write "</siebel-xmlext-fields-ret>"

R.Close



Case "siebel-xmlext-query-req"



'This section of SelectCase is for the Query Request

dim attVal1(25)

dim attName1(25)



set mainNodes = root.childNodes

ts.writeline "Document have MainNodes: " & mainNodes.length

Dim z

z = 0

For each matchNode in MainNodes

  'attVal1(z) = matchNode.text

  'set attribs = matchNode.attributes

  'set attrib = attribs(0)

  'attName1(z) = attrib.nodeValue

'ts.writeline

ts.writeline "MainNode " & z

'ts.write z

ts.writeline "Main Node Name: " & matchNode.nodeName

ts.writeline "Main Node type: " & matchNode.nodeType

ts.writeline "Main Node value: " & matchNode.nodeValue

'ts.writeline "match Node data: " & matchNode.data

ts.writeline "Main line text: " & matchNode.text

'ts.write attrib.nodeValue



z = z +1

next

set matchNodes = root.SelectNodes("search-string")

ts.writeline "MatchNodes in document are : " & matchNodes.length

x = 0

For each matchNode in matchNodes



ts.writeline "Match string is :" & matchNode.text

sWhere = matchNode.text

x = x +1

next



ts.writeline "This is sWhere " & sWhere



'setting the WHERE clause in order to query the correct recordset



if  sWhere="" then

SQLwhere = SQL

else

SQLwhere = " WHERE " & sWhere

SQLwhere = SQL + SQLwhere

end if

'Response.Write SQLwhere

R.Open SQLwhere, Conn, 3, 1, &H0001



'for debugging

domDoc.save (server.MapPath("init2.xml"))



'build response stream by iterating through the recordset

Response.Write "<?xml version= ""1.0"" encoding=""UTF-8""?>"

Response.Write "<siebel-xmlext-query-ret>"

'ts.write "<?xml version="1.0" encoding="UTF-8"?>"

'ts.write "<siebel-xmlext-query-ret>"



While Not R.EOF

  Response.Write "<row>"

  'ts.write "<row>"

For Each F in R.Fields

  Response.Write "<value field="""& F.Name &""">"& F.Value &"</value>"

  'ts.write "<value field="""& F.Name &""">"& F.Value &"</value>"

Next

Response.Write "</row>"

'ts.write "</row>"

R.MoveNext

Wend

Response.Write "</siebel-xmlext-query-ret>"

'ts.write "</siebel-xmlext-query-ret>"

R.Close



Case "siebel-xmlext-preinsert-req"


'Section for PreInsert

Response.Write "<siebel-xmlext-preinsert-ret>"

Response.Write "<row></row>"

Response.Write "</siebel-xmlext-preinsert-ret>"




Case "siebel-xmlext-insert-req"

'Section for Insert

Case "siebel-xmlext-delete-req"

'Section for Delete



End Select


'cleaning up the objects in memory

ts.close

set root = Nothing

set domDoc = Nothing

set ts = Nothing

set fs = Nothing

Set R = Nothing

Conn.Close

Set Conn = Nothing

%>