Screen scraping, then caching.... not working on web parts page?

I

itfetish

We have a web parts intranet at our office here I have been working
on.

I have been trying to create a way of getting our OCE TDS 600 plotter
queue to be a web part on the page, seeing as their is no way of
interfacing apart from their 'print exec workgroup' web based program.

So I decided to screen scrape, I've done a scrape of the intranet page
of print exec workgroup (http://tds600 on our network) seemed to go
fine, then i used regex, and some replace's to delete the stuff I
didn't want and change some formatting to suit my page then wrote the
html code to a label, seemed to work fine.

I then decided maybe I should do some caching, as this plotter doesnt
want to be hit up when ever user in the network (with autorefresh
every 5 mins) as it is receiving drawings and stuff.

So I tried caching it just for a minute or two, just so that way only
one person hits it every 2 minutes - the rest get it from cache.

But it doesn't seem to be working, I made a test page, seemed to cache
fine, but then when I made it an ascx control and put it on my web
parts page, it never caches. And perhaps as a result, actually
retreiving the scrape is a hit and miss afair, and even worse, people
can't access print exec (which is used to send drawings to plotter) as
it says theres too many users connected (theres no license limit - but
it's obviously a hard limit set so that bandwidth for plots doesnt
suffer - so the web connections must be making lots and overloading
it)

I'm making two parts, 1 to get the status on rolls (empty icons etc)
and one for queue, they are essentiall they same.

Code:
 Sub Page_Load(sender as Object, e as EventArgs)
        Dim RollStatus
        Const strURL As String = "http://tds600/servlet/PEBServlet?
pag=info"


        If Cache.Get("RollState") IsNot Nothing Then
            RollStatus = Cache.Get("RollState")
                Response.Write("retrieved from cache")
            End If

        Else
           response.write ("Regenerating Data")
            Dim PrintExecPage As String
            Dim req As HttpWebRequest = WebRequest.Create(strURL)
            req.Timeout = 1000

            Dim resp As HttpWebResponse = req.GetResponse()

            Dim sr As New StreamReader(resp.GetResponseStream())
            PrintExecPage = sr.ReadToEnd()

            Dim RegEx As New Regex("<table width='100%' border='0'
cellpadding='2' cellspacing='0'><tr>(.*?)Feeder</td>(.*?)</table>",
RegexOptions.None)

            Dim objmatch As Match

            For Each objmatch In RegEx.Matches(PrintExecPage)

               'filter out the shit, store it in RollStatus string


            Next

            If Len(RollStatus) > 20 Then
                Cache.Insert("RollState", RollStatus, Nothing,
DateTime.Now.AddMinutes(3), TimeSpan.Zero)
               response.write ("Cache Written")

            End If

            sr.Close()
            resp.Close()


        End If


        If RollStatus Is Nothing Then
            RollStatus = "Did not load."
        End If


        lblHTMLOutput.Text = RollStatus

    End Sub

whenever the stream actually loads, it tells me its regenerating data,
and that its written to cache, then I hit refresh, and it says the
same thing - no recall from cache.


Any ideas? what have I done wrong? Is it possible our web server is
deleting cache, is there any way to check?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top