文章編號 | : | 244049 |
最后修改 | : | 2005年12月6日 |
修訂 | : | 3.2 |
1. | 啟動 Microsoft Visual InterDev。 |
2. | 創(chuàng)建一個名為 ServerChart 的新 Web 項目,然后單擊下一步按鈕。 |
3. | 鍵入將用于此 Web 項目的服務(wù)器。 |
4. | 單擊完成以創(chuàng)建此 Web 項目。 |
5. | 右鍵單擊服務(wù)器中的項目目錄(通常為 C:\Inetpub\wwwroot\ServerChart),選擇屬性,然后單擊安全性選項卡。 |
6. | 單擊權(quán)限,然后添加以下目錄權(quán)限: IUSR_SERVERNAME:讀取、寫入、執(zhí)行和刪除 創(chuàng)建者 :讀取、寫入、執(zhí)行和刪除 |
7. | 單擊確定以設(shè)置權(quán)限。 |
8. | 在該 Visual InterDev 項目中,右鍵單擊 global.asa 文件并選擇獲取工作副本。 |
9. | 修改 global.asa 文件以包含下面的腳本: <SCRIPT LANGUAGE=VBScript RUNAT=Server> Sub Session_OnStart ‘ Create a FileSystemObject to provide files in the script Set Session("FSO") = CreateObject("Scripting.FileSystemObject") ‘ Create a variable that has the number of files created in this session Session("n") = 0 ‘ Set timeout to be 1 minute Session.Timeout = 1 End Sub Sub Session_OnEnd ‘ Delete the files created in this session Dim x For x = 0 to Session("n")-1 Session("FSO").DeleteFile Session("sTempFile" & x), True Next End Sub </SCRIPT> |
10. | 單擊項目菜單,選擇添加 Web 項,然后選擇 Active Server Page。將該頁命名為 chart.asp。 |
11. | 修改 chart.asp 中的腳本以包含以下代碼: <%@ language="vbscript" %> <html> <body> <h1>Realtime CPU Utilization by Configurations</h1> <FORM action="chart.asp" method=get name=frmChooseOrg> <p> Select an Organization to see values for their machines: <SELECT name=sOrg> <OPTION SELECTED value= 5>Org1</OPTION> <OPTION value= 10>Org2</OPTION> <OPTION value= 15>Org3</OPTION> <OPTION value= 20>Org4</OPTION> </SELECT> <INPUT type="submit" value="Go"></p> </FORM> <% Dim oChart, c, Categories(5), Vals(5), i, sCaption, nData, nOrg ‘ Get the input value nData = Request.QueryString("sOrg") ‘When the page loads the first time, set ndata to 5 if len(nData) = 0 then nData = 5 ‘ Generate random categories and values for the chart ‘ These values can come from some existing data source for i = 1 to 5 Categories(i) = "Machine" & CStr(i) Vals(i) = nData * Rnd(100) next ‘ Create a Chart Object Set oChart = CreateObject("OWC.Chart") Set c = oChart.Constants ‘ Set the different parameters for the ChartSpace oChart.Border.Color = c.chColorNone ‘ Get Organization number and use it to set the Caption nOrg = nData/5 sCaption = "Current Utilizations for Org" sCaption = sCaption & CStr(nOrg) ‘ Add a chart and set parameters for the chart oChart.Charts.Add oChart.Charts(0).Type = oChart.Constants.chChartTypeColumnClustered oChart.Charts(0).SeriesCollection.Add oChart.Charts(0).SeriesCollection(0).Caption = sCaption oChart.Charts(0).SeriesCollection(0).SetData c.chDimCategories, c.chDataLiteral, Categories oChart.Charts(0).SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, Vals oChart.Charts(0).HasLegend = True oChart.Charts(0).HasTitle = True ‘ Get a temporary filename to save chart in that file sFname = Session("FSO").GetTempName & session.SessionID & ".gif" ‘ Export the chart to the temporary file oChart.ExportPicture server.MapPath(sFname), "gif", 600, 512 ‘ Create a link to the generated file Response.Write "<img src=‘" & sFname & "‘>" ‘ Store the file with its path in the session object for cleanup Session("sTempFile" & Session("n")) = Server.MapPath(sFname) ‘ Increment the number of files Session("n") = Session("n") + 1 %> </body> </html> |
12. | 保存該項目。 |
13. | 在項目資源管理器中,右鍵單擊“chart.asp”并在瀏覽器中選擇查看。 |
聯(lián)系客服