When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sections:
Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
XML Info
Information:
Feedback
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Wednesday, February 02, 2000

Generating a Web Site File System Report, Part 4


  • Read Part 1
  • Read Part 2
  • Read Part 3


  • In Part 3 we examined the first half of ExamineWeb.asp. In this intallment, we'll look at the remainder of ExamineWeb.asp! Here is the remaining code:

    - continued -

    <HTML>
    <BODY>
      <FONT SIZE=+2><B>
        Web Site File System Report
      </B></FONT><BR>
      (Report started at <%=dtStartReport%> 
      on directory <%=strRootFolder%>.
    
    <% If bolRecurseDirectories then
         Response.Write "The subdirectories were recursed."
       Else
         Response.Write "The subdirectories were <b>not</b> recursed."
       End If
    %>
      The report finsihed at <%=dtStopReport%>.)
    
      <P><HR NOSHADE><P>
      <CENTER>
      <TABLE WIDTH=100% BORDER=0>
      <TR><TD WIDTH=50% ALIGN=LEFT VALIGN=TOP>
        <I>To view a more detailed report, click on one of the
        file extensions shown in the table to the right.
        The detailed report will show you the exact locations of
        the files with the given extension.
        </I>
        <P>
        <FORM METHOD=GET>
          Recurse Directories:
          <INPUT TYPE=CHECKBOX NAME=chkRecurse
            <% if bolRecurseDirectories then Response.Write "CHECKED" %>
          >
          <BR>
          <INPUT TYPE=SUBMIT VALUE="ReRun Report">
        </FORM>
      </TD><TD WIDTH=50% ALIGN=CENTER>
        <TABLE BORDER=1 CELLSPACING=1 CELLPADDING=5>
        <TR>
          <TH COLSPAN=5>
            File Types & Sizes
          </TH>
        </TR>
    
    <%
      Dim aData, aLabel, iPos, iTotal, iTotalSize
      Dim aDataSize
      Redim aData(objDict.Count - 1)
      Redim aDataSize(objSizeDict.Count - 1)
      Redim aLabel(objDict.Count - 1)
    
      iPos = 0
      iTotal = 0
      iTotalSize = 0
    
      Dim strKey
    
      For Each strKey in objDict
        iTotal = iTotal + objDict(strKey)
        iTotalSize = iTotalSize + objSizeDict(strKey)
      Next
    
      For Each strKey in objDict
        Response.Write "<TR>"
        Response.Write "<TD><A HREF=""DetailedReport.asp?ext="
        Response.Write strKey & "&chkRecurse=" & Request("chkRecurse")
        Response.Write """>" & strKey & "</A></TD>"
        Response.Write "<TD>" & objDict(strKey) & "</TD>"
        Response.Write "<TD ALIGN=RIGHT>"
        Response.Write FormatPercent(objDict(strKey) / iTotal, 1)
        Response.Write "</TD>"
        Response.Write "<TD>"
        If objSizeDict(strKey) > 1000 then
          Response.Write FormatNumber(objSizeDict(strKey) / 1000,2)
          Response.Write " KB</TD>"
        Else
          Response.Write FormatNumber(objSizeDict(strKey), 0)
          Response.Write " Bytes</TD>"
        End If
        Response.Write "<TD ALIGN=RIGHT>"
        Response.Write FormatPercent(objSizeDict(strKey) / iTotalSize, 1)
        Response.Write "</TD>"
    
    
        aData(iPos) = objDict(strKey)
        aLabel(iPos) = strKey
        aDataSize(iPos) = objSizeDict(strKey)
    
        iPos = iPos + 1
    
        Response.Write "</TR>"
      Next
    
      Set objDict = Nothing
      Set objSizeDict = Nothing
    %>
        </TABLE>
      </TD></TR>
      </TABLE>
      <P><HR NOSHADE><P>
    
      <% BarChart aData, aLabel, "File Type Distribution", "Extension"%>
      <P><HR NOSHADE><P>
      <% BarChart aDataSize, aLabel, "File Size Distribution", "Extension"%>
      </CENTER>
    </BODY>
    </HTML>
    

    Click for a larger image! We begin by displaying a nice looking header at the top of our page, indicating the physical path of the Web's root directory, and the start and stop times of the report. We then create a full-screen TABLE essentially splitting the screen in half. On the left side, we provide an instructional message, and provide the checkbox that allows the user to determine whether or not she would like to recurse directories. Also present is a ReRun Report button. (A screenshot can be seen to the right.)

    Next, three arrays are created a dimensionalized based upon the size of the dictionary objDict. These arrays, aData, aDataSize, and aLabel will hold the values in objDict and objSizeDict, and the value of the keys in objDict. These arrays will later be used to create the dynamic bar charts! Also, two counting variables are declared and initialized to zero. These counting variables will determine the total number of files with a particular extension (iTotal) and the total number of bytes consumed in the Web site (iTotalSize). These totals are needed to calculate the percentage numbers. We then use a For Next ... Each to calculate these two totals.

    We then use another For Each ... Next loop to display the keys and values in both the objDict and objSizeDict dictionaries. We also incrementally populate our three arrays in this loop. Note that each file extension key, when displayed, it hyperlinked to DetailedReport.asp, passing the extension name through the QueryString. Once we have displayed the information collected by our two dictionary objects, we clean up these two objects.

    We conclude by displaying the two bar charts. The first bar chart displays how the file types are distributed. That is, there are X ASP pages and Y HTML pages. The second bar chart displays how the file sizes are distributes by file type. To learn how to use the BarChart function, be sure to read Making Bar Charts Using ASP. An example screenshot of a dynamic bar chart from this application can be seen below:

    Click for a larger image!

    In Part 5 we'll look at the code for DetailedReport.asp.

  • Read Part 5
  • Read Part 3
  • Read Part 2
  • Read Part 1


  • ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article